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
| | |
| | | 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 //完成 |
| | | ) |
New file |
| | |
| | | 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(¶ms); 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 |
| | | } |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "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": [ |
| | |
| | | "LocationTypeTransit" |
| | | ] |
| | | }, |
| | | "constvar.OrderCreation": { |
| | | "constvar.OperationStatus": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | |
| | | 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": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": [ |
| | |
| | | "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" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "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" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "util.JSONTime": { |
| | | "type": "object", |
| | | "properties": { |
| | | "time.Time": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "util.Response": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | Description: "", |
| | | InfoInstanceName: "swagger", |
| | | SwaggerTemplate: docTemplate, |
| | | LeftDelim: "{{", |
| | | RightDelim: "}}", |
| | | } |
| | | |
| | | func init() { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "/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" |
| | | } |
| | | } |
| | | ], |
| | |
| | | "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": [ |
| | |
| | | "LocationTypeTransit" |
| | | ] |
| | | }, |
| | | "constvar.OrderCreation": { |
| | | "constvar.OperationStatus": { |
| | | "type": "integer", |
| | | "enum": [ |
| | | 1, |
| | |
| | | 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": { |
| | |
| | | } |
| | | } |
| | | }, |
| | | "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": [ |
| | |
| | | "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" |
| | | } |
| | | } |
| | | }, |
| | |
| | | "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" |
| | | } |
| | | } |
| | | }, |
| | |
| | | } |
| | | } |
| | | }, |
| | | "util.JSONTime": { |
| | | "type": "object", |
| | | "properties": { |
| | | "time.Time": { |
| | | "type": "string" |
| | | } |
| | | } |
| | | }, |
| | | "util.Response": { |
| | | "type": "object", |
| | | "properties": { |
| | |
| | | - 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 |
| | |
| | | - LocationTypeInventoryLoss |
| | | - LocationTypeProduction |
| | | - LocationTypeTransit |
| | | constvar.OrderCreation: |
| | | constvar.OperationStatus: |
| | | enum: |
| | | - 1 |
| | | - 2 |
| | |
| | | - 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 |
| | |
| | | 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: |
| | |
| | | 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: |
| | |
| | | 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: |
| | |
| | | type: array |
| | | required: |
| | | - code |
| | | type: object |
| | | util.JSONTime: |
| | | properties: |
| | | time.Time: |
| | | type: string |
| | | type: object |
| | | util.Response: |
| | | properties: |
| | |
| | | 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: |
| | |
| | | description: 成功 |
| | | schema: |
| | | $ref: '#/definitions/util.Response' |
| | | summary: 添加产品 |
| | | summary: 添加入库/出库 |
| | | tags: |
| | | - 产品 |
| | | - 入库/出库 |
| | | /api-wms/v1/warehouse/operationType: |
| | | get: |
| | | parameters: |
| | |
| | | "fmt" |
| | | "gorm.io/gorm" |
| | | "wms/constvar" |
| | | "wms/extend/util" |
| | | "wms/pkg/mysqlx" |
| | | ) |
| | | |
| | |
| | | // 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 { |
| | |
| | | |
| | | import ( |
| | | "fmt" |
| | | "google.golang.org/genproto/googleapis/type/decimal" |
| | | "github.com/shopspring/decimal" |
| | | "gorm.io/gorm" |
| | | "wms/pkg/mysqlx" |
| | | ) |
| | |
| | | |
| | | import ( |
| | | "time" |
| | | "wms/constvar" |
| | | ) |
| | | |
| | | func StringToTime(timeStr string) (time.Time, error) { |
| | |
| | | |
| | | 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 |
| | | } |
New file |
| | |
| | | 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:数量"` //完成数量 |
| | | } |
| | |
| | | |
| | | // 作业类型 |
| | | operationTypeController := new(controllers.OperationTypeController) |
| | | operationTypeAPI := r.Group(urlPrefix + "/warehouse") |
| | | operationTypeAPI := r.Group(urlPrefix + "/operationType") |
| | | { |
| | | operationTypeAPI.GET("operationType", operationTypeController.List) // 获取作业类型列表 |
| | | operationTypeAPI.POST("operationType", operationTypeController.Add) // 新增作业类型 |
| | |
| | | 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") |