From b97b0ba40ae012e59cd3bba0960f485aae86bb13 Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期二, 26 九月 2023 09:31:04 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- controllers/product_controller.go | 20 + models/operation_type.go | 25 ++ controllers/operation_type.go | 30 ++ controllers/operation.go | 6 models/operation.go | 2 request/product_request.go | 28 +- docs/swagger.yaml | 116 +--------- request/operation.go | 11 docs/docs.go | 180 +--------------- models/operation_details.go | 13 docs/swagger.json | 180 +--------------- 11 files changed, 133 insertions(+), 478 deletions(-) diff --git a/controllers/operation.go b/controllers/operation.go index 9d6fa9b..872fb4c 100644 --- a/controllers/operation.go +++ b/controllers/operation.go @@ -115,9 +115,9 @@ if v.ProductId == "" { return errors.New("productID涓虹┖") } - if v.ProductName == "" { - return errors.New("浜у搧鍚嶇О寮傚父") - } + //if v.ProductName == "" { + // return errors.New("浜у搧鍚嶇О寮傚父") + //} if v.Amount.IsNegative() { return errors.New("浜у搧鏁伴噺鍑洪敊") } diff --git a/controllers/operation_type.go b/controllers/operation_type.go index 3d21412..8737781 100644 --- a/controllers/operation_type.go +++ b/controllers/operation_type.go @@ -6,6 +6,8 @@ "github.com/gin-gonic/gin" "github.com/spf13/cast" "gorm.io/gorm" + "strconv" + "wms/constvar" "wms/extend/code" "wms/extend/util" "wms/models" @@ -106,7 +108,7 @@ // @Summary 鏌ヨ浣滀笟绫诲瀷鍒楄〃 // @Produce application/json // @Param object query request.GetOperationTypeList true "鏌ヨ鍙傛暟" -// @Success 200 {object} util.ResponseList{data=[]models.OperationType} "鎴愬姛" +// @Success 200 {object} util.ResponseList "鎴愬姛" // @Router /api-wms/v1/operationType/operationType [get] func (slf OperationTypeController) List(c *gin.Context) { var params request.GetOperationTypeList @@ -116,11 +118,31 @@ } list, total, err := models.NewOperationTypeSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find() if err != nil { - util.ResponseFormat(c, code.RequestParamError, "鏌ユ壘澶辫触") + util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触") return } - - util.ResponseFormatList(c, code.Success, list, cast.ToInt(total)) + var idList []int + for _, v := range list { + idList = append(idList, v.Id) + } + statistics, err := models.NewOperationTypeSearch().ListByStatusAndCount(idList) + if err != nil { + util.ResponseFormat(c, code.RequestError, err.Error()) + return + } + mapStatistics := make(map[string]*models.OperationTypeByStatus, 0) + for _, v := range statistics { + mapStatistics[strconv.Itoa(v.Id)+string(v.Status)] = v + } + for k, v := range list { + if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Ready)]; ok { + list[k].ReadyCount = value.Count + } + if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Finish)]; ok { + list[k].FinishCount = value.Count + } + } + util.ResponseFormatListWithPage(c, code.Success, list, cast.ToInt(total), params.Page, params.PageSize) } // Delete diff --git a/controllers/product_controller.go b/controllers/product_controller.go index ea2a74b..c5d99a2 100644 --- a/controllers/product_controller.go +++ b/controllers/product_controller.go @@ -359,10 +359,10 @@ return } detail := &models.OperationDetails{ - ProductId: params.ProductId, - ProductName: params.ProductName, - Amount: params.Amount, - Unit: params.Unit, + ProductId: params.ProductId, + //ProductName: params.ProductName, + Amount: params.Amount, + //Unit: params.Unit, } operation := models.Operation{ Number: strconv.FormatInt(time.Now().Unix(), 10), @@ -400,7 +400,9 @@ return } - db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id") + //db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,wms_operation_details.product_name,wms_operation_details.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id") + + db := models.NewOperationSearch().Orm.Table("wms_operation").Select("wms_operation.id,wms_operation.number,wms_operation.source_number,wms_operation.status,wms_operation.from_location_id,wms_operation.to_location_id,wms_operation.operation_date,wms_operation.contacter_id,wms_operation.contacter_name,wms_operation.company_id,wms_operation.company_name,wms_operation.comment,wms_operation_details.product_id,material.name as product_name,material.unit,wms_operation_details.amount").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").InnerJoins("inner join material on material.id=wms_operation_details.product_id") if params.SourceNumber != "" { db = db.Where("wms_operation.source_number like ?", fmt.Sprintf("%%%v%%", params.SourceNumber)) @@ -531,10 +533,10 @@ return } detail := &models.OperationDetails{ - ProductId: params.ProductId, - ProductName: params.ProductName, - Amount: params.Amount, - Unit: params.Unit, + ProductId: params.ProductId, + //ProductName: params.ProductName, + Amount: params.Amount, + //Unit: params.Unit, } operation := models.Operation{ Id: params.Id, diff --git a/docs/docs.go b/docs/docs.go index 5554acc..20caec6 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -675,22 +675,7 @@ "200": { "description": "鎴愬姛", "schema": { - "allOf": [ - { - "$ref": "#/definitions/util.ResponseList" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/models.OperationType" - } - } - } - } - ] + "$ref": "#/definitions/util.ResponseList" } } } @@ -2118,7 +2103,7 @@ "type": "object", "properties": { "amount": { - "description": "鏁伴噺", + "description": "ProductName string ` + "`" + `json:\"productName\" gorm:\"type:varchar(255);not null;comment:浜у搧鍚嶇О\"` + "`" + ` //浜у搧鍚嶇О", "type": "number" }, "createTime": { @@ -2131,141 +2116,20 @@ "description": "鎿嶄綔id", "type": "integer" }, + "product": { + "description": "Unit string ` + "`" + `json:\"unit\" gorm:\"type:varchar(31);comment:鍗曚綅\"` + "`" + ` //鍗曚綅", + "allOf": [ + { + "$ref": "#/definitions/models.Material" + } + ] + }, "productId": { "description": "浜у搧id", "type": "string" }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "unit": { - "type": "string" - }, "updateTime": { "type": "string" - } - } - }, - "models.OperationType": { - "type": "object", - "properties": { - "ReservationDaysBeforePriority": { - "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", - "type": "integer" - }, - "baseOperationType": { - "description": "鍩虹浣滀笟绫诲瀷", - "allOf": [ - { - "$ref": "#/definitions/constvar.BaseOperationType" - } - ] - }, - "company": { - "description": "鍏徃", - "allOf": [ - { - "$ref": "#/definitions/models.Company" - } - ] - }, - "companyId": { - "description": "鍏徃id", - "type": "integer" - }, - "createBackorder": { - "description": "鍒涘缓娆犲崟", - "allOf": [ - { - "$ref": "#/definitions/constvar.WhetherType" - } - ] - }, - "createTime": { - "type": "string" - }, - "defaultLocationDest": { - "description": "榛樿鐩爣浣嶇疆", - "allOf": [ - { - "$ref": "#/definitions/models.Location" - } - ] - }, - "defaultLocationDestId": { - "description": "榛樿鐩爣浣嶇疆id", - "type": "integer" - }, - "defaultLocationSrc": { - "description": "榛樿婧愪綅缃�", - "allOf": [ - { - "$ref": "#/definitions/models.Location" - } - ] - }, - "defaultLocationSrcId": { - "description": "榛樿婧愪綅缃甶d", - "type": "integer" - }, - "earlyOperations": { - "description": "棰勫~鍐欎綔涓氳鎯�", - "type": "boolean" - }, - "id": { - "type": "integer" - }, - "name": { - "description": "浠撳簱鍚嶇О", - "type": "string" - }, - "prefix": { - "description": "鍓嶇紑", - "type": "string" - }, - "printLabel": { - "description": "鏄惁鎵撳嵃鏍囩", - "type": "boolean" - }, - "reservationDaysBefore": { - "description": "鏀惰揣鍓嶅嚑澶�", - "type": "integer" - }, - "reservationMethod": { - "description": "淇濈暀鏂瑰紡", - "allOf": [ - { - "$ref": "#/definitions/constvar.ReservationMethod" - } - ] - }, - "returnOperationType": { - "description": "閫�璐х被鍨嬪悕绉�", - "type": "string" - }, - "returnOperationTypeID": { - "description": "閫�璐х被鍨婭D", - "type": "integer" - }, - "showOperations": { - "description": "鏄剧ず浣滀笟璇︽儏", - "type": "boolean" - }, - "updateTime": { - "type": "string" - }, - "warehouse": { - "description": "浠撳簱", - "allOf": [ - { - "$ref": "#/definitions/models.Warehouse" - } - ] - }, - "warehouseId": { - "description": "浠撳簱id", - "type": "integer" } } }, @@ -2430,6 +2294,7 @@ "type": "object", "properties": { "amount": { + "description": "ProductName string ` + "`" + `json:\"productName\"` + "`" + `", "type": "number" }, "fromLocationId": { @@ -2438,17 +2303,11 @@ "productId": { "type": "string" }, - "productName": { - "type": "string" - }, "sourceNumber": { "type": "string" }, "toLocationId": { "type": "integer" - }, - "unit": { - "type": "string" } } }, @@ -2693,18 +2552,11 @@ "type": "integer" }, "amount": { - "description": "鏁伴噺", + "description": "ProductName string ` + "`" + `json:\"productName\" gorm:\"type:varchar(255);not null;comment:浜у搧鍚嶇О\"` + "`" + ` //浜у搧鍚嶇О", "type": "number" }, "productId": { "description": "浜у搧id", - "type": "string" - }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "unit": { "type": "string" } } @@ -2806,6 +2658,7 @@ "type": "object", "properties": { "amount": { + "description": "ProductName string ` + "`" + `json:\"productName\"` + "`" + `", "type": "number" }, "fromLocationId": { @@ -2815,15 +2668,13 @@ "type": "integer" }, "number": { + "description": "Unit string ` + "`" + `json:\"unit\"` + "`" + `", "type": "string" }, "operationDate": { "type": "string" }, "productId": { - "type": "string" - }, - "productName": { "type": "string" }, "sourceNumber": { @@ -2834,9 +2685,6 @@ }, "toLocationId": { "type": "integer" - }, - "unit": { - "type": "string" } } }, diff --git a/docs/swagger.json b/docs/swagger.json index 86a516f..801bf26 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -663,22 +663,7 @@ "200": { "description": "鎴愬姛", "schema": { - "allOf": [ - { - "$ref": "#/definitions/util.ResponseList" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/models.OperationType" - } - } - } - } - ] + "$ref": "#/definitions/util.ResponseList" } } } @@ -2106,7 +2091,7 @@ "type": "object", "properties": { "amount": { - "description": "鏁伴噺", + "description": "ProductName string `json:\"productName\" gorm:\"type:varchar(255);not null;comment:浜у搧鍚嶇О\"` //浜у搧鍚嶇О", "type": "number" }, "createTime": { @@ -2119,141 +2104,20 @@ "description": "鎿嶄綔id", "type": "integer" }, + "product": { + "description": "Unit string `json:\"unit\" gorm:\"type:varchar(31);comment:鍗曚綅\"` //鍗曚綅", + "allOf": [ + { + "$ref": "#/definitions/models.Material" + } + ] + }, "productId": { "description": "浜у搧id", "type": "string" }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "unit": { - "type": "string" - }, "updateTime": { "type": "string" - } - } - }, - "models.OperationType": { - "type": "object", - "properties": { - "ReservationDaysBeforePriority": { - "description": "鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ", - "type": "integer" - }, - "baseOperationType": { - "description": "鍩虹浣滀笟绫诲瀷", - "allOf": [ - { - "$ref": "#/definitions/constvar.BaseOperationType" - } - ] - }, - "company": { - "description": "鍏徃", - "allOf": [ - { - "$ref": "#/definitions/models.Company" - } - ] - }, - "companyId": { - "description": "鍏徃id", - "type": "integer" - }, - "createBackorder": { - "description": "鍒涘缓娆犲崟", - "allOf": [ - { - "$ref": "#/definitions/constvar.WhetherType" - } - ] - }, - "createTime": { - "type": "string" - }, - "defaultLocationDest": { - "description": "榛樿鐩爣浣嶇疆", - "allOf": [ - { - "$ref": "#/definitions/models.Location" - } - ] - }, - "defaultLocationDestId": { - "description": "榛樿鐩爣浣嶇疆id", - "type": "integer" - }, - "defaultLocationSrc": { - "description": "榛樿婧愪綅缃�", - "allOf": [ - { - "$ref": "#/definitions/models.Location" - } - ] - }, - "defaultLocationSrcId": { - "description": "榛樿婧愪綅缃甶d", - "type": "integer" - }, - "earlyOperations": { - "description": "棰勫~鍐欎綔涓氳鎯�", - "type": "boolean" - }, - "id": { - "type": "integer" - }, - "name": { - "description": "浠撳簱鍚嶇О", - "type": "string" - }, - "prefix": { - "description": "鍓嶇紑", - "type": "string" - }, - "printLabel": { - "description": "鏄惁鎵撳嵃鏍囩", - "type": "boolean" - }, - "reservationDaysBefore": { - "description": "鏀惰揣鍓嶅嚑澶�", - "type": "integer" - }, - "reservationMethod": { - "description": "淇濈暀鏂瑰紡", - "allOf": [ - { - "$ref": "#/definitions/constvar.ReservationMethod" - } - ] - }, - "returnOperationType": { - "description": "閫�璐х被鍨嬪悕绉�", - "type": "string" - }, - "returnOperationTypeID": { - "description": "閫�璐х被鍨婭D", - "type": "integer" - }, - "showOperations": { - "description": "鏄剧ず浣滀笟璇︽儏", - "type": "boolean" - }, - "updateTime": { - "type": "string" - }, - "warehouse": { - "description": "浠撳簱", - "allOf": [ - { - "$ref": "#/definitions/models.Warehouse" - } - ] - }, - "warehouseId": { - "description": "浠撳簱id", - "type": "integer" } } }, @@ -2418,6 +2282,7 @@ "type": "object", "properties": { "amount": { + "description": "ProductName string `json:\"productName\"`", "type": "number" }, "fromLocationId": { @@ -2426,17 +2291,11 @@ "productId": { "type": "string" }, - "productName": { - "type": "string" - }, "sourceNumber": { "type": "string" }, "toLocationId": { "type": "integer" - }, - "unit": { - "type": "string" } } }, @@ -2681,18 +2540,11 @@ "type": "integer" }, "amount": { - "description": "鏁伴噺", + "description": "ProductName string `json:\"productName\" gorm:\"type:varchar(255);not null;comment:浜у搧鍚嶇О\"` //浜у搧鍚嶇О", "type": "number" }, "productId": { "description": "浜у搧id", - "type": "string" - }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "unit": { "type": "string" } } @@ -2794,6 +2646,7 @@ "type": "object", "properties": { "amount": { + "description": "ProductName string `json:\"productName\"`", "type": "number" }, "fromLocationId": { @@ -2803,15 +2656,13 @@ "type": "integer" }, "number": { + "description": "Unit string `json:\"unit\"`", "type": "string" }, "operationDate": { "type": "string" }, "productId": { - "type": "string" - }, - "productName": { "type": "string" }, "sourceNumber": { @@ -2822,9 +2673,6 @@ }, "toLocationId": { "type": "integer" - }, - "unit": { - "type": "string" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d43edc4..81acff3 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -478,7 +478,8 @@ models.OperationDetails: properties: amount: - description: 鏁伴噺 + description: ProductName string `json:"productName" gorm:"type:varchar(255);not + null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О type: number createTime: type: string @@ -487,92 +488,15 @@ operationId: description: 鎿嶄綔id type: integer + product: + allOf: + - $ref: '#/definitions/models.Material' + description: Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` //鍗曚綅 productId: description: 浜у搧id type: string - productName: - description: 浜у搧鍚嶇О - type: string - unit: - type: string updateTime: type: string - type: object - models.OperationType: - properties: - ReservationDaysBeforePriority: - description: 鍦ㄤ紭鍏堢骇鐨勫墠鍑犲ぉ - type: integer - baseOperationType: - allOf: - - $ref: '#/definitions/constvar.BaseOperationType' - description: 鍩虹浣滀笟绫诲瀷 - company: - allOf: - - $ref: '#/definitions/models.Company' - description: 鍏徃 - companyId: - description: 鍏徃id - type: integer - createBackorder: - allOf: - - $ref: '#/definitions/constvar.WhetherType' - description: 鍒涘缓娆犲崟 - createTime: - type: string - defaultLocationDest: - allOf: - - $ref: '#/definitions/models.Location' - description: 榛樿鐩爣浣嶇疆 - defaultLocationDestId: - description: 榛樿鐩爣浣嶇疆id - type: integer - defaultLocationSrc: - allOf: - - $ref: '#/definitions/models.Location' - description: 榛樿婧愪綅缃� - defaultLocationSrcId: - description: 榛樿婧愪綅缃甶d - type: integer - earlyOperations: - description: 棰勫~鍐欎綔涓氳鎯� - type: boolean - id: - type: integer - name: - description: 浠撳簱鍚嶇О - type: string - prefix: - description: 鍓嶇紑 - type: string - printLabel: - description: 鏄惁鎵撳嵃鏍囩 - type: boolean - reservationDaysBefore: - description: 鏀惰揣鍓嶅嚑澶� - type: integer - reservationMethod: - allOf: - - $ref: '#/definitions/constvar.ReservationMethod' - description: 淇濈暀鏂瑰紡 - returnOperationType: - description: 閫�璐х被鍨嬪悕绉� - type: string - returnOperationTypeID: - description: 閫�璐х被鍨婭D - type: integer - showOperations: - description: 鏄剧ず浣滀笟璇︽儏 - type: boolean - updateTime: - type: string - warehouse: - allOf: - - $ref: '#/definitions/models.Warehouse' - description: 浠撳簱 - warehouseId: - description: 浠撳簱id - type: integer type: object models.ProductCategory: properties: @@ -684,19 +608,16 @@ request.AddDisuse: properties: amount: + description: ProductName string `json:"productName"` type: number fromLocationId: type: integer productId: type: string - productName: - type: string sourceNumber: type: string toLocationId: type: integer - unit: - type: string type: object request.AddOperation: properties: @@ -865,15 +786,11 @@ description: 鎿嶄綔id type: integer amount: - description: 鏁伴噺 + description: ProductName string `json:"productName" gorm:"type:varchar(255);not + null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О type: number productId: description: 浜у搧id - type: string - productName: - description: 浜у搧鍚嶇О - type: string - unit: type: string type: object request.OperationList: @@ -943,18 +860,18 @@ request.UpdateDisuse: properties: amount: + description: ProductName string `json:"productName"` type: number fromLocationId: type: integer id: type: integer number: + description: Unit string `json:"unit"` type: string operationDate: type: string productId: - type: string - productName: type: string sourceNumber: type: string @@ -962,8 +879,6 @@ $ref: '#/definitions/constvar.OperationStatus' toLocationId: type: integer - unit: - type: string type: object request.UpdateOperation: properties: @@ -1496,14 +1411,7 @@ "200": description: 鎴愬姛 schema: - allOf: - - $ref: '#/definitions/util.ResponseList' - - properties: - data: - items: - $ref: '#/definitions/models.OperationType' - type: array - type: object + $ref: '#/definitions/util.ResponseList' summary: 鏌ヨ浣滀笟绫诲瀷鍒楄〃 tags: - 涓氬姟绫诲瀷 diff --git a/models/operation.go b/models/operation.go index b0d64d4..7f17d4a 100644 --- a/models/operation.go +++ b/models/operation.go @@ -134,7 +134,7 @@ } if slf.Preload { - db = db.Model(&Operation{}).Preload("Details").Preload("FromLocation").Preload("ToLocation") + db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").Preload("ToLocation") } if slf.Disuse { diff --git a/models/operation_details.go b/models/operation_details.go index 18e8cfd..32e8f9a 100644 --- a/models/operation_details.go +++ b/models/operation_details.go @@ -11,12 +11,13 @@ // OperationDetails 鎿嶄綔鏄庣粏琛� OperationDetails struct { WmsModel - Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` - OperationID int `json:"operationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id - ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id - ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О - Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺 - Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` + Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` + OperationID int `json:"operationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id + ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id + //ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О + Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺 + //Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` //鍗曚綅 + Product Material `json:"product" gorm:"foreignKey:ProductId;references:ID"` } OperationDetailsSearch struct { diff --git a/models/operation_type.go b/models/operation_type.go index b97e0b0..26842f7 100644 --- a/models/operation_type.go +++ b/models/operation_type.go @@ -34,6 +34,8 @@ CreateBackorder constvar.WhetherType `json:"createBackorder" gorm:"column:create_backorder"` //鍒涘缓娆犲崟 ReturnOperationTypeID int `json:"returnOperationTypeID" gorm:"column:return_job_type_id"` //閫�璐х被鍨婭D ReturnOperationType string `json:"returnOperationType" gorm:"-"` //閫�璐х被鍨嬪悕绉� + ReadyCount int `json:"readyCount" gorm:"-"` //灏辩华鏁伴噺 + FinishCount int `json:"finishCount" gorm:"-"` //瀹屾垚鏁伴噺 } OperationTypeSearch struct { @@ -44,6 +46,12 @@ Keyword string Orm *gorm.DB Preload bool + } + + OperationTypeByStatus struct { + Id int `gorm:"column:id"` + Status constvar.OperationStatus `gorm:"column:status"` + Count int `gorm:"column:count"` } ) @@ -268,3 +276,20 @@ return records, nil } + +func (slf *OperationTypeSearch) ListByStatusAndCount(idList []int) ([]*OperationTypeByStatus, error) { + var ( + records = make([]*OperationTypeByStatus, 0) + db = slf.Orm + ) + db = db.Table("wms_job_type").Select("wms_job_type.id,wms_operation.status,count(wms_operation.id) as count").InnerJoins("inner join wms_operation on wms_operation.operation_type_id=wms_job_type.id").Group("wms_job_type.id,wms_operation.status") + if len(idList) > 0 { + db = db.Where("wms_job_type.id IN ?", idList) + } + + if err := db.Find(&records).Error; err != nil { + return records, fmt.Errorf("func ListByStatusAndCount err: %v, ", err) + } + + return records, nil +} diff --git a/request/operation.go b/request/operation.go index 9e730f2..5f17078 100644 --- a/request/operation.go +++ b/request/operation.go @@ -30,11 +30,12 @@ } type OperationDetails struct { - OperationId int `json:"OperationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id - ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id - ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О - Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺 - Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` + OperationId int `json:"OperationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id + ProductId string `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"` //浜у搧id + //ProductName string `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О + Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"` //鏁伴噺 + //Unit string `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"` //鍗曚綅 + //Product models.Material `json:"product" gorm:"foreignKey:ProductId;references:ID"` } type OperationList struct { diff --git a/request/product_request.go b/request/product_request.go index c33ccea..2c91b79 100644 --- a/request/product_request.go +++ b/request/product_request.go @@ -17,13 +17,13 @@ } type AddDisuse struct { - ProductId string `json:"productId"` - ProductName string `json:"productName"` + ProductId string `json:"productId"` + //ProductName string `json:"productName"` Amount decimal.Decimal `json:"amount"` FromLocationId int `json:"fromLocationId"` ToLocationId int `json:"toLocationId"` SourceNumber string `json:"sourceNumber"` - Unit string `json:"unit"` + //Unit string `json:"unit"` } type QueryDisuseList struct { @@ -33,15 +33,15 @@ } type UpdateDisuse struct { - Id int `json:"id"` - ProductId string `json:"productId"` - ProductName string `json:"productName"` - Amount decimal.Decimal `json:"amount"` - FromLocationId int `json:"fromLocationId"` - ToLocationId int `json:"toLocationId"` - SourceNumber string `json:"sourceNumber"` - Unit string `json:"unit"` - Number string `json:"number"` - Status constvar.OperationStatus `json:"status"` - OperationDate string `json:"operationDate"` + Id int `json:"id"` + ProductId string `json:"productId"` + //ProductName string `json:"productName"` + Amount decimal.Decimal `json:"amount"` + FromLocationId int `json:"fromLocationId"` + ToLocationId int `json:"toLocationId"` + SourceNumber string `json:"sourceNumber"` + //Unit string `json:"unit"` + Number string `json:"number"` + Status constvar.OperationStatus `json:"status"` + OperationDate string `json:"operationDate"` } -- Gitblit v1.8.0