zhangqian
2024-07-03 a2cfbd59045d7426088e9ec9e93794dc895849a9
获取位置列表增加仓库ID传参,默认位置去掉仓库code拼接, 修复若干bug
10个文件已修改
347 ■■■■■ 已修改文件
conf/config.yaml 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/location.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/warehouse.go 42 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 105 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 70 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/location.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/location.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/location_forms.go 3 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
service/operation.go 1 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
conf/config.yaml
@@ -9,6 +9,7 @@
  serverId: wms
  # 通过公司名称区分出入库明细打印模版,目前支持:geruimi,jialian
  companyName: jialian
  env: dev
db:
  #  dsn: root:c++java123@tcp(192.168.20.119:3306)/wms?charset=utf8&parseTime=True&loc=Local
  dsn: root:c++java123@tcp(127.0.0.1:3306)/aps_server2?charset=utf8&parseTime=True&loc=Local
controllers/location.go
@@ -31,6 +31,12 @@
        util.ResponseFormat(c, code.RequestParamError, err)
        return
    }
    if params.WarehouseId == 0 {
        util.ResponseFormat(c, code.RequestParamError, "仓库ID参数缺失")
        return
    }
    if params.ParentId != 0 {
        //查询上级名称
        first, err := models.NewLocationSearch().SetID(params.ParentId).First()
@@ -82,7 +88,9 @@
        search.SetPage(params.Page, params.PageSize)
    }
    list, total, err := search.SetKeyword(params.KeyWord).SetType(params.Type).SetJointName(params.JointName).
        SetIsScrapLocation(params.IsScrapLocation).SetOrder("created_at desc").Find()
        SetIsScrapLocation(params.IsScrapLocation).SetOrder("created_at desc").
        SetWarehouseId(params.WarehouseId).
        Find()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "查找失败")
        return
controllers/warehouse.go
@@ -12,7 +12,6 @@
    "wms/extend/code"
    "wms/extend/util"
    "wms/models"
    "wms/pkg/logx"
    "wms/pkg/structx"
    "wms/request"
)
@@ -53,25 +52,33 @@
        util.ResponseFormat(c, code.SaveFail, "视图创建失败")
        return
    }
    //创建默认位置
    location := &models.Location{
        Name:              params.Name,
        JointName:         params.Name,
        Type:              constvar.LocationTypeInternal,
        ReplenishLocation: true,
        ParentId:          id,
    }
    locationId, err := models.NewLocationSearch().CreateReturnId(location)
    if err != nil {
        util.ResponseFormat(c, code.SaveFail, "位置创建失败")
        return
    }
    params.LocationId = locationId
    err = models.WithTransaction(func(tx *gorm.DB) error {
        err := models.NewWarehouseSearch().SetOrm(tx).Create(&params)
        if err != nil {
            return err
        }
        //创建默认位置
        location := &models.Location{
            Name:              params.Name,
            JointName:         params.Name,
            Type:              constvar.LocationTypeInternal,
            ReplenishLocation: true,
            ParentId:          id,
            WarehouseId:       params.Id,
        }
        locationId, err := models.NewLocationSearch().SetOrm(tx).CreateReturnId(location)
        if err != nil {
            return err
        }
        //更改仓库记录里的位置id
        params.LocationId = locationId
        err = models.NewWarehouseSearch().SetOrm(tx).SetID(params.Id).UpdateByMap(map[string]interface{}{"location_id": locationId})
        if err != nil {
            return err
        }
        //创建三个默认操作类型
        var types []*models.OperationType
        inType := &models.OperationType{
@@ -95,9 +102,8 @@
        err = models.NewOperationTypeSearch().SetOrm(tx).CreateBatch(types)
        return err
    })
    if err != nil {
        _ = models.NewLocationSearch().SetID(locationId).Delete()
        logx.Errorf("warehouse create err: %v", err)
        util.ResponseFormat(c, code.SaveFail, "插入失败")
        return
    }
@@ -238,7 +244,7 @@
    for _, warehouse := range list {
        for _, location := range locations {
            if warehouse.LocationId == location.Id {
                warehouse.WarehouseLocation = warehouse.Code + "/" + location.Name
                warehouse.WarehouseLocation = location.Name
                break
            }
        }
docs/docs.go
@@ -2023,37 +2023,11 @@
                    "入库/出库"
                ],
                "summary": "获取人员列表",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.OperationCondition"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/inventory_order.WorkerInfo"
                                            }
                                        }
                                    }
                                }
                            ]
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
@@ -2797,6 +2771,31 @@
                }
            }
        },
        "/api-wms/v1/product/downloadInputFormat": {
            "get": {
                "tags": [
                    "产品"
                ],
                "summary": "下载导入物料/产品模板",
                "parameters": [
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/product/finishDisuse/{id}": {
            "put": {
                "produces": [
@@ -3124,9 +3123,9 @@
                    "application/xlsx"
                ],
                "tags": [
                    "物料管理"
                    "产品"
                ],
                "summary": "导入物料",
                "summary": "导入物料/产品",
                "parameters": [
                    {
                        "type": "file",
@@ -4152,19 +4151,22 @@
                1,
                2,
                3,
                4
                4,
                5
            ],
            "x-enum-comments": {
                "DisuseType": "报废类型",
                "StockoutType": "出库类型",
                "StorageType": "入库类型",
                "TakeStock": "盘点类型",
                "TakeStockType": "盘点类型",
                "TransferType": "调拨类型"
            },
            "x-enum-varnames": [
                "StorageType",
                "StockoutType",
                "TransferType",
                "TakeStock"
                "TakeStockType",
                "DisuseType"
            ]
        },
        "constvar.OperationSource": {
@@ -4347,17 +4349,6 @@
                "valid": {
                    "description": "Valid is true if Time is not NULL",
                    "type": "boolean"
                }
            }
        },
        "inventory_order.WorkerInfo": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
@@ -5038,6 +5029,21 @@
                    "type": "number"
                }
            }
        },
        "models.MonthStatsItemsType": {
            "type": "integer",
            "enum": [
                1,
                2
            ],
            "x-enum-comments": {
                "MonthStatsItemsTypeInput": "入库",
                "MonthStatsItemsTypeOutput": "出库"
            },
            "x-enum-varnames": [
                "MonthStatsItemsTypeInput",
                "MonthStatsItemsTypeOutput"
            ]
        },
        "models.MoveHistory": {
            "type": "object",
@@ -5740,6 +5746,9 @@
                    "description": "入库来源,出库去处",
                    "type": "string"
                },
                "type": {
                    "$ref": "#/definitions/models.MonthStatsItemsType"
                },
                "warehouseMonthStatsId": {
                    "type": "integer"
                }
@@ -6333,6 +6342,12 @@
                "locationId": {
                    "type": "integer"
                },
                "locationIds": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -6373,6 +6388,10 @@
                },
                "type": {
                    "type": "integer"
                },
                "warehouseId": {
                    "description": "仓库ID",
                    "type": "integer"
                }
            }
        },
docs/swagger.json
@@ -2012,37 +2012,11 @@
                    "入库/出库"
                ],
                "summary": "获取人员列表",
                "parameters": [
                    {
                        "description": "参数",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/request.OperationCondition"
                        }
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "allOf": [
                                {
                                    "$ref": "#/definitions/util.ResponseList"
                                },
                                {
                                    "type": "object",
                                    "properties": {
                                        "data": {
                                            "type": "array",
                                            "items": {
                                                "$ref": "#/definitions/inventory_order.WorkerInfo"
                                            }
                                        }
                                    }
                                }
                            ]
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
@@ -2786,6 +2760,31 @@
                }
            }
        },
        "/api-wms/v1/product/downloadInputFormat": {
            "get": {
                "tags": [
                    "产品"
                ],
                "summary": "下载导入物料/产品模板",
                "parameters": [
                    {
                        "type": "string",
                        "description": "token",
                        "name": "Authorization",
                        "in": "header",
                        "required": true
                    }
                ],
                "responses": {
                    "200": {
                        "description": "成功",
                        "schema": {
                            "$ref": "#/definitions/util.Response"
                        }
                    }
                }
            }
        },
        "/api-wms/v1/product/finishDisuse/{id}": {
            "put": {
                "produces": [
@@ -3113,9 +3112,9 @@
                    "application/xlsx"
                ],
                "tags": [
                    "物料管理"
                    "产品"
                ],
                "summary": "导入物料",
                "summary": "导入物料/产品",
                "parameters": [
                    {
                        "type": "file",
@@ -4141,19 +4140,22 @@
                1,
                2,
                3,
                4
                4,
                5
            ],
            "x-enum-comments": {
                "DisuseType": "报废类型",
                "StockoutType": "出库类型",
                "StorageType": "入库类型",
                "TakeStock": "盘点类型",
                "TakeStockType": "盘点类型",
                "TransferType": "调拨类型"
            },
            "x-enum-varnames": [
                "StorageType",
                "StockoutType",
                "TransferType",
                "TakeStock"
                "TakeStockType",
                "DisuseType"
            ]
        },
        "constvar.OperationSource": {
@@ -4336,17 +4338,6 @@
                "valid": {
                    "description": "Valid is true if Time is not NULL",
                    "type": "boolean"
                }
            }
        },
        "inventory_order.WorkerInfo": {
            "type": "object",
            "properties": {
                "id": {
                    "type": "string"
                },
                "name": {
                    "type": "string"
                }
            }
        },
@@ -5027,6 +5018,21 @@
                    "type": "number"
                }
            }
        },
        "models.MonthStatsItemsType": {
            "type": "integer",
            "enum": [
                1,
                2
            ],
            "x-enum-comments": {
                "MonthStatsItemsTypeInput": "入库",
                "MonthStatsItemsTypeOutput": "出库"
            },
            "x-enum-varnames": [
                "MonthStatsItemsTypeInput",
                "MonthStatsItemsTypeOutput"
            ]
        },
        "models.MoveHistory": {
            "type": "object",
@@ -5729,6 +5735,9 @@
                    "description": "入库来源,出库去处",
                    "type": "string"
                },
                "type": {
                    "$ref": "#/definitions/models.MonthStatsItemsType"
                },
                "warehouseMonthStatsId": {
                    "type": "integer"
                }
@@ -6322,6 +6331,12 @@
                "locationId": {
                    "type": "integer"
                },
                "locationIds": {
                    "type": "array",
                    "items": {
                        "type": "integer"
                    }
                },
                "page": {
                    "description": "页码",
                    "type": "integer"
@@ -6362,6 +6377,10 @@
                },
                "type": {
                    "type": "integer"
                },
                "warehouseId": {
                    "description": "仓库ID",
                    "type": "integer"
                }
            }
        },
docs/swagger.yaml
@@ -212,17 +212,20 @@
    - 2
    - 3
    - 4
    - 5
    type: integer
    x-enum-comments:
      DisuseType: 报废类型
      StockoutType: 出库类型
      StorageType: 入库类型
      TakeStock: 盘点类型
      TakeStockType: 盘点类型
      TransferType: 调拨类型
    x-enum-varnames:
    - StorageType
    - StockoutType
    - TransferType
    - TakeStock
    - TakeStockType
    - DisuseType
  constvar.OperationSource:
    enum:
    - 1
@@ -365,13 +368,6 @@
      valid:
        description: Valid is true if Time is not NULL
        type: boolean
    type: object
  inventory_order.WorkerInfo:
    properties:
      id:
        type: string
      name:
        type: string
    type: object
  models.Attachment:
    properties:
@@ -854,6 +850,17 @@
        description: 重量
        type: number
    type: object
  models.MonthStatsItemsType:
    enum:
    - 1
    - 2
    type: integer
    x-enum-comments:
      MonthStatsItemsTypeInput: 入库
      MonthStatsItemsTypeOutput: 出库
    x-enum-varnames:
    - MonthStatsItemsTypeInput
    - MonthStatsItemsTypeOutput
  models.MoveHistory:
    properties:
      amount:
@@ -1329,6 +1336,8 @@
      name:
        description: 入库来源,出库去处
        type: string
      type:
        $ref: '#/definitions/models.MonthStatsItemsType'
      warehouseMonthStatsId:
        type: integer
    type: object
@@ -1734,6 +1743,10 @@
        type: string
      locationId:
        type: integer
      locationIds:
        items:
          type: integer
        type: array
      page:
        description: 页码
        type: integer
@@ -1762,6 +1775,9 @@
        description: 每页大小
        type: integer
      type:
        type: integer
      warehouseId:
        description: 仓库ID
        type: integer
    type: object
  request.GetMiniDictList:
@@ -3627,27 +3643,13 @@
      - 入库/出库
  /api-wms/v1/operation/getPersonnelList:
    get:
      parameters:
      - description: 参数
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/request.OperationCondition'
      produces:
      - application/json
      responses:
        "200":
          description: 成功
          schema:
            allOf:
            - $ref: '#/definitions/util.ResponseList'
            - properties:
                data:
                  items:
                    $ref: '#/definitions/inventory_order.WorkerInfo'
                  type: array
              type: object
            $ref: '#/definitions/util.Response'
      summary: 获取人员列表
      tags:
      - 入库/出库
@@ -4117,6 +4119,22 @@
      summary: 删除产品类型
      tags:
      - 产品类型
  /api-wms/v1/product/downloadInputFormat:
    get:
      parameters:
      - description: token
        in: header
        name: Authorization
        required: true
        type: string
      responses:
        "200":
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 下载导入物料/产品模板
      tags:
      - 产品
  /api-wms/v1/product/finishDisuse/{id}:
    put:
      parameters:
@@ -4325,9 +4343,9 @@
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 导入物料
      summary: 导入物料/产品
      tags:
      - 物料管理
      - 产品
  /api-wms/v1/product/listDisuse:
    post:
      parameters:
models/location.go
@@ -122,6 +122,11 @@
    return slf
}
func (slf *LocationSearch) SetWarehouseId(warehouseId int) *LocationSearch {
    slf.WarehouseId = warehouseId
    return slf
}
func (slf *LocationSearch) build() *gorm.DB {
    var db = slf.Orm.Table(slf.TableName())
@@ -171,6 +176,10 @@
        db = db.Preload("Warehouse")
    }
    if slf.WarehouseId != 0 {
        db = db.Where("warehouse_id = ?", slf.WarehouseId)
    }
    return db
}
request/location.go
@@ -13,4 +13,5 @@
    KeyWord         string `json:"keyWord"`
    JointName       string `json:"jointName"`       //拼接名称
    IsScrapLocation bool   `json:"isScrapLocation"` //是否报废
    WarehouseId     int    `json:"warehouseId"`     //仓库ID
}
service/location_forms.go
@@ -49,7 +49,8 @@
    ids := params.LocationIds
    if params.LocationId != 0 {
        ids = append(ids, params.LocationId)
    } else {
    }
    if len(ids) == 0 {
        //查询位置
        locations, err := models.NewLocationSearch().SetJointName(params.WareHouseCode).SetType(3).FindAll()
        if err != nil {
service/operation.go
@@ -182,6 +182,7 @@
            } else {
                if locAmount, aok := mapLocAmount[strconv.Itoa(operation.LocationID)+v.ProductId]; aok {
                    locAmount.Amount = locAmount.Amount.Add(v.Amount)
                    locAmount.ID = uint(locAmount.Id)
                    if err := models.NewLocationProductAmountSearch().SetOrm(tx).SetID(int(locAmount.ID)).Save(locAmount); err != nil {
                        return err
                    }