| | |
| | | // @Tags 库存盘点 |
| | | // @Summary 库存盘点列表 |
| | | // @Produce application/json |
| | | // @Param object body request.PageInfo true "查询参数" |
| | | // @Param object body request.GetList true "查询参数" |
| | | // @Success 200 {object} util.Response "成功" |
| | | // @Router /api-wms/v1/locationProductAmount/list [post] |
| | | func (slf LocationProductAmountController) List(c *gin.Context) { |
| | | var params request.PageInfo |
| | | var params request.GetList |
| | | if err := c.BindJSON(¶ms); err != nil { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error()) |
| | | return |
| | |
| | | if !params.Check() { |
| | | util.ResponseFormat(c, code.RequestParamError, "参数异常") |
| | | return |
| | | } |
| | | productIds := make([]string, 0) |
| | | locationIds := make([]int, 0) |
| | | if params.Keyword != "" { |
| | | materials, _ := models.NewMaterialSearch().SetKeyword(params.Keyword).FindNotTotal() |
| | | for _, material := range materials { |
| | | productIds = append(productIds, material.ID) |
| | | } |
| | | locations, _ := models.NewLocationSearch().SetKeyword(params.Keyword).FindNotTotal() |
| | | for _, location := range locations { |
| | | locationIds = append(locationIds, location.Id) |
| | | } |
| | | } |
| | | |
| | | search := models.NewLocationProductAmountSearch() |
| | |
| | | records = make([]*models.LocationProductAmountWithOperation, 0) |
| | | total int64 |
| | | ) |
| | | if len(productIds) > 0 { |
| | | search.Orm = search.Orm.Where("wms_location_product_amount.product_id in (?)", productIds) |
| | | |
| | | } |
| | | if len(locationIds) > 0 { |
| | | search.Orm = search.Orm.Where("wms_location_product_amount.location_id in (?)", locationIds) |
| | | } |
| | | |
| | | if err := search.Orm.Count(&total).Error; err != nil { |
| | | util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err)) |
| | |
| | | util.ResponseFormat(c, code.RequestError, fmt.Errorf("find count err: %v", err)) |
| | | return |
| | | } |
| | | var operation models.Operation |
| | | |
| | | for k, v := range records { |
| | | if res := mysqlx.GetDB().Table("wms_operation").Preload("Details").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 { |
| | | var operation models.Operation |
| | | db := mysqlx.GetDB() |
| | | if res := db.Table("wms_operation").Preload("Details").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 |
| | |
| | | |
| | | if err := AddLocationProductAmount(reqParams); err != nil { |
| | | util.ResponseFormat(c, code.RequestError, err) |
| | | return |
| | | } |
| | | |
| | | util.ResponseFormat(c, code.Success, "添加成功") |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.PageInfo" |
| | | "$ref": "#/definitions/request.GetList" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "type": "string" |
| | | }, |
| | | "companyID": { |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "companyName": { |
| | | "type": "string" |
| | |
| | | }, |
| | | "companyID": { |
| | | "description": "公司ID-客户", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "companyName": { |
| | | "description": "公司名称-客户名称", |
| | |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "companyID": { |
| | | "description": "公司ID-客户", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "companyName": { |
| | | "description": "公司名称-客户名称", |
| | |
| | | "in": "body", |
| | | "required": true, |
| | | "schema": { |
| | | "$ref": "#/definitions/request.PageInfo" |
| | | "$ref": "#/definitions/request.GetList" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "type": "string" |
| | | }, |
| | | "companyID": { |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "companyName": { |
| | | "type": "string" |
| | |
| | | }, |
| | | "companyID": { |
| | | "description": "公司ID-客户", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "companyName": { |
| | | "description": "公司名称-客户名称", |
| | |
| | | "unit": { |
| | | "description": "单位", |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "request.GetList": { |
| | | "type": "object", |
| | | "properties": { |
| | | "keyword": { |
| | | "type": "string" |
| | | }, |
| | | "page": { |
| | | "description": "页码", |
| | | "type": "integer" |
| | | }, |
| | | "pageSize": { |
| | | "description": "每页大小", |
| | | "type": "integer" |
| | | } |
| | | } |
| | | }, |
| | |
| | | }, |
| | | "companyID": { |
| | | "description": "公司ID-客户", |
| | | "type": "integer" |
| | | "type": "string" |
| | | }, |
| | | "companyName": { |
| | | "description": "公司名称-客户名称", |
| | |
| | | comment: |
| | | type: string |
| | | companyID: |
| | | type: integer |
| | | type: string |
| | | companyName: |
| | | type: string |
| | | contacterID: |
| | |
| | | type: string |
| | | companyID: |
| | | description: 公司ID-客户 |
| | | type: integer |
| | | type: string |
| | | companyName: |
| | | description: 公司名称-客户名称 |
| | | type: string |
| | |
| | | unit: |
| | | description: 单位 |
| | | type: string |
| | | type: object |
| | | request.GetList: |
| | | properties: |
| | | keyword: |
| | | type: string |
| | | page: |
| | | description: 页码 |
| | | type: integer |
| | | pageSize: |
| | | description: 每页大小 |
| | | type: integer |
| | | type: object |
| | | request.GetLocationForms: |
| | | properties: |
| | |
| | | type: string |
| | | companyID: |
| | | description: 公司ID-客户 |
| | | type: integer |
| | | type: string |
| | | companyName: |
| | | description: 公司名称-客户名称 |
| | | type: string |
| | |
| | | name: object |
| | | required: true |
| | | schema: |
| | | $ref: '#/definitions/request.PageInfo' |
| | | $ref: '#/definitions/request.GetList' |
| | | produces: |
| | | - application/json |
| | | responses: |
| | |
| | | "github.com/shopspring/decimal" |
| | | ) |
| | | |
| | | type GetList struct { |
| | | PageInfo |
| | | Keyword string `json:"keyword"` |
| | | } |
| | | |
| | | type AddLocationProductAmount struct { |
| | | AdjustAmount decimal.Decimal `json:"adjustAmount" ` //差值 |
| | | DifferenceAmount decimal.Decimal `json:"differenceAmount"` //计数数量 |