From 96844c22ef3fba86a55e0af1b51bc1009d6fa950 Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期五, 20 十月 2023 11:57:48 +0800
Subject: [PATCH] 1.库存盘点bug修改

---
 models/material.go |  123 ++++++++++++++++++++++++++++------------
 1 files changed, 86 insertions(+), 37 deletions(-)

diff --git a/models/material.go b/models/material.go
index 8d9a4ee..7fc8138 100644
--- a/models/material.go
+++ b/models/material.go
@@ -12,7 +12,7 @@
 	// Material 鐗╂枡
 	Material struct {
 		BaseModelString
-		Name string `gorm:"unique;type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"name"` //鐗╂枡鍚嶇О
+		Name string `gorm:"type:varchar(191);not null;comment:鐗╂枡鍚嶇О" json:"name"` //鐗╂枡鍚嶇О
 		//MaterialType constvar.ProductType  `gorm:"index;type:int(11);comment:鐗╂枡绫诲瀷(鏁板瓧)" json:"materialType"`
 		Model constvar.MaterialMode `gorm:"type:varchar(191);not null;comment:鐗╂枡绫诲瀷(瀛楃涓�)" json:"model"` //鐗╂枡绫诲瀷(瀛楃涓�)
 		//Explain           string                  `gorm:"type:varchar(512);comment:缂栧彿璇存槑" json:"explain"`
@@ -38,36 +38,38 @@
 		SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` //閿�鍞崟浠�
 		AutoIncr  uint            `gorm:"type:int(11);comment:鑷ID;default:0;" json:"-"`
 		//wms娣诲姞瀛楁
-		ProductType             constvar.ProductType       `gorm:"type:int(11);comment:浜у搧绫诲瀷" json:"productType"`                    //浜у搧绫诲瀷
-		InvoicingStrategy       constvar.InvoicingStrategy `gorm:"type:int(11);comment:寮�绁ㄧ瓥鐣�" json:"invoicingStrategy"`              //寮�绁ㄧ瓥鐣�
-		OrderCreation           constvar.OrderCreation     `gorm:"type:int(11);comment:璁㈠崟鍒涘缓" json:"orderCreation"`                  //璁㈠崟鍒涘缓
-		CustomerTaxes           decimal.Decimal            `gorm:"type:decimal(20,2);comment:瀹㈡埛绋�" json:"customerTaxes"`             //瀹㈡埛绋庣櫨鍒嗘瘮
-		Cost                    decimal.Decimal            `gorm:"type:decimal(20,2);comment:鎴愭湰" json:"cost"`                       //鎴愭湰
-		CategoryId              int                        `gorm:"type:int(11);comment:浜у搧绫诲埆id" json:"categoryId"`                   //浜у搧绫诲埆id
-		CategoryName            string                     `gorm:"type:varchar(255);comment:浜у搧绫诲埆鍚嶇О" json:"categoryName"`            //浜у搧绫诲埆鍚嶇О
-		InternalReference       string                     `gorm:"type:varchar(255);comment:鍐呴儴鍙傝��" json:"internalReference"`         //鍐呴儴鍙傝��
-		Barcode                 string                     `gorm:"type:varchar(255);comment:鏉$爜" json:"barcode"`                     //鏉$爜
-		ProductTagId            int                        `gorm:"type:int(11);comment:浜у搧鏍囩id" json:"productTagId"`                 //浜у搧鏍囩id
-		ProductTagName          string                     `gorm:"type:varchar(255);comment:浜у搧鏍囩鍚嶇О" json:"productTagName"`          //浜у搧鏍囩鍚嶇О
-		CompanyId               int                        `gorm:"type:int(11);comment:鍏徃id" json:"companyId"`                      //鍏徃id
-		CompanyName             string                     `gorm:"type:varchar(255);comment:鍏徃鍚嶇О" json:"companyName"`               //鍏徃鍚嶇О
-		InternalNotes           string                     `gorm:"type:varchar(512);comment:鍐呴儴璇存槑" json:"internalNotes"`             //鍐呴儴璇存槑
-		SelectProduct           string                     `gorm:"type:varchar(255);comment:鍙�変骇鍝乮d" json:"selectProduct"`           //鍙�変骇鍝乮d
-		SellExplain             string                     `gorm:"type:varchar(512);comment:閿�鍞鏄�" json:"sellExplain"`               //閿�鍞鏄�
-		CanBePurchased          bool                       `gorm:"type:int(11);comment:鏄惁鍙噰璐�" json:"canBePurchased"`                //鏄惁鍙噰璐�
-		CurrencyName            string                     `gorm:"type:varchar(255);comment:甯佺鍚嶇О" json:"currencyName"`              //甯佺鍚嶇О
-		DeliveryAdvanceTime     int                        `gorm:"type:int(11);comment:浜よ揣鎻愬墠鏃堕棿(澶�)" json:"deliveryAdvanceTime"`       //浜よ揣鎻愬墠鏃堕棿(澶�)
-		ControlStrategy         constvar.InvoicingStrategy `gorm:"type:int(11);comment:鎺у埗绛栫暐" json:"controlStrategy"`                //鎺у埗绛栫暐
-		BuyExplain              string                     `gorm:"type:varchar(512);comment:閲囪喘璇存槑" json:"buyExplain"`                //閲囪喘璇存槑
-		Principal               string                     `gorm:"type:varchar(255);comment:璐熻矗浜�" json:"principal"`                  //璐熻矗浜�
-		Weight                  decimal.Decimal            `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"`                     //閲嶉噺
-		Volume                  decimal.Decimal            `gorm:"type:decimal(20,2);comment:浣撶Н" json:"volume"`                     //浣撶Н
-		HSCode                  string                     `gorm:"type:varchar(255);comment:HS缂栫爜" json:"HSCode"`                    //HS缂栫爜
-		OriginCountryId         int                        `gorm:"type:int(11);comment:鍘熶骇鍦癷d" json:"originCountryId"`               //鍘熶骇鍦癷d
-		OriginCountryName       string                     `gorm:"type:varchar(255);comment:鍘熶骇鍦板悕绉�" json:"originCountryName"`        //鍘熶骇鍦板悕绉�
-		InStorageExplain        string                     `gorm:"type:varchar(512);comment:鍏ュ簱璇存槑" json:"inStorageExplain"`          //鍏ュ簱璇存槑
-		OutStorageExplain       string                     `gorm:"type:varchar(512);comment:鍑哄簱璇存槑" json:"outStorageExplain"`         //鍑哄簱璇存槑
-		InternalTransferExplain string                     `gorm:"type:varchar(512);comment:鍐呴儴璋冩嫧璇存槑" json:"internalTransferExplain"` //鍐呴儴璋冩嫧璇存槑
+		ProductType         constvar.ProductType       `gorm:"type:int(11);comment:浜у搧绫诲瀷" json:"productType"`                 //浜у搧绫诲瀷
+		InvoicingStrategy   constvar.InvoicingStrategy `gorm:"type:int(11);comment:寮�绁ㄧ瓥鐣�" json:"invoicingStrategy"`           //寮�绁ㄧ瓥鐣�
+		OrderCreation       constvar.OrderCreation     `gorm:"type:int(11);comment:璁㈠崟鍒涘缓" json:"orderCreation"`               //璁㈠崟鍒涘缓
+		CustomerTaxes       decimal.Decimal            `gorm:"type:decimal(20,2);comment:瀹㈡埛绋�" json:"customerTaxes"`          //瀹㈡埛绋庣櫨鍒嗘瘮
+		Cost                decimal.Decimal            `gorm:"type:decimal(20,2);comment:鎴愭湰" json:"cost"`                    //鎴愭湰
+		CategoryId          int                        `gorm:"type:int(11);comment:浜у搧绫诲埆id" json:"categoryId"`                //浜у搧绫诲埆id
+		CategoryName        string                     `gorm:"type:varchar(255);comment:浜у搧绫诲埆鍚嶇О" json:"categoryName"`         //浜у搧绫诲埆鍚嶇О
+		InternalReference   string                     `gorm:"type:varchar(255);comment:鍐呴儴鍙傝��" json:"internalReference"`      //鍐呴儴鍙傝��
+		Barcode             string                     `gorm:"type:varchar(255);comment:鏉$爜" json:"barcode"`                  //鏉$爜
+		ProductTagId        int                        `gorm:"type:int(11);comment:浜у搧鏍囩id" json:"productTagId"`              //浜у搧鏍囩id
+		ProductTagName      string                     `gorm:"type:varchar(255);comment:浜у搧鏍囩鍚嶇О" json:"productTagName"`       //浜у搧鏍囩鍚嶇О
+		CompanyId           int                        `gorm:"type:int(11);comment:鍏徃id" json:"companyId"`                   //鍏徃id
+		CompanyName         string                     `gorm:"type:varchar(255);comment:鍏徃鍚嶇О" json:"companyName"`            //鍏徃鍚嶇О
+		InternalNotes       string                     `gorm:"type:varchar(512);comment:鍐呴儴璇存槑" json:"internalNotes"`          //鍐呴儴璇存槑
+		SelectProduct       string                     `gorm:"type:varchar(255);comment:鍙�変骇鍝乮d" json:"selectProduct"`        //鍙�変骇鍝乮d
+		SellExplain         string                     `gorm:"type:varchar(512);comment:閿�鍞鏄�" json:"sellExplain"`            //閿�鍞鏄�
+		CanBePurchased      bool                       `gorm:"type:int(11);comment:鏄惁鍙噰璐�" json:"canBePurchased"`             //鏄惁鍙噰璐�
+		CurrencyName        string                     `gorm:"type:varchar(255);comment:甯佺鍚嶇О" json:"currencyName"`           //甯佺鍚嶇О
+		ControlStrategy     constvar.InvoicingStrategy `gorm:"type:int(11);comment:鎺у埗绛栫暐" json:"controlStrategy"`             //鎺у埗绛栫暐
+		BuyExplain          string                     `gorm:"type:varchar(512);comment:閲囪喘璇存槑" json:"buyExplain"`             //閲囪喘璇存槑
+		Principal           string                     `gorm:"type:varchar(255);comment:璐熻矗浜�" json:"principal"`               //璐熻矗浜�
+		Weight              decimal.Decimal            `gorm:"type:decimal(20,2);comment:閲嶉噺" json:"weight"`                  //閲嶉噺
+		Volume              decimal.Decimal            `gorm:"type:decimal(20,2);comment:浣撶Н" json:"volume"`                  //浣撶Н
+		MakeAdvanceTime     decimal.Decimal            `gorm:"type:decimal(20,2);comment:鍒堕�犲墠缃椂闂�" json:"makeAdvanceTime"`     //鍒堕�犲墠缃椂闂�(澶�)
+		OrderAdvanceTime    decimal.Decimal            `gorm:"type:decimal(20,2);comment:璁㈠崟鍑嗗澶╂暟" json:"orderAdvanceTime"`    //璁㈠崟鍑嗗澶╂暟(澶�)
+		DeliveryAdvanceTime decimal.Decimal            `gorm:"type:decimal(20,2);comment:瀹㈡埛鍓嶇疆鏃堕棿" json:"deliveryAdvanceTime"` //瀹㈡埛鍓嶇疆鏃堕棿(澶�)
+		//HSCode                  string                     `gorm:"type:varchar(255);comment:HS缂栫爜" json:"HSCode"`                    //HS缂栫爜
+		//OriginCountryId         int                        `gorm:"type:int(11);comment:鍘熶骇鍦癷d" json:"originCountryId"`               //鍘熶骇鍦癷d
+		//OriginCountryName       string                     `gorm:"type:varchar(255);comment:鍘熶骇鍦板悕绉�" json:"originCountryName"`        //鍘熶骇鍦板悕绉�
+		InStorageExplain        string `gorm:"type:varchar(512);comment:鍏ュ簱璇存槑" json:"inStorageExplain"`          //鍏ュ簱璇存槑
+		OutStorageExplain       string `gorm:"type:varchar(512);comment:鍑哄簱璇存槑" json:"outStorageExplain"`         //鍑哄簱璇存槑
+		InternalTransferExplain string `gorm:"type:varchar(512);comment:鍐呴儴璋冩嫧璇存槑" json:"internalTransferExplain"` //鍐呴儴璋冩嫧璇存槑
 	}
 
 	MaterialSearch struct {
@@ -75,11 +77,12 @@
 		//MaterialTypes   []constvar.MaterialType
 		Keyword string
 		//SetTemplateType constvar.SetTemplateType
-		Order    string
-		PageNum  int
-		PageSize int
-		Ids      []string
-		Orm      *gorm.DB
+		Order       string
+		PageNum     int
+		PageSize    int
+		Ids         []string
+		Orm         *gorm.DB
+		CategoryIds []int
 	}
 
 	IdAndName struct {
@@ -150,6 +153,15 @@
 	slf.TemplateID = id
 	return slf
 }
+func (slf *MaterialSearch) SetCategoryId(id int) *MaterialSearch {
+	slf.CategoryId = id
+	return slf
+}
+
+func (slf *MaterialSearch) SetCategoryIds(ids []int) *MaterialSearch {
+	slf.CategoryIds = ids
+	return slf
+}
 
 //
 //func (slf *MaterialSearch) SetSetTemplateType(setType constvar.SetTemplateType) *MaterialSearch {
@@ -205,7 +217,7 @@
 	//}
 
 	if slf.Keyword != "" {
-		db = db.Where("name LIKE ? or id LIKE ? ", "%"+slf.Keyword+"%", "%"+slf.Keyword+"%")
+		db = db.Where("name LIKE ? ", "%"+slf.Keyword+"%")
 	}
 
 	if slf.Order != "" {
@@ -220,6 +232,12 @@
 	}
 	if slf.IsSale {
 		db = db.Where("is_sale = ?", 1)
+	}
+	if slf.CategoryId > 0 {
+		db = db.Where("category_id = ?", slf.CategoryId)
+	}
+	if len(slf.CategoryIds) > 0 {
+		db = db.Where("category_id in ?", slf.CategoryIds)
 	}
 
 	return db
@@ -473,3 +491,34 @@
 	}
 	return result.Max, nil
 }
+
+type ResponseDisuseList struct {
+	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)"`                           //婧愬崟鍙�
+	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"` //婧愪綅缃�
+	ToLocation     Location                 `json:"toLocation"      gorm:"foreignKey:ToLocationID;references:Id"`    //鐩爣浣嶇疆
+	ToLocationID   int                      `json:"toLocationId"    gorm:"type:int;not null;comment:鐩爣浣嶇疆id"`         //鐩爣浣嶇疆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:澶囨敞"`
+	ProductId      string                   `json:"productId" gorm:"type:varchar(191);not null;comment:浜у搧id"`   //浜у搧id
+	ProductName    string                   `json:"productName" gorm:"type:varchar(255);not null;comment:浜у搧鍚嶇О"` //浜у搧鍚嶇О
+	Amount         decimal.Decimal          `json:"amount" gorm:"type:decimal(20,2);not null;comment:鏁伴噺"`       //鏁伴噺
+	Unit           string                   `json:"unit" gorm:"type:varchar(31);comment:鍗曚綅"`
+}
+
+func (slf *MaterialSearch) Update(record *Material) error {
+	var db = slf.build()
+
+	if err := db.Omit("CreatedAt").Updates(record).Error; err != nil {
+		return fmt.Errorf("save err: %v, record: %+v", err, record)
+	}
+
+	return nil
+}

--
Gitblit v1.8.0