From 79aef24a785581d95343ccd99e9cb362b2bc9c97 Mon Sep 17 00:00:00 2001
From: yinbentan <yinbentan@live.com>
Date: 星期六, 06 七月 2024 21:31:59 +0800
Subject: [PATCH] 调整库存商品位置错误

---
 service/warehouse_month_forms.go |   17 +++++++++++------
 1 files changed, 11 insertions(+), 6 deletions(-)

diff --git a/service/warehouse_month_forms.go b/service/warehouse_month_forms.go
index 3a60cd3..09ccfe6 100644
--- a/service/warehouse_month_forms.go
+++ b/service/warehouse_month_forms.go
@@ -25,7 +25,8 @@
 }
 
 func (slf *WarehouseMonthFormsService) BuildSearch(params request.GetMonthStats) (search *models.WarehouseMonthStatsSearch) {
-	search = models.NewWarehouseMonthStatsSearch().SetKeyword(params.Keyword).SetDate(params.Date)
+	search = models.NewWarehouseMonthStatsSearch().
+		SetKeyword(params.Keyword).SetDate(params.Date).SetWarehouseId(params.WarehouseID)
 	if params.Preload {
 		search = search.SetPreload(true)
 	}
@@ -98,8 +99,8 @@
 		f.SetCellValue("Sheet1", "E"+column, v.Unit)
 		f.SetCellValue("Sheet1", "F"+column, v.SalePrice)
 
-		slf.FillDealerTypeToExcel(v.InputItems, inputStart, i+3, inputTypes, f)
-		slf.FillDealerTypeToExcel(v.OutputItems, outputStart, i+3, outputTypes, f)
+		slf.FillDealerTypeToExcel(v.InputItems, inputStart, i+3, inputTypes, f, constvar.InputTotalHeader)
+		slf.FillDealerTypeToExcel(v.OutputItems, outputStart, i+3, outputTypes, f, constvar.OutPutTotalHeader)
 	}
 
 	fileName := fmt.Sprintf("%s鏈堝害缁熻鎶ヨ〃%s.xlsx", "浠撳簱", time.Now().Format("2006-01-02-1504"))
@@ -138,7 +139,7 @@
 	return sum
 }
 
-func (slf *WarehouseMonthFormsService) FillDealerTypeToExcel(items []*models.WarehouseStatsItems, startIndex int, column int, dealerTypes []string, f *excelize.File) {
+func (slf *WarehouseMonthFormsService) FillDealerTypeToExcel(items []*models.WarehouseStatsItems, startIndex int, column int, dealerTypes []string, f *excelize.File, totalHeader string) {
 	columnStr := strconv.Itoa(column)
 	sum := slf.SumItems(items)
 	detailMap := models.WarehouseStatsItemMap(items)
@@ -153,7 +154,7 @@
 		var amount decimal.Decimal
 		if detailMap[dealerTypes[i]] != nil {
 			amount = detailMap[dealerTypes[i]].Amount
-		} else if dealerTypes[i] == constvar.InputTotalHeader {
+		} else if dealerTypes[i] == totalHeader {
 			amount = sum
 		}
 		f.SetCellValue("Sheet1", getColumnAlphabet(startIndex+i)+columnStr, amount)
@@ -161,7 +162,7 @@
 	return
 }
 
-func GetCurrentWarehouseStats(date string, warehouseId int, productIds []string) (statRecords []*models.WarehouseMonthStats, err error) {
+func GetCurrentWarehouseStats(date string, warehouseId int, productIds []string, realTime bool) (statRecords []*models.WarehouseMonthStats, err error) {
 	//鏈湀鏈熷垵鏁伴噺/涓婃湀缁撲綑鏁伴噺
 	groupSumList, err := models.NewLocationProductAmountSearch().SetProductIds(productIds).GroupSum("product_id", "amount")
 	productIds = make([]string, 0, len(groupSumList))
@@ -177,6 +178,10 @@
 
 	//鎸夐厤缃彇寮�濮嬫椂闂村拰缁撴潫鏃堕棿
 	beginTime, endTime, err := NewSystemConfigService().GetInventoryCutOffTime()
+	if realTime {
+		beginTime = endTime
+		endTime = time.Now()
+	}
 	if err != nil {
 		logx.Errorf("MonthStats GetCurrentStats get GetInventoryCutOffTime err:%v", err)
 		return

--
Gitblit v1.8.0