zhangqian
2024-07-04 c950586b718ae6fc198bedf424609a4ac94cb5d1
增加根据位置或仓库查询产品及库存列表
9个文件已修改
253 ■■■■■ 已修改文件
controllers/location_product_amount.go 46 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 64 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 45 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/db.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location_product_amount.go 18 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/location_product_amount.go 12 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location_product_amount.go
@@ -143,6 +143,52 @@
    util.ResponseFormatListWithPage(c, code.Success, records, int(total), params.Page, params.PageSize)
}
// LocationProductList
// @Tags      库存盘点
// @Summary   获取位置对应产品列表
// @Produce   application/json
// @Param         object  body  request.GetLocationProductList true  "查询参数"
// @Param     Authorization    header string true "token"
// @Success   200 {object} util.Response    "成功"
// @Router    /api-wms/v1/locationProductAmount/locationProductList [post]
func (slf LocationProductAmountController) LocationProductList(c *gin.Context) {
    var params request.GetLocationProductList
    if err := c.BindJSON(&params); 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, total, err := search.
        SetLocationIds(locationIds).SetWarehouseId(params.WarehouseId).SetProductIds(productIds).SetLocationId(params.LocationId).
        SetPage(params.Page, params.PageSize).
        SetOrder("id desc").
        SetPreload(true).
        FindByPage()
    if err != nil {
        util.ResponseFormat(c, code.InternalError, "查询失败")
        return
    }
    util.ResponseFormatList(c, code.Success, records, int(total))
}
// Add
// @Tags      库存盘点
// @Summary   添加库存盘点信息
docs/docs.go
@@ -1847,6 +1847,43 @@
                }
            }
        },
        "/api-wms/v1/locationProductAmount/locationProductList": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "获取位置对应产品列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetLocationProductList"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProductAmount/update": {
            "post": {
                "produces": [
@@ -4581,7 +4618,7 @@
                    "$ref": "#/definitions/models.Location"
                },
                "locationId": {
                    "description": "LocationProductId int             ` + "`" + `json:\"locationProductId\" gorm:\"type:int;not null;comment:上架规则id\"` + "`" + ` //上架规则id\nLocationProduct   LocationProduct ` + "`" + `json:\"locationProduct\" gorm:\"foreignKey:LocationProductId;references:Id\"` + "`" + `",
                    "description": "位置id",
                    "type": "integer"
                },
                "product": {
@@ -4600,6 +4637,9 @@
                },
                "updateTime": {
                    "type": "string"
                },
                "warehouseId": {
                    "type": "integer"
                }
            }
        },
@@ -6395,6 +6435,28 @@
                }
            }
        },
        "request.GetLocationProductList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "locationId": {
                    "type": "integer"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "warehouseId": {
                    "type": "integer"
                }
            }
        },
        "request.GetMiniDictList": {
            "type": "object",
            "properties": {
docs/swagger.json
@@ -1836,6 +1836,43 @@
                }
            }
        },
        "/api-wms/v1/locationProductAmount/locationProductList": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "库存盘点"
                ],
                "summary": "获取位置对应产品列表",
                "parameters": [
                    {
                        "description": "查询参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.GetLocationProductList"
                        }
                    },
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/locationProductAmount/update": {
            "post": {
                "produces": [
@@ -4570,7 +4607,7 @@
                    "$ref": "#/definitions/models.Location"
                },
                "locationId": {
                    "description": "LocationProductId int             `json:\"locationProductId\" gorm:\"type:int;not null;comment:上架规则id\"` //上架规则id\nLocationProduct   LocationProduct `json:\"locationProduct\" gorm:\"foreignKey:LocationProductId;references:Id\"`",
                    "description": "位置id",
                    "type": "integer"
                },
                "product": {
@@ -4589,6 +4626,9 @@
                },
                "updateTime": {
                    "type": "string"
                },
                "warehouseId": {
                    "type": "integer"
                }
            }
        },
@@ -6384,6 +6424,28 @@
                }
            }
        },
        "request.GetLocationProductList": {
            "type": "object",
            "properties": {
                "keyword": {
                    "type": "string"
                },
                "locationId": {
                    "type": "integer"
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
                },
                "pageSize": {
                    "description": "每页大小",
                    "type": "integer"
                },
                "warehouseId": {
                    "type": "integer"
                }
            }
        },
        "request.GetMiniDictList": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -526,9 +526,7 @@
      location:
        $ref: '#/definitions/models.Location'
      locationId:
        description: |-
          LocationProductId int             `json:"locationProductId" gorm:"type:int;not null;comment:上架规则id"` //上架规则id
          LocationProduct   LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"`
        description: 位置id
        type: integer
      product:
        $ref: '#/definitions/models.Material'
@@ -542,6 +540,8 @@
        type: string
      updateTime:
        type: string
      warehouseId:
        type: integer
    type: object
  models.LogisticCompany:
    properties:
@@ -1778,6 +1778,21 @@
        type: integer
      warehouseId:
        description: 仓库ID
        type: integer
    type: object
  request.GetLocationProductList:
    properties:
      keyword:
        type: string
      locationId:
        type: integer
      page:
        description: 页码
        type: integer
      pageSize:
        description: 每页大小
        type: integer
      warehouseId:
        type: integer
    type: object
  request.GetMiniDictList:
@@ -3537,6 +3552,30 @@
      summary: 库存盘点列表
      tags:
      - 库存盘点
  /api-wms/v1/locationProductAmount/locationProductList:
    post:
      parameters:
      - description: 查询参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.GetLocationProductList'
      - description: token
        in: header
        name: Authorization
        required: true
        type: string
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 获取位置对应产品列表
      tags:
      - 库存盘点
  /api-wms/v1/locationProductAmount/update:
    post:
      parameters:
models/db.go
@@ -135,7 +135,6 @@
func InsertDefaultData() {
    models := []interface{}{
        NewDepartmentSearch(),
        NewLocationSearch(),
    }
    for _, model := range models {
models/location_product_amount.go
@@ -11,10 +11,9 @@
type (
    LocationProductAmount struct {
        WmsModel
        Id int `json:"id"  gorm:"column:id;primary_key;AUTO_INCREMENT"`
        //LocationProductId int             `json:"locationProductId" gorm:"type:int;not null;comment:上架规则id"` //上架规则id
        //LocationProduct   LocationProduct `json:"locationProduct" gorm:"foreignKey:LocationProductId;references:Id"`
        Id                int             `json:"id"  gorm:"column:id;primary_key;AUTO_INCREMENT"`
        LocationId        int             `json:"locationId" gorm:"type:int;not null;comment:位置id"` //位置id
        WarehouseId       int             `json:"warehouseId" gorm:"type:int;not null;default:0;comment:仓库id"`
        Location          Location        `json:"location" gorm:"foreignKey:LocationId;references:id"`
        ProductCategoryID int             `json:"productCategoryId" gorm:"type:int;not null;comment:产品种类id"` //产品种类id
        ProductCategory   ProductCategory `json:"productCategory" gorm:"foreignKey:ProductCategoryID;references:Id"`
@@ -127,6 +126,11 @@
    return slf
}
func (slf *LocationProductAmountSearch) SetWarehouseId(wid int) *LocationProductAmountSearch {
    slf.WarehouseId = wid
    return slf
}
func (slf *LocationProductAmountSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&LocationProductAmount{})
@@ -148,9 +152,7 @@
    if slf.Preload {
        db = db.Model(&LocationProductAmount{}).Preload("Location").Preload("Product").Preload("ProductCategory")
    }
    //if slf.LocationProductId != 0 {
    //    db = db.Where("location_product_id=?", slf.LocationProductId)
    //}
    if len(slf.ProductIds) > 0 {
        db = db.Where("product_id in (?)", slf.ProductIds)
    }
@@ -175,6 +177,10 @@
        db = db.Where(slf.Query)
    }
    if slf.WarehouseId != 0 {
        db = db.Where("warehouse_id = ?", slf.WarehouseId)
    }
    return db
}
models/operation.go
@@ -61,7 +61,7 @@
        CheckedBy    string `json:"checkedBy" gorm:"type:varchar(255);comment:验证者UserId"`
        Remark       string `json:"remark"`
        WarehouseId         int       `json:"warehouseId" gorm:"type:int;not null;comment:仓库id"`
        WarehouseId         int       `json:"warehouseId" gorm:"type:int;not null;default:0;comment:仓库id"`
        Warehouse           Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"`
        IsInternalOutput    bool      `json:"isInternalOutput"` //是否调拨产生的出库
        InventoryDealerType int       `json:"inventoryDealerType" gorm:"type:varchar(255);comment:调拨出入库分类(对应dict字典表的ID)"`
request/location_product_amount.go
@@ -2,6 +2,7 @@
import (
    "github.com/shopspring/decimal"
    "wms/models"
)
type GetList struct {
@@ -38,3 +39,14 @@
    ProductId               string `json:"productId"`               //产品id
    LocationProductAmountId int    `json:"locationProductAmountId"` //库存盘点id
}
type GetLocationProductList struct {
    PageInfo
    Keyword     string `json:"keyword"`
    WarehouseId int    `json:"warehouseId"`
    LocationId  int    `json:"locationId"`
}
type GetLocationProductListResponse struct {
    models.Material
}
router/router.go
@@ -160,6 +160,7 @@
    {
        locationProductAmountAPI.POST("add", locationProductAmountController.Add)                                           //添加库存盘点信息
        locationProductAmountAPI.POST("list", locationProductAmountController.List)                                         //查看库存盘点列表
        locationProductAmountAPI.POST("locationProductList", locationProductAmountController.LocationProductList)           //查看产品库存列表
        locationProductAmountAPI.POST("update", locationProductAmountController.Update)                                     //修改库存盘点信息
        locationProductAmountAPI.POST("finish", locationProductAmountController.Finish)                                     //应用、验证库存盘点信息
        locationProductAmountAPI.POST("getRuleList", locationProductAmountController.GetRuleList)                           //获取上架规则