liujiandao
2023-09-18 1770deb5829f745194508339a7924eefd4dbd627
Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

# Conflicts:
# docs/docs.go
# docs/swagger.json
# docs/swagger.yaml
# router/router.go
2个文件已添加
8个文件已修改
992 ■■■■■ 已修改文件
constvar/const.go 9 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
controllers/operation.go 86 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/docs.go 293 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.json 291 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
docs/swagger.yaml 213 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation.go 34 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
models/operation_details.go 2 ●●● 补丁 | 查看 | 原始文档 | blame | 历史
pkg/timex/timex.go 28 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
request/operation.go 26 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
router/router.go 10 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
constvar/const.go
@@ -148,3 +148,12 @@
func (t InventoryValuation) Valid() bool {
    return t >= InventoryValuationManual && t <= InventoryValuationAuto
}
type OperationStatus int
const (
    OperationStatus_Draft   OperationStatus = iota + 1 //草稿
    OperationStatus_Waiting                            //正在等待
    OperationStatus_Ready                              //就绪
    OperationStatus_Finish                             //完成
)
controllers/operation.go
New file
@@ -0,0 +1,86 @@
package controllers
import (
    "errors"
    "github.com/gin-gonic/gin"
    "wms/extend/code"
    "wms/extend/util"
    "wms/models"
    "wms/pkg/logx"
    "wms/pkg/structx"
    "wms/request"
)
type OperationController struct {
}
// Add
// @Tags      入库/出库
// @Summary   添加入库/出库
// @Produce   application/json
// @Param     object  body  request.AddOperation true  "入库/出库信息"
// @Success   200 {object} util.Response "成功"
// @Router    /api-wms/v1/operation/operation [post]
func (slf OperationController) Add(c *gin.Context) {
    var reqParams request.AddOperation
    var params models.Operation
    if err := c.BindJSON(&reqParams); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "参数解析失败,数据类型错误")
    }
    if err := structx.AssignTo(reqParams, params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, "数据转换错误")
    }
    if err := slf.CheckParams(params); err != nil {
        util.ResponseFormat(c, code.RequestParamError, err.Error())
    }
    if err := models.NewOperationSearch().Create(&params); err != nil {
        logx.Errorf("Operation create err: %v", err)
        util.ResponseFormat(c, code.SaveFail, "添加失败:"+err.Error())
    }
    util.ResponseFormat(c, code.Success, "添加成功")
}
func (slf OperationController) CheckParams(params models.Operation) error {
    if params.SourceNumber == "" {
        return errors.New("请填入源单号")
    }
    if params.OperationTypeId == 0 {
        return errors.New("operationTypeId为0")
    }
    if params.FromLocationId == 0 {
        return errors.New("请选择源位置")
    }
    if params.ToLocationId == 0 {
        return errors.New("请选择目标位置")
    }
    if params.OperationDate.IsZero() {
        return errors.New("请选择安排日期")
    }
    if len(params.Details) <= 0 {
        return errors.New("请添加明细信息")
    }
    //检查明细部分
    for _, v := range params.Details {
        if v.ProductId == 0 {
            return errors.New("productID为0")
        }
        if v.ProductName == "" {
            return errors.New("产品名称异常")
        }
        if v.Quantity.IsNegative() {
            return errors.New("产品数量出错")
        }
        if v.FinishQuantity.IsNegative() {
            return errors.New("产品数量出错")
        }
    }
    return nil
}
docs/docs.go
@@ -294,23 +294,23 @@
                }
            }
        },
        "/api-wms/v1/product/addProduct": {
        "/api-wms/v1/operation/operation": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                    "入库/出库"
                ],
                "summary": "添加产品",
                "summary": "添加入库/出库",
                "parameters": [
                    {
                        "description": "产品信息",
                        "description": "入库/出库信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Product"
                            "$ref": "#/definitions/request.AddOperation"
                        }
                    }
                ],
