From 5c1dfdd9f0d51821ac47a46cba74ef94bfe0141e Mon Sep 17 00:00:00 2001 From: liujiandao <274878379@qq.com> Date: 星期三, 27 九月 2023 17:28:13 +0800 Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS --- controllers/product_controller.go | 30 + controllers/operation.go | 28 + models/location_product_amount.go | 15 controllers/location_product.go | 12 docs/swagger.yaml | 251 ++++------ docs/docs.go | 388 ++++++---------- docs/swagger.json | 386 ++++++---------- router/router.go | 18 constvar/const.go | 3 models/location_product.go | 18 models/db.go | 2 request/location_product_amount.go | 11 request/product_request.go | 6 controllers/location_product_amount.go | 205 +++++++- 14 files changed, 717 insertions(+), 656 deletions(-) diff --git a/constvar/const.go b/constvar/const.go index f92ca9a..5c6a63f 100644 --- a/constvar/const.go +++ b/constvar/const.go @@ -126,7 +126,8 @@ LocationTypeInventoryLoss // 搴撳瓨鎹熷け LocationTypeProduction // 鐢熶骇 LocationTypeTransit // 涓浆浣嶇疆 - LocationTypeDisuse + LocationTypeDisuse //鎶ュ簾浣嶇疆 + LocationTypeAdjust //搴撳瓨鐩樼偣 ) func (t LocationType) Valid() bool { diff --git a/controllers/location_product.go b/controllers/location_product.go index 07d012b..3ebb6ef 100644 --- a/controllers/location_product.go +++ b/controllers/location_product.go @@ -44,10 +44,10 @@ util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨浜у搧") return } - if params.ProductCategoryID == 0 { - util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨浜у搧绫诲埆") - return - } + //if params.ProductCategoryID == 0 { + // util.ResponseFormat(c, code.RequestParamError, "璇烽�夋嫨浜у搧绫诲埆") + // return + //} if err := models.NewLocationProductSearch().Create(¶ms); err != nil { logx.Errorf("Operation create err: %v", err) util.ResponseFormat(c, code.SaveFail, "娣诲姞澶辫触锛�"+err.Error()) @@ -69,7 +69,7 @@ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error()) return } - if params.Check() { + if !params.Check() { util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父") return } @@ -89,7 +89,7 @@ // @Tags 涓婃灦瑙勫垯 // @Summary 淇敼涓婃灦瑙勫垯 // @Produce application/json -// @Param object body request.UpdateLocationProduct true "鍏ュ簱淇℃伅" +// @Param object body request.UpdateLocationProduct true "淇敼鍙傛暟" // @Success 200 {object} util.Response "鎴愬姛" // @Router /api-wms/v1/locationProduct/update [post] func (slf LocationProductController) Update(c *gin.Context) { diff --git a/controllers/location_product_amount.go b/controllers/location_product_amount.go index 701a205..c2c1c16 100644 --- a/controllers/location_product_amount.go +++ b/controllers/location_product_amount.go @@ -3,6 +3,10 @@ import ( "fmt" "github.com/gin-gonic/gin" + "github.com/shopspring/decimal" + "gorm.io/gorm" + "strconv" + "time" "wms/constvar" "wms/extend/code" "wms/extend/util" @@ -19,14 +23,14 @@ // @Produce application/json // @Param object body request.PageInfo true "鏌ヨ鍙傛暟" // @Success 200 {object} util.Response "鎴愬姛" -// @Router /api-wms/v1/locationProduct/list [post] +// @Router /api-wms/v1/locationProductAmount/list [post] func (slf LocationProductAmountController) List(c *gin.Context) { var params request.PageInfo if err := c.BindJSON(¶ms); err != nil { util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error()) return } - if params.Check() { + if !params.Check() { util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父") return } @@ -34,10 +38,27 @@ search := models.NewLocationProductAmountSearch() search.SetPage(params.Page, params.PageSize) - search.Orm = search.Orm.Model(&models.LocationProductAmountWithOperation{}).Table("wms_location_product_amount").Select("wms_location_product_amount.*,wms_operation.amount as adjust_amount").InnerJoins("inner join wms_location_product on wms_location_product.id=wms_location_product_amount.location_product_id").InnerJoins("inner join wms_operation_details on wms_operation_details.product_id=wms_location_product.product_id").InnerJoins("inner join wms_operation on wms_operation.id=wms_operation_details.operation_id").Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeAdjust) + search.Orm = search.Orm. + Table("wms_location_product_amount"). + Select(` + wms_location.id as location_id, + wms_location.name as location_name, + material.id as product_id, + material.name as product_name, + wms_location_product_amount.amount, + material.unit, + wms_location_product_amount.create_date, + wms_operation_details.amount as adjust_amount, + wms_operation.id as operation_id`). + InnerJoins("inner join wms_location_product on wms_location_product.id=wms_location_product_amount.location_product_id"). + InnerJoins("inner join wms_location on wms_location.id=wms_location_product.location_id"). + InnerJoins("inner join wms_operation_details on wms_operation_details.product_id=wms_location_product.product_id"). + InnerJoins("inner join material on material.id=wms_operation_details.product_id"). + InnerJoins("inner join wms_operation on wms_operation.id=wms_operation_details.operation_id"). + Where("wms_operation.base_operation_type=?", constvar.BaseOperationTypeAdjust) var ( - records = make([]*models.ResponseDisuseList, 0) + records = make([]*models.LocationProductAmountWithOperation, 0) total int64 ) @@ -45,7 +66,7 @@ util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err)) return } - search.Orm = search.Orm.Preload("LocationProduct").Preload("LocationProduct.Location").Preload("LocationProduct.Product") + //search.Orm = search.Orm.Preload("LocationProduct").Preload("LocationProduct.Location").Preload("LocationProduct.Product") if params.Page*params.PageSize > 0 { search.Orm = search.Orm.Offset((params.Page - 1) * params.PageSize).Limit(params.PageSize) } @@ -53,7 +74,9 @@ util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err)) return } - + for k, v := range records { + records[k].DifferenceAmount = v.Amount.Sub(v.AdjustAmount) + } util.ResponseFormatListWithPage(c, code.Success, records, int(total), params.Page, params.PageSize) } @@ -63,40 +86,172 @@ // @Produce application/json // @Param object body request.AddLocationProductAmount true "鍏ュ簱/鍑哄簱淇℃伅" // @Success 200 {object} util.Response "鎴愬姛" -// @Router /api-wms/v1/operation/operation [post] -//func (slf LocationProductAmountController) Add(c *gin.Context) { -// var reqParams request.AddLocationProductAmount +// @Router /api-wms/v1/locationProductAmount/add [post] +func (slf LocationProductAmountController) Add(c *gin.Context) { + var reqParams request.AddLocationProductAmount + if err := c.BindJSON(&reqParams); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") + return + } + if reqParams.LocationId == 0 { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父锛岃閫夋嫨浣嶇疆") + return + } + if reqParams.ProductId == "" { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父锛岃閫夋嫨浜у搧") + return + } + + var existCount int64 + if err := models.NewOperationSearch().Orm.Table("wms_operation").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.from_location_id=? and wms_operation_details.product_id=? and wms_operation.base_operation_type=? and wms_operation.status=?", reqParams.LocationId, reqParams.ProductId, constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready).Count(&existCount).Error; err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + if existCount > 0 { + util.ResponseFormat(c, code.RequestError, "璇ュ晢鍝佸湪宸查�変腑鐨勪綅缃瓨鍦ㄦ湭楠岃瘉鐨勫簱瀛樼洏鐐逛俊鎭紝鏃犳硶缁х画娣诲姞鐩稿叧淇℃伅") + return + } + + locProduct, err := models.NewLocationProductSearch().SetLocationId(reqParams.LocationId).SetProductId(reqParams.ProductId).First() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父锛屾湭鎵惧埌璇ヤ笂鏋惰鍒�") + return + } + if locProduct.Id == 0 { + util.ResponseFormat(c, code.RequestError, "涓嶅瓨鍦ㄨ涓婃灦瑙勫垯锛屾棤娉曡繘琛屽簱瀛樼洏鐐�") + return + } + location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeAdjust)).First() + if err != nil { + util.ResponseFormat(c, code.RequestParamError, err.Error()) + return + } + //reqParams.AdjustAmount = reqParams.Amount.Sub(reqParams.DifferenceAmount) + reqParams.AdjustAmount = reqParams.DifferenceAmount.Sub(reqParams.Amount) + locAmount := models.LocationProductAmount{ + LocationProductId: locProduct.Id, + Amount: decimal.NewFromInt(0), + CreateDate: time.Now().Format("2006-01-02 15:04:05"), + } + detail := &models.OperationDetails{ + ProductId: reqParams.ProductId, + Amount: reqParams.AdjustAmount, + } + operation := models.Operation{ + Number: strconv.FormatInt(time.Now().Unix(), 10), + Status: constvar.OperationStatus_Ready, + OperationDate: time.Now().Format("2006-01-02 15:04:05"), + Comment: "搴撳瓨鐩樼偣", + BaseOperationType: constvar.BaseOperationTypeAdjust, + Details: []*models.OperationDetails{detail}, + FromLocationID: location.Id, + ToLocationID: reqParams.LocationId, + } + + //if reqParams.AdjustAmount.GreaterThanOrEqual(decimal.NewFromInt(0)) { + // operation.FromLocationID = Location.Id + // operation.ToLocationID = reqParams.LocationId + //} else { + // operation.FromLocationID = reqParams.LocationId + // operation.ToLocationID = Location.Id + //} + + if err := models.WithTransaction(func(tx *gorm.DB) error { + if err := models.NewOperationSearch().SetOrm(tx).Create(&operation); err != nil { + return err + } + if err := models.NewLocationProductAmountSearch().SetOrm(tx).Create(&locAmount); err != nil { + return err + } + return nil + }); err != nil { + util.ResponseFormat(c, code.RequestError, err.Error()) + return + } + + util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") +} + +// Add +// @Tags 搴撳瓨鐩樼偣 +// @Summary 淇敼搴撳瓨鐩樼偣淇℃伅 +// @Produce application/json +// @Param object body request.UpdateLocationProductAmount true "鍏ュ簱/鍑哄簱淇℃伅" +// @Success 200 {object} util.Response "鎴愬姛" +// @Router /api-wms/v1/locationProductAmount/update [post] +//func (slf LocationProductAmountController) Update(c *gin.Context) { +// var reqParams request.UpdateLocationProductAmount // if err := c.BindJSON(&reqParams); err != nil { // util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�") // return // } -// if reqParams.LocationProductAmountId==0 { -// util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父锛宭ocationProductAmountId涓�0") +// +// var existCount int64 +// if err := models.NewOperationSearch().Orm.Table("wms_operation").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.from_location_id=? and wms_operation_details.product_id=? and wms_operation.base_operation_type=? and wms_operation.status=?", reqParams.LocationId, reqParams.ProductId, constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready).Count(&existCount).Error; err != nil { +// util.ResponseFormat(c, code.RequestParamError, err.Error()) // return // } -// locAmount:=models.LocationProductAmount{ -// LocationProductId: reqParams.LocationProductAmountId +// if existCount > 0 { +// util.ResponseFormat(c, code.RequestError, "璇ュ晢鍝佸湪宸查�変腑鐨勪綅缃瓨鍦ㄦ湭楠岃瘉鐨勫簱瀛樼洏鐐逛俊鎭紝鏃犳硶缁х画娣诲姞鐩稿叧淇℃伅") +// return // } -// operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First() +// +// locProduct, err := models.NewLocationProductSearch().SetLocationId(reqParams.LocationId).SetProductId(reqParams.ProductId).First() +// if err != nil { +// util.ResponseFormat(c, code.RequestParamError, "鍙傛暟寮傚父锛屾湭鎵惧埌璇ヤ笂鏋惰鍒�") +// return +// } +// if locProduct.Id == 0 { +// util.ResponseFormat(c, code.RequestError, "涓嶅瓨鍦ㄨ涓婃灦瑙勫垯锛屾棤娉曡繘琛屽簱瀛樼洏鐐�") +// return +// } +// location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeAdjust)).First() // if err != nil { // util.ResponseFormat(c, code.RequestParamError, err.Error()) // return // } -// ////// -// if location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeCustomer)).First(); err != nil { -// return err -// } else { -// params.ToLocationID = location.Id +// //reqParams.AdjustAmount = reqParams.Amount.Sub(reqParams.DifferenceAmount) +// reqParams.AdjustAmount = reqParams.DifferenceAmount.Sub(reqParams.Amount) +// locAmount := models.LocationProductAmount{ +// LocationProductId: locProduct.Id, +// Amount: decimal.NewFromInt(0), +// CreateDate: time.Now().Format("2006-01-02 15:04:05"), +// } +// detail := &models.OperationDetails{ +// ProductId: reqParams.ProductId, +// Amount: reqParams.AdjustAmount, +// } +// operation := models.Operation{ +// Number: strconv.FormatInt(time.Now().Unix(), 10), +// Status: constvar.OperationStatus_Ready, +// OperationDate: time.Now().Format("2006-01-02 15:04:05"), +// Comment: "搴撳瓨鐩樼偣", +// BaseOperationType: constvar.BaseOperationTypeAdjust, +// Details: []*models.OperationDetails{detail}, +// FromLocationID: location.Id, +// ToLocationID: reqParams.LocationId, // } // +// //if reqParams.AdjustAmount.GreaterThanOrEqual(decimal.NewFromInt(0)) { +// // operation.FromLocationID = Location.Id +// // operation.ToLocationID = reqParams.LocationId +// //} else { +// // operation.FromLocationID = reqParams.LocationId +// // operation.ToLocationID = Location.Id +// //} // -// params.Status = constvar.OperationStatus_Ready -// params.Number = strconv.FormatInt(time.Now().Unix(), 10) -// params.BaseOperationType = operationType.BaseOperationType -// if err := models.NewOperationSearch().Create(¶ms); err != nil { -// logx.Errorf("Operation create err: %v", err) -// util.ResponseFormat(c, code.SaveFail, "娣诲姞澶辫触锛�"+err.Error()) +// if err := models.WithTransaction(func(tx *gorm.DB) error { +// if err := models.NewOperationSearch().SetOrm(tx).Create(&operation); err != nil { +// return err +// } +// if err := models.NewLocationProductAmountSearch().SetOrm(tx).Create(&locAmount); err != nil { +// return err +// } +// return nil +// }); err != nil { +// util.ResponseFormat(c, code.RequestError, err.Error()) // return // } +// // util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") //} diff --git a/controllers/operation.go b/controllers/operation.go index 9a87ab0..fa8137d 100644 --- a/controllers/operation.go +++ b/controllers/operation.go @@ -6,6 +6,7 @@ "github.com/gin-gonic/gin" "github.com/shopspring/decimal" "gorm.io/gorm" + "sort" "strconv" "time" "wms/constvar" @@ -46,6 +47,12 @@ util.ResponseFormat(c, code.RequestParamError, err.Error()) return } + + if CheckDetailsRepeat(params.Details) { + util.ResponseFormat(c, code.RequestParamError, "鏄庣粏涓笉鑳藉瓨鍦ㄩ噸澶嶇殑浜у搧") + return + } + operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First() if err != nil { util.ResponseFormat(c, code.RequestParamError, err.Error()) @@ -61,6 +68,23 @@ return } util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") +} + +func CheckDetailsRepeat(details []*models.OperationDetails) bool { + detailIDs := []string{} + var tempID string + for _, v := range details { + detailIDs = append(detailIDs, v.ProductId) + } + sort.Strings(detailIDs) + for _, v := range detailIDs { + if v != tempID { + tempID = v + } else { + return true + } + } + return false } func (slf OperationController) FormatLocation(params *models.Operation) error { @@ -202,6 +226,10 @@ util.ResponseFormat(c, code.RequestParamError, err.Error()) return } + if CheckDetailsRepeat(params.Details) { + util.ResponseFormat(c, code.RequestParamError, "鏄庣粏涓笉鑳藉瓨鍦ㄩ噸澶嶇殑浜у搧") + return + } if err := slf.FormatLocation(¶ms); err != nil { util.ResponseFormat(c, code.RequestParamError, err.Error()) return diff --git a/controllers/product_controller.go b/controllers/product_controller.go index c1f3d00..333d2b0 100644 --- a/controllers/product_controller.go +++ b/controllers/product_controller.go @@ -566,3 +566,33 @@ } util.ResponseFormat(c, code.Success, "娣诲姞鎴愬姛") } + +// ListHistory +// @Tags 浜у搧 +// @Summary 浜у搧浣嶇疆鍘嗗彶淇℃伅 +// @Produce application/json +// @Param object body request.QueryOperationHistory true "鏌ヨ鍙傛暟" +// @Success 200 {object} util.ResponseList{data=[]models.Operation} "鎴愬姛" +// @Router /api-wms/v1/product/listHistory [post] +func (slf ProductController) ListHistory(c *gin.Context) { + var params request.QueryOperationHistory + if err := c.BindJSON(¶ms); err != nil { + util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error()) + return + } + if !params.PageInfo.Check() { + util.ResponseFormat(c, code.RequestParamError, "椤电爜淇℃伅閿欒") + return + } + + search := models.NewOperationSearch().SetPage(params.Page, params.PageSize).SetPreload(true).SetOrder("created_at desc") + search.SetOrm(search.Orm.InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation_details.product_id=? and (wms_operation.from_location_id=? or wms_operation.to_location_id=?)", params.ProductId, params.LocationId, params.LocationId)) + + list, total, err := search.Find() + if err != nil { + util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error()) + return + } + + util.ResponseFormatListWithPage(c, code.Success, list, int(total), params.Page, params.PageSize) +} diff --git a/docs/docs.go b/docs/docs.go index 00d724a..d20b847 100644 --- a/docs/docs.go +++ b/docs/docs.go @@ -294,96 +294,6 @@ } } }, - "/api-wms/v1/forms/getInventoryForms": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "鎶ヨ〃" - ], - "summary": "鑾峰彇搴撳瓨鎶ヨ〃", - "parameters": [ - { - "description": "鏌ヨ鍙傛暟", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.GetInventoryForms" - } - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/util.ResponseList" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/response.InventoryForms" - } - } - } - } - ] - } - } - } - } - }, - "/api-wms/v1/forms/getInventoryHistory": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "鎶ヨ〃" - ], - "summary": "鑾峰彇搴撳瓨鍘嗗彶", - "parameters": [ - { - "description": "鏌ヨ鍙傛暟", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.GetInventoryHistory" - } - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/util.ResponseList" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/response.InventoryHistory" - } - } - } - } - ] - } - } - } - } - }, "/api-wms/v1/location/addLocation": { "post": { "produces": [ @@ -621,9 +531,9 @@ "application/json" ], "tags": [ - "搴撳瓨鐩樼偣" + "涓婃灦瑙勫垯" ], - "summary": "搴撳瓨鐩樼偣鍒楄〃", + "summary": "涓婃灦瑙勫垯鍒楄〃", "parameters": [ { "description": "鏌ヨ鍙傛暟", @@ -656,12 +566,72 @@ "summary": "淇敼涓婃灦瑙勫垯", "parameters": [ { - "description": "鍏ュ簱淇℃伅", + "description": "淇敼鍙傛暟", "name": "object", "in": "body", "required": true, "schema": { "$ref": "#/definitions/request.UpdateLocationProduct" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/locationProductAmount/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "搴撳瓨鐩樼偣" + ], + "summary": "娣诲姞搴撳瓨鐩樼偣淇℃伅", + "parameters": [ + { + "description": "鍏ュ簱/鍑哄簱淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddLocationProductAmount" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/locationProductAmount/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "搴撳瓨鐩樼偣" + ], + "summary": "搴撳瓨鐩樼偣鍒楄〃", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.PageInfo" } } ], @@ -1354,6 +1324,51 @@ } } }, + "/api-wms/v1/product/listHistory": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "浜у搧浣嶇疆鍘嗗彶淇℃伅", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.QueryOperationHistory" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Operation" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/product/listOperaton": { "post": { "produces": [ @@ -1774,10 +1789,13 @@ 5, 6, 7, - 8 + 8, + 9 ], "x-enum-comments": { + "LocationTypeAdjust": "搴撳瓨鐩樼偣", "LocationTypeCustomer": "瀹㈡埛浣嶇疆", + "LocationTypeDisuse": "鎶ュ簾浣嶇疆", "LocationTypeInternal": "鍐呴儴浣嶇疆", "LocationTypeInventoryLoss": "搴撳瓨鎹熷け", "LocationTypeProduction": "鐢熶骇", @@ -1793,7 +1811,8 @@ "LocationTypeInventoryLoss", "LocationTypeProduction", "LocationTypeTransit", - "LocationTypeDisuse" + "LocationTypeDisuse", + "LocationTypeAdjust" ] }, "constvar.MaterialMode": { @@ -2554,6 +2573,29 @@ } } }, + "request.AddLocationProductAmount": { + "type": "object", + "properties": { + "Amount": { + "description": "搴撳瓨鏁伴噺", + "type": "number" + }, + "adjustAmount": { + "description": "宸��", + "type": "number" + }, + "differenceAmount": { + "description": "璁℃暟鏁伴噺", + "type": "number" + }, + "locationId": { + "type": "integer" + }, + "productId": { + "type": "string" + } + } + }, "request.AddOperation": { "type": "object", "properties": { @@ -2749,55 +2791,6 @@ } } }, - "request.GetInventoryForms": { - "type": "object", - "properties": { - "categoryIds": { - "description": "浜у搧绫诲瀷id", - "type": "array", - "items": { - "type": "integer" - } - }, - "page": { - "description": "椤电爜", - "type": "integer" - }, - "pageSize": { - "description": "姣忛〉澶у皬", - "type": "integer" - }, - "warehouseCode": { - "description": "浠撳簱缂╁啓", - "type": "string" - } - } - }, - "request.GetInventoryHistory": { - "type": "object", - "properties": { - "page": { - "description": "椤电爜", - "type": "integer" - }, - "pageSize": { - "description": "姣忛〉澶у皬", - "type": "integer" - }, - "produceId": { - "description": "浜у搧id", - "type": "string" - }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "unit": { - "description": "鍗曚綅", - "type": "string" - } - } - }, "request.GetProductList": { "type": "object", "properties": { @@ -2903,6 +2896,25 @@ "type": "integer" }, "sourceNumber": { + "type": "string" + } + } + }, + "request.QueryOperationHistory": { + "type": "object", + "properties": { + "locationId": { + "type": "integer" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + }, + "productId": { "type": "string" } } @@ -3168,92 +3180,6 @@ } } }, - "response.InventoryForms": { - "type": "object", - "properties": { - "amount": { - "description": "鍦ㄥ簱鏁伴噺", - "type": "number" - }, - "availableNumber": { - "description": "鍙敤搴撳瓨", - "type": "number" - }, - "cost": { - "description": "鎴愭湰", - "type": "number" - }, - "in": { - "description": "鍏ュ簱", - "type": "number" - }, - "out": { - "description": "鍑哄簱", - "type": "number" - }, - "produceId": { - "description": "浜у搧id", - "type": "string" - }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "productType": { - "description": "浜у搧绫诲瀷", - "type": "string" - }, - "unit": { - "description": "鍗曚綅", - "type": "string" - }, - "value": { - "description": "鎬讳环鍊�", - "type": "number" - } - } - }, - "response.InventoryHistory": { - "type": "object", - "properties": { - "amount": { - "description": "鏁伴噺", - "type": "number" - }, - "baseOperationType": { - "description": "鍩虹浣滀笟绫诲瀷", - "allOf": [ - { - "$ref": "#/definitions/constvar.BaseOperationType" - } - ] - }, - "contactedName": { - "description": "瀹屾垚鑰�", - "type": "string" - }, - "date": { - "description": "鏃ユ湡", - "type": "string" - }, - "fromLocation": { - "description": "婧愪綅缃�", - "type": "string" - }, - "number": { - "description": "鍗曞彿", - "type": "string" - }, - "toLocation": { - "description": "鐩爣浣嶇疆", - "type": "string" - }, - "unit": { - "description": "鍗曚綅", - "type": "string" - } - } - }, "util.Response": { "type": "object", "properties": { @@ -3300,8 +3226,6 @@ Description: "", InfoInstanceName: "swagger", SwaggerTemplate: docTemplate, - LeftDelim: "{{", - RightDelim: "}}", } func init() { diff --git a/docs/swagger.json b/docs/swagger.json index f34ccf1..330c147 100644 --- a/docs/swagger.json +++ b/docs/swagger.json @@ -282,96 +282,6 @@ } } }, - "/api-wms/v1/forms/getInventoryForms": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "鎶ヨ〃" - ], - "summary": "鑾峰彇搴撳瓨鎶ヨ〃", - "parameters": [ - { - "description": "鏌ヨ鍙傛暟", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.GetInventoryForms" - } - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/util.ResponseList" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/response.InventoryForms" - } - } - } - } - ] - } - } - } - } - }, - "/api-wms/v1/forms/getInventoryHistory": { - "post": { - "produces": [ - "application/json" - ], - "tags": [ - "鎶ヨ〃" - ], - "summary": "鑾峰彇搴撳瓨鍘嗗彶", - "parameters": [ - { - "description": "鏌ヨ鍙傛暟", - "name": "object", - "in": "body", - "required": true, - "schema": { - "$ref": "#/definitions/request.GetInventoryHistory" - } - } - ], - "responses": { - "200": { - "description": "鎴愬姛", - "schema": { - "allOf": [ - { - "$ref": "#/definitions/util.ResponseList" - }, - { - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/definitions/response.InventoryHistory" - } - } - } - } - ] - } - } - } - } - }, "/api-wms/v1/location/addLocation": { "post": { "produces": [ @@ -609,9 +519,9 @@ "application/json" ], "tags": [ - "搴撳瓨鐩樼偣" + "涓婃灦瑙勫垯" ], - "summary": "搴撳瓨鐩樼偣鍒楄〃", + "summary": "涓婃灦瑙勫垯鍒楄〃", "parameters": [ { "description": "鏌ヨ鍙傛暟", @@ -644,12 +554,72 @@ "summary": "淇敼涓婃灦瑙勫垯", "parameters": [ { - "description": "鍏ュ簱淇℃伅", + "description": "淇敼鍙傛暟", "name": "object", "in": "body", "required": true, "schema": { "$ref": "#/definitions/request.UpdateLocationProduct" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/locationProductAmount/add": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "搴撳瓨鐩樼偣" + ], + "summary": "娣诲姞搴撳瓨鐩樼偣淇℃伅", + "parameters": [ + { + "description": "鍏ュ簱/鍑哄簱淇℃伅", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.AddLocationProductAmount" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "$ref": "#/definitions/util.Response" + } + } + } + } + }, + "/api-wms/v1/locationProductAmount/list": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "搴撳瓨鐩樼偣" + ], + "summary": "搴撳瓨鐩樼偣鍒楄〃", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.PageInfo" } } ], @@ -1342,6 +1312,51 @@ } } }, + "/api-wms/v1/product/listHistory": { + "post": { + "produces": [ + "application/json" + ], + "tags": [ + "浜у搧" + ], + "summary": "浜у搧浣嶇疆鍘嗗彶淇℃伅", + "parameters": [ + { + "description": "鏌ヨ鍙傛暟", + "name": "object", + "in": "body", + "required": true, + "schema": { + "$ref": "#/definitions/request.QueryOperationHistory" + } + } + ], + "responses": { + "200": { + "description": "鎴愬姛", + "schema": { + "allOf": [ + { + "$ref": "#/definitions/util.ResponseList" + }, + { + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/definitions/models.Operation" + } + } + } + } + ] + } + } + } + } + }, "/api-wms/v1/product/listOperaton": { "post": { "produces": [ @@ -1762,10 +1777,13 @@ 5, 6, 7, - 8 + 8, + 9 ], "x-enum-comments": { + "LocationTypeAdjust": "搴撳瓨鐩樼偣", "LocationTypeCustomer": "瀹㈡埛浣嶇疆", + "LocationTypeDisuse": "鎶ュ簾浣嶇疆", "LocationTypeInternal": "鍐呴儴浣嶇疆", "LocationTypeInventoryLoss": "搴撳瓨鎹熷け", "LocationTypeProduction": "鐢熶骇", @@ -1781,7 +1799,8 @@ "LocationTypeInventoryLoss", "LocationTypeProduction", "LocationTypeTransit", - "LocationTypeDisuse" + "LocationTypeDisuse", + "LocationTypeAdjust" ] }, "constvar.MaterialMode": { @@ -2542,6 +2561,29 @@ } } }, + "request.AddLocationProductAmount": { + "type": "object", + "properties": { + "Amount": { + "description": "搴撳瓨鏁伴噺", + "type": "number" + }, + "adjustAmount": { + "description": "宸��", + "type": "number" + }, + "differenceAmount": { + "description": "璁℃暟鏁伴噺", + "type": "number" + }, + "locationId": { + "type": "integer" + }, + "productId": { + "type": "string" + } + } + }, "request.AddOperation": { "type": "object", "properties": { @@ -2737,55 +2779,6 @@ } } }, - "request.GetInventoryForms": { - "type": "object", - "properties": { - "categoryIds": { - "description": "浜у搧绫诲瀷id", - "type": "array", - "items": { - "type": "integer" - } - }, - "page": { - "description": "椤电爜", - "type": "integer" - }, - "pageSize": { - "description": "姣忛〉澶у皬", - "type": "integer" - }, - "warehouseCode": { - "description": "浠撳簱缂╁啓", - "type": "string" - } - } - }, - "request.GetInventoryHistory": { - "type": "object", - "properties": { - "page": { - "description": "椤电爜", - "type": "integer" - }, - "pageSize": { - "description": "姣忛〉澶у皬", - "type": "integer" - }, - "produceId": { - "description": "浜у搧id", - "type": "string" - }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "unit": { - "description": "鍗曚綅", - "type": "string" - } - } - }, "request.GetProductList": { "type": "object", "properties": { @@ -2891,6 +2884,25 @@ "type": "integer" }, "sourceNumber": { + "type": "string" + } + } + }, + "request.QueryOperationHistory": { + "type": "object", + "properties": { + "locationId": { + "type": "integer" + }, + "page": { + "description": "椤电爜", + "type": "integer" + }, + "pageSize": { + "description": "姣忛〉澶у皬", + "type": "integer" + }, + "productId": { "type": "string" } } @@ -3153,92 +3165,6 @@ "warehouseId": { "description": "浠撳簱id", "type": "integer" - } - } - }, - "response.InventoryForms": { - "type": "object", - "properties": { - "amount": { - "description": "鍦ㄥ簱鏁伴噺", - "type": "number" - }, - "availableNumber": { - "description": "鍙敤搴撳瓨", - "type": "number" - }, - "cost": { - "description": "鎴愭湰", - "type": "number" - }, - "in": { - "description": "鍏ュ簱", - "type": "number" - }, - "out": { - "description": "鍑哄簱", - "type": "number" - }, - "produceId": { - "description": "浜у搧id", - "type": "string" - }, - "productName": { - "description": "浜у搧鍚嶇О", - "type": "string" - }, - "productType": { - "description": "浜у搧绫诲瀷", - "type": "string" - }, - "unit": { - "description": "鍗曚綅", - "type": "string" - }, - "value": { - "description": "鎬讳环鍊�", - "type": "number" - } - } - }, - "response.InventoryHistory": { - "type": "object", - "properties": { - "amount": { - "description": "鏁伴噺", - "type": "number" - }, - "baseOperationType": { - "description": "鍩虹浣滀笟绫诲瀷", - "allOf": [ - { - "$ref": "#/definitions/constvar.BaseOperationType" - } - ] - }, - "contactedName": { - "description": "瀹屾垚鑰�", - "type": "string" - }, - "date": { - "description": "鏃ユ湡", - "type": "string" - }, - "fromLocation": { - "description": "婧愪綅缃�", - "type": "string" - }, - "number": { - "description": "鍗曞彿", - "type": "string" - }, - "toLocation": { - "description": "鐩爣浣嶇疆", - "type": "string" - }, - "unit": { - "description": "鍗曚綅", - "type": "string" } } }, diff --git a/docs/swagger.yaml b/docs/swagger.yaml index d0c176d..a87ffb6 100644 --- a/docs/swagger.yaml +++ b/docs/swagger.yaml @@ -84,9 +84,12 @@ - 6 - 7 - 8 + - 9 type: integer x-enum-comments: + LocationTypeAdjust: 搴撳瓨鐩樼偣 LocationTypeCustomer: 瀹㈡埛浣嶇疆 + LocationTypeDisuse: 鎶ュ簾浣嶇疆 LocationTypeInternal: 鍐呴儴浣嶇疆 LocationTypeInventoryLoss: 搴撳瓨鎹熷け LocationTypeProduction: 鐢熶骇 @@ -102,6 +105,7 @@ - LocationTypeProduction - LocationTypeTransit - LocationTypeDisuse + - LocationTypeAdjust constvar.MaterialMode: enum: - 鍘熸潗鏂� @@ -644,6 +648,22 @@ description: 浜у搧id type: string type: object + request.AddLocationProductAmount: + properties: + Amount: + description: 搴撳瓨鏁伴噺 + type: number + adjustAmount: + description: 宸�� + type: number + differenceAmount: + description: 璁℃暟鏁伴噺 + type: number + locationId: + type: integer + productId: + type: string + type: object request.AddOperation: properties: comment: @@ -779,41 +799,6 @@ required: - code type: object - request.GetInventoryForms: - properties: - categoryIds: - description: 浜у搧绫诲瀷id - items: - type: integer - type: array - page: - description: 椤电爜 - type: integer - pageSize: - description: 姣忛〉澶у皬 - type: integer - warehouseCode: - description: 浠撳簱缂╁啓 - type: string - type: object - request.GetInventoryHistory: - properties: - page: - description: 椤电爜 - type: integer - pageSize: - description: 姣忛〉澶у皬 - type: integer - produceId: - description: 浜у搧id - type: string - productName: - description: 浜у搧鍚嶇О - type: string - unit: - description: 鍗曚綅 - type: string - type: object request.GetProductList: properties: categoryId: @@ -888,6 +873,19 @@ description: 姣忛〉澶у皬 type: integer sourceNumber: + type: string + type: object + request.QueryOperationHistory: + properties: + locationId: + type: integer + page: + description: 椤电爜 + type: integer + pageSize: + description: 姣忛〉澶у皬 + type: integer + productId: type: string type: object request.QueryOperationList: @@ -1065,67 +1063,6 @@ warehouseId: description: 浠撳簱id type: integer - type: object - response.InventoryForms: - properties: - amount: - description: 鍦ㄥ簱鏁伴噺 - type: number - availableNumber: - description: 鍙敤搴撳瓨 - type: number - cost: - description: 鎴愭湰 - type: number - in: - description: 鍏ュ簱 - type: number - out: - description: 鍑哄簱 - type: number - produceId: - description: 浜у搧id - type: string - productName: - description: 浜у搧鍚嶇О - type: string - productType: - description: 浜у搧绫诲瀷 - type: string - unit: - description: 鍗曚綅 - type: string - value: - description: 鎬讳环鍊� - type: number - type: object - response.InventoryHistory: - properties: - amount: - description: 鏁伴噺 - type: number - baseOperationType: - allOf: - - $ref: '#/definitions/constvar.BaseOperationType' - description: 鍩虹浣滀笟绫诲瀷 - contactedName: - description: 瀹屾垚鑰� - type: string - date: - description: 鏃ユ湡 - type: string - fromLocation: - description: 婧愪綅缃� - type: string - number: - description: 鍗曞彿 - type: string - toLocation: - description: 鐩爣浣嶇疆 - type: string - unit: - description: 鍗曚綅 - type: string type: object util.Response: properties: @@ -1325,58 +1262,6 @@ summary: 缂栬緫鍏徃 tags: - 鍏徃 - /api-wms/v1/forms/getInventoryForms: - post: - parameters: - - description: 鏌ヨ鍙傛暟 - in: body - name: object - required: true - schema: - $ref: '#/definitions/request.GetInventoryForms' - produces: - - application/json - responses: - "200": - description: 鎴愬姛 - schema: - allOf: - - $ref: '#/definitions/util.ResponseList' - - properties: - data: - items: - $ref: '#/definitions/response.InventoryForms' - type: array - type: object - summary: 鑾峰彇搴撳瓨鎶ヨ〃 - tags: - - 鎶ヨ〃 - /api-wms/v1/forms/getInventoryHistory: - post: - parameters: - - description: 鏌ヨ鍙傛暟 - in: body - name: object - required: true - schema: - $ref: '#/definitions/request.GetInventoryHistory' - produces: - - application/json - responses: - "200": - description: 鎴愬姛 - schema: - allOf: - - $ref: '#/definitions/util.ResponseList' - - properties: - data: - items: - $ref: '#/definitions/response.InventoryHistory' - type: array - type: object - summary: 鑾峰彇搴撳瓨鍘嗗彶 - tags: - - 鎶ヨ〃 /api-wms/v1/location/addLocation: post: parameters: @@ -1535,13 +1420,13 @@ description: 鎴愬姛 schema: $ref: '#/definitions/util.Response' - summary: 搴撳瓨鐩樼偣鍒楄〃 + summary: 涓婃灦瑙勫垯鍒楄〃 tags: - - 搴撳瓨鐩樼偣 + - 涓婃灦瑙勫垯 /api-wms/v1/locationProduct/update: post: parameters: - - description: 鍏ュ簱淇℃伅 + - description: 淇敼鍙傛暟 in: body name: object required: true @@ -1557,6 +1442,44 @@ summary: 淇敼涓婃灦瑙勫垯 tags: - 涓婃灦瑙勫垯 + /api-wms/v1/locationProductAmount/add: + post: + parameters: + - description: 鍏ュ簱/鍑哄簱淇℃伅 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.AddLocationProductAmount' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 娣诲姞搴撳瓨鐩樼偣淇℃伅 + tags: + - 搴撳瓨鐩樼偣 + /api-wms/v1/locationProductAmount/list: + post: + parameters: + - description: 鏌ヨ鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.PageInfo' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + $ref: '#/definitions/util.Response' + summary: 搴撳瓨鐩樼偣鍒楄〃 + tags: + - 搴撳瓨鐩樼偣 /api-wms/v1/operation/finish/{id}: put: parameters: @@ -1980,6 +1903,32 @@ summary: 鎶ュ簾鍒楄〃 tags: - 浜у搧 + /api-wms/v1/product/listHistory: + post: + parameters: + - description: 鏌ヨ鍙傛暟 + in: body + name: object + required: true + schema: + $ref: '#/definitions/request.QueryOperationHistory' + produces: + - application/json + responses: + "200": + description: 鎴愬姛 + schema: + allOf: + - $ref: '#/definitions/util.ResponseList' + - properties: + data: + items: + $ref: '#/definitions/models.Operation' + type: array + type: object + summary: 浜у搧浣嶇疆鍘嗗彶淇℃伅 + tags: + - 浜у搧 /api-wms/v1/product/listOperaton: post: parameters: diff --git a/models/db.go b/models/db.go index ed1c78b..8f47201 100644 --- a/models/db.go +++ b/models/db.go @@ -85,6 +85,8 @@ //Product{}, ProductCategory{}, Material{}, + LocationProduct{}, + LocationProductAmount{}, ) return err } diff --git a/models/location_product.go b/models/location_product.go index 7f8a946..520b18a 100644 --- a/models/location_product.go +++ b/models/location_product.go @@ -69,6 +69,16 @@ return slf } +func (slf *LocationProductSearch) SetProductId(productId string) *LocationProductSearch { + slf.ProductId = productId + return slf +} + +func (slf *LocationProductSearch) SetLocationId(locationId int) *LocationProductSearch { + slf.LocationId = locationId + return slf +} + func (slf *LocationProductSearch) build() *gorm.DB { var db = slf.Orm.Model(&LocationProduct{}) @@ -87,6 +97,14 @@ db = db.Model(&LocationProduct{}).Preload("Location").Preload("Area").Preload("ProductCategory").Preload("Product") } + if slf.LocationId != 0 { + db = db.Where("location_id = ?", slf.LocationId) + } + + if slf.ProductId != "" { + db = db.Where("product_id=?", slf.ProductId) + } + return db } diff --git a/models/location_product_amount.go b/models/location_product_amount.go index e8e0e7e..1f77ec0 100644 --- a/models/location_product_amount.go +++ b/models/location_product_amount.go @@ -14,6 +14,7 @@ LocationProductId int `json:"locationProductId" gorm:"type:int;not null;comment:涓婃灦瑙勫垯id"` //涓婃灦瑙勫垯id LocationProduct LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"` Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:搴撳瓨鏁伴噺"` //搴撳瓨鏁伴噺 + CreateDate string `json:"createDate" gorm:"type:varchar(63);comment:鏃ユ湡"` //鏃ユ湡 } LocationProductAmountSearch struct { @@ -27,9 +28,17 @@ } LocationProductAmountWithOperation struct { - LocationProductAmount LocationProductAmount `json:"locationProductAmount"` - AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` - DifferenceAmount decimal.Decimal `json:"difference_amount"` + //LocationProductAmount LocationProductAmount `json:"locationProductAmount"` + LocationId int `json:"locationId" gorm:"column:location_id"` + LocationName string `json:"locationName" gorm:"column:location_name"` + ProductId string `json:"productId" gorm:"column:product_id"` + ProductName string `json:"productName" gorm:"column:product_name"` + Amount decimal.Decimal `json:"amount" gorm:"column:amount"` + Unit string `json:"unit" gorm:"column:unit"` + CreateDate string `json:"createDate" gorm:"column:create_date"` + AdjustAmount decimal.Decimal `json:"adjustAmount" gorm:"column:adjust_amount"` + DifferenceAmount decimal.Decimal `json:"differenceAmount" gorm:"-"` + OperationId int `json:"operationId" gorm:"column:operation_id"` } ) diff --git a/request/location_product_amount.go b/request/location_product_amount.go index bc7fa2d..faa7b02 100644 --- a/request/location_product_amount.go +++ b/request/location_product_amount.go @@ -3,13 +3,16 @@ import "github.com/shopspring/decimal" type AddLocationProductAmount struct { - LocationProductAmountId int `json:"locationProductAmountId"` //搴撳瓨鐩樼偣id - AdjustAmount decimal.Decimal `json:"adjustAmount" ` //宸�� - DifferenceAmount decimal.Decimal `json:"difference_amount"` //璁℃暟鏁伴噺 + LocationId int `json:"locationId"` + ProductId string `json:"productId"` + Amount decimal.Decimal `json:"Amount"` //搴撳瓨鏁伴噺 + AdjustAmount decimal.Decimal `json:"adjustAmount" ` //宸�� + DifferenceAmount decimal.Decimal `json:"differenceAmount"` //璁℃暟鏁伴噺 } type UpdateLocationProductAmount struct { LocationProductAmountId int `json:"locationProductAmountId"` //搴撳瓨鐩樼偣id AdjustAmount decimal.Decimal `json:"adjustAmount" ` //宸�� - DifferenceAmount decimal.Decimal `json:"difference_amount"` //璁℃暟鏁伴噺 + DifferenceAmount decimal.Decimal `json:"differenceAmount"` //璁℃暟鏁伴噺 + OperationId int `json:"operationId"` //鍑哄叆搴搃d } diff --git a/request/product_request.go b/request/product_request.go index c0e7ea7..6cdafe1 100644 --- a/request/product_request.go +++ b/request/product_request.go @@ -44,3 +44,9 @@ OperationDate string `json:"operationDate"` BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` } + +type QueryOperationHistory struct { + PageInfo + ProductId string `json:"productId"` + LocationId int `json:"locationId"` +} diff --git a/router/router.go b/router/router.go index f18f617..0224086 100644 --- a/router/router.go +++ b/router/router.go @@ -107,16 +107,26 @@ productAPI.POST("listDisuse", productController.ListDisuse) //鏌ョ湅浜у搧鐨勫巻鍙插嚭鍏ュ簱淇℃伅 productAPI.PUT("finishDisuse/:id", productController.FinishDisuse) //鎶ュ簾楠岃瘉 productAPI.POST("updateDisuse", productController.UpdateDisuse) //淇敼鎶ュ簾淇℃伅 + productAPI.POST("listHistory", productController.ListHistory) //浜у搧浣嶇疆鍘嗗彶璁板綍 + } // 涓婃灦瑙勫垯 locationProductController := new(controllers.LocationProductController) locationProductAPI := r.Group(urlPrefix + "/locationProduct") { - locationProductAPI.GET("operationType", locationProductController.List) // 鑾峰彇涓婃灦瑙勫垯鍒楄〃 - locationProductAPI.POST("operationType", locationProductController.Add) // 鏂板涓婃灦瑙勫垯 - locationProductAPI.PUT("operationType/:id", locationProductController.Update) // 淇敼涓婃灦瑙勫垯 - locationProductAPI.DELETE("operationType/:id", locationProductController.Delete) // 鍒犻櫎涓婃灦瑙勫垯 + locationProductAPI.POST("list", locationProductController.List) // 鑾峰彇涓婃灦瑙勫垯鍒楄〃 + locationProductAPI.POST("add", locationProductController.Add) // 鏂板涓婃灦瑙勫垯 + locationProductAPI.POST("update", locationProductController.Update) // 淇敼涓婃灦瑙勫垯 + locationProductAPI.DELETE("delete/:id", locationProductController.Delete) // 鍒犻櫎涓婃灦瑙勫垯 + } + + //搴撳瓨鐩樼偣 + locationProductAmountController := new(controllers.LocationProductAmountController) + locationProductAmountAPI := r.Group(urlPrefix + "/locationProductAmount") + { + locationProductAmountAPI.POST("add", locationProductAmountController.Add) //娣诲姞搴撳瓨鐩樼偣淇℃伅 + locationProductAmountAPI.POST("list", locationProductAmountController.List) //鏌ョ湅搴撳瓨鐩樼偣鍒楄〃 } //鎶ヨ〃 -- Gitblit v1.8.0