From 6c8fc638919e5bf778f47f4d2be188717b7de23b Mon Sep 17 00:00:00 2001
From: lishihai <dslsh@dscom>
Date: 星期六, 29 六月 2024 17:51:54 +0800
Subject: [PATCH] 概述->业务类型->按仓库Ids筛选->BUG REPORT
---
controllers/report_forms_controller.go | 97 ++++++++++++++++++++++++++++++++++++++++++------
1 files changed, 85 insertions(+), 12 deletions(-)
diff --git a/controllers/report_forms_controller.go b/controllers/report_forms_controller.go
index 6d7b0ce..e3346ae 100644
--- a/controllers/report_forms_controller.go
+++ b/controllers/report_forms_controller.go
@@ -5,6 +5,7 @@
"github.com/shopspring/decimal"
"net/url"
"os"
+ "time"
"wms/constvar"
"wms/extend/code"
"wms/extend/util"
@@ -83,11 +84,6 @@
if err != nil {
logx.Errorf("DownloadInventoryForms Export err:%v", err)
util.ResponseFormat(c, code.InternalError, "瀵煎嚭鏁版嵁鍒版枃浠跺け璐�")
- return
- }
-
- if err != nil {
- util.ResponseFormat(c, code.RequestParamError, "瀵煎嚭澶辫触")
return
}
@@ -225,6 +221,12 @@
util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
return
}
+
+ if params.BaseOperationType == 0 {
+ util.ResponseFormat(c, code.RequestParamError, "鍩虹鎿嶄綔绫诲瀷涓嶈兘涓虹┖")
+ return
+ }
+
historyFormsService := service.NewHistoryFormsService()
list, err := historyFormsService.FetchAll(params)
if err != nil {
@@ -306,11 +308,6 @@
return
}
- if err != nil {
- util.ResponseFormat(c, code.RequestParamError, "瀵煎嚭澶辫触")
- return
- }
-
fileContentDisposition := "attachment;filename=\"" + url.QueryEscape(filename) + "\""
c.Header("Content-Type", "application/xlsx")
c.Header("Content-Disposition", fileContentDisposition)
@@ -333,13 +330,89 @@
return
}
- list, total, err := models.NewMonthStatsSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetDate(params.Date).Find()
+ monthFormsService := service.NewMonthFormsService()
+ total, err := monthFormsService.Count(params)
if err != nil {
+ logx.Errorf("MonthStats count err:%v", err)
+ util.ResponseFormat(c, code.InternalError, "鏌ヨ鎬绘暟澶辫触")
+ return
+ }
+
+ result, err := monthFormsService.Query(params)
+ if err != nil {
+ logx.Errorf("MonthStats query err:%v", err)
util.ResponseFormat(c, code.InternalError, "鏌ヨ澶辫触")
return
}
- util.ResponseFormatList(c, code.Success, list, int(total))
+ now := time.Now().Local()
+ today := now.Day()
+ nowMonth := now.Format("2006-01")
+
+ day, dateStr, err := service.NewSystemConfigService().GetInventoryCutOffPoint()
+ if nowMonth == params.Date && today < day || today == day && now.Format("15:04") < dateStr { //鏈湀鏈嚦缁撶畻鏃堕棿鐐�
+ productIds := make([]string, 0, len(result))
+ for _, item := range result {
+ productIds = append(productIds, item.ProductId)
+ }
+ statsRecords, err := service.GetCurrentStats(params.Date, productIds)
+ if err != nil {
+ util.ResponseFormat(c, code.InternalError, "鍐呴儴閿欒")
+ return
+ }
+ statsMap := models.MonthStatsMap(statsRecords)
+ for k, v := range result {
+ if statsMap[v.ProductId] == nil {
+ continue
+ }
+
+ result[k].OutputAmount = statsMap[v.ProductId].OutputAmount
+ result[k].OutputMoreUnits = statsMap[v.ProductId].OutputMoreUnits
+ result[k].EndAmount = statsMap[v.ProductId].EndAmount
+ result[k].EndMoreUnits = statsMap[v.ProductId].EndMoreUnits
+ result[k].InputAmount = statsMap[v.ProductId].InputAmount
+ result[k].InputMoreUnits = statsMap[v.ProductId].InputMoreUnits
+ }
+
+ }
+
+ util.ResponseFormatList(c, code.Success, result, int(total))
+}
+
+// DownloadMonthStats
+// @Tags 鎶ヨ〃
+// @Summary 涓嬭浇鏈堝害缁熻搴撳瓨鎶ヨ〃
+// @Produce application/json
+// @Param object body request.GetMonthStats true "鏌ヨ鍙傛暟"
+// @Param Authorization header string true "token"
+// @Success 200 {object} util.ResponseList{data=[]models.MonthStats} "鎴愬姛"
+// @Router /api-wms/v1/forms/downloadMonthStats [post]
+func (slf ReportFormsController) DownloadMonthStats(c *gin.Context) {
+ var params request.GetMonthStats
+ if err := c.BindJSON(¶ms); err != nil {
+ util.ResponseFormat(c, code.RequestParamError, "鍙傛暟瑙f瀽澶辫触锛屾暟鎹被鍨嬮敊璇�")
+ return
+ }
+
+ monthFormsService := service.NewMonthFormsService()
+ list, err := monthFormsService.FetchAll(params)
+ if err != nil {
+ logx.Errorf("DownloadMonthStats FetchAll err:%v", err)
+ util.ResponseFormat(c, code.InternalError, "鏌ヨ澶辫触")
+ return
+ }
+ filename, err := monthFormsService.Export(list)
+ if err != nil {
+ logx.Errorf("DownloadMonthStats Export err:%v", err)
+ util.ResponseFormat(c, code.InternalError, "瀵煎嚭鏁版嵁鍒版枃浠跺け璐�")
+ return
+ }
+
+ fileContentDisposition := "attachment;filename=\"" + url.QueryEscape(filename) + "\""
+ c.Header("Content-Type", "application/xlsx")
+ c.Header("Content-Disposition", fileContentDisposition)
+ c.File(filename)
+ defer os.Remove(filename)
}
// DoMonthStats
--
Gitblit v1.8.0