From a8914a16b23e93f6bfd12bcfd5cbe8b24cf7eb84 Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期日, 07 四月 2024 21:49:01 +0800 Subject: [PATCH] 发货支持仓库传参 --- models/operation.go | 83 ++++++++++++++++++++++++++++++----------- 1 files changed, 61 insertions(+), 22 deletions(-) diff --git a/models/operation.go b/models/operation.go index c16e13a..bd56ea2 100644 --- a/models/operation.go +++ b/models/operation.go @@ -14,7 +14,7 @@ WmsModel Id int `json:"id" gorm:"column:id;primary_key;AUTO_INCREMENT"` Number string `json:"number" gorm:"type:varchar(255)"` //鍗曞彿 - SourceNumber string `json:"sourceNumber" gorm:"type:varchar(255)"` //婧愬崟鍙� + SourceNumber string `json:"sourceNumber" gorm:"index;type:varchar(255)"` //婧愬崟鍙� 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:鐘舵��"` //鐘舵�� @@ -22,18 +22,19 @@ //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:鑱旂郴浜哄鍚�"` - CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃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"` - LogisticCompany LogisticCompany `json:"logisticCompany" gorm:"foreignKey:LogisticCompanyId"` - 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"` //鐗╂祦閲嶉噺 - Source string `json:"source" gorm:"type:varchar(255);comment:鏉ユ簮绯荤粺,鐢ㄤ簬杩斿洖淇敼鐘舵��"` + 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:鑱旂郴浜哄鍚�"` + CompanyID int `json:"companyID" gorm:"type:int;comment:鍏徃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"` + LogisticCompany LogisticCompany `json:"logisticCompany" gorm:"foreignKey:LogisticCompanyId"` + 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"` //鐗╂祦閲嶉噺 + Source string `json:"source" gorm:"type:varchar(255);comment:鏉ユ簮绯荤粺,鐢ㄤ簬杩斿洖淇敼鐘舵��"` + OperationSource constvar.OperationSource `json:"operationSource" gorm:"type:tinyint(3);not null;default:0;comment:鎿嶄綔鏉ユ簮"` //鎿嶄綔鏉ユ簮 Details []*OperationDetails `json:"details" gorm:"foreignKey:OperationID;references:Id"` BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷 @@ -52,15 +53,16 @@ OperationSearch struct { Operation - Order string - PageNum int - PageSize int - Keyword string - Orm *gorm.DB - Preload bool - Disuse bool - Ids []int - Numbers []string + Order string + PageNum int + PageSize int + Keyword string + Orm *gorm.DB + Preload bool + Disuse bool + Ids []int + SourceNumbers []string + SalesDetailsNumbers []string } ) @@ -117,6 +119,11 @@ return slf } +func (slf *OperationSearch) SetSourceNumbers(numbers []string) *OperationSearch { + slf.SourceNumbers = numbers + return slf +} + func (slf *OperationSearch) SetDisuse(disuse bool) *OperationSearch { slf.Disuse = disuse return slf @@ -142,6 +149,16 @@ return slf } +func (slf *OperationSearch) SetSalesDetailsNumbers(salesDetailsNumbers []string) *OperationSearch { + slf.SalesDetailsNumbers = salesDetailsNumbers + return slf +} + +func (slf *OperationSearch) SetOperationSource(operationSource constvar.OperationSource) *OperationSearch { + slf.OperationSource = operationSource + return slf +} + func (slf *OperationSearch) build() *gorm.DB { var db = slf.Orm.Model(&Operation{}) @@ -158,6 +175,10 @@ if slf.SourceNumber != "" { db = db.Where("source_number = ?", slf.SourceNumber) + } + + if len(slf.SourceNumbers) > 0 { + db = db.Where("source_number in (?)", slf.SourceNumbers) } if slf.Number != "" { @@ -190,6 +211,14 @@ if slf.SalesDetailsNumber != "" { db = db.Where("sales_details_number = ?", slf.SalesDetailsNumber) + } + + if len(slf.SalesDetailsNumbers) > 0 { + db = db.Where("sales_details_number in (?)", slf.SalesDetailsNumbers) + } + + if slf.OperationSource != 0 { + db = db.Where("operation_source = ?", slf.OperationSource) } return db @@ -364,3 +393,13 @@ } return int(total), nil } + +func (slf *OperationSearch) Count() (int64, error) { + var ( + total int64 + db = slf.build() + ) + + err := db.Count(&total).Error + return total, err +} -- Gitblit v1.8.0