| | |
| | | wms_location_product_amount.amount, |
| | | material.unit, |
| | | wms_location_product_amount.create_date, |
| | | wms_operation_details.amount as adjust_amount`). |
| | | 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"). |
| | |
| | | util.ResponseFormat(c, code.RequestParamError, err.Error()) |
| | | return |
| | | } |
| | | reqParams.AdjustAmount = reqParams.Amount.Sub(reqParams.DifferenceAmount) |
| | | //reqParams.AdjustAmount = reqParams.DifferenceAmount.Sub(reqParams.Amount) |
| | | //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, |
| | |
| | | Comment: "库存盘点", |
| | | BaseOperationType: constvar.BaseOperationTypeAdjust, |
| | | Details: []*models.OperationDetails{detail}, |
| | | FromLocationID: reqParams.LocationId, |
| | | ToLocationID: location.Id, |
| | | FromLocationID: location.Id, |
| | | ToLocationID: reqParams.LocationId, |
| | | } |
| | | |
| | | //if reqParams.AdjustAmount.GreaterThanOrEqual(decimal.NewFromInt(0)) { |
| | |
| | | |
| | | 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, "参数解析失败,数据类型错误") |
| | | // 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, "添加成功") |
| | | //} |
| | |
| | | } |
| | | 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, "参数解析失败,数据类型错误:"+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) |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryOperationHistory": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryOperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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": [ |
| | |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryOperationHistory": { |
| | | "type": "object", |
| | | "properties": { |
| | | "locationId": { |
| | | "type": "integer" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | }, |
| | | "productId": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.QueryOperationList": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | 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: |
| | | properties: |
| | | page: |
| | |
| | | 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: |
| | |
| | | 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"` |
| | | } |
| | | ) |
| | | |
| | |
| | | LocationProductAmountId int `json:"locationProductAmountId"` //库存盘点id |
| | | AdjustAmount decimal.Decimal `json:"adjustAmount" ` //差值 |
| | | DifferenceAmount decimal.Decimal `json:"differenceAmount"` //计数数量 |
| | | OperationId int `json:"operationId"` //出入库id |
| | | } |
| | |
| | | OperationDate string `json:"operationDate"` |
| | | BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` |
| | | } |
| | | |
| | | type QueryOperationHistory struct { |
| | | PageInfo |
| | | ProductId string `json:"productId"` |
| | | LocationId int `json:"locationId"` |
| | | } |
| | |
| | | productAPI.POST("listDisuse", productController.ListDisuse) //查看产品的历史出入库信息 |
| | | productAPI.PUT("finishDisuse/:id", productController.FinishDisuse) //报废验证 |
| | | productAPI.POST("updateDisuse", productController.UpdateDisuse) //修改报废信息 |
| | | productAPI.POST("listHistory", productController.ListHistory) //产品位置历史记录 |
| | | |
| | | } |
| | | |
| | | // 上架规则 |