From 318c49da20ec30c4f85ef35e479499e82a841b25 Mon Sep 17 00:00:00 2001
From: liujiandao <274878379@qq.com>
Date: 星期一, 11 三月 2024 14:18:13 +0800
Subject: [PATCH] swag提交

---
 models/operation.go |   73 ++++++++++++++++++++++++------------
 1 files changed, 48 insertions(+), 25 deletions(-)

diff --git a/models/operation.go b/models/operation.go
index a06bdda..9d34771 100644
--- a/models/operation.go
+++ b/models/operation.go
@@ -13,29 +13,40 @@
 	Operation struct {
 		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)"`                           //婧愬崟鍙�
-		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:鑱旂郴浜哄鍚�"`
-		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"` //鐗╂祦閲嶉噺
+		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
+		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:鑱旂郴浜哄鍚�"`
+		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:鏉ユ簮绯荤粺,鐢ㄤ簬杩斿洖淇敼鐘舵��"`
 
 		Details           []*OperationDetails        `json:"details" gorm:"foreignKey:OperationID;references:Id"`
 		BaseOperationType constvar.BaseOperationType `json:"baseOperationType" gorm:"type:tinyint;not null;comment:鍩虹浣滀笟绫诲瀷"` //鍩虹浣滀笟绫诲瀷
+
+		AuditDate     string `json:"auditDate" gorm:"type:varchar(31);comment:瀹℃壒鏃堕棿"`
+		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
+		Location     Location `json:"location" gorm:"foreignkey:LocationID;references:Id"`          //婧愪綅缃�
+		ToLocationID int      `json:"toLocationId"    gorm:"type:int;not null;comment:浠撳簱浣嶇疆id"`      //鐩爣浣嶇疆id
+		ToLocation   Location `json:"toLocation"      gorm:"foreignKey:ToLocationID;references:Id"` //鐩爣浣嶇疆
 	}
 
 	OperationSearch struct {
@@ -48,6 +59,7 @@
 		Preload  bool
 		Disuse   bool
 		Ids      []int
+		Numbers  []string
 	}
 )
 
@@ -139,7 +151,7 @@
 	}
 
 	if slf.SourceNumber != "" {
-		db = db.Where("source_number like ?", fmt.Sprintf("%%%v%%", slf.SourceNumber))
+		db = db.Where("source_number = ?", slf.SourceNumber)
 	}
 
 	if slf.Number != "" {
@@ -151,8 +163,7 @@
 	}
 
 	if slf.Preload {
-		db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("FromLocation").
-			Preload("ToLocation").Preload("LogisticCompany")
+		db = db.Model(&Operation{}).Preload("Details").Preload("Details.Product").Preload("LogisticCompany").Preload("Location").Preload("ToLocation").Preload("Details.FromLocation").Preload("Details.ToLocation")
 	}
 
 	if slf.Disuse {
@@ -271,7 +282,7 @@
 	if slf.PageNum*slf.PageSize > 0 {
 		db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
 	}
-	if err := db.Preload("FromLocation").Preload("ToLocation").Order("created_at desc").Find(&records).Error; err != nil {
+	if err := db.Order("created_at desc").Find(&records).Error; err != nil {
 		return records, total, fmt.Errorf("find records err: %v", err)
 	}
 
@@ -287,7 +298,7 @@
 	if slf.PageNum*slf.PageSize > 0 {
 		db = db.Offset((slf.PageNum - 1) * slf.PageSize).Limit(slf.PageSize)
 	}
-	if err := db.Preload("FromLocation").Preload("ToLocation").Find(&records).Error; err != nil {
+	if err := db.Find(&records).Error; err != nil {
 		return records, fmt.Errorf("find records err: %v", err)
 	}
 
@@ -331,3 +342,15 @@
 
 	return records, nil
 }
+
+func (slf *OperationSearch) MaxAutoIncr() (int, error) {
+	var (
+		db    = slf.build()
+		total int64
+	)
+
+	if err := db.Count(&total).Error; err != nil {
+		return int(total), fmt.Errorf("max err: %v", err)
+	}
+	return int(total), nil
+}

--
Gitblit v1.8.0