jiangshuai
2023-09-27 7edecfcf0f48ba6d6177486a57399a558c4c79e7
1.二期一部分代码
10个文件已修改
969 ■■■■■ 已修改文件
constvar/const.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location_product.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location_product_amount.go 127 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 301 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 299 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 193 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/db.go 2 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location_product.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/location_product_amount.go 8 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 16 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go
@@ -126,7 +126,8 @@
    LocationTypeInventoryLoss                         // 库存损失
    LocationTypeProduction                            // 生产
    LocationTypeTransit                               // 中转位置
    LocationTypeDisuse
    LocationTypeDisuse                                //报废位置
    LocationTypeAdjust                                //库存盘点
)
func (t LocationType) Valid() bool {
controllers/location_product.go
@@ -89,7 +89,7 @@
// @Tags      上架规则
// @Summary   修改上架规则
// @Produce   application/json
// @Param     object  body request.UpdateLocationProduct true  "入库信息"
// @Param     object  body request.UpdateLocationProduct true  "修改参数"
// @Success   200 {object} util.Response "成功"
// @Router    /api-wms/v1/locationProduct/update [post]
func (slf LocationProductController) Update(c *gin.Context) {
controllers/location_product_amount.go
@@ -3,6 +3,10 @@
import (
    "fmt"
    "github.com/gin-gonic/gin"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
    "strconv"
    "time"
    "wms/constvar"
    "wms/extend/code"
    "wms/extend/util"
@@ -19,7 +23,7 @@
// @Produce   application/json
// @Param         object  body  request.PageInfo true  "查询参数"
// @Success   200 {object} util.Response    "成功"
// @Router    /api-wms/v1/locationProduct/list [post]
// @Router    /api-wms/v1/locationProductamount/list [post]
func (slf LocationProductAmountController) List(c *gin.Context) {
    var params request.PageInfo
    if err := c.BindJSON(&params); err != nil {
@@ -63,40 +67,87 @@
// @Produce   application/json
// @Param     object  body  request.AddLocationProductAmount true  "入库/出库信息"
// @Success   200 {object} util.Response "成功"
// @Router    /api-wms/v1/operation/operation [post]
//func (slf LocationProductAmountController) Add(c *gin.Context) {
//    var reqParams request.AddLocationProductAmount
//    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
//    }
//    locAmount:=models.LocationProductAmount{
//        LocationProductId: reqParams.LocationProductAmountId
//    }
//    operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
//    if err != nil {
//        util.ResponseFormat(c, code.RequestParamError, err.Error())
//        return
//    }
//    //////
//    if location, err := models.NewLocationSearch().SetType(int(constvar.LocationTypeCustomer)).First(); err != nil {
//        return err
//    } else {
//        params.ToLocationID = location.Id
//    }
//
//
//    params.Status = constvar.OperationStatus_Ready
//    params.Number = strconv.FormatInt(time.Now().Unix(), 10)
//    params.BaseOperationType = operationType.BaseOperationType
//    if err := models.NewOperationSearch().Create(&params); err != nil {
//        logx.Errorf("Operation create err: %v", err)
//        util.ResponseFormat(c, code.SaveFail, "添加失败:"+err.Error())
//        return
//    }
//    util.ResponseFormat(c, code.Success, "添加成功")
//}
// @Router    /api-wms/v1/locationProductamount/add [post]
func (slf LocationProductAmountController) Add(c *gin.Context) {
    var reqParams request.AddLocationProductAmount
    if err := c.BindJSON(&reqParams); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
        return
    }
    if reqParams.LocationId == 0 {
        util.ResponseFormat(c, code.RequestParamError, "参数异常,请选择位置")
        return
    }
    if reqParams.ProductId == "" {
        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_operaton.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),
    }
    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:    reqParams.LocationId,
        ToLocationID:      location.Id,
    }
    //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, "添加成功")
}
docs/docs.go
@@ -467,6 +467,184 @@
                }
            }
        },
        "/api-wms/v1/locationProduct/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "添加上架规则",
                "parameters": [
                    {
                        "description": "新增上架规则",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddLocationProduct"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "删除上架规则",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/list": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "上架规则列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/update": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "修改上架规则",
                "parameters": [
                    {
                        "description": "修改参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateLocationProduct"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProductamount/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "添加库存盘点信息",
                "parameters": [
                    {
                        "description": "入库/出库信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddLocationProductAmount"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProductamount/list": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "库存盘点列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/operation/finish/{id}": {
            "put": {
                "produces": [
@@ -1467,9 +1645,13 @@
            "enum": [
                1,
                2,
                3
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BaseOperationTypeAdjust": "库存盘点",
                "BaseOperationTypeDisuse": "报废",
                "BaseOperationTypeIncoming": "收货",
                "BaseOperationTypeInternal": "内部调拨",
                "BaseOperationTypeOutgoing": "交货"
@@ -1477,7 +1659,9 @@
            "x-enum-varnames": [
                "BaseOperationTypeIncoming",
                "BaseOperationTypeOutgoing",
                "BaseOperationTypeInternal"
                "BaseOperationTypeInternal",
                "BaseOperationTypeDisuse",
                "BaseOperationTypeAdjust"
            ]
        },
        "constvar.CostingMethod": {
@@ -1560,10 +1744,12 @@
                5,
                6,
                7,
                8
                8,
                9
            ],
            "x-enum-comments": {
                "LocationTypeCustomer": "客户位置",
                "LocationTypeDisuse": "报废位置",
                "LocationTypeInternal": "内部位置",
                "LocationTypeInventoryLoss": "库存损失",
                "LocationTypeProduction": "生产",
@@ -1579,7 +1765,8 @@
                "LocationTypeInventoryLoss",
                "LocationTypeProduction",
                "LocationTypeTransit",
                "LocationTypeDisuse"
                "LocationTypeDisuse",
                "LocationTypeAdjust"
            ]
        },
        "constvar.MaterialMode": {
@@ -1798,7 +1985,7 @@
                },
                "parentId": {
                    "description": "上级id",
                    "type": "string"
                    "type": "integer"
                },
                "recentlyCount": {
                    "description": "最近盘点",
@@ -2016,6 +2203,14 @@
        "models.Operation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "type": "string"
                },
@@ -2311,6 +2506,50 @@
                }
            }
        },
        "request.AddLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.AddLocationProductAmount": {
            "type": "object",
            "properties": {
                "adjustAmount": {
                    "description": "差值",
                    "type": "number"
                },
                "decimal": {
                    "description": "库存数量",
                    "type": "number"
                },
                "difference_amount": {
                    "description": "计数数量",
                    "type": "number"
                },
                "locationId": {
                    "type": "integer"
                },
                "productId": {
                    "type": "string"
                }
            }
        },
        "request.AddOperation": {
            "type": "object",
            "properties": {
@@ -2583,6 +2822,19 @@
                }
            }
        },
        "request.PageInfo": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.QueryDisuseList": {
            "type": "object",
            "properties": {
@@ -2658,8 +2910,10 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string                   ` + "`" + `json:\"productName\"` + "`" + `",
                    "type": "number"
                },
                "baseOperationType": {
                    "$ref": "#/definitions/constvar.BaseOperationType"
                },
                "fromLocationId": {
                    "type": "integer"
@@ -2668,7 +2922,6 @@
                    "type": "integer"
                },
                "number": {
                    "description": "Unit           string                   ` + "`" + `json:\"unit\"` + "`" + `",
                    "type": "string"
                },
                "operationDate": {
@@ -2688,9 +2941,41 @@
                }
            }
        },
        "request.UpdateLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.UpdateOperation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "description": "备注",
                    "type": "string"
@@ -2876,8 +3161,6 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -455,6 +455,184 @@
                }
            }
        },
        "/api-wms/v1/locationProduct/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "添加上架规则",
                "parameters": [
                    {
                        "description": "新增上架规则",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddLocationProduct"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/delete/{id}": {
            "delete": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "删除上架规则",
                "parameters": [
                    {
                        "type": "integer",
                        "description": "id",
                        "name": "id",
                        "in": "path",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/list": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "上架规则列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProduct/update": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "上架规则"
                ],
                "summary": "修改上架规则",
                "parameters": [
                    {
                        "description": "修改参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.UpdateLocationProduct"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProductamount/add": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "添加库存盘点信息",
                "parameters": [
                    {
                        "description": "入库/出库信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.AddLocationProductAmount"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProductamount/list": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "库存盘点列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.PageInfo"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/operation/finish/{id}": {
            "put": {
                "produces": [
@@ -1455,9 +1633,13 @@
            "enum": [
                1,
                2,
                3
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BaseOperationTypeAdjust": "库存盘点",
                "BaseOperationTypeDisuse": "报废",
                "BaseOperationTypeIncoming": "收货",
                "BaseOperationTypeInternal": "内部调拨",
                "BaseOperationTypeOutgoing": "交货"
@@ -1465,7 +1647,9 @@
            "x-enum-varnames": [
                "BaseOperationTypeIncoming",
                "BaseOperationTypeOutgoing",
                "BaseOperationTypeInternal"
                "BaseOperationTypeInternal",
                "BaseOperationTypeDisuse",
                "BaseOperationTypeAdjust"
            ]
        },
        "constvar.CostingMethod": {
@@ -1548,10 +1732,12 @@
                5,
                6,
                7,
                8
                8,
                9
            ],
            "x-enum-comments": {
                "LocationTypeCustomer": "客户位置",
                "LocationTypeDisuse": "报废位置",
                "LocationTypeInternal": "内部位置",
                "LocationTypeInventoryLoss": "库存损失",
                "LocationTypeProduction": "生产",
@@ -1567,7 +1753,8 @@
                "LocationTypeInventoryLoss",
                "LocationTypeProduction",
                "LocationTypeTransit",
                "LocationTypeDisuse"
                "LocationTypeDisuse",
                "LocationTypeAdjust"
            ]
        },
        "constvar.MaterialMode": {
@@ -1786,7 +1973,7 @@
                },
                "parentId": {
                    "description": "上级id",
                    "type": "string"
                    "type": "integer"
                },
                "recentlyCount": {
                    "description": "最近盘点",
@@ -2004,6 +2191,14 @@
        "models.Operation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "type": "string"
                },
@@ -2299,6 +2494,50 @@
                }
            }
        },
        "request.AddLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.AddLocationProductAmount": {
            "type": "object",
            "properties": {
                "adjustAmount": {
                    "description": "差值",
                    "type": "number"
                },
                "decimal": {
                    "description": "库存数量",
                    "type": "number"
                },
                "difference_amount": {
                    "description": "计数数量",
                    "type": "number"
                },
                "locationId": {
                    "type": "integer"
                },
                "productId": {
                    "type": "string"
                }
            }
        },
        "request.AddOperation": {
            "type": "object",
            "properties": {
@@ -2571,6 +2810,19 @@
                }
            }
        },
        "request.PageInfo": {
            "type": "object",
            "properties": {
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                }
            }
        },
        "request.QueryDisuseList": {
            "type": "object",
            "properties": {
@@ -2646,8 +2898,10 @@
            "type": "object",
            "properties": {
                "amount": {
                    "description": "ProductName    string                   `json:\"productName\"`",
                    "type": "number"
                },
                "baseOperationType": {
                    "$ref": "#/definitions/constvar.BaseOperationType"
                },
                "fromLocationId": {
                    "type": "integer"
@@ -2656,7 +2910,6 @@
                    "type": "integer"
                },
                "number": {
                    "description": "Unit           string                   `json:\"unit\"`",
                    "type": "string"
                },
                "operationDate": {
@@ -2676,9 +2929,41 @@
                }
            }
        },
        "request.UpdateLocationProduct": {
            "type": "object",
            "properties": {
                "areaId": {
                    "description": "区域id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "locationId": {
                    "description": "位置id",
                    "type": "integer"
                },
                "productCategoryId": {
                    "description": "产品种类id",
                    "type": "integer"
                },
                "productId": {
                    "description": "产品id",
                    "type": "string"
                }
            }
        },
        "request.UpdateOperation": {
            "type": "object",
            "properties": {
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "comment": {
                    "description": "备注",
                    "type": "string"
docs/swagger.yaml
@@ -4,8 +4,12 @@
    - 1
    - 2
    - 3
    - 4
    - 5
    type: integer
    x-enum-comments:
      BaseOperationTypeAdjust: 库存盘点
      BaseOperationTypeDisuse: 报废
      BaseOperationTypeIncoming: 收货
      BaseOperationTypeInternal: 内部调拨
      BaseOperationTypeOutgoing: 交货
@@ -13,6 +17,8 @@
    - BaseOperationTypeIncoming
    - BaseOperationTypeOutgoing
    - BaseOperationTypeInternal
    - BaseOperationTypeDisuse
    - BaseOperationTypeAdjust
  constvar.CostingMethod:
    enum:
    - 1
@@ -78,9 +84,11 @@
    - 6
    - 7
    - 8
    - 9
    type: integer
    x-enum-comments:
      LocationTypeCustomer: 客户位置
      LocationTypeDisuse: 报废位置
      LocationTypeInternal: 内部位置
      LocationTypeInventoryLoss: 库存损失
      LocationTypeProduction: 生产
@@ -96,6 +104,7 @@
    - LocationTypeProduction
    - LocationTypeTransit
    - LocationTypeDisuse
    - LocationTypeAdjust
  constvar.MaterialMode:
    enum:
    - 原材料
@@ -257,7 +266,7 @@
        type: string
      parentId:
        description: 上级id
        type: string
        type: integer
      recentlyCount:
        description: 最近盘点
        type: string
@@ -422,6 +431,10 @@
    type: object
  models.Operation:
    properties:
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型
      comment:
        type: string
      companyID:
@@ -619,6 +632,37 @@
      toLocationId:
        type: integer
    type: object
  request.AddLocationProduct:
    properties:
      areaId:
        description: 区域id
        type: integer
      locationId:
        description: 位置id
        type: integer
      productCategoryId:
        description: 产品种类id
        type: integer
      productId:
        description: 产品id
        type: string
    type: object
  request.AddLocationProductAmount:
    properties:
      adjustAmount:
        description: 差值
        type: number
      decimal:
        description: 库存数量
        type: number
      difference_amount:
        description: 计数数量
        type: number
      locationId:
        type: integer
      productId:
        type: string
    type: object
  request.AddOperation:
    properties:
      comment:
@@ -808,6 +852,15 @@
      sourceNumber:
        type: string
    type: object
  request.PageInfo:
    properties:
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
    type: object
  request.QueryDisuseList:
    properties:
      number:
@@ -860,14 +913,14 @@
  request.UpdateDisuse:
    properties:
      amount:
        description: ProductName    string                   `json:"productName"`
        type: number
      baseOperationType:
        $ref: '#/definitions/constvar.BaseOperationType'
      fromLocationId:
        type: integer
      id:
        type: integer
      number:
        description: Unit           string                   `json:"unit"`
        type: string
      operationDate:
        type: string
@@ -880,8 +933,29 @@
      toLocationId:
        type: integer
    type: object
  request.UpdateLocationProduct:
    properties:
      areaId:
        description: 区域id
        type: integer
      id:
        type: integer
      locationId:
        description: 位置id
        type: integer
      productCategoryId:
        description: 产品种类id
        type: integer
      productId:
        description: 产品id
        type: string
    type: object
  request.UpdateOperation:
    properties:
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型
      comment:
        description: 备注
        type: string
@@ -1279,6 +1353,119 @@
      summary: 修改位置
      tags:
      - 位置
  /api-wms/v1/locationProduct/add:
    post:
      parameters:
      - description: 新增上架规则
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddLocationProduct'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 添加上架规则
      tags:
      - 上架规则
  /api-wms/v1/locationProduct/delete/{id}:
    delete:
      parameters:
      - description: id
        in: path
        name: id
        required: true
        type: integer
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 删除上架规则
      tags:
      - 上架规则
  /api-wms/v1/locationProduct/list:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.PageInfo'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 上架规则列表
      tags:
      - 上架规则
  /api-wms/v1/locationProduct/update:
    post:
      parameters:
      - description: 修改参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.UpdateLocationProduct'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 修改上架规则
      tags:
      - 上架规则
  /api-wms/v1/locationProductamount/add:
    post:
      parameters:
      - description: 入库/出库信息
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.AddLocationProductAmount'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 添加库存盘点信息
      tags:
      - 库存盘点
  /api-wms/v1/locationProductamount/list:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.PageInfo'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 库存盘点列表
      tags:
      - 库存盘点
  /api-wms/v1/operation/finish/{id}:
    put:
      parameters:
models/db.go
@@ -85,6 +85,8 @@
        //Product{},
        ProductCategory{},
        Material{},
        LocationProduct{},
        LocationProductAmount{},
    )
    return err
}
models/location_product.go
@@ -69,6 +69,16 @@
    return slf
}
func (slf *LocationProductSearch) SetProductId(productId string) *LocationProductSearch {
    slf.ProductId = productId
    return slf
}
func (slf *LocationProductSearch) SetLocationId(locationId int) *LocationProductSearch {
    slf.LocationId = locationId
    return slf
}
func (slf *LocationProductSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&LocationProduct{})
@@ -87,6 +97,14 @@
        db = db.Model(&LocationProduct{}).Preload("Location").Preload("Area").Preload("ProductCategory").Preload("Product")
    }
    if slf.LocationId != 0 {
        db = db.Where("location_id = ?", slf.LocationId)
    }
    if slf.ProductId != "" {
        db = db.Where("product_id=?", slf.ProductId)
    }
    return db
}
request/location_product_amount.go
@@ -3,9 +3,11 @@
import "github.com/shopspring/decimal"
type AddLocationProductAmount struct {
    LocationProductAmountId int             `json:"locationProductAmountId"` //库存盘点id
    AdjustAmount            decimal.Decimal `json:"adjustAmount" `           //差值
    DifferenceAmount        decimal.Decimal `json:"difference_amount"`       //计数数量
    LocationId       int             `json:"locationId"`
    ProductId        string          `json:"productId"`
    Amount           decimal.Decimal `json:"decimal"`           //库存数量
    AdjustAmount     decimal.Decimal `json:"adjustAmount" `     //差值
    DifferenceAmount decimal.Decimal `json:"difference_amount"` //计数数量
}
type UpdateLocationProductAmount struct {
router/router.go
@@ -113,10 +113,18 @@
    locationProductController := new(controllers.LocationProductController)
    locationProductAPI := r.Group(urlPrefix + "/locationProduct")
    {
        locationProductAPI.GET("operationType", locationProductController.List)          // 获取上架规则列表
        locationProductAPI.POST("operationType", locationProductController.Add)          // 新增上架规则
        locationProductAPI.PUT("operationType/:id", locationProductController.Update)    // 修改上架规则
        locationProductAPI.DELETE("operationType/:id", locationProductController.Delete) // 删除上架规则
        locationProductAPI.POST("list", locationProductController.List)           // 获取上架规则列表
        locationProductAPI.POST("add", locationProductController.Add)             // 新增上架规则
        locationProductAPI.POST("update", locationProductController.Update)       // 修改上架规则
        locationProductAPI.DELETE("delete/:id", locationProductController.Delete) // 删除上架规则
    }
    //库存盘点
    locationProductAmountController := new(controllers.LocationProductAmountController)
    locationProductAmountAPI := r.Group(urlPrefix + "/locationProductAmount")
    {
        locationProductAmountAPI.POST("add", locationProductAmountController.Add)   //添加库存盘点信息
        locationProductAmountAPI.POST("list", locationProductAmountController.List) //查看库存盘点列表
    }
    return r