liujiandao
2024-04-22 8cb1da78fd4d237b278ed4d512c6c4f04b663cfc
库存调整修改
5个文件已修改
105 ■■■■ 已修改文件
controllers/location_product_amount.go 33 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 19 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/location_product_amount.go 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location_product_amount.go
@@ -25,11 +25,11 @@
// @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(&params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误:"+err.Error())
        return
@@ -37,6 +37,18 @@
    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()
@@ -55,6 +67,13 @@
        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))
@@ -68,9 +87,14 @@
        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
@@ -108,6 +132,7 @@
    if err := AddLocationProductAmount(reqParams); err != nil {
        util.ResponseFormat(c, code.RequestError, err)
        return
    }
    util.ResponseFormat(c, code.Success, "添加成功")
docs/docs.go
@@ -1091,7 +1091,7 @@
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                            "$ref": "#/definitions/request.GetList"
                        }
                    }
                ],
@@ -3794,7 +3794,7 @@
                    "type": "string"
                },
                "companyID": {
                    "type": "integer"
                    "type": "string"
                },
                "companyName": {
                    "type": "string"
@@ -4316,7 +4316,7 @@
                },
                "companyID": {
                    "description": "公司ID-客户",
                    "type": "integer"
                    "type": "string"
                },
                "companyName": {
                    "description": "公司名称-客户名称",
@@ -4636,6 +4636,22 @@
                "unit": {
                    "description": "单位",
                    "type": "string"
                }
            }
        },
        "request.GetList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
@@ -5111,7 +5127,7 @@
                },
                "companyID": {
                    "description": "公司ID-客户",
                    "type": "integer"
                    "type": "string"
                },
                "companyName": {
                    "description": "公司名称-客户名称",
docs/swagger.json
@@ -1079,7 +1079,7 @@
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                            "$ref": "#/definitions/request.GetList"
                        }
                    }
                ],
@@ -3782,7 +3782,7 @@
                    "type": "string"
                },
                "companyID": {
                    "type": "integer"
                    "type": "string"
                },
                "companyName": {
                    "type": "string"
@@ -4304,7 +4304,7 @@
                },
                "companyID": {
                    "description": "公司ID-客户",
                    "type": "integer"
                    "type": "string"
                },
                "companyName": {
                    "description": "公司名称-客户名称",
@@ -4624,6 +4624,22 @@
                "unit": {
                    "description": "单位",
                    "type": "string"
                }
            }
        },
        "request.GetList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
@@ -5099,7 +5115,7 @@
                },
                "companyID": {
                    "description": "公司ID-客户",
                    "type": "integer"
                    "type": "string"
                },
                "companyName": {
                    "description": "公司名称-客户名称",
docs/swagger.yaml
@@ -757,7 +757,7 @@
      comment:
        type: string
      companyID:
        type: integer
        type: string
      companyName:
        type: string
      contacterID:
@@ -1110,7 +1110,7 @@
        type: string
      companyID:
        description: 公司ID-客户
        type: integer
        type: string
      companyName:
        description: 公司名称-客户名称
        type: string
@@ -1334,6 +1334,17 @@
      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:
@@ -1663,7 +1674,7 @@
        type: string
      companyID:
        description: 公司ID-客户
        type: integer
        type: string
      companyName:
        description: 公司名称-客户名称
        type: string
@@ -2577,7 +2588,7 @@
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.PageInfo'
          $ref: '#/definitions/request.GetList'
      produces:
      - application/json
      responses:
request/location_product_amount.go
@@ -4,6 +4,11 @@
    "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"` //计数数量