From 4a8a520396df8a780e71b2c2a1c757dfab7ad831 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期二, 16 四月 2024 20:56:22 +0800 Subject: [PATCH] 月度统计报表查询接口 --- models/month_stats.go | 3 request/report_forms_request.go | 6 controllers/report_forms_controller.go | 24 ++ docs/swagger.yaml | 133 +++++++++++++ docs/docs.go | 198 +++++++++++++++++++ docs/swagger.json | 198 +++++++++++++++++++ router/router.go | 1 7 files changed, 562 insertions(+), 1 deletions(-) diff --git a/controllers/report_forms_controller.go b/controllers/report_forms_controller.go index 1c7bb9a..6870409 100644 --- a/controllers/report_forms_controller.go +++ b/controllers/report_forms_controller.go @@ -370,3 +370,27 @@ util.ResponseFormatList(c, code.Success, result, int(total)) } + +// MonthStats +// @Tags 鎶ヨ〃 +// @Summary 鏈堝害缁熻搴撳瓨鎶ヨ〃 +// @Produce application/json +// @Param object body request.GetMonthStats true "鏌ヨ鍙傛暟" +// @Param Authorization header string true "token" +// @Success 200 {object} util.ResponseList{data=[]models.MonthStats} "鎴愬姛" +// @Router /api-wms/v1/forms/monthStats [post] +func (slf ReportFormsController) MonthStats(c *gin.Context) { + var params request.GetMonthStats + if err := c.BindJSON(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + return + } + + list, total, err := models.NewMonthStatsSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetDate(params.Date).Find() + if err != nil { + util.ResponseFormat(c, code.InternalError, "鏌ヨ澶辫触") + return + } + + util.ResponseFormatList(c, code.Success, list, int(total)) +} diff --git a/docs/docs.go b/docs/docs.go index a9b4d8d..6806e6e 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -551,6 +551,58 @@ } } }, + "/api-wms/v1/forms/monthStats": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "鎶ヨ〃" + ], + "summary": "鏈堝害缁熻搴撳瓨鎶ヨ〃", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetMonthStats" + } + }, + { + "type": "string", + "description": "token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.MonthStats" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/location/addLocation": { "post": { "produces": [ @@ -3440,6 +3492,12 @@ "description": "瀹㈡埛鍓嶇疆鏃堕棿(澶�)", "type": "number" }, + "grossUnit": { + "type": "string" + }, + "grossWeight": { + "type": "number" + }, "id": { "type": "string" }, @@ -3514,9 +3572,24 @@ } ] }, + "moreUnit": { + "type": "boolean" + }, + "moreUnitList": { + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, "name": { "description": "鐗╂枡鍚嶇О", "type": "string" + }, + "netUnit": { + "type": "string" + }, + "netWeight": { + "type": "number" }, "note": { "type": "string" @@ -3612,6 +3685,84 @@ "volume": { "description": "浣撶Н", "type": "number" + }, + "weight": { + "description": "閲嶉噺", + "type": "number" + } + } + }, + "models.MonthStats": { + "type": "object", + "properties": { + "MoreUnitsArr": { + "description": "鏈熸湯鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "amount": { + "description": "鏈熸湯缁撲綑鏁伴噺", + "type": "number" + }, + "beginAmount": { + "description": "鏈熷垵鏁伴噺", + "type": "number" + }, + "beginMoreUnitsArr": { + "description": "鏈熷垵鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "createTime": { + "type": "string" + }, + "date": { + "description": "鏃ユ湡 2024-04", + "type": "string" + }, + "id": { + "type": "integer" + }, + "inputAmount": { + "description": "鍏ュ簱鏁伴噺", + "type": "number" + }, + "inputMoreUnitsArr": { + "description": "鍏ュ簱鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "outputAmount": { + "description": "鍑哄簱鏁伴噺", + "type": "number" + }, + "outputMoreUnitsArr": { + "description": "鍑哄簱鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "productId": { + "description": "浜у搧id", + "type": "string" + }, + "productName": { + "description": "浜у搧鍚嶇О", + "type": "string" + }, + "unit": { + "description": "鍗曚綅", + "type": "string" + }, + "updateTime": { + "type": "string" }, "weight": { "description": "閲嶉噺", @@ -3829,6 +3980,12 @@ "description": "鐩爣浣嶇疆id", "type": "integer" }, + "totalGrossWeight": { + "type": "number" + }, + "totalNetWeight": { + "type": "number" + }, "updateTime": { "type": "string" } @@ -3958,6 +4115,20 @@ "type": "boolean" }, "name": { + "type": "string" + } + } + }, + "models.UnitItems": { + "type": "object", + "properties": { + "amount": { + "type": "number" + }, + "floating": { + "type": "boolean" + }, + "unit": { "type": "string" } } @@ -4514,6 +4685,25 @@ } } }, + "request.GetMonthStats": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "keyword": { + "type": "string" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + } + } + }, "request.GetProductList": { "type": "object", "properties": { @@ -4629,6 +4819,14 @@ "toLocationId": { "description": "鐩爣浣嶇疆id", "type": "integer" + }, + "totalGrossWeight": { + "description": "鎬绘瘺閲�", + "type": "number" + }, + "totalNetWeight": { + "description": "鎬诲噣閲�", + "type": "number" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index ef51205..2f1e070 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -539,6 +539,58 @@ } } }, + "/api-wms/v1/forms/monthStats": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "鎶ヨ〃" + ], + "summary": "鏈堝害缁熻搴撳瓨鎶ヨ〃", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.GetMonthStats" + } + }, + { + "type": "string", + "description": "token", + "name": "Authorization", + "in": "header", + "required": true + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.MonthStats" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/location/addLocation": { "post": { "produces": [ @@ -3428,6 +3480,12 @@ "description": "瀹㈡埛鍓嶇疆鏃堕棿(澶�)", "type": "number" }, + "grossUnit": { + "type": "string" + }, + "grossWeight": { + "type": "number" + }, "id": { "type": "string" }, @@ -3502,9 +3560,24 @@ } ] }, + "moreUnit": { + "type": "boolean" + }, + "moreUnitList": { + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, "name": { "description": "鐗╂枡鍚嶇О", "type": "string" + }, + "netUnit": { + "type": "string" + }, + "netWeight": { + "type": "number" }, "note": { "type": "string" @@ -3600,6 +3673,84 @@ "volume": { "description": "浣撶Н", "type": "number" + }, + "weight": { + "description": "閲嶉噺", + "type": "number" + } + } + }, + "models.MonthStats": { + "type": "object", + "properties": { + "MoreUnitsArr": { + "description": "鏈熸湯鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "amount": { + "description": "鏈熸湯缁撲綑鏁伴噺", + "type": "number" + }, + "beginAmount": { + "description": "鏈熷垵鏁伴噺", + "type": "number" + }, + "beginMoreUnitsArr": { + "description": "鏈熷垵鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "createTime": { + "type": "string" + }, + "date": { + "description": "鏃ユ湡 2024-04", + "type": "string" + }, + "id": { + "type": "integer" + }, + "inputAmount": { + "description": "鍏ュ簱鏁伴噺", + "type": "number" + }, + "inputMoreUnitsArr": { + "description": "鍏ュ簱鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "outputAmount": { + "description": "鍑哄簱鏁伴噺", + "type": "number" + }, + "outputMoreUnitsArr": { + "description": "鍑哄簱鍏朵粬鍗曚綅鏁扮粍", + "type": "array", + "items": { + "$ref": "#/definitions/models.UnitItems" + } + }, + "productId": { + "description": "浜у搧id", + "type": "string" + }, + "productName": { + "description": "浜у搧鍚嶇О", + "type": "string" + }, + "unit": { + "description": "鍗曚綅", + "type": "string" + }, + "updateTime": { + "type": "string" }, "weight": { "description": "閲嶉噺", @@ -3817,6 +3968,12 @@ "description": "鐩爣浣嶇疆id", "type": "integer" }, + "totalGrossWeight": { + "type": "number" + }, + "totalNetWeight": { + "type": "number" + }, "updateTime": { "type": "string" } @@ -3946,6 +4103,20 @@ "type": "boolean" }, "name": { + "type": "string" + } + } + }, + "models.UnitItems": { + "type": "object", + "properties": { + "amount": { + "type": "number" + }, + "floating": { + "type": "boolean" + }, + "unit": { "type": "string" } } @@ -4502,6 +4673,25 @@ } } }, + "request.GetMonthStats": { + "type": "object", + "properties": { + "date": { + "type": "string" + }, + "keyword": { + "type": "string" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + } + } + }, "request.GetProductList": { "type": "object", "properties": { @@ -4617,6 +4807,14 @@ "toLocationId": { "description": "鐩爣浣嶇疆id", "type": "integer" + }, + "totalGrossWeight": { + "description": "鎬绘瘺閲�", + "type": "number" + }, + "totalNetWeight": { + "description": "鎬诲噣閲�", + "type": "number" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index 223308f..d32b9c0 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -540,6 +540,10 @@ deliveryAdvanceTime: description: 瀹㈡埛鍓嶇疆鏃堕棿(澶�) type: number + grossUnit: + type: string + grossWeight: + type: number id: type: string inStorageExplain: @@ -597,9 +601,19 @@ - $ref: '#/definitions/constvar.MaterialMode' description: MaterialType constvar.ProductType `gorm:"index;type:int(11);comment:鐗╂枡绫诲瀷(鏁板瓧)" json:"materialType"` + moreUnit: + type: boolean + moreUnitList: + items: + $ref: '#/definitions/models.UnitItems' + type: array name: description: 鐗╂枡鍚嶇О type: string + netUnit: + type: string + netWeight: + type: number note: type: string orderAdvanceTime: @@ -668,6 +682,62 @@ volume: description: 浣撶Н type: number + weight: + description: 閲嶉噺 + type: number + type: object + models.MonthStats: + properties: + MoreUnitsArr: + description: 鏈熸湯鍏朵粬鍗曚綅鏁扮粍 + items: + $ref: '#/definitions/models.UnitItems' + type: array + amount: + description: 鏈熸湯缁撲綑鏁伴噺 + type: number + beginAmount: + description: 鏈熷垵鏁伴噺 + type: number + beginMoreUnitsArr: + description: 鏈熷垵鍏朵粬鍗曚綅鏁扮粍 + items: + $ref: '#/definitions/models.UnitItems' + type: array + createTime: + type: string + date: + description: 鏃ユ湡 2024-04 + type: string + id: + type: integer + inputAmount: + description: 鍏ュ簱鏁伴噺 + type: number + inputMoreUnitsArr: + description: 鍏ュ簱鍏朵粬鍗曚綅鏁扮粍 + items: + $ref: '#/definitions/models.UnitItems' + type: array + outputAmount: + description: 鍑哄簱鏁伴噺 + type: number + outputMoreUnitsArr: + description: 鍑哄簱鍏朵粬鍗曚綅鏁扮粍 + items: + $ref: '#/definitions/models.UnitItems' + type: array + productId: + description: 浜у搧id + type: string + productName: + description: 浜у搧鍚嶇О + type: string + unit: + description: 鍗曚綅 + type: string + updateTime: + type: string weight: description: 閲嶉噺 type: number @@ -811,6 +881,10 @@ toLocationId: description: 鐩爣浣嶇疆id type: integer + totalGrossWeight: + type: number + totalNetWeight: + type: number updateTime: type: string type: object @@ -897,6 +971,15 @@ isDefault: type: boolean name: + type: string + type: object + models.UnitItems: + properties: + amount: + type: number + floating: + type: boolean + unit: type: string type: object models.Warehouse: @@ -1284,6 +1367,19 @@ type: type: integer type: object + request.GetMonthStats: + properties: + date: + type: string + keyword: + type: string + page: + description: 椤电爜 + type: integer + pageSize: + description: 姣忛〉澶у皬 + type: integer + type: object request.GetProductList: properties: categoryId: @@ -1368,6 +1464,12 @@ toLocationId: description: 鐩爣浣嶇疆id type: integer + totalGrossWeight: + description: 鎬绘瘺閲� + type: number + totalNetWeight: + description: 鎬诲噣閲� + type: number type: object request.OperationList: properties: @@ -2139,6 +2241,37 @@ summary: 鑾峰彇浣嶇疆鎶ヨ〃 tags: - 鎶ヨ〃 + /api-wms/v1/forms/monthStats: + post: + parameters: + - description: 鏌ヨ鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.GetMonthStats' + - description: token + in: header + name: Authorization + required: true + type: string + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.MonthStats' + type: array + type: object + summary: 鏈堝害缁熻搴撳瓨鎶ヨ〃 + tags: + - 鎶ヨ〃 /api-wms/v1/location/addLocation: post: parameters: diff --git a/models/month_stats.go b/models/month_stats.go index 7d73f36..a40c003 100644 --- a/models/month_stats.go +++ b/models/month_stats.go @@ -177,7 +177,8 @@ } if slf.Keyword != "" { - db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword)) + kw := fmt.Sprintf("%%%v%%", slf.Keyword) + db = db.Where("product_id like ? or product_name like ?", kw, kw) } if slf.Date != "" { diff --git a/request/report_forms_request.go b/request/report_forms_request.go index 5956eaa..7c50d03 100644 --- a/request/report_forms_request.go +++ b/request/report_forms_request.go @@ -25,3 +25,9 @@ ProductId string `json:"productId"` LocationId int `json:"locationId"` } + +type GetMonthStats struct { + PageInfo + Keyword string `json:"keyword"` + Date string `json:"date"` +} diff --git a/router/router.go b/router/router.go index b759a4c..5a37434 100644 --- a/router/router.go +++ b/router/router.go @@ -156,6 +156,7 @@ reportFormsAPI.POST("getInventoryForms", reportFormsController.GetInventoryForms) //鑾峰彇搴撳瓨鎶ヨ〃 reportFormsAPI.POST("getHistory", reportFormsController.GetHistory) //鑾峰彇搴撳瓨鍘嗗彶 reportFormsAPI.POST("getLocationForms", reportFormsController.GetLocationForms) //鑾峰彇浣嶇疆鎶ヨ〃 + reportFormsAPI.POST("monthStats", reportFormsController.MonthStats) //鑾峰彇鏈堝害缁熻鎶ヨ〃 } //閲嶈璐ц鍒� -- Gitblit v1.8.0