From 5de4db2e60ff62c9a791c3b9b769623fd2fe3239 Mon Sep 17 00:00:00 2001
From: dongyukun <1208714201@qq.com>
Date: 星期二, 06 五月 2025 17:19:45 +0800
Subject: [PATCH] Merge remote-tracking branch 'origin/master'

---
 ansteel-biz/src/main/java/com/iailab/module/ansteel/coking/service/impl/CokingOverviewServiceImpl.java |   35 ++++++++++++++++++++++++++++-------
 1 files changed, 28 insertions(+), 7 deletions(-)

diff --git a/ansteel-biz/src/main/java/com/iailab/module/ansteel/coking/service/impl/CokingOverviewServiceImpl.java b/ansteel-biz/src/main/java/com/iailab/module/ansteel/coking/service/impl/CokingOverviewServiceImpl.java
index 8755fab..47da4b6 100644
--- a/ansteel-biz/src/main/java/com/iailab/module/ansteel/coking/service/impl/CokingOverviewServiceImpl.java
+++ b/ansteel-biz/src/main/java/com/iailab/module/ansteel/coking/service/impl/CokingOverviewServiceImpl.java
@@ -14,7 +14,10 @@
 import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
+import java.math.BigDecimal;
 import java.util.*;
+import java.util.function.Function;
+import java.util.stream.Collectors;
 
 @Slf4j
 @Service
@@ -32,19 +35,19 @@
         }
 
         String clock = (String) params.get("clock");
-        String monthEndClock;
+        String monthStartClock;
         if (StringUtils.isBlank(clock)) {
             Calendar calendar = Calendar.getInstance();
             calendar.add(Calendar.DAY_OF_YEAR, -1);
             clock = DateUtils.format(calendar.getTime(), "yyyy-MM-dd");
             calendar.add(Calendar.DAY_OF_YEAR, -30);
-            monthEndClock = DateUtils.format(calendar.getTime(), "yyyy-MM-dd");
+            monthStartClock = DateUtils.format(calendar.getTime(), "yyyy-MM-dd");
         }else {
             Date parse = DateUtils.parse(clock, "yyyy-MM-dd");
             Calendar c = Calendar.getInstance();
             c.setTime(parse);
             c.add(Calendar.DAY_OF_YEAR, -29);
-            monthEndClock = DateUtils.format(c.getTime(), "yyyy-MM-dd");
+            monthStartClock= DateUtils.format(c.getTime(), "yyyy-MM-dd");
         }
 
         // 天数据
@@ -60,20 +63,38 @@
         });
         result.put("day", dayDTOList);
 
+        Map<String, CokingOverviewEntity> ratioMonth = new HashMap<>();
+        if (processType.equals(ProcessTypeEnum.BM.getCode())) {
+            ratioMonth = dayList.stream().collect(Collectors.toMap(CokingOverviewEntity::getSubProcessType, Function.identity(), (e1, e2) -> e1));
+        }
+
         // 月数据
         QueryWrapper<CokingOverviewEntity> queryWrapperMonth = new QueryWrapper<>();
         queryWrapperMonth.eq("process_type", processType);
-        queryWrapperMonth.between("clock", clock,monthEndClock);
-        queryWrapperMonth.select("sub_process_type","SUM(steam_p) as steam_p","SUM(dj_steam_p) as dj_steam_p","SUM(steam_c) as steam_c","SUM(steam_only_c) as steam_only_c","SUM(steam_v) as steam_v","SUM(gas_p) as gas_p","SUM(gas_c) as gas_c","SUM(power_c) as power_c","SUM(power_only_c) as power_only_c","SUM(power_c_standard) as power_c_standard","SUM(idle_time) as idle_time","SUM(bfg_c) as bfg_c","SUM(cog_p) as cog_p","SUM(cog_c) as cog_c","SUM(bfg_only_c) as bfg_only_c","SUM(cog_only_c) as cog_only_c","SUM(gxls) as gxls","SUM(fg_ratio) as fg_ratio")
+        queryWrapperMonth.between("clock", monthStartClock,clock);
+        queryWrapperMonth.select("sub_process_type","SUM(steam_p) as steam_p","SUM(dj_steam_p) as dj_steam_p","SUM(steam_c) as steam_c","SUM(steam_only_c) as steam_only_c","SUM(steam_v) as steam_v","SUM(gas_p) as gas_p","SUM(gas_c) as gas_c","SUM(power_c) as power_c","SUM(power_only_c) as power_only_c","SUM(power_c_standard) as power_c_standard","SUM(idle_time) as idle_time","SUM(bfg_c) as bfg_c","SUM(cog_p) as cog_p","SUM(cog_c) as cog_c","SUM(bfg_only_c) as bfg_only_c","SUM(cog_only_c) as cog_only_c","SUM(gxls) as gxls","SUM(fs_ratio) as fs_ratio","SUM(gs_ratio) as gs_ratio","SUM(ps_ratio) as ps_ratio")
                 .groupBy("sub_process_type");
 
         List<CokingOverviewEntity> monthList = cokingOverviewDao.selectList(queryWrapperMonth);
         monthList.forEach(e -> e.setClock("前30日累计"));
         List<CokingOverviewDTO> monthDTOList = ConvertUtils.sourceToTarget(monthList, CokingOverviewDTO.class);
-        monthDTOList.forEach(e -> {
+        for (CokingOverviewDTO e : monthDTOList) {
             e.setProcessTypeName(processName);
             e.setSubProcessTypeName(SubProcessTypeEnum.getEumByCode(e.getSubProcessType()).getProcess());
-        });
+            if (processType.equals(ProcessTypeEnum.BM.getCode())) {
+                // 月占比
+                if (ratioMonth.containsKey(e.getSubProcessType())) {
+                    e.setFsRatio(ratioMonth.get(e.getSubProcessType()).getFsRatioMonth());
+                    e.setGsRatio(ratioMonth.get(e.getSubProcessType()).getGsRatioMonth());
+                    e.setPsRatio(ratioMonth.get(e.getSubProcessType()).getPsRatioMonth());
+                }else {
+                    e.setFsRatio(BigDecimal.ZERO);
+                    e.setGsRatio(BigDecimal.ZERO);
+                    e.setPsRatio(BigDecimal.ZERO);
+                }
+
+            }
+        }
         result.put("month", monthDTOList);
 
         return result;

--
Gitblit v1.9.3