From fc3313955a083c9480e4ea74398f72f9ba6addcd Mon Sep 17 00:00:00 2001 From: zhangqian <zhangqian@123.com> Date: 星期四, 01 八月 2024 20:29:51 +0800 Subject: [PATCH] 月度统计查询多单位数据计算改查询。 --- models/material.go | 20 ++++++++++++++++++-- 1 files changed, 18 insertions(+), 2 deletions(-) diff --git a/models/material.go b/models/material.go index e410f35..f28215e 100644 --- a/models/material.go +++ b/models/material.go @@ -80,7 +80,9 @@ ReorderRuleNum int64 `json:"reorderRuleNum"` MoreUnit *bool `json:"moreUnit" gorm:"type:tinyint(1);default:false;comment:鍚姩澶氬崟浣�"` MoreUnitList []UnitItems `json:"moreUnitList" gorm:"-"` - MoreUnitValue string `json:"-" gorm:"type:varchar(255);comment:澶氬崟浣嶅��"` + MoreUnitValue string `json:"-" gorm:"type:varchar(255);comment:澶氬崟浣嶅��"` //澶氬崟浣嶆崲绠楁瘮渚� + StockMoreUnitList []UnitItems `json:"-" gorm:"-"` //澶氬崟浣嶅瓨鍌ㄧ殑鍊� + StockMoreUnitValue string `json:"-" gorm:"type:varchar(512);comment:澶氬崟浣嶅��"` //澶氬崟浣嶅瓨鍌ㄧ殑鍊� GrossWeight decimal.Decimal `json:"grossWeight" gorm:"type:decimal(20,3);comment:姣涢噸"` NetWeight decimal.Decimal `json:"netWeight" gorm:"type:decimal(20,3);comment:鍑�閲�"` GrossUnit string `json:"grossUnit" gorm:"type:varchar(255);comment:姣涢噸鍗曚綅"` @@ -120,7 +122,7 @@ } UnitItems struct { - Amount decimal.Decimal `json:"amount"` + Amount decimal.Decimal `json:"amount"` //鍦ㄧ墿鏂欎腑涓烘崲绠楃巼锛�1杈呭崟浣�=鎹㈢畻鐜�*涓诲崟浣嶏級锛屽湪鏄庣粏鎴栧簱瀛樹腑涓哄叿浣撳�� Unit string `json:"unit"` Floating bool `json:"floating"` //鏄惁娴姩鍒╃巼 } @@ -177,6 +179,20 @@ } slf.MoreUnitValue = string(str) } + if len(slf.StockMoreUnitList) != 0 { + items := make([]UnitItems, 0) + for k, item := range slf.StockMoreUnitList { + if item.Unit != "" && !item.Amount.IsZero() { + items = append(items, slf.StockMoreUnitList[k]) + } + } + + str, err := json.Marshal(items) + if err != nil { + return err + } + slf.StockMoreUnitValue = string(str) + } return } -- Gitblit v1.8.0