From f72fb9ca31fbf27b4abbc0156e60ea162f58df81 Mon Sep 17 00:00:00 2001
From: dsmzx <dsmzx@123.com>
Date: 星期四, 13 六月 2024 15:30:50 +0800
Subject: [PATCH] 出入库调拨产品明细增加备注字段(同步产品的备注字段)

---
 controllers/operation.go    |   19 +++++++++++++++++++
 models/operation_details.go |    1 +
 2 files changed, 20 insertions(+), 0 deletions(-)

diff --git a/controllers/operation.go b/controllers/operation.go
index 4a74aec..d519e04 100644
--- a/controllers/operation.go
+++ b/controllers/operation.go
@@ -92,6 +92,25 @@
 		return
 	}
 
+	var productIds []string
+	for _, v := range params.Details {
+		productIds = append(productIds, v.ProductId)
+	}
+	products, err := models.NewMaterialSearch().SetIDs(productIds).FindNotTotal()
+	if err != nil {
+		logx.Errorf("MonthStats get products err:%v", err)
+		return
+	}
+	productMap := models.MaterialMap(products)
+	for key, value := range productMap {
+		for i := 0; i < len(params.Details); i++ {
+			if key == params.Details[i].ProductId {
+				params.Details[i].Note = value.Note
+				break
+			}
+		}
+	}
+
 	if err := models.NewOperationSearch().Create(&params); err != nil {
 		logx.Errorf("Operation create err: %v", err)
 		util.ResponseFormat(c, code.SaveFail, "娣诲姞澶辫触锛�"+err.Error())
diff --git a/models/operation_details.go b/models/operation_details.go
index f793077..ea37b72 100644
--- a/models/operation_details.go
+++ b/models/operation_details.go
@@ -27,6 +27,7 @@
 		TotalNetWeight   decimal.Decimal `json:"totalNetWeight" gorm:"type:decimal(20,3);comment:鎬诲噣閲�"`
 		AuxiliaryAmount  decimal.Decimal `json:"auxiliaryAmount" gorm:"type:decimal(20,3);comment:杈呭姪鏁伴噺"`
 		AuxiliaryUnit    string          `json:"auxiliaryUnit" gorm:"type:varchar(191);comment:杈呭姪鍗曚綅"`
+		Note             string          `gorm:"type:varchar(1024);comment:澶囨敞" json:"note"`
 	}
 
 	OperationDetailsSearch struct {

--
Gitblit v1.8.0