@@ -632,30 +632,6 @@
                "BaseOperationTypeInternal"
            ]
        },
        "constvar.InvoicingStrategy": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BasedDeliverNumber": "基于交付数量",
                "DeliverNumber": "交付数量",
                "IndentNumber": "订购数量",
                "Milestones": "基于里程碑",
                "PrepaidPrice": "预付\\固定价格"
            },
            "x-enum-varnames": [
                "IndentNumber",
                "DeliverNumber",
                "PrepaidPrice",
                "Milestones",
                "BasedDeliverNumber"
            ]
        },
        "constvar.LocationType": {
            "type": "integer",
            "enum": [
@@ -686,7 +662,7 @@
                "LocationTypeTransit"
            ]
        },
        "constvar.OrderCreation": {
        "constvar.OperationStatus": {
            "type": "integer",
            "enum": [
                1,
@@ -695,34 +671,16 @@
                4
            ],
            "x-enum-comments": {
                "Nothing": "不操作",
                "Object": "项目",
                "Task": "任务",
                "TaskAndObject": "任务和项目"
                "OperationStatus_Draft": "草稿",
                "OperationStatus_Finish": "完成",
                "OperationStatus_Ready": "就绪",
                "OperationStatus_Waiting": "正在等待"
            },
            "x-enum-varnames": [
                "Nothing",
                "Task",
                "Object",
                "TaskAndObject"
            ]
        },
        "constvar.ProductType": {
            "type": "integer",
            "enum": [
                1,
                2,
                3
            ],
            "x-enum-comments": {
                "Consumables": "消耗品",
                "Server": "服务",
                "StoredProduct": "可储存的产品"
            },
            "x-enum-varnames": [
                "Consumables",
                "Server",
                "StoredProduct"
                "OperationStatus_Draft",
                "OperationStatus_Waiting",
                "OperationStatus_Ready",
                "OperationStatus_Finish"
            ]
        },
        "constvar.ReservationMethod": {
@@ -989,153 +947,6 @@
                }
            }
        },
        "models.Product": {
            "type": "object",
            "properties": {
                "HSCode": {
                    "type": "string"
                },
                "barcode": {
                    "description": "条码",
                    "type": "string"
                },
                "buyExplain": {
                    "type": "string"
                },
                "canBePurchased": {
                    "description": "是否可采购",
                    "type": "boolean"
                },
                "canBeSell": {
                    "description": "是否销售",
                    "type": "boolean"
                },
                "categoryId": {
                    "description": "产品分类id",
                    "type": "integer"
                },
                "companyId": {
                    "type": "integer"
                },
                "companyName": {
                    "type": "string"
                },
                "controlStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "cost": {
                    "description": "成本",
                    "type": "number"
                },
                "createTime": {
                    "type": "string"
                },
                "currencyId": {
                    "type": "integer"
                },
                "currencyName": {
                    "type": "string"
                },
                "customerAdvanceTime": {
                    "type": "number"
                },
                "customerTaxes": {
                    "description": "客户税百分比",
                    "type": "number"
                },
                "deliveryAdvanceTime": {
                    "type": "number"
                },
                "id": {
                    "type": "integer"
                },
                "inStorageExplain": {
                    "type": "string"
                },
                "internalNotes": {
                    "description": "内部说明",
                    "type": "string"
                },
                "internalReference": {
                    "description": "内部参考",
                    "type": "string"
                },
                "internalTransferExplain": {
                    "type": "string"
                },
                "invoicingStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "name": {
                    "description": "产品名称",
                    "type": "string"
                },
                "objectTemplateId": {
                    "type": "string"
                },
                "orderCreation": {
                    "$ref": "#/definitions/constvar.OrderCreation"
                },
                "originCountryId": {
                    "type": "integer"
                },
                "originCountryName": {
                    "type": "string"
                },
                "outStorageExplain": {
                    "type": "string"
                },
                "price": {
                    "type": "number"
                },
                "principal": {
                    "description": "负责人",
                    "type": "string"
                },
                "productTagId": {
                    "description": "产品标签",
                    "type": "integer"
                },
                "productTagName": {
                    "type": "string"
                },
                "salePrice": {
                    "description": "销售价格",
                    "type": "number"
                },
                "selectProduct": {
                    "type": "integer"
                },
                "sellExplain": {
                    "type": "string"
                },
                "supplierId": {
                    "type": "integer"
                },
                "supplierName": {
                    "type": "string"
                },
                "type": {
                    "description": "产品类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.ProductType"
                        }
                    ]
                },
                "updateTime": {
                    "type": "string"
                },
                "volume": {
                    "description": "体积",
                    "type": "number"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
        "models.Warehouse": {
            "type": "object",
            "required": [
@@ -1222,6 +1033,51 @@
                "remark": {
                    "description": "备注",
                    "type": "string"
                }
            }
        },
        "request.AddOperation": {
            "type": "object",
            "properties": {
                "details": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.OperationDetails"
                    }
                },
                "fromLocationId": {
                    "description": "源位置id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "operationDate": {
                    "$ref": "#/definitions/util.JSONTime"
                },
                "operationTypeId": {
                    "description": "作业类型id",
                    "type": "integer"
                },
                "sourceNumber": {
                    "description": "源单号",
                    "type": "string"
                },
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.OperationStatus"
                        }
                    ]
                },
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                }
            }
        },
