From 286adacbe154f984b500cd7df16e332e255f2010 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期四, 04 七月 2024 22:40:07 +0800
Subject: [PATCH] fix
---
controllers/operation.go | 18 +++------
models/operation.go | 17 +++-----
request/operation.go | 50 ++++++++++++------------
3 files changed, 37 insertions(+), 48 deletions(-)
diff --git a/controllers/operation.go b/controllers/operation.go
index 51c3f77..f0afda4 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -94,7 +94,7 @@
params.WarehouseId = operationType.WarehouseId
}
- if params.InventoryDealerType == 0 {
+ if params.DealerType == "" {
CheckInventoryDealerType(¶ms)
}
@@ -169,21 +169,15 @@
default:
return
}
- miniDict, _ := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First()
- if miniDict != nil {
- params.InventoryDealerType = int(miniDict.ID)
- } else {
- dict := &models.MiniDict{
+ miniDict, err := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First()
+ if err == gorm.ErrRecordNotFound {
+ miniDict = &models.MiniDict{
Type: dictType,
Name: dictName,
}
- models.NewMiniDictSearch().Create(dict)
- miniDict, err := models.NewMiniDictSearch().SetType(dictType).SetName(dictName).First()
- if err != nil {
- return
- }
- params.InventoryDealerType = int(miniDict.ID)
+ models.NewMiniDictSearch().Create(miniDict)
}
+ params.DealerType = miniDict.Name
}
func CheckDetailsRepeat(details []*models.OperationDetails) bool {
diff --git a/models/operation.go b/models/operation.go
index 12ea942..8fdf2a2 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -19,10 +19,6 @@
OperationTypeId int `json:"operationTypeId" gorm:"type:int;not null;comment:浣滀笟绫诲瀷id"` //浣滀笟绫诲瀷id
OperationTypeName string `json:"operationTypeName" gorm:"type:varchar(127);comment:浣滀笟绫诲瀷鍚嶇О"` //浣滀笟绫诲瀷鍚嶇О
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;references:Id"` //婧愪綅缃�
- //ToLocationID int `json:"toLocationId" gorm:"type:int;not null;comment:鐩爣浣嶇疆id"` //鐩爣浣嶇疆id
- //ToLocation Location `json:"toLocation" gorm:"foreignKey:ToLocationID;references:Id"` //鐩爣浣嶇疆
OperationDate string `json:"operationDate" gorm:"type:varchar(31);comment:瀹夋帓鏃ユ湡"`
ContacterID int `json:"contacterID" gorm:"type:int;comment:鑱旂郴浜篒D"`
ContacterName string `json:"contacterName" gorm:"type:varchar(63);comment:鑱旂郴浜哄鍚�"`
@@ -61,11 +57,10 @@
CheckedBy string `json:"checkedBy" gorm:"type:varchar(255);comment:楠岃瘉鑰匲serId"`
Remark string `json:"remark"`
- WarehouseId int `json:"warehouseId" gorm:"type:int;not null;default:0;comment:浠撳簱id"`
- Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"`
- IsInternalOutput bool `json:"isInternalOutput"` //鏄惁璋冩嫧浜х敓鐨勫嚭搴�
- InventoryDealerType int `json:"inventoryDealerType" gorm:"type:varchar(255);comment:璋冩嫧鍑哄叆搴撳垎绫�(瀵瑰簲dict瀛楀吀琛ㄧ殑ID)"`
- InventoryDealer MiniDict `json:"inventoryDealer" gorm:"foreignKey:InventoryDealerType;"`
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;default:0;comment:浠撳簱id"`
+ Warehouse Warehouse `json:"warehouse" gorm:"foreignKey:WarehouseId"`
+ IsInternalOutput bool `json:"isInternalOutput"` //鏄惁璋冩嫧浜х敓鐨勫嚭搴�
+ DealerType string `json:"dealerType" gorm:"type:varchar(255);comment:璋冩嫧鍑哄叆搴撶被鍨�"`
}
OperationSearch struct {
@@ -98,6 +93,7 @@
func (slf *OperationSearch) BeforeCreate(tx *gorm.DB) {
for k := range slf.Details {
slf.Details[k].BaseOperationType = slf.BaseOperationType
+ slf.Details[k].DealerType = slf.DealerType
}
}
@@ -244,8 +240,7 @@
Preload("Location").
Preload("ToLocation").
Preload("Details.FromLocation").
- Preload("Details.ToLocation").
- Preload("InventoryDealer").Preload("Warehouse")
+ Preload("Details.ToLocation").Preload("Warehouse")
}
if slf.Disuse {
diff --git a/request/operation.go b/request/operation.go
index 56de42d..f73dd24 100644
--- a/request/operation.go
+++ b/request/operation.go
@@ -14,31 +14,31 @@
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:淇濈鍛樺悕绉�"`
- BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣
- WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"` //浠撳簱id
- InventoryDealerType int `json:"inventoryDealerType" gorm:"type:varchar(255);comment:璋冩嫧鍑哄叆搴撳垎绫�(瀵瑰簲dict瀛楀吀琛ㄧ殑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:淇濈鍛樺悕绉�"`
+ BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 5搴撳瓨鐩樼偣
+ WarehouseId int `json:"warehouseId" gorm:"type:int;not null;comment:浠撳簱id"` //浠撳簱id
+ DealerType string `json:"dealerType" gorm:"type:varchar(255);comment:璋冩嫧鍑哄叆搴撶被鍨�"`
}
type OperationDetails struct {
--
Gitblit v1.8.0