From 1770deb5829f745194508339a7924eefd4dbd627 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期一, 18 九月 2023 20:04:25 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS

---
 constvar/const.go           |    9 
 pkg/timex/timex.go          |   28 -
 controllers/operation.go    |   86 +++++
 models/operation.go         |   34 +
 docs/swagger.yaml           |  213 +++--------
 request/operation.go        |   26 +
 docs/docs.go                |  293 +++++------------
 models/operation_details.go |    2 
 docs/swagger.json           |  291 +++++-----------
 router/router.go            |   10 
 10 files changed, 392 insertions(+), 600 deletions(-)

diff --git a/constvar/const.go b/constvar/const.go
index 9a5246d..640baa6 100644
--- a/constvar/const.go
+++ b/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                            //姝e湪绛夊緟
+	OperationStatus_Ready                              //灏辩华
+	OperationStatus_Finish                             //瀹屾垚
+)
diff --git a/controllers/operation.go b/controllers/operation.go
new file mode 100644
index 0000000..18a26f7
--- /dev/null
+++ b/controllers/operation.go
@@ -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, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+	}
+	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
+}
diff --git a/docs/docs.go b/docs/docs.go
index 7a99fb9..0f27c63 100644
--- a/docs/docs.go
+++ b/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": "姝e湪绛夊緟"
             },
             "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": "婧愪綅缃甶d",
+                    "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() {
diff --git a/docs/swagger.json b/docs/swagger.json
index bfd55df..8d67b82 100644
--- a/docs/swagger.json
+++ b/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": "姝e湪绛夊緟"
             },
             "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": "婧愪綅缃甶d",
+                    "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": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 32ad891..7f4c9c9 100644
--- a/docs/swagger.yaml
+++ b/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: 姝e湪绛夊緟
     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: 婧愪綅缃甶d
+        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:
diff --git a/models/operation.go b/models/operation.go
index b1b3355..450bd27 100644
--- a/models/operation.go
+++ b/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:婧愪綅缃甶d"` //婧愪綅缃甶d
-		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:婧愪綅缃甶d"` //婧愪綅缃甶d
+		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:鎵胯繍鍟咺D"`
+		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:鑱旂郴浜篒D"`
+		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 {
diff --git a/models/operation_details.go b/models/operation_details.go
index 742d651..8595052 100644
--- a/models/operation_details.go
+++ b/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"
 )
diff --git a/pkg/timex/timex.go b/pkg/timex/timex.go
index c443050..68f63c9 100644
--- a/pkg/timex/timex.go
+++ b/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
 }
diff --git a/request/operation.go b/request/operation.go
new file mode 100644
index 0000000..63639fc
--- /dev/null
+++ b/request/operation.go
@@ -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:婧愪綅缃甶d"` //婧愪綅缃甶d
+	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:鏁伴噺"` //瀹屾垚鏁伴噺
+}
diff --git a/router/router.go b/router/router.go
index 05a0153..0df3ac9 100644
--- a/router/router.go
+++ b/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")

--
Gitblit v1.8.0