@@ -1331,6 +1187,27 @@
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "request.OperationDetails": {
            "type": "object",
            "properties": {
                "finishQuantity": {
                    "description": "完成数量",
                    "type": "number"
                },
                "productId": {
                    "description": "产品id",
                    "type": "integer"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "quantity": {
                    "description": "数量",
                    "type": "number"
                }
            }
        },
@@ -1482,6 +1359,14 @@
                }
            }
        },
        "util.JSONTime": {
            "type": "object",
            "properties": {
                "time.Time": {
                    "type": "string"
                }
            }
        },
        "util.Response": {
            "type": "object",
            "properties": {
@@ -1528,8 +1413,6 @@
    Description:      "",
    InfoInstanceName: "swagger",
    SwaggerTemplate:  docTemplate,
    LeftDelim:        "{{",
    RightDelim:       "}}",
}
func init() {
docs/swagger.json
@@ -282,23 +282,23 @@
                }
            }
        },
        "/api-wms/v1/product/addProduct": {
        "/api-wms/v1/operation/operation": {
            "post": {
                "produces": [
                    "application/json"
                ],
                "tags": [
                    "产品"
                    "入库/出库"
                ],
                "summary": "添加产品",
                "summary": "添加入库/出库",
                "parameters": [
                    {
                        "description": "产品信息",
                        "description": "入库/出库信息",
                        "name": "object",
                        "in": "body",
                        "required": true,
                        "schema": {
                            "$ref": "#/definitions/models.Product"
                            "$ref": "#/definitions/request.AddOperation"
                        }
                    }
                ],
@@ -620,30 +620,6 @@
                "BaseOperationTypeInternal"
            ]
        },
        "constvar.InvoicingStrategy": {
            "type": "integer",
            "enum": [
                1,
                2,
                3,
                4,
                5
            ],
            "x-enum-comments": {
                "BasedDeliverNumber": "基于交付数量",
                "DeliverNumber": "交付数量",
                "IndentNumber": "订购数量",
                "Milestones": "基于里程碑",
                "PrepaidPrice": "预付\\固定价格"
            },
            "x-enum-varnames": [
                "IndentNumber",
                "DeliverNumber",
                "PrepaidPrice",
                "Milestones",
                "BasedDeliverNumber"
            ]
        },
        "constvar.LocationType": {
            "type": "integer",
            "enum": [
@@ -674,7 +650,7 @@
                "LocationTypeTransit"
            ]
        },
        "constvar.OrderCreation": {
        "constvar.OperationStatus": {
            "type": "integer",
            "enum": [
                1,
@@ -683,34 +659,16 @@
                4
            ],
            "x-enum-comments": {
                "Nothing": "不操作",
                "Object": "项目",
                "Task": "任务",
                "TaskAndObject": "任务和项目"
                "OperationStatus_Draft": "草稿",
                "OperationStatus_Finish": "完成",
                "OperationStatus_Ready": "就绪",
                "OperationStatus_Waiting": "正在等待"
            },
            "x-enum-varnames": [
                "Nothing",
                "Task",
                "Object",
                "TaskAndObject"
            ]
        },
        "constvar.ProductType": {
            "type": "integer",
            "enum": [
                1,
                2,
                3
            ],
            "x-enum-comments": {
                "Consumables": "消耗品",
                "Server": "服务",
                "StoredProduct": "可储存的产品"
            },
            "x-enum-varnames": [
                "Consumables",
                "Server",
                "StoredProduct"
                "OperationStatus_Draft",
                "OperationStatus_Waiting",
                "OperationStatus_Ready",
                "OperationStatus_Finish"
            ]
        },
        "constvar.ReservationMethod": {
@@ -977,153 +935,6 @@
                }
            }
        },
        "models.Product": {
            "type": "object",
            "properties": {
                "HSCode": {
                    "type": "string"
                },
                "barcode": {
                    "description": "条码",
                    "type": "string"
                },
                "buyExplain": {
                    "type": "string"
                },
                "canBePurchased": {
                    "description": "是否可采购",
                    "type": "boolean"
                },
                "canBeSell": {
                    "description": "是否销售",
                    "type": "boolean"
                },
                "categoryId": {
                    "description": "产品分类id",
                    "type": "integer"
                },
                "companyId": {
                    "type": "integer"
                },
                "companyName": {
                    "type": "string"
                },
                "controlStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "cost": {
                    "description": "成本",
                    "type": "number"
                },
                "createTime": {
                    "type": "string"
                },
                "currencyId": {
                    "type": "integer"
                },
                "currencyName": {
                    "type": "string"
                },
                "customerAdvanceTime": {
                    "type": "number"
                },
                "customerTaxes": {
                    "description": "客户税百分比",
                    "type": "number"
                },
                "deliveryAdvanceTime": {
                    "type": "number"
                },
                "id": {
                    "type": "integer"
                },
                "inStorageExplain": {
                    "type": "string"
                },
                "internalNotes": {
                    "description": "内部说明",
                    "type": "string"
                },
                "internalReference": {
                    "description": "内部参考",
                    "type": "string"
                },
                "internalTransferExplain": {
                    "type": "string"
                },
                "invoicingStrategy": {
                    "$ref": "#/definitions/constvar.InvoicingStrategy"
                },
                "name": {
                    "description": "产品名称",
                    "type": "string"
                },
                "objectTemplateId": {
                    "type": "string"
                },
                "orderCreation": {
                    "$ref": "#/definitions/constvar.OrderCreation"
                },
                "originCountryId": {
                    "type": "integer"
                },
                "originCountryName": {
                    "type": "string"
                },
                "outStorageExplain": {
                    "type": "string"
                },
                "price": {
                    "type": "number"
                },
                "principal": {
                    "description": "负责人",
                    "type": "string"
                },
                "productTagId": {
                    "description": "产品标签",
                    "type": "integer"
                },
                "productTagName": {
                    "type": "string"
                },
                "salePrice": {
                    "description": "销售价格",
                    "type": "number"
                },
                "selectProduct": {
                    "type": "integer"
                },
                "sellExplain": {
                    "type": "string"
                },
                "supplierId": {
                    "type": "integer"
                },
                "supplierName": {
                    "type": "string"
                },
                "type": {
                    "description": "产品类型",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.ProductType"
                        }
                    ]
                },
                "updateTime": {
                    "type": "string"
                },
                "volume": {
                    "description": "体积",
                    "type": "number"
                },
                "weight": {
                    "description": "重量",
                    "type": "number"
                }
            }
        },
        "models.Warehouse": {
            "type": "object",
            "required": [
@@ -1210,6 +1021,51 @@
                "remark": {
                    "description": "备注",
                    "type": "string"
                }
            }
        },
        "request.AddOperation": {
            "type": "object",
            "properties": {
                "details": {
                    "type": "array",
                    "items": {
                        "$ref": "#/definitions/request.OperationDetails"
                    }
                },
                "fromLocationId": {
                    "description": "源位置id",
                    "type": "integer"
                },
                "id": {
                    "type": "integer"
                },
                "number": {
                    "description": "单号",
                    "type": "string"
                },
                "operationDate": {
                    "$ref": "#/definitions/util.JSONTime"
                },
                "operationTypeId": {
                    "description": "作业类型id",
                    "type": "integer"
                },
                "sourceNumber": {
                    "description": "源单号",
                    "type": "string"
                },
                "status": {
                    "description": "状态",
                    "allOf": [
                        {
                            "$ref": "#/definitions/constvar.OperationStatus"
                        }
                    ]
                },
                "toLocationId": {
                    "description": "目标位置id",
                    "type": "integer"
                }
            }
        },
