From 1691d8ee8fe10799d98b296625fd30183407ef25 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期五, 28 六月 2024 12:17:22 +0800
Subject: [PATCH] 新增操作类型增加基础操作类型和仓库id来支持库存盘点
---
controllers/operation.go | 37 +++++++++---
models/operation.go | 1
docs/swagger.yaml | 13 ++++
request/operation.go | 53 +++++++++--------
docs/docs.go | 23 +++++++
docs/swagger.json | 23 +++++++
6 files changed, 116 insertions(+), 34 deletions(-)
diff --git a/controllers/operation.go b/controllers/operation.go
index af310c4..e174c67 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -72,17 +72,28 @@
util.ResponseFormat(c, code.RequestParamError, "鏄庣粏涓笉鑳藉瓨鍦ㄩ噸澶嶇殑浜у搧")
return
}
-
- operationType, err := models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
- if err != nil {
- util.ResponseFormat(c, code.RequestParamError, err.Error())
- return
+ var operationType *models.OperationType
+ var err error
+ if params.OperationTypeId == 0 {
+ operationType, err = models.NewOperationTypeSearch().SetWarehouseId(params.WarehouseId).SetBaseOperationType(params.BaseOperationType).First()
+ if err != nil || params.WarehouseId != operationType.WarehouseId {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟缂哄け")
+ return
+ }
+ } else {
+ operationType, err = models.NewOperationTypeSearch().SetID(uint(params.OperationTypeId)).First()
+ if err != nil {
+ util.ResponseFormat(c, code.RequestParamError, err.Error())
+ return
+ }
}
+
userInfo := middleware.GetUserInfo(c)
params.CreatedBy = userInfo.Username
params.Status = constvar.OperationStatus_Ready
//params.Number = strconv.FormatInt(time.Now().Unix(), 10)
params.BaseOperationType = operationType.BaseOperationType
+ params.WarehouseId = operationType.WarehouseId
var numberNum int64
if err := mysqlx.GetDB().Model(&models.Operation{}).Where("number=?", params.Number).Count(&numberNum).Error; err != nil {
@@ -191,7 +202,13 @@
}
if params.OperationTypeId == 0 && int(params.BaseOperationType) == 0 {
- return errors.New("鏈瘑鍒璁板綍绫诲瀷")
+ return errors.New("鏈瘑鍒璁板綍绫诲瀷1")
+ }
+
+ if params.BaseOperationType != 0 {
+ if params.WarehouseId == 0 {
+ return errors.New("鏈瘑鍒璁板綍绫诲瀷2")
+ }
}
if params.OperationDate == "" {
@@ -282,7 +299,9 @@
costMap[material.ID] = material.Cost
salePriceMap[material.ID] = material.SalePrice
}
- list, total, err := search.SetOperationTypeId(params.OperationTypeId).SetPreload(true).SetOrder("created_at desc").Find()
+ list, total, err := search.SetOperationTypeId(params.OperationTypeId).
+ SetBaseOperationType(params.BaseOperationType).
+ SetPreload(true).SetOrder("created_at desc").Find()
if err != nil {
util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触:"+err.Error())
return
@@ -303,8 +322,8 @@
if !params.PageInfo.Check() {
return errors.New("鏁版嵁鍒嗛〉淇℃伅閿欒")
}
- if params.OperationTypeId == 0 {
- return errors.New("operationTypeId涓�0")
+ if params.OperationTypeId == 0 && params.BaseOperationType == 0 {
+ return errors.New("operationTypeId鍜宐aseOperationType涓嶈兘鍚屾椂涓�0")
}
return nil
}
diff --git a/docs/docs.go b/docs/docs.go
index 3297b01..6bec29b 100644
--- a/docs/docs.go
+++ b/docs/docs.go
@@ -4878,6 +4878,9 @@
"updateTime": {
"type": "string"
},
+ "warehouseId": {
+ "type": "integer"
+ },
"waybillNumber": {
"description": "杩愬崟鍙�",
"type": "string"
@@ -5360,6 +5363,14 @@
"accountantId": {
"type": "string"
},
+ "baseOperationType": {
+ "description": "鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"comment": {
"description": "澶囨敞",
"type": "string"
@@ -5451,6 +5462,10 @@
},
"toLocationId": {
"description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
+ "warehouseId": {
+ "description": "浠撳簱id",
"type": "integer"
},
"waybillNumber": {
@@ -5963,6 +5978,14 @@
"request.OperationList": {
"type": "object",
"properties": {
+ "baseOperationType": {
+ "description": "1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"number": {
"type": "string"
},
diff --git a/docs/swagger.json b/docs/swagger.json
index 7bd351e..93d6dd4 100644
--- a/docs/swagger.json
+++ b/docs/swagger.json
@@ -4867,6 +4867,9 @@
"updateTime": {
"type": "string"
},
+ "warehouseId": {
+ "type": "integer"
+ },
"waybillNumber": {
"description": "杩愬崟鍙�",
"type": "string"
@@ -5349,6 +5352,14 @@
"accountantId": {
"type": "string"
},
+ "baseOperationType": {
+ "description": "鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"comment": {
"description": "澶囨敞",
"type": "string"
@@ -5440,6 +5451,10 @@
},
"toLocationId": {
"description": "鐩爣浣嶇疆id",
+ "type": "integer"
+ },
+ "warehouseId": {
+ "description": "浠撳簱id",
"type": "integer"
},
"waybillNumber": {
@@ -5952,6 +5967,14 @@
"request.OperationList": {
"type": "object",
"properties": {
+ "baseOperationType": {
+ "description": "1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣",
+ "allOf": [
+ {
+ "$ref": "#/definitions/constvar.BaseOperationType"
+ }
+ ]
+ },
"number": {
"type": "string"
},
diff --git a/docs/swagger.yaml b/docs/swagger.yaml
index 3262537..83f23c2 100644
--- a/docs/swagger.yaml
+++ b/docs/swagger.yaml
@@ -967,6 +967,8 @@
type: integer
updateTime:
type: string
+ warehouseId:
+ type: integer
waybillNumber:
description: 杩愬崟鍙�
type: string
@@ -1292,6 +1294,10 @@
type: string
accountantId:
type: string
+ baseOperationType:
+ allOf:
+ - $ref: '#/definitions/constvar.BaseOperationType'
+ description: 鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣
comment:
description: 澶囨敞
type: string
@@ -1358,6 +1364,9 @@
description: 鐘舵��
toLocationId:
description: 鐩爣浣嶇疆id
+ type: integer
+ warehouseId:
+ description: 浠撳簱id
type: integer
waybillNumber:
description: 杩愬崟鍙�
@@ -1716,6 +1725,10 @@
type: object
request.OperationList:
properties:
+ baseOperationType:
+ allOf:
+ - $ref: '#/definitions/constvar.BaseOperationType'
+ description: 1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣
number:
type: string
operationTypeId:
diff --git a/models/operation.go b/models/operation.go
index 8eb2fb8..fb9a0c7 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -61,6 +61,7 @@
CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:楠岃瘉鑰匲serId"`
Remark string `json:"remark"`
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"`
IsInternalOutput bool `json:"isInternalOutput"` //鏄惁璋冩嫧浜х敓鐨勫嚭搴�
}
diff --git a/request/operation.go b/request/operation.go
index bc4942e..a68aa72 100644
--- a/request/operation.go
+++ b/request/operation.go
@@ -14,28 +14,30 @@
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"`
- ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"` //鑱旂郴浜篒D-闈炲繀濉�
- ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"` //鑱旂郴浜哄鍚�-闈炲繀濉�
- CompanyID string `json:"companyID"` //鍏徃ID-瀹㈡埛
- CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О-瀹㈡埛鍚嶇О
- Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` //澶囨敞
- LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"`
- WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙�
- Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺
- LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺
- ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:鏀惰揣浜哄鍚�"`
- ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:鑱旂郴鐢佃瘽"`
- ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:鏀惰揣鍦板潃"`
- LocationId int `json:"locationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
- ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:浠撳簱浣嶇疆id"` //鐩爣浣嶇疆id
- ManagerId string `json:"managerId" gorm:"type:varchar(255);comment:涓荤id"`
- Manager string `json:"manager" gorm:"type:varchar(255);comment:涓荤鍚嶇О"`
- AccountantId string `json:"accountantId" gorm:"type:varchar(255);comment:浼氳id"`
- Accountant string `json:"accountant" gorm:"type:varchar(255);comment:浼氳鍚嶇О"`
- CustodianId string `json:"custodianId" gorm:"type:varchar(255);comment:淇濈鍛榠d"`
- Custodian string `json:"custodian" gorm:"type:varchar(255);comment:淇濈鍛樺悕绉�"`
+ OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"` //瀹夋帓鏃ユ湡
+ Details []*OperationDetails `json:"details"`
+ ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"` //鑱旂郴浜篒D-闈炲繀濉�
+ ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"` //鑱旂郴浜哄鍚�-闈炲繀濉�
+ CompanyID string `json:"companyID"` //鍏徃ID-瀹㈡埛
+ CompanyName string `json:"companyName" gorm:"type:varchar(127);comment:鍏徃鍚嶇О"` //鍏徃鍚嶇О-瀹㈡埛鍚嶇О
+ Comment string `json:"comment" gorm:"type:text;comment:澶囨敞"` //澶囨敞
+ LogisticCompanyId string `json:"logisticCompanyId" gorm:"type:varchar(191);comment:鐗╂祦鍏徃id"`
+ WaybillNumber string `json:"waybillNumber" gorm:"type:varchar(255);comment:杩愬崟鍙�"` //杩愬崟鍙�
+ Weight decimal.Decimal `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"` //閲嶉噺
+ LogisticWeight decimal.Decimal `gorm:"type:decimal(20,2);comment:鐗╂祦閲嶉噺" json:"logisticWeight"` //鐗╂祦閲嶉噺
+ ReceiverName string `json:"receiverName" gorm:"type:varchar(31);comment:鏀惰揣浜哄鍚�"`
+ ReceiverPhone string `json:"receiverPhone" gorm:"type:varchar(31);comment:鑱旂郴鐢佃瘽"`
+ ReceiverAddr string `json:"receiverAddr" gorm:"type:varchar(255);comment:鏀惰揣鍦板潃"`
+ LocationId int `json:"locationId" gorm:"type:int;not null;comment:婧愪綅缃甶d"` //婧愪綅缃甶d
+ ToLocationId int `json:"toLocationId" gorm:"type:int;not null;comment:浠撳簱浣嶇疆id"` //鐩爣浣嶇疆id
+ ManagerId string `json:"managerId" gorm:"type:varchar(255);comment:涓荤id"`
+ Manager string `json:"manager" gorm:"type:varchar(255);comment:涓荤鍚嶇О"`
+ AccountantId string `json:"accountantId" gorm:"type:varchar(255);comment:浼氳id"`
+ Accountant string `json:"accountant" gorm:"type:varchar(255);comment:浼氳鍚嶇О"`
+ CustodianId string `json:"custodianId" gorm:"type:varchar(255);comment:淇濈鍛榠d"`
+ Custodian string `json:"custodian" gorm:"type:varchar(255);comment:淇濈鍛樺悕绉�"`
+ BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"` //浠撳簱id
}
type OperationDetails struct {
@@ -59,9 +61,10 @@
type OperationList struct {
PageInfo
- OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
- Number string `json:"number"`
- Status constvar.OperationStatus `json:"status"`
+ OperationTypeId int `json:"operationTypeId" form:"operationTypeId"`
+ BaseOperationType constvar.BaseOperationType `json:"baseOperationType"` // 1 鍏ュ簱 2 鍑哄簱 3 鍐呴儴璋冩嫧 4 鎶ュ簾 5 搴撳瓨鐩樼偣
+ Number string `json:"number"`
+ Status constvar.OperationStatus `json:"status"`
}
type UpdateOperation struct {
--
Gitblit v1.8.0