liujiandao
2023-10-09 2716487d13f3521adeb25a48aa07a89f885d32c7
仓库功能修改
5个文件已修改
131 ■■■■■ 已修改文件
controllers/warehouse.go 56 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 26 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 24 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation_type.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/warehouse.go
@@ -54,7 +54,36 @@
        return
    }
    params.LocationId = locationId
    if err := models.NewWarehouseSearch().Create(&params); err != nil {
    err = models.WithTransaction(func(tx *gorm.DB) error {
        err := models.NewWarehouseSearch().SetOrm(tx).Create(&params)
        if err != nil {
            return err
        }
        //创建三个默认操作类型
        var types []*models.OperationType
        inType := &models.OperationType{
            Name:              params.Name + "-入库",
            BaseOperationType: constvar.BaseOperationTypeIncoming,
            WarehouseId:       params.Id,
        }
        types = append(types, inType)
        outType := &models.OperationType{
            Name:              params.Name + "-出库",
            BaseOperationType: constvar.BaseOperationTypeOutgoing,
            WarehouseId:       params.Id,
        }
        types = append(types, outType)
        internalType := &models.OperationType{
            Name:              params.Name + "-内部调拨",
            BaseOperationType: constvar.BaseOperationTypeInternal,
            WarehouseId:       params.Id,
        }
        types = append(types, internalType)
        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
@@ -174,22 +203,31 @@
        return
    }
    //删除位置信息
    first, err := models.NewWarehouseSearch().SetID(id).First()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "获取仓库信息失败")
        return
    }
    err = models.NewLocationSearch().SetID(first.LocationId).Delete()
    err = models.WithTransaction(func(tx *gorm.DB) error {
        //删除位置信息
        err = models.NewLocationSearch().SetOrm(tx).SetJointName(first.Code).Delete()
        if err != nil {
            return err
        }
        //删除操作类型
        err = models.NewOperationTypeSearch().SetOrm(tx).SetWarehouseId(first.Id).Delete()
        if err != nil {
            return err
        }
        //删除仓库
        err = models.NewWarehouseSearch().SetOrm(tx).SetID(id).Delete()
        return err
    })
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "删除位置信息失败")
        util.ResponseFormat(c, code.RequestParamError, "删除仓库失败")
        return
    }
    err = models.NewWarehouseSearch().SetID(id).Delete()
    if err != nil {
        util.ResponseFormat(c, code.RequestParamError, "删除仓库信息失败")
        return
    }
    util.ResponseFormat(c, code.UpdateSuccess, "删除成功")
}
docs/docs.go
@@ -3346,12 +3346,12 @@
        "request.UpdateLocationProductAmount": {
            "type": "object",
            "properties": {
                "Amount": {
                    "description": "库存数量",
                    "type": "number"
                },
                "adjustAmount": {
                    "description": "LocationProductAmountId int             ` + "`" + `json:\"locationProductAmountId\"` + "`" + ` //库存盘点id",
                    "type": "number"
                },
                "amount": {
                    "description": "库存数量",
                    "type": "number"
                },
                "differenceAmount": {
@@ -3570,14 +3570,6 @@
                    "description": "数量",
                    "type": "number"
                },
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "contactedName": {
                    "description": "完成者",
                    "type": "string"
@@ -3592,6 +3584,14 @@
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "status": {
                    "description": "状态",
                    "type": "string"
                },
                "toLocation": {
@@ -3702,6 +3702,8 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -3334,12 +3334,12 @@
        "request.UpdateLocationProductAmount": {
            "type": "object",
            "properties": {
                "Amount": {
                    "description": "库存数量",
                    "type": "number"
                },
                "adjustAmount": {
                    "description": "LocationProductAmountId int             `json:\"locationProductAmountId\"` //库存盘点id",
                    "type": "number"
                },
                "amount": {
                    "description": "库存数量",
                    "type": "number"
                },
                "differenceAmount": {
@@ -3558,14 +3558,6 @@
                    "description": "数量",
                    "type": "number"
                },
                "baseOperationType": {
                    "description": "基础作业类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.BaseOperationType"
                        }
                    ]
                },
                "contactedName": {
                    "description": "完成者",
                    "type": "string"
@@ -3582,6 +3574,14 @@
                    "description": "单号",
                    "type": "string"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "status": {
                    "description": "状态",
                    "type": "string"
                },
                "toLocation": {
                    "description": "目标位置",
                    "type": "string"
docs/swagger.yaml
@@ -1018,12 +1018,12 @@
    type: object
  request.UpdateLocationProductAmount:
    properties:
      Amount:
        description: 库存数量
        type: number
      adjustAmount:
        description: LocationProductAmountId int             `json:"locationProductAmountId"`
          //库存盘点id
        type: number
      amount:
        description: 库存数量
        type: number
      differenceAmount:
        description: 计数数量
@@ -1173,10 +1173,6 @@
      amount:
        description: 数量
        type: number
      baseOperationType:
        allOf:
        - $ref: '#/definitions/constvar.BaseOperationType'
        description: 基础作业类型
      contactedName:
        description: 完成者
        type: string
@@ -1189,6 +1185,12 @@
      number:
        description: 单号
        type: string
      productName:
        description: 产品名称
        type: string
      status:
        description: 状态
        type: string
      toLocation:
        description: 目标位置
        type: string
models/operation_type.go
@@ -103,6 +103,11 @@
    return slf
}
func (slf *OperationTypeSearch) SetWarehouseId(warehouseId int) *OperationTypeSearch {
    slf.WarehouseId = warehouseId
    return slf
}
func (slf *OperationTypeSearch) build() *gorm.DB {
    var db = slf.Orm.Model(&OperationType{})
@@ -126,6 +131,10 @@
        db = db.Preload("Company").Preload("Warehouse").Preload("DefaultLocationSrc").Preload("DefaultLocationDest")
    }
    if slf.WarehouseId > 0 {
        db = db.Where("warehouse_id = ?", slf.WarehouseId)
    }
    return db
}