| | |
| | | |
| | | util.ResponseFormat(c, code.Success, "修改成功") |
| | | } |
| | | |
| | | // finish |
| | | // |
| | | // @Tags 库存盘点 |
| | | // @Summary 应用、验证 |
| | | // @Produce application/json |
| | | // @Param object body request.FinishLocationProductAmount true "入参" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/locationProductAmount/finish [post] |
| | | func (slf LocationProductAmountController) Finish(c *gin.Context) { |
| | | var reqParams request.FinishLocationProductAmount |
| | | if err := c.BindJSON(&reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if reqParams.LocationProductAmountId == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "locationProductAmountId为0") |
| | | return |
| | | } |
| | | if reqParams.OperationId == 0 { |
| | | util.ResponseFormat(c, code.RequestParamError, "operationId为0") |
| | | return |
| | | } |
| | | operationSearch := models.NewOperationSearch().SetPreload(true) |
| | | operationSearch.SetOrm(operationSearch.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.id=?", reqParams.ProductId, reqParams.OperationId)) |
| | | operation, err := operationSearch.First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "未找到相关信息:"+err.Error()) |
| | | return |
| | | } |
| | | if operation.Status != constvar.OperationStatus_Ready { |
| | | util.ResponseFormat(c, code.RequestError, "该验证无法完成") |
| | | return |
| | | } |
| | | material, err := models.NewMaterialSearch().SetID(reqParams.ProductId).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, err.Error()) |
| | | return |
| | | } |
| | | locProdtAmount, err := models.NewLocationProductAmountSearch().SetID(reqParams.LocationProductAmountId).First() |
| | | if err != nil { |
| | | util.ResponseFormat(c, code.RequestError, err.Error()) |
| | | return |
| | | } |
| | | if err := models.WithTransaction(func(tx *gorm.DB) error { |
| | | if err := models.NewOperationSearch().SetOrm(tx).SetID(reqParams.OperationId).Update(&models.Operation{Status: constvar.OperationStatus_Finish}); err != nil { |
| | | return err |
| | | } |
| | | if err := models.NewMaterialSearch().SetOrm(tx).SetID(reqParams.ProductId).Update(&models.Material{Amount: material.Amount.Add(operation.Details[0].Amount)}); err != nil { |
| | | return err |
| | | } |
| | | if err := models.NewLocationProductAmountSearch().SetOrm(tx).SetID(reqParams.LocationProductAmountId).Update(&models.LocationProductAmount{Amount: locProdtAmount.Amount.Add(operation.Details[0].Amount)}); err != nil { |
| | | return err |
| | | } |
| | | return nil |
| | | }); err != nil { |
| | | util.ResponseFormat(c, code.RequestError, err.Error()) |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/finish": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "应用、验证", |
| | | "parameters": [ |
| | | { |
| | | "description": "入参", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.FinishLocationProductAmount" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/list": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.FinishLocationProductAmount": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationProductAmountId": { |
| | | "description": "库存盘点id", |
| | | "type": "integer" |
| | | }, |
| | | "operationId": { |
| | | "description": "出入库id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetInventoryForms": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/finish": { |
| | | "post": { |
| | | "produces": [ |
| | | "application/json" |
| | | ], |
| | | "tags": [ |
| | | "库存盘点" |
| | | ], |
| | | "summary": "应用、验证", |
| | | "parameters": [ |
| | | { |
| | | "description": "入参", |
| | | "name": "object", |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.FinishLocationProductAmount" |
| | | } |
| | | } |
| | | ], |
| | | "responses": { |
| | | "200": { |
| | | "description": "成功", |
| | | "schema": { |
| | | "$ref": "#/definitions/util.Response" |
| | | } |
| | | } |
| | | } |
| | | } |
| | | }, |
| | | "/api-wms/v1/locationProductAmount/list": { |
| | | "post": { |
| | | "produces": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.FinishLocationProductAmount": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationProductAmountId": { |
| | | "description": "库存盘点id", |
| | | "type": "integer" |
| | | }, |
| | | "operationId": { |
| | | "description": "出入库id", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "description": "产品id", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetInventoryForms": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | required: |
| | | - code |
| | | type: object |
| | | request.FinishLocationProductAmount: |
| | | properties: |
| | | locationProductAmountId: |
| | | description: 库存盘点id |
| | | type: integer |
| | | operationId: |
| | | description: 出入库id |
| | | type: integer |
| | | productId: |
| | | description: 产品id |
| | | type: string |
| | | type: object |
| | | request.GetInventoryForms: |
| | | properties: |
| | | categoryIds: |
| | |
| | | summary: 添加库存盘点信息 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/finish: |
| | | post: |
| | | parameters: |
| | | - description: 入参 |
| | | in: body |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.FinishLocationProductAmount' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | | "200": |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 应用、验证 |
| | | tags: |
| | | - 库存盘点 |
| | | /api-wms/v1/locationProductAmount/list: |
| | | post: |
| | | parameters: |
| | |
| | | Amount decimal.Decimal `json:"amount" gorm:"type:decimal(20,2);not null;comment:数量"` //数量 |
| | | Unit string `json:"unit" gorm:"type:varchar(31);comment:单位"` |
| | | } |
| | | |
| | | func (slf *MaterialSearch) Update(record *Material) error { |
| | | var db = slf.build() |
| | | |
| | | if err := db.Omit("CreatedAt").Updates(record).Error; err != nil { |
| | | return fmt.Errorf("save err: %v, record: %+v", err, record) |
| | | } |
| | | |
| | | return nil |
| | | } |
| | |
| | | Amount decimal.Decimal `json:"Amount"` //库存数量 |
| | | ProductId string `json:"productId"` //产品id |
| | | } |
| | | |
| | | type FinishLocationProductAmount struct { |
| | | LocationProductAmountId int `json:"locationProductAmountId"` //库存盘点id |
| | | OperationId int `json:"operationId"` //出入库id |
| | | ProductId string `json:"productId"` //产品id |
| | | } |
| | |
| | | locationProductAmountAPI.POST("add", locationProductAmountController.Add) //添加库存盘点信息 |
| | | locationProductAmountAPI.POST("list", locationProductAmountController.List) //查看库存盘点列表 |
| | | locationProductAmountAPI.POST("update", locationProductAmountController.Update) //修改库存盘点信息 |
| | | locationProductAmountAPI.POST("finish", locationProductAmountController.Finish) //应用、验证库存盘点信息 |
| | | } |
| | | |
| | | //报表 |