From 73b6baf6af3d88cdcb0e2df7932a9bd96b0b85c5 Mon Sep 17 00:00:00 2001
From: zhangqian <zhangqian@123.com>
Date: 星期一, 01 七月 2024 22:32:34 +0800
Subject: [PATCH] 月度统计出入库按类型汇总报表定时任务和手动跑任务接口

---
 controllers/operation_type.go |   26 ++++++++++++++++++++++++--
 1 files changed, 24 insertions(+), 2 deletions(-)

diff --git a/controllers/operation_type.go b/controllers/operation_type.go
index c0ea4a9..cf07e2f 100644
--- a/controllers/operation_type.go
+++ b/controllers/operation_type.go
@@ -7,6 +7,7 @@
 	"github.com/spf13/cast"
 	"gorm.io/gorm"
 	"strconv"
+	"strings"
 	"wms/constvar"
 	"wms/extend/code"
 	"wms/extend/util"
@@ -116,7 +117,22 @@
 		util.ResponseFormat(c, code.RequestParamError, err.Error())
 		return
 	}
-	list, total, err := models.NewOperationTypeSearch().SetPage(params.Page, params.PageSize).SetKeyword(params.Keyword).SetOrder("id desc").SetPreload(true).Find()
+	warehouseIds := make([]int, 0)
+	if "" != params.WarehouseIds {
+		for _, strId := range strings.Split(params.WarehouseIds, ",") {
+			intId, err := strconv.Atoi(strId)
+			if err != nil {
+				util.ResponseFormat(c, code.RequestParamError, err.Error())
+			}
+			warehouseIds = append(warehouseIds, intId)
+		}
+	}
+	list, total, err := models.NewOperationTypeSearch().
+		SetPage(params.Page, params.PageSize).
+		SetKeyword(params.Keyword).
+		SetOrder("id desc").
+		SetWarehouseIds(warehouseIds).
+		SetPreload(true).Find()
 	if err != nil {
 		util.ResponseFormat(c, code.RequestError, "鏌ユ壘澶辫触")
 		return
@@ -140,6 +156,9 @@
 		}
 		if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Finish)]; ok {
 			list[k].FinishCount = value.Count
+		}
+		if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Cancel)]; ok {
+			list[k].CancelCount = value.Count
 		}
 	}
 	util.ResponseFormatListWithPage(c, code.Success, list, cast.ToInt(total), params.Page, params.PageSize)
@@ -173,7 +192,7 @@
 // @Produce   application/json
 // @Param     object  query    request.ListTransfer true  "鏌ヨ鍙傛暟"
 // @Success   200   {object}  util.ResponseList  "鎴愬姛"
-// @Router    /api-wms/v1/operationType/operationType [get]
+// @Router    /api-wms/v1/operationType/listTransfer [get]
 func (slf OperationTypeController) ListTransfer(c *gin.Context) {
 	var params request.GetOperationTypeList
 	if err := c.ShouldBindQuery(&params); err != nil {
@@ -205,6 +224,9 @@
 		if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Finish)]; ok {
 			list[k].FinishCount = value.Count
 		}
+		if value, ok := mapStatistics[strconv.Itoa(v.Id)+string(constvar.OperationStatus_Cancel)]; ok {
+			list[k].FinishCount = value.Count
+		}
 	}
 	util.ResponseFormatListWithPage(c, code.Success, list, cast.ToInt(total), params.Page, params.PageSize)
 }

--
Gitblit v1.8.0