From a0125ef3d6ce35be7b6dc4919c4192dba4a7329a Mon Sep 17 00:00:00 2001
From: jiangshuai <291802688@qq.com>
Date: 星期四, 16 十一月 2023 14:33:51 +0800
Subject: [PATCH] 报废数量bug

---
 models/material.go |   48 +++++++++++++++++++++++++++---------------------
 1 files changed, 27 insertions(+), 21 deletions(-)

diff --git a/models/material.go b/models/material.go
index 5084258..16a6e10 100644
--- a/models/material.go
+++ b/models/material.go
@@ -16,15 +16,15 @@
 		//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"`
-		//CodeStandardID    string                  `gorm:"type:varchar(191);comment:缂栫爜瑙勮寖ID" json:"codeStandardID"`
-		//Specs             string                  `gorm:"type:varchar(191);comment:鐗╂枡瑙勬牸" json:"specs"`
-		//Type              string                  `gorm:"type:varchar(191);comment:鐗╂枡鍨嬪彿" json:"type"`
-		MinInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忓簱瀛�" json:"minInventory"` //鏈�灏忓簱瀛�
-		MaxInventory decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�澶у簱瀛�" json:"maxInventory"` //鏈�澶у簱瀛�
-		Amount       decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"`         //鏁伴噺
+		CodeStandardID string          `gorm:"type:varchar(191);comment:缂栫爜瑙勮寖ID" json:"codeStandardID"`
+		Specs          string          `gorm:"type:varchar(191);comment:鐗╂枡瑙勬牸" json:"specs"`
+		Type           string          `gorm:"type:varchar(191);comment:鐗╂枡鍨嬪彿" json:"type"`
+		MinInventory   decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忓簱瀛�" json:"minInventory"` //鏈�灏忓簱瀛�
+		MaxInventory   decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�澶у簱瀛�" json:"maxInventory"` //鏈�澶у簱瀛�
+		Amount         decimal.Decimal `gorm:"type:decimal(35,18);comment:鏁伴噺" json:"amount"`         //鏁伴噺
 		//LockAmount        decimal.Decimal         `gorm:"type:decimal(35,18);default:0;comment:閿佸畾鏁伴噺" json:"lockAmount"`
-		Unit string `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"` //鍗曚綅
-		//Note              string                  `gorm:"type:varchar(1024);comment:澶囨敞" json:"note"`
+		Unit       string `gorm:"type:varchar(100);comment:鍗曚綅" json:"unit"` //鍗曚綅
+		Note       string `gorm:"type:varchar(1024);comment:澶囨敞" json:"note"`
 		TemplateID string `gorm:"type:varchar(191);comment:妯℃澘ID" json:"templateID"` //妯℃澘ID
 		//FSource           string                  `gorm:"type:varchar(191);comment:鐢熶骇杞﹂棿" json:"-"`
 		//Status            constvar.MaterialStatus `gorm:"type:int(11);comment:鐘舵��" json:"status"`
@@ -32,11 +32,11 @@
 		PurchasePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閲囪喘浠锋牸" json:"purchasePrice"` //閲囪喘浠锋牸
 		//PurchaseAheadDay  int                     `gorm:"type:int(11);comment:閲囪喘鎻愬墠鏈�(澶�)" json:"purchaseAheadDay"`
 		//ProduceAheadDay   int                     `gorm:"type:int(11);comment:鍒堕�犳彁鍓嶆湡(澶�)" json:"produceAheadDay"`
-		MinPurchaseAmount decimal.Decimal `gorm:"type:decimal(35,18);comment:鏈�灏忛噰璐噺" json:"minPurchaseAmount"` //鏈�灏忛噰璐噺
-		//PurchaseType      constvar.PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷" json:"purchaseType"`
-		IsSale    bool            `gorm:"type:tinyint(1);comment:鏄惁閿�鍞�" json:"isSale"`        //鏄惁閿�鍞�
-		SalePrice decimal.Decimal `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` //閿�鍞崟浠�
-		AutoIncr  uint            `gorm:"type:int(11);comment:鑷ID;default:0;" json:"-"`
+		MinPurchaseAmount decimal.Decimal       `gorm:"type:decimal(35,18);comment:鏈�灏忛噰璐噺" json:"minPurchaseAmount"` //鏈�灏忛噰璐噺
+		PurchaseType      constvar.PurchaseType `gorm:"type:int(11);comment:閲囪喘绫诲瀷" json:"purchaseType"`
+		IsSale            bool                  `gorm:"type:tinyint(1);comment:鏄惁閿�鍞�" json:"isSale"`        //鏄惁閿�鍞�
+		SalePrice         decimal.Decimal       `gorm:"type:decimal(35,18);comment:閿�鍞崟浠�" json:"salePrice"` //閿�鍞崟浠�
+		AutoIncr          uint                  `gorm:"type:int(11);comment:鑷ID;default:0;" json:"autoIncr"`
 		//wms娣诲姞瀛楁
 		ProductType         constvar.ProductType       `gorm:"type:int(11);comment:浜у搧绫诲瀷" json:"productType"`                 //浜у搧绫诲瀷
 		InvoicingStrategy   constvar.InvoicingStrategy `gorm:"type:int(11);comment:寮�绁ㄧ瓥鐣�" json:"invoicingStrategy"`           //寮�绁ㄧ瓥鐣�
@@ -67,11 +67,17 @@
 		//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"` //鍐呴儴璋冩嫧璇存槑
-		AttachmentList          []*Attachment `json:"attachmentList" gorm:"many2many:material_attachment"`
-		AttachmentIDs           []uint        `json:"attachmentIDs" gorm:"-"`
+		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"` //鍐呴儴璋冩嫧璇存槑
+		AttachmentList          []*Attachment   `json:"attachmentList" gorm:"many2many:material_attachment"`
+		AttachmentIDs           []uint          `json:"attachmentIDs" gorm:"-"`
+		PredictionAmount        decimal.Decimal `json:"predictionAmount" gorm:"-"`
+		InputAmount             decimal.Decimal `json:"inputAmount" gorm:"-"`
+		OutputAmount            decimal.Decimal `json:"outputAmount" gorm:"-"`
+		MinInventoryRule        decimal.Decimal `json:"minInventoryRule" gorm:"-"` //鏈�灏忓簱瀛�
+		MaxInventoryRule        decimal.Decimal `json:"maxInventoryRule" gorm:"-"` //鏈�澶у簱瀛�
+		ReorderRuleNum          int64           `json:"reorderRuleNum"`
 	}
 
 	MaterialSearch struct {
@@ -341,7 +347,7 @@
 		db      = slf.build()
 	)
 
-	if err := db.Count(&total).Error; err != nil {
+	if err := db.Model(&Material{}).Count(&total).Error; err != nil {
 		return records, total, fmt.Errorf("find count err: %v", err)
 	}
 	if slf.PageNum*slf.PageSize > 0 {
@@ -487,9 +493,9 @@
 //	return fileName, nil
 //}
 
-func (slf *MaterialSearch) MaxAutoIncr() (int64, error) {
+func (slf *MaterialSearch) MaxAutoIncr() (int, error) {
 	type Result struct {
-		Max int64
+		Max int
 	}
 
 	var (

--
Gitblit v1.8.0