From 2baa7bad0482613829e217997c44a51d8ec0ec66 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期三, 20 九月 2023 09:51:58 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.5.5:10010/r/aps/WMS
---
extend/code/code.go | 1
controllers/operation.go | 128 ++++++++
models/location.go | 39 ++
models/operation.go | 47 ++
docs/swagger.yaml | 132 ++++++++
request/operation.go | 37 ++
controllers/location.go | 53 +++
docs/docs.go | 201 +++++++++++++
models/operation_details.go | 14
docs/swagger.json | 201 +++++++++++++
request/location.go | 8
router/router.go | 10
12 files changed, 848 insertions(+), 23 deletions(-)
diff --git a/controllers/location.go b/controllers/location.go
new file mode 100644
index 0000000..128eb14
--- /dev/null
+++ b/controllers/location.go
@@ -0,0 +1,53 @@
+package controllers
+
+import (
+ "errors"
+ "github.com/gin-gonic/gin"
+ "wms/extend/code"
+ "wms/extend/util"
+ "wms/models"
+ "wms/request"
+)
+
+type LocationController struct {
+}
+
+func (slf LocationController) ListLocationByType(c *gin.Context) {
+ var params request.LocationByType
+ if err := c.BindJSON(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟缁戝畾澶辫触")
+ return
+ }
+ if err := slf.CheckLocationByTypeParams(params); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ }
+ search := models.NewLocationSearch()
+ search.SetType(params.Type)
+ if params.Keyword != "" {
+ search.SetKeyword(params.Keyword)
+ }
+ if params.ParentId != 0 {
+ search.SetParentId(params.ParentId)
+ }
+ if params.CompanyId != 0 {
+ search.SetCompanyId(params.CompanyId)
+ }
+ res, err := search.SetOrder("created_at desc").FindAll()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestError, err.Error())
+ }
+ util.ResponseFormat(c, code.Success, res)
+}
+
+func (slf LocationController) CheckLocationByTypeParams(params request.LocationByType) error {
+ if params.Type == 0 {
+ return errors.New("璇烽�夋嫨姝g‘鐨勪綅缃被鍨�")
+ }
+ if params.ParentId < 0 {
+ return errors.New("閿欒鍙傛暟ParentId")
+ }
+ if params.CompanyId < 0 {
+ return errors.New("閿欒鍙傛暟CompanyId")
+ }
+ return nil
+}
diff --git a/controllers/operation.go b/controllers/operation.go
index bbe2288..581f085 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -2,8 +2,10 @@
import (
"errors"
- "fmt"
"github.com/gin-gonic/gin"
+ "github.com/spf13/cast"
+ "gorm.io/gorm"
+ "strconv"
"wms/extend/code"
"wms/extend/util"
"wms/models"
@@ -26,11 +28,11 @@
var reqParams request.AddOperation
var params models.Operation
if err := c.BindJSON(&reqParams); err != nil {
- util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�"+err.Error())
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
return
}
- if err := structx.AssignTo(reqParams, params); err != nil {
- util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒")
+ if err := structx.AssignTo(reqParams, ¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒"+err.Error())
return
}
if err := slf.CheckParams(params); err != nil {
@@ -85,7 +87,123 @@
return errors.New("浜у搧鏁伴噺鍑洪敊")
}
}
- fmt.Println(111111)
return nil
}
+
+// List
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 鍏ュ簱/鍑哄簱鍒楄〃
+// @Produce application/json
+// @Accept json
+// @Param object query request.OperationList true "鍙傛暟"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/operation/operation [get]
+func (slf OperationController) List(c *gin.Context) {
+ var params request.OperationList
+ if err := c.ShouldBindQuery(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�:"+err.Error())
+ return
+ }
+ if err := slf.CheckListParams(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
+ search := models.NewOperationSearch()
+ search.SetPage(params.Page, params.PageSize)
+ list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
+ return
+ }
+
+ util.ResponseFormatList(c, code.Success, list, int(total))
+
+}
+
+func (slf OperationController) CheckListParams(params *request.OperationList) error {
+ if !params.PageInfo.Check() {
+ return errors.New("鏁版嵁鍒嗛〉淇℃伅閿欒")
+ }
+ if params.OperationTypeId == 0 {
+ return errors.New("operationTypeId涓�0")
+ }
+ return nil
+}
+
+// Update
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 淇敼鍏ュ簱/鍑哄簱淇℃伅
+// @Produce application/json
+// @Param object body request.UpdateOperation true "鍏ュ簱淇℃伅"
+// @Param id path int true "鍏ュ簱淇℃伅id"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/operation/operation/{id} [put]
+func (slf OperationController) Update(c *gin.Context) {
+ id := cast.ToUint(c.Param("id"))
+ if id == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id")
+ return
+ }
+ var reqParams request.UpdateOperation
+ var params models.Operation
+ if err := c.BindJSON(&reqParams); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇細"+err.Error())
+ return
+ }
+ if err := structx.AssignTo(reqParams, ¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鏁版嵁杞崲閿欒"+err.Error())
+ return
+ }
+ if err := slf.CheckParams(params); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
+ if err := models.WithTransaction(func(tx *gorm.DB) error {
+ if err := models.NewOperationDetailsSearch().SetOrm(tx).SetOperationId(params.Id).Delete(); err != nil {
+ return err
+ }
+ if err := models.NewOperationSearch().SetOrm(tx).SetID(params.Id).Save(¶ms); err != nil {
+ return err
+ }
+ return nil
+ }); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触锛�"+err.Error())
+ return
+ }
+
+ util.ResponseFormat(c, code.Success, "淇敼鎴愬姛")
+}
+
+// DeleteDevice
+//
+// @Tags 鍏ュ簱/鍑哄簱
+// @Summary 鍒犻櫎鍏ュ簱/鍑哄簱淇℃伅
+// @Produce application/json
+// @Param id path int true "id"
+// @Success 200 {object} util.Response "鎴愬姛"
+// @Router /api-wms/v1/operation/operation/{id} [delete]
+func (slf OperationController) Delete(c *gin.Context) {
+ id, err := strconv.Atoi(c.Param("id"))
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "閿欒鐨刬d鍊�")
+ return
+ }
+ if id == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "绌虹殑璁板綍id")
+ return
+ }
+ if err := models.WithTransaction(func(tx *gorm.DB) error {
+ if err := models.NewOperationDetailsSearch().SetOrm(tx).SetOperationId(id).Delete(); err != nil {
+ return err
+ }
+ if err := models.NewOperationSearch().SetOrm(tx).SetID(id).Delete(); err != nil {
+ return err
+ }
+ return nil
+ }); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "淇敼澶辫触锛�"+err.Error())
+ return
+ }
+ util.ResponseFormat(c, code.Success, "鍒犻櫎鎴愬姛")
+}
diff --git a/docs/docs.go b/docs/docs.go
index dd6d9d1..c19f52e 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -295,6 +295,45 @@
}
},
"/api-wms/v1/operation/operation": {
+ "get": {
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "鍏ュ簱/鍑哄簱鍒楄〃",
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "operationTypeId",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ },
"post": {
"produces": [
"application/json"
@@ -312,6 +351,69 @@
"schema": {
"$ref": "#/definitions/request.AddOperation"
}
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/operation/operation/{id}": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "淇敼鍏ュ簱/鍑哄簱淇℃伅",
+ "parameters": [
+ {
+ "description": "鍏ュ簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateOperation"
+ }
+ },
+ {
+ "type": "integer",
+ "description": "鍏ュ簱淇℃伅id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ },
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "鍒犻櫎鍏ュ簱/鍑哄簱淇℃伅",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
}
],
"responses": {
@@ -1687,6 +1789,24 @@
"request.AddOperation": {
"type": "object",
"properties": {
+ "carrierID": {
+ "type": "integer"
+ },
+ "carrierName": {
+ "type": "string"
+ },
+ "companyID": {
+ "type": "integer"
+ },
+ "companyName": {
+ "type": "string"
+ },
+ "contacterID": {
+ "type": "integer"
+ },
+ "contacterName": {
+ "type": "string"
+ },
"details": {
"type": "array",
"items": {
@@ -1726,6 +1846,15 @@
"toLocationId": {
"description": "鐩爣浣嶇疆id",
"type": "integer"
+ },
+ "tracking": {
+ "type": "string"
+ },
+ "transferWeight": {
+ "type": "number"
+ },
+ "weight": {
+ "type": "number"
}
}
},
@@ -1911,6 +2040,78 @@
}
}
},
+ "request.UpdateOperation": {
+ "type": "object",
+ "properties": {
+ "carrierID": {
+ "type": "integer"
+ },
+ "carrierName": {
+ "type": "string"
+ },
+ "companyID": {
+ "type": "integer"
+ },
+ "companyName": {
+ "type": "string"
+ },
+ "contacterID": {
+ "type": "integer"
+ },
+ "contacterName": {
+ "type": "string"
+ },
+ "details": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/request.OperationDetails"
+ }
+ },
+ "fromLocationId": {
+ "description": "婧愪綅缃甶d",
+ "type": "integer"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "number": {
+ "description": "鍗曞彿",
+ "type": "string"
+ },
+ "operationDate": {
+ "type": "string"
+ },
+ "operationTypeId": {
+ "description": "浣滀笟绫诲瀷id",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "description": "婧愬崟鍙�",
+ "type": "string"
+ },
+ "status": {
+ "description": "鐘舵��",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.OperationStatus"
+ }
+ ]
+ },
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
+ "tracking": {
+ "type": "string"
+ },
+ "transferWeight": {
+ "type": "number"
+ },
+ "weight": {
+ "type": "number"
+ }
+ }
+ },
"request.UpdateOperationType": {
"type": "object",
"properties": {
diff --git a/docs/swagger.json b/docs/swagger.json
index 1435b82..a6aa289 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -283,6 +283,45 @@
}
},
"/api-wms/v1/operation/operation": {
+ "get": {
+ "consumes": [
+ "application/json"
+ ],
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "鍏ュ簱/鍑哄簱鍒楄〃",
+ "parameters": [
+ {
+ "type": "integer",
+ "name": "operationTypeId",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "椤电爜",
+ "name": "page",
+ "in": "query"
+ },
+ {
+ "type": "integer",
+ "description": "姣忛〉澶у皬",
+ "name": "pageSize",
+ "in": "query"
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ },
"post": {
"produces": [
"application/json"
@@ -300,6 +339,69 @@
"schema": {
"$ref": "#/definitions/request.AddOperation"
}
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ }
+ },
+ "/api-wms/v1/operation/operation/{id}": {
+ "put": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "淇敼鍏ュ簱/鍑哄簱淇℃伅",
+ "parameters": [
+ {
+ "description": "鍏ュ簱淇℃伅",
+ "name": "object",
+ "in": "body",
+ "required": true,
+ "schema": {
+ "$ref": "#/definitions/request.UpdateOperation"
+ }
+ },
+ {
+ "type": "integer",
+ "description": "鍏ュ簱淇℃伅id",
+ "name": "id",
+ "in": "path",
+ "required": true
+ }
+ ],
+ "responses": {
+ "200": {
+ "description": "鎴愬姛",
+ "schema": {
+ "$ref": "#/definitions/util.Response"
+ }
+ }
+ }
+ },
+ "delete": {
+ "produces": [
+ "application/json"
+ ],
+ "tags": [
+ "鍏ュ簱/鍑哄簱"
+ ],
+ "summary": "鍒犻櫎鍏ュ簱/鍑哄簱淇℃伅",
+ "parameters": [
+ {
+ "type": "integer",
+ "description": "id",
+ "name": "id",
+ "in": "path",
+ "required": true
}
],
"responses": {
@@ -1675,6 +1777,24 @@
"request.AddOperation": {
"type": "object",
"properties": {
+ "carrierID": {
+ "type": "integer"
+ },
+ "carrierName": {
+ "type": "string"
+ },
+ "companyID": {
+ "type": "integer"
+ },
+ "companyName": {
+ "type": "string"
+ },
+ "contacterID": {
+ "type": "integer"
+ },
+ "contacterName": {
+ "type": "string"
+ },
"details": {
"type": "array",
"items": {
@@ -1714,6 +1834,15 @@
"toLocationId": {
"description": "鐩爣浣嶇疆id",
"type": "integer"
+ },
+ "tracking": {
+ "type": "string"
+ },
+ "transferWeight": {
+ "type": "number"
+ },
+ "weight": {
+ "type": "number"
}
}
},
@@ -1899,6 +2028,78 @@
}
}
},
+ "request.UpdateOperation": {
+ "type": "object",
+ "properties": {
+ "carrierID": {
+ "type": "integer"
+ },
+ "carrierName": {
+ "type": "string"
+ },
+ "companyID": {
+ "type": "integer"
+ },
+ "companyName": {
+ "type": "string"
+ },
+ "contacterID": {
+ "type": "integer"
+ },
+ "contacterName": {
+ "type": "string"
+ },
+ "details": {
+ "type": "array",
+ "items": {
+ "$ref": "#/definitions/request.OperationDetails"
+ }
+ },
+ "fromLocationId": {
+ "description": "婧愪綅缃甶d",
+ "type": "integer"
+ },
+ "id": {
+ "type": "integer"
+ },
+ "number": {
+ "description": "鍗曞彿",
+ "type": "string"
+ },
+ "operationDate": {
+ "type": "string"
+ },
+ "operationTypeId": {
+ "description": "浣滀笟绫诲瀷id",
+ "type": "integer"
+ },
+ "sourceNumber": {
+ "description": "婧愬崟鍙�",
+ "type": "string"
+ },
+ "status": {
+ "description": "鐘舵��",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.OperationStatus"
+ }
+ ]
+ },
+ "toLocationId": {
+ "description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
+ "tracking": {
+ "type": "string"
+ },
+ "transferWeight": {
+ "type": "number"
+ },
+ "weight": {
+ "type": "number"
+ }
+ }
+ },
"request.UpdateOperationType": {
"type": "object",
"properties": {
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 2d89dc0..2dc5f06 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -520,6 +520,18 @@
type: object
request.AddOperation:
properties:
+ carrierID:
+ type: integer
+ carrierName:
+ type: string
+ companyID:
+ type: integer
+ companyName:
+ type: string
+ contacterID:
+ type: integer
+ contacterName:
+ type: string
details:
items:
$ref: '#/definitions/request.OperationDetails'
@@ -547,6 +559,12 @@
toLocationId:
description: 鐩爣浣嶇疆id
type: integer
+ tracking:
+ type: string
+ transferWeight:
+ type: number
+ weight:
+ type: number
type: object
request.AddOperationType:
properties:
@@ -672,6 +690,54 @@
remark:
description: 澶囨敞
type: string
+ type: object
+ request.UpdateOperation:
+ properties:
+ carrierID:
+ type: integer
+ carrierName:
+ type: string
+ companyID:
+ type: integer
+ companyName:
+ type: string
+ contacterID:
+ type: integer
+ contacterName:
+ type: string
+ details:
+ items:
+ $ref: '#/definitions/request.OperationDetails'
+ type: array
+ fromLocationId:
+ description: 婧愪綅缃甶d
+ type: integer
+ id:
+ type: integer
+ number:
+ description: 鍗曞彿
+ type: string
+ operationDate:
+ type: string
+ operationTypeId:
+ description: 浣滀笟绫诲瀷id
+ type: integer
+ sourceNumber:
+ description: 婧愬崟鍙�
+ type: string
+ status:
+ allOf:
+ - $ref: '#/definitions/constvar.OperationStatus'
+ description: 鐘舵��
+ toLocationId:
+ description: 鐩爣浣嶇疆id
+ type: integer
+ tracking:
+ type: string
+ transferWeight:
+ type: number
+ weight:
+ type: number
type: object
request.UpdateOperationType:
properties:
@@ -948,6 +1014,31 @@
tags:
- 鍏徃
/api-wms/v1/operation/operation:
+ get:
+ consumes:
+ - application/json
+ parameters:
+ - in: query
+ name: operationTypeId
+ type: integer
+ - description: 椤电爜
+ in: query
+ name: page
+ type: integer
+ - description: 姣忛〉澶у皬
+ in: query
+ name: pageSize
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 鍏ュ簱/鍑哄簱鍒楄〃
+ tags:
+ - 鍏ュ簱/鍑哄簱
post:
parameters:
- description: 鍏ュ簱/鍑哄簱淇℃伅
@@ -966,6 +1057,47 @@
summary: 娣诲姞鍏ュ簱/鍑哄簱
tags:
- 鍏ュ簱/鍑哄簱
+ /api-wms/v1/operation/operation/{id}:
+ delete:
+ parameters:
+ - description: id
+ in: path
+ name: id
+ required: true
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 鍒犻櫎鍏ュ簱/鍑哄簱淇℃伅
+ tags:
+ - 鍏ュ簱/鍑哄簱
+ put:
+ parameters:
+ - description: 鍏ュ簱淇℃伅
+ in: body
+ name: object
+ required: true
+ schema:
+ $ref: '#/definitions/request.UpdateOperation'
+ - description: 鍏ュ簱淇℃伅id
+ in: path
+ name: id
+ required: true
+ type: integer
+ produces:
+ - application/json
+ responses:
+ "200":
+ description: 鎴愬姛
+ schema:
+ $ref: '#/definitions/util.Response'
+ summary: 淇敼鍏ュ簱/鍑哄簱淇℃伅
+ tags:
+ - 鍏ュ簱/鍑哄簱
/api-wms/v1/product/addProduct:
post:
parameters:
diff --git a/extend/code/code.go b/extend/code/code.go
index a7c4970..402da3c 100644
--- a/extend/code/code.go
+++ b/extend/code/code.go
@@ -25,4 +25,5 @@
NoTemplateError = &Code{3010, "鏈厤缃鍗曟ā鏉�"}
InternalError = &Code{3011, "鍐呴儴閿欒"}
NoProductionRequiredError = &Code{3012, "褰撳墠搴撳瓨婊¤冻姣涢渶姹傞噺锛屾殏鏃舵棤闇�杩涜鐢熶骇"}
+ RequestError = &Code{3013, "璇锋眰澶辫触"}
)
diff --git a/models/location.go b/models/location.go
index 41e6992..5bcffe7 100644
--- a/models/location.go
+++ b/models/location.go
@@ -16,7 +16,7 @@
ParentId int `json:"parentId" gorm:"type:int;not null"` //涓婄骇id
CompanyId int `json:"companyId" gorm:"type:int;not null"` //鍏徃id
Company Company `json:"company" gorm:"foreignKey:CompanyId"` //鍏徃
- Type constvar.LocationType `json:"type" gorm:"type:tinyint;not null;comment:浣嶇疆绫诲瀷"` //浣嶇疆绫诲瀷
+ Type constvar.LocationType `json:"type" gorm:"type:int(11);not null;comment:浣嶇疆绫诲瀷"` //浣嶇疆绫诲瀷
CountFrequency int `json:"countFrequency" gorm:"type:tinyint;not null;comment:鐩樼偣棰戠巼锛堝ぉ锛�"` //鐩樼偣棰戠巼锛堝ぉ锛�
IsScrapLocation bool `json:"isScrapLocation" gorm:"type:tinyint;not null;comment:鏄惁鎶ュ簾浣嶇疆"` //鏄惁鎶ュ簾浣嶇疆
IsReturnLocation bool `json:"isReturnLocation" gorm:"type:tinyint;not null;comment:鏄惁閫�璐т綅缃�"` //鏄惁閫�璐т綅缃�
@@ -77,6 +77,21 @@
return slf
}
+func (slf *LocationSearch) SetType(_type int) *LocationSearch {
+ slf.Type = constvar.LocationType(_type)
+ return slf
+}
+
+func (slf *LocationSearch) SetParentId(parentId int) *LocationSearch {
+ slf.ParentId = parentId
+ return slf
+}
+
+func (slf *LocationSearch) SetCompanyId(companyId int) *LocationSearch {
+ slf.CompanyId = companyId
+ return slf
+}
+
func (slf *LocationSearch) build() *gorm.DB {
var db = slf.Orm.Model(&Location{})
@@ -94,6 +109,17 @@
if slf.Name != "" {
db = db.Where("name = ?", slf.Name)
+ }
+
+ if slf.Type != 0 {
+ db = db.Where("type=?", slf.Type)
+ }
+
+ if slf.ParentId != 0 {
+ db = db.Where("parent_id=?", slf.ParentId)
+ }
+ if slf.CompanyId != 0 {
+ db = db.Where("company_id=?", slf.CompanyId)
}
return db
@@ -246,3 +272,14 @@
return records, nil
}
+
+func (slf *LocationSearch) FindAll() ([]*Location, error) {
+ var (
+ records = make([]*Location, 0)
+ db = slf.build()
+ )
+ if err := db.Find(&records); err != nil {
+ return records, fmt.Errorf("func FindAll err: %v", err)
+ }
+ return records, nil
+}
diff --git a/models/operation.go b/models/operation.go
index 5fa92ad..76b7797 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -2,6 +2,7 @@
import (
"fmt"
+ "github.com/shopspring/decimal"
"gorm.io/gorm"
"wms/constvar"
"wms/pkg/mysqlx"
@@ -12,7 +13,7 @@
Operation struct {
WmsModel
Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
- Number string `json:"number" gorm:"column:number;type:varchar(255)"` //鍗曞彿
+ Number string `json:"number" gorm:"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:鐘舵��"` //鐘舵��
@@ -26,8 +27,8 @@
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)"`
+ Weight decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);comment:閲嶉噺(kg)"`
+ TransferWeight decimal.Decimal `json:"transferWeight" gorm:"type:decimal(20,2);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"`
@@ -67,13 +68,18 @@
return slf
}
-func (slf *OperationSearch) SetID(id uint) *OperationSearch {
- slf.ID = id
+func (slf *OperationSearch) SetID(id int) *OperationSearch {
+ slf.Id = id
return slf
}
-func (slf *OperationSearch) SetKeyword(keyword string) *OperationSearch {
- slf.Keyword = keyword
+//func (slf *OperationSearch) SetKeyword(keyword string) *OperationSearch {
+// slf.Keyword = keyword
+// return slf
+//}
+
+func (slf *OperationSearch) SetOperationTypeId(operationTypeId int) *OperationSearch {
+ slf.OperationTypeId = operationTypeId
return slf
}
@@ -85,16 +91,23 @@
func (slf *OperationSearch) build() *gorm.DB {
var db = slf.Orm.Model(&Operation{})
- if slf.ID != 0 {
- db = db.Where("id = ?", slf.ID)
+ if slf.Id != 0 {
+ db = db.Where("id = ?", slf.Id)
}
-
if slf.Order != "" {
db = db.Order(slf.Order)
}
- if slf.Keyword != "" {
- db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
+ //if slf.Keyword != "" {
+ // db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
+ //}
+
+ if slf.OperationTypeId != 0 {
+ db.Where("operation_type_id = ?", slf.OperationTypeId)
+ }
+
+ if slf.Preload {
+ db = db.Model(&Operation{}).Preload("Details")
}
return db
@@ -122,6 +135,16 @@
return nil
}
+func (slf *OperationSearch) Save(record *Operation) error {
+ var db = slf.build()
+
+ if err := db.Omit("CreatedAt").Save(record).Error; err != nil {
+ return fmt.Errorf("save err: %v, record: %+v", err, record)
+ }
+
+ return nil
+}
+
func (slf *OperationSearch) Update(record *Operation) error {
var db = slf.build()
diff --git a/models/operation_details.go b/models/operation_details.go
index f7b5479..6792f45 100644
--- a/models/operation_details.go
+++ b/models/operation_details.go
@@ -12,9 +12,8 @@
OperationDetails struct {
WmsModel
- Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
- OperationId int `json:"OperationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id
-
+ Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"`
+ OperationId int `json:"OperationId" gorm:"type:int;not null;comment:鎿嶄綔璁板綍id"` //鎿嶄綔id
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:鏁伴噺"` //鏁伴噺
@@ -70,6 +69,11 @@
return slf
}
+func (slf *OperationDetailsSearch) SetOperationId(operationId int) *OperationDetailsSearch {
+ slf.OperationId = operationId
+ return slf
+}
+
func (slf *OperationDetailsSearch) build() *gorm.DB {
var db = slf.Orm.Model(&OperationDetails{})
@@ -85,6 +89,10 @@
db = db.Where("product_name like ?", fmt.Sprintf("%%%v%%", slf.Keyword))
}
+ if slf.OperationId != 0 {
+ db = db.Where("operation_id = ?", slf.OperationId)
+ }
+
return db
}
diff --git a/request/location.go b/request/location.go
new file mode 100644
index 0000000..18a6c36
--- /dev/null
+++ b/request/location.go
@@ -0,0 +1,8 @@
+package request
+
+type LocationByType struct {
+ Type int `json:"type" form:"type"`
+ Keyword string `json:"keyword" form:"keyword"`
+ ParentId int `json:"parentId" form:"parentId"`
+ CompanyId int `json:"companyId" form:"companyId"`
+}
diff --git a/request/operation.go b/request/operation.go
index d62a74f..3df3d69 100644
--- a/request/operation.go
+++ b/request/operation.go
@@ -1,7 +1,7 @@
package request
import (
- "google.golang.org/genproto/googleapis/type/decimal"
+ "github.com/shopspring/decimal"
"wms/constvar"
)
@@ -15,6 +15,15 @@
ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id
OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"`
Details []*OperationDetails `json:"details"`
+ 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 decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);comment:閲嶉噺(kg)"`
+ TransferWeight decimal.Decimal `json:"transferWeight" gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺(kg)"`
+ CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID"`
+ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О(kg)"`
}
type OperationDetails struct {
@@ -23,3 +32,29 @@
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:鏁伴噺"` //瀹屾垚鏁伴噺
}
+
+type OperationList struct {
+ PageInfo
+ OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
+}
+
+type UpdateOperation 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 string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"`
+ Details []*OperationDetails `json:"details"`
+ 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 decimal.Decimal `json:"weight" gorm:"type:decimal(20,2);comment:閲嶉噺(kg)"`
+ TransferWeight decimal.Decimal `json:"transferWeight" gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺(kg)"`
+ CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃ID"`
+ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О(kg)"`
+}
diff --git a/router/router.go b/router/router.go
index 926c4af..d0a5e50 100644
--- a/router/router.go
+++ b/router/router.go
@@ -65,8 +65,10 @@
operationController := new(controllers.OperationController)
operationAPI := r.Group(urlPrefix + "/operation")
{
- //operationAPI.GET()
+ operationAPI.GET("operation", operationController.List)
operationAPI.POST("operation", operationController.Add)
+ operationAPI.PUT("operation/:id", operationController.Update)
+ operationAPI.DELETE("operation/:id", operationController.Delete)
}
//浜у搧
@@ -86,5 +88,11 @@
productAPI.DELETE("deleteProductCategory/:id", productController.DeleteProductCategory) //鍒犻櫎浜у搧绫诲瀷
}
+ locationController := new(controllers.LocationController)
+ locationAPI := r.Group(urlPrefix + "/location")
+ {
+ locationAPI.POST("listByType", locationController.ListLocationByType)
+ }
+
return r
}
--
Gitblit v1.8.0