| | |
| | | //wms_operation_details.amount as adjust_amount,wms_operation.id as operation_id,wms_operation.status |
| | | search.Orm = search.Orm. |
| | | Table("wms_location_product_amount"). |
| | | Select(`wms_location_product_amount.id as location_product_amount_id,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`). |
| | | Select(`wms_location_product_amount.id as location_product_amount_id,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,material.weight`). |
| | | InnerJoins("inner join material on material.id=wms_location_product_amount.product_id"). |
| | | InnerJoins("inner join wms_location on wms_location.id=wms_location_product_amount.location_id") |
| | | |
| | |
| | | } |
| | | var operation models.Operation |
| | | for k, v := range records { |
| | | if res := mysqlx.GetDB().Table("wms_operation").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.base_operation_type=? and wms_operation.status=? and wms_operation.to_location_id=? and wms_operation_details.product_id=?", constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready, v.LocationId, v.ProductId).First(&operation); res.Error != nil { |
| | | if res := mysqlx.GetDB().Table("wms_operation").InnerJoins("inner join wms_operation_details on wms_operation_details.operation_id=wms_operation.id").Where("wms_operation.base_operation_type=? and wms_operation.status=? and wms_operation_details.to_location_id=? and wms_operation_details.product_id=?", constvar.BaseOperationTypeAdjust, constvar.OperationStatus_Ready, v.LocationId, v.ProductId).First(&operation); res.Error != nil { |
| | | if errors.Is(res.Error, gorm.ErrRecordNotFound) { |
| | | records[k].Status = constvar.OperationStatus_Finish |
| | | records[k].BaseOperationType = constvar.BaseOperationTypeAdjust |
| | |
| | | Comment: "库存盘点", |
| | | BaseOperationType: constvar.BaseOperationTypeAdjust, |
| | | Details: []*models.OperationDetails{detail}, |
| | | LocationID: location.Id, |
| | | } |
| | | |
| | | if err := models.WithTransaction(func(tx *gorm.DB) error { |
| | |
| | | util.ResponseFormat(c, code.Success, "修改成功") |
| | | } |
| | | |
| | | // finish |
| | | // Finish |
| | | // |
| | | // @Tags 库存盘点 |
| | | // @Summary 应用、验证 |
| | |
| | | } |
| | | util.ResponseFormat(c, code.Success, "操作成功") |
| | | } |
| | | |
| | | // GetLocationProductAmount |
| | | // |
| | | // @Tags 库存盘点 |
| | | // @Summary 获取位置产品信息 |
| | | // @Produce application/json |
| | | // @Param object body request.GetRuleList true "入参" |
| | | // @Success 200 {object} util.Response{data=models.LocationProductAmount} "成功" |
| | | // @Router /api-wms/v1/locationProductAmount/getLocationProductAmount [post] |
| | | func (slf LocationProductAmountController) GetLocationProductAmount(c *gin.Context) { |
| | | var params request.GetRuleList |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误") |
| | | return |
| | | } |
| | | if params.LocationId == 0 || params.ProductId == "" { |
| | | util.ResponseFormat(c, code.Success, nil) |
| | | return |
| | | } |
| | | first, err := models.NewLocationProductAmountSearch().SetLocationId(params.LocationId).SetProductId(params.ProductId).First() |
| | | if err != nil { |
| | | if err == gorm.ErrRecordNotFound { |
| | | util.ResponseFormat(c, code.Success, nil) |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | util.ResponseFormat(c, code.Success, first) |
| | | } |