@@ -1319,6 +1175,27 @@
                    "items": {
                        "type": "string"
                    }
                }
            }
        },
        "request.OperationDetails": {
            "type": "object",
            "properties": {
                "finishQuantity": {
                    "description": "完成数量",
                    "type": "number"
                },
                "productId": {
                    "description": "产品id",
                    "type": "integer"
                },
                "productName": {
                    "description": "产品名称",
                    "type": "string"
                },
                "quantity": {
                    "description": "数量",
                    "type": "number"
                }
            }
        },
@@ -1470,6 +1347,14 @@
                }
            }
        },
        "util.JSONTime": {
            "type": "object",
            "properties": {
                "time.Time": {
                    "type": "string"
                }
            }
        },
        "util.Response": {
            "type": "object",
            "properties": {
docs/swagger.yaml
@@ -13,26 +13,6 @@
    - BaseOperationTypeIncoming
    - BaseOperationTypeOutgoing
    - BaseOperationTypeInternal
  constvar.InvoicingStrategy:
    enum:
    - 1
    - 2
    - 3
    - 4
    - 5
    type: integer
    x-enum-comments:
      BasedDeliverNumber: 基于交付数量
      DeliverNumber: 交付数量
      IndentNumber: 订购数量
      Milestones: 基于里程碑
      PrepaidPrice: 预付\固定价格
    x-enum-varnames:
    - IndentNumber
    - DeliverNumber
    - PrepaidPrice
    - Milestones
    - BasedDeliverNumber
  constvar.LocationType:
    enum:
    - 1
@@ -59,7 +39,7 @@
    - LocationTypeInventoryLoss
    - LocationTypeProduction
    - LocationTypeTransit
  constvar.OrderCreation:
  constvar.OperationStatus:
    enum:
    - 1
    - 2
@@ -67,29 +47,15 @@
    - 4
    type: integer
    x-enum-comments:
      Nothing: 不操作
      Object: 项目
      Task: 任务
      TaskAndObject: 任务和项目
      OperationStatus_Draft: 草稿
      OperationStatus_Finish: 完成
      OperationStatus_Ready: 就绪
      OperationStatus_Waiting: 正在等待
    x-enum-varnames:
    - Nothing
    - Task
    - Object
    - TaskAndObject
  constvar.ProductType:
    enum:
    - 1
    - 2
    - 3
    type: integer
    x-enum-comments:
      Consumables: 消耗品
      Server: 服务
      StoredProduct: 可储存的产品
    x-enum-varnames:
    - Consumables
    - Server
    - StoredProduct
    - OperationStatus_Draft
    - OperationStatus_Waiting
    - OperationStatus_Ready
    - OperationStatus_Finish
  constvar.ReservationMethod:
    enum:
    - 1
@@ -265,107 +231,6 @@
        description: 仓库id
        type: integer
    type: object
  models.Product:
    properties:
      HSCode:
        type: string
      barcode:
        description: 条码
        type: string
      buyExplain:
        type: string
      canBePurchased:
        description: 是否可采购
        type: boolean
      canBeSell:
        description: 是否销售
        type: boolean
      categoryId:
        description: 产品分类id
        type: integer
      companyId:
        type: integer
      companyName:
        type: string
      controlStrategy:
        $ref: '#/definitions/constvar.InvoicingStrategy'
      cost:
        description: 成本
        type: number
      createTime:
        type: string
      currencyId:
        type: integer
      currencyName:
        type: string
      customerAdvanceTime:
        type: number
      customerTaxes:
        description: 客户税百分比
        type: number
      deliveryAdvanceTime:
        type: number
      id:
        type: integer
      inStorageExplain:
        type: string
      internalNotes:
        description: 内部说明
        type: string
      internalReference:
        description: 内部参考
        type: string
      internalTransferExplain:
        type: string
      invoicingStrategy:
        $ref: '#/definitions/constvar.InvoicingStrategy'
      name:
        description: 产品名称
        type: string
      objectTemplateId:
        type: string
      orderCreation:
        $ref: '#/definitions/constvar.OrderCreation'
      originCountryId:
        type: integer
      originCountryName:
        type: string
      outStorageExplain:
        type: string
      price:
        type: number
      principal:
        description: 负责人
        type: string
      productTagId:
        description: 产品标签
        type: integer
      productTagName:
        type: string
      salePrice:
        description: 销售价格
        type: number
      selectProduct:
        type: integer
      sellExplain:
        type: string
      supplierId:
        type: integer
      supplierName:
        type: string
      type:
        allOf:
        - $ref: '#/definitions/constvar.ProductType'
        description: 产品类型
      updateTime:
        type: string
      volume:
        description: 体积
        type: number
      weight:
        description: 重量
        type: number
    type: object
  models.Warehouse:
    properties:
      active:
@@ -428,6 +293,36 @@
      remark:
        description: 备注
        type: string
    type: object
  request.AddOperation:
    properties:
      details:
        items:
          $ref: '#/definitions/request.OperationDetails'
        type: array
      fromLocationId:
        description: 源位置id
        type: integer
      id:
        type: integer
      number:
        description: 单号
        type: string
      operationDate:
        $ref: '#/definitions/util.JSONTime'
      operationTypeId:
        description: 作业类型id
        type: integer
      sourceNumber:
        description: 源单号
        type: string
      status:
        allOf:
        - $ref: '#/definitions/constvar.OperationStatus'
        description: 状态
      toLocationId:
        description: 目标位置id
        type: integer
    type: object
  request.AddOperationType:
    properties:
@@ -502,6 +397,21 @@
        type: array
    required:
    - code
    type: object
  request.OperationDetails:
    properties:
      finishQuantity:
        description: 完成数量
        type: number
      productId:
        description: 产品id
        type: integer
      productName:
        description: 产品名称
        type: string
      quantity:
        description: 数量
        type: number
    type: object
  request.UpdateCompany:
    properties:
@@ -603,6 +513,11 @@
        type: array
    required:
    - code
    type: object
  util.JSONTime:
    properties:
      time.Time:
        type: string
    type: object
  util.Response:
    properties:
@@ -802,15 +717,15 @@
      summary: 编辑公司
      tags:
      - 公司
  /api-wms/v1/product/addProduct:
  /api-wms/v1/operation/operation:
    post:
      parameters:
      - description: 产品信息
      - description: 入库/出库信息
        in: body
        name: object
        required: true
        schema:
          $ref: '#/definitions/models.Product'
          $ref: '#/definitions/request.AddOperation'
      produces:
      - application/json
      responses:
@@ -818,9 +733,9 @@
          description: 成功
          schema:
            $ref: '#/definitions/util.Response'
      summary: 添加产品
      summary: 添加入库/出库
      tags:
      - 产品
      - 入库/出库
  /api-wms/v1/warehouse/operationType:
    get:
      parameters:
models/operation.go
@@ -4,6 +4,7 @@
    "fmt"
    "gorm.io/gorm"
    "wms/constvar"
    "wms/extend/util"
    "wms/pkg/mysqlx"
)
@@ -11,19 +12,26 @@
    // Operation 操作表
    Operation struct {
        WmsModel
        Id           int    `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Number       string `json:"number" gorm:"column:number;type:varchar(255)"` //单号
        SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"`         //源单号
        BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:基础作业类型"` //基础作业类型
        OperationTypeId   int                        `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"`       //作业类型id
        Status            int                        `json:"status" gorm:"type:tinyint;not null;comment:状态"`                //状态
        FromLocationId int      `json:"fromLocationId"   gorm:"type:int;not null;comment:源位置id"` //源位置id
        FromLocation   Location `json:"fromLocation"     gorm:"foreignKey:FromLocationId"`       //源位置
        ToLocationId   int      `json:"toLocationId"    gorm:"type:int;not null;comment:目标位置id"` //目标位置id
        ToLocation     Location `json:"toLocation"      gorm:"foreignKey:ToLocationId"`          //目标位置
        Id              int                      `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
        Number          string                   `json:"number" gorm:"column:number;type:varchar(255)"`           //单号
        SourceNumber    string                   `json:"sourceNumber" gorm:"type:varchar(255)"`                   //源单号
        OperationTypeId int                      `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"` //作业类型id
        Status          constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:状态"`          //状态
        FromLocationId  int                      `json:"fromLocationId"   gorm:"type:int;not null;comment:源位置id"` //源位置id
        FromLocation    Location                 `json:"fromLocation"     gorm:"foreignKey:FromLocationId"`       //源位置
        ToLocationId    int                      `json:"toLocationId"    gorm:"type:int;not null;comment:目标位置id"` //目标位置id
        ToLocation      Location                 `json:"toLocation"      gorm:"foreignKey:ToLocationId"`          //目标位置
        OperationDate   util.JSONTime            `json:"operationDate" gorm:"comment:安排日期"`
        CarrierID       int                      `json:"carrierID" gorm:"type:int;comment:承运商ID"`
        CarrierName     string                   `json:"carrierName" gorm:"type:varchar(63);comment:承运商名称"`
        Tracking        string                   `json:"tracking" gorm:"type:varchar(127);comment:追踪参考"`
        ContacterID     int                      `json:"contacterID" gorm:"type:int;comment:联系人ID"`
        ContacterName   string                   `json:"contacterName" gorm:"type:varchar(63);comment:联系人姓名"`
        Weight          float64                  `json:"weight" gorm:"type:decimal;comment:重量(kg)"`
        TransferWeight  float64                  `json:"transferWeight" gorm:"type:decimal;comment:物流重量(kg)"`
        CompanyID       int                      `json:"companyID" gorm:"type:int;comment:公司ID"`
        CompanyName     string                   `json:"companyName" gorm:"type:varchar(127);comment:公司名称(kg)"`
        Details         []*OperationDetails      `json:"details"`
    }
    OperationSearch struct {
models/operation_details.go
@@ -2,7 +2,7 @@
import (
    "fmt"
    "google.golang.org/genproto/googleapis/type/decimal"
    "github.com/shopspring/decimal"
    "gorm.io/gorm"
    "wms/pkg/mysqlx"
)
pkg/timex/timex.go
@@ -2,7 +2,6 @@
import (
    "time"
    "wms/constvar"
)
func StringToTime(timeStr string) (time.Time, error) {
@@ -56,31 +55,4 @@
func GetCurrentTime() string {
    return time.Now().Format(timeLayout)
}
func NextDateTimestamp(base time.Time, unit constvar.InspectCycleUnit, cycle int) time.Time {
    var t time.Time
    switch unit {
    case constvar.InspectCycleUnitWeek:
        t = base.AddDate(0, 0, cycle*7)
    case constvar.InspectCycleUnitMonth:
        t = base.AddDate(0, cycle, 0)
    case constvar.InspectCycleUnitDay:
        t = base.AddDate(0, 0, cycle)
    }
    return time.Date(t.Year(), t.Month(), t.Day(), 0, 0, 0, 0, t.Location())
}
// Cycle2Seconds 周期换算成秒数
func Cycle2Seconds(unit constvar.InspectCycleUnit, cycle int) int {
    var s int
    switch unit {
    case constvar.InspectCycleUnitWeek:
        s = cycle * 86400 * 7
    case constvar.InspectCycleUnitMonth:
        s = cycle * 86400 * 30
    case constvar.InspectCycleUnitDay:
        s = cycle * 86400
    }
    return s
}
request/operation.go
New file
@@ -0,0 +1,26 @@
package request
import (
    "google.golang.org/genproto/googleapis/type/decimal"
    "wms/constvar"
    "wms/extend/util"
)
type AddOperation struct {
    Id              int                      `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
    Number          string                   `json:"number" gorm:"column:number;type:varchar(255)"`           //单号
    SourceNumber    string                   `json:"sourceNumber" gorm:"type:varchar(255)"`                   //源单号
    OperationTypeId int                      `json:"operationTypeId" gorm:"type:int;not null;comment:作业类型id"` //作业类型id
    Status          constvar.OperationStatus `json:"status" gorm:"type:int(11);not null;comment:状态"`          //状态
    FromLocationId  int                      `json:"fromLocationId"   gorm:"type:int;not null;comment:源位置id"` //源位置id
    ToLocationId    int                      `json:"toLocationId"    gorm:"type:int;not null;comment:目标位置id"` //目标位置id
    OperationDate   util.JSONTime            `json:"operationDate" gorm:"comment:安排日期"`
    Details         []*OperationDetails      `json:"details"`
}
type OperationDetails struct {
    ProductId      int             `json:"productId" gorm:"type:int;not null;comment:产品id"`              //产品id
    ProductName    string          `json:"productName" gorm:"type:varchar(255);not null;comment:产品名称"`   //产品名称
    Quantity       decimal.Decimal `json:"quantity" gorm:"type:decimal(20,2);not null;comment:数量"`       //数量
    FinishQuantity decimal.Decimal `json:"finishQuantity" gorm:"type:decimal(20,2);not null;comment:数量"` //完成数量
}
router/router.go
@@ -53,7 +53,7 @@
    // 作业类型
    operationTypeController := new(controllers.OperationTypeController)
    operationTypeAPI := r.Group(urlPrefix + "/warehouse")
    operationTypeAPI := r.Group(urlPrefix + "/operationType")
    {
        operationTypeAPI.GET("operationType", operationTypeController.List)          // 获取作业类型列表
        operationTypeAPI.POST("operationType", operationTypeController.Add)          // 新增作业类型
@@ -61,6 +61,14 @@
        operationTypeAPI.DELETE("operationType/:id", operationTypeController.Delete) // 删除作业类型
    }
    // 入库/出库
    operationController := new(controllers.OperationController)
    operationAPI := r.Group(urlPrefix + "/operation")
    {
        //operationAPI.GET()
        operationAPI.POST("operation", operationController.Add)
    }
    //产品
    productController := new(controllers.ProductController)
    productAPI := r.Group(urlPrefix + "/product")