From c971825d2a2bc48c74f2ffe97127b50b14445e12 Mon Sep 17 00:00:00 2001
From: whycxzp <glperry@163.com>
Date: 星期一, 09 六月 2025 20:56:16 +0800
Subject: [PATCH] 压入变动的时间列的总电压和电流

---
 src/main/java/com/whyc/service/ExcelService.java |  175 ++++++++++++++++++++++++++++++++++++++++++++++++----------
 1 files changed, 144 insertions(+), 31 deletions(-)

diff --git a/src/main/java/com/whyc/service/ExcelService.java b/src/main/java/com/whyc/service/ExcelService.java
index a65dc88..4927078 100644
--- a/src/main/java/com/whyc/service/ExcelService.java
+++ b/src/main/java/com/whyc/service/ExcelService.java
@@ -588,9 +588,13 @@
         CellRangeAddress region25 = new CellRangeAddress(1, 1,  18, 24);
         sheet.addMergedRegion(region25);
 
-        //绗笁琛岀殑鍚堝苟鍒�,鍓嶄袱涓崟鍏冩ā鍧楁槸鍥哄畾鐨�,鍏朵腑1涓悎骞跺崟鍏�
+        //绗笁琛�,绗簲琛�,绗叚琛岀殑鍚堝苟鍒�,鍓嶄袱涓崟鍏冩ā鍧楁槸鍥哄畾鐨�,鍏朵腑1涓悎骞跺崟鍏�
         CellRangeAddress region31 = new CellRangeAddress(2, 2,  2, 3);
+        CellRangeAddress region51 = new CellRangeAddress(4, 4,  2, 3);
+        CellRangeAddress region61 = new CellRangeAddress(5, 5,  2, 3);
         sheet.addMergedRegion(region31);
+        sheet.addMergedRegion(region51);
+        sheet.addMergedRegion(region61);
 
 
         // 鍒涘缓灞呬腑鏍峰紡
@@ -633,6 +637,9 @@
         //绗洓琛屾槸鐢靛帇鍒楀拰娓╁害鍒楁爣璇�
         XSSFRow row2 = sheet.createRow(2);
         XSSFRow row3 = sheet.createRow(3);
+        XSSFRow row4 = sheet.createRow(4);
+        XSSFRow row5 = sheet.createRow(5);
+
         row2.createCell(0).setCellValue("钃勭數姹犲彿锛�#锛�");
         row2.createCell(1).setCellValue("钃勭數姹犳诞鍏呯數鍘嬪�硷紙V锛�");
         row2.createCell(2).setCellValue("鏀剧數鍓嶈搫鐢垫睜寮�璺數鍘嬪�硷紙V锛�");
@@ -647,14 +654,26 @@
         if(dischargeColumnCount > 0){
             row2.createCell(5).setCellValue("鏀剧數0.5h钃勭數姹犵數鍘嬪�硷紙V锛�");
             CellRangeAddress region33 = new CellRangeAddress(2, 2,  4, 5);
+            CellRangeAddress region53 = new CellRangeAddress(4, 4,  4, 5);
+            CellRangeAddress region63 = new CellRangeAddress(5, 5,  4, 5);
+
             sheet.addMergedRegion(region33);
+            sheet.addMergedRegion(region53);
+            sheet.addMergedRegion(region63);
+
             row3.createCell(4).setCellValue("0.5锛堢數鍘嬶級");
             row3.createCell(5).setCellValue("0.5锛堟俯搴︼級");
             columnIndex+=2;
             if(dischargeColumnCount > 2){ //鍚堝苟鍗曞厓鏍间簡,鎵�浠ョ储寮�+2
                 row2.createCell(7).setCellValue("鏀剧數1h钃勭數姹犵數鍘嬪�硷紙V锛�");
                 CellRangeAddress region34 = new CellRangeAddress(2, 2,  6, 7);
+                CellRangeAddress region54 = new CellRangeAddress(4, 2,  6, 7);
+                CellRangeAddress region64 = new CellRangeAddress(5, 2,  6, 7);
+
                 sheet.addMergedRegion(region34);
+                sheet.addMergedRegion(region54);
+                sheet.addMergedRegion(region64);
+
                 row3.createCell(6).setCellValue("1锛堢數鍘嬶級");
                 row3.createCell(7).setCellValue("1锛堟俯搴︼級");
                 columnIndex+=2;
@@ -695,48 +714,118 @@
 
 
 
-        //浠巖owIndex=6寮�濮�
-        int rowIndex = 6;
+        //浠巖owIndex=4寮�濮�
+        int rowIndex = 4;
         // 鍏�104鑺傚崟浣�,104琛�. 杩涜閬嶅巻,濉厖
         //钃勭數姹犳诞鍏呯數鍘嬪�煎垪琛�
         List<BattRealTimeDataHistory> fcVolList = new ArrayList<>();
-        fcVolList = battRTDataHisService.getFcVolList(battGroupId,dischargeStartTime);
+        List<BattRealTimeDataHistory> fcVolListOriginal = battRTDataHisService.getFcVolList(battGroupId,dischargeStartTime);
         //鎸夊崟浣撶紪鍙锋帓搴�,鎸夌紪鍙峰崌搴�
-        fcVolList.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
+        fcVolListOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
+        addStatistics(fcVolListOriginal,"vol");
+        //鎬荤數娴佹�荤數鍘嬪垪鍏�
+        Float fcGroupVol = fcVolListOriginal.get(0).getGroupVol();
+        Float fcGroupCurr = fcVolListOriginal.get(0).getGroupCurr();
+
+        BattRealTimeDataHistory fcGroupVolData = new BattRealTimeDataHistory();
+        fcGroupVolData.setMonNum(-2);
+        fcGroupVolData.setGroupVol(fcGroupVol);
+
+        BattRealTimeDataHistory fcGroupCurrData = new BattRealTimeDataHistory();
+        fcGroupCurrData.setMonNum(-1);
+        fcGroupCurrData.setGroupCurr(fcGroupCurr);
+
+        fcVolList.add(fcGroupVolData);
+        fcVolList.add(fcGroupCurrData);
+        fcVolList.addAll(fcVolListOriginal);
+
         //鏀剧偣鍓嶈搫鐢垫睜寮�璺數鍘嬪��
         List<BattRealTimeDataHistory> preVolList = new ArrayList<>();
-        preVolList = battRTDataHisService.getPreVolList(battGroupId,dischargeStartTime);
+        List<BattRealTimeDataHistory> preVolListOriginal = battRTDataHisService.getPreVolList(battGroupId,dischargeStartTime);
+        addStatistics(preVolListOriginal,"vol","tmp");
+        //鎬荤數娴佹�荤數鍘嬪垪鍏�
+        Float preGroupVol = preVolListOriginal.get(0).getGroupVol();
+        Float preGroupCurr = preVolListOriginal.get(0).getGroupCurr();
 
-        addStatistics(fcVolList,"vol");
-        addStatistics(preVolList,"vol","tmp");
+        BattRealTimeDataHistory preGroupVolData = new BattRealTimeDataHistory();
+        preGroupVolData.setMonNum(-2);
+        preGroupVolData.setGroupVol(preGroupVol);
+
+        BattRealTimeDataHistory preGroupCurrData = new BattRealTimeDataHistory();
+        preGroupCurrData.setMonNum(-1);
+        preGroupCurrData.setGroupCurr(preGroupCurr);
+
+        preVolList.add(preGroupVolData);
+        preVolList.add(preGroupCurrData);
+        preVolList.addAll(preVolListOriginal);
 
         //鏀剧數缁撴潫0.5h鍚庤搫鐢垫睜寮�璺數鍘嬪��
         Calendar dischargeEndCalendar = Calendar.getInstance();
         dischargeEndCalendar.setTime(dischargeEndTime.getTime());
         dischargeEndCalendar.add(Calendar.MINUTE,30);
-        List<BattRealTimeDataHistory> dischargeSetVolListOne = battRTDataHisService.getRecordList(battGroupId, dischargeEndCalendar.getTime());
-        dischargeSetVolListOne.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
-        addStatistics(dischargeSetVolListOne,"vol","tmp");
+        List<BattRealTimeDataHistory> dischargeSetVolListOne = new ArrayList<>();
+        List<BattRealTimeDataHistory> dischargeSetVolListOneOriginal = battRTDataHisService.getRecordList(battGroupId, dischargeEndCalendar.getTime());
+        dischargeSetVolListOneOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
+        addStatistics(dischargeSetVolListOneOriginal,"vol","tmp");
+        //鎬荤數娴佹�荤數鍘嬪垪鍏�
+        Float groupVolOne = dischargeSetVolListOneOriginal.get(0).getGroupVol();
+        Float groupCurrOne = dischargeSetVolListOneOriginal.get(0).getGroupCurr();
+
+        BattRealTimeDataHistory groupVolDataOne = new BattRealTimeDataHistory();
+        groupVolDataOne.setMonNum(-2);
+        groupVolDataOne.setGroupVol(groupVolOne);
+
+        BattRealTimeDataHistory groupCurrDataOne = new BattRealTimeDataHistory();
+        groupCurrDataOne.setMonNum(-1);
+        groupCurrDataOne.setGroupCurr(groupCurrOne);
+
+        dischargeSetVolListOne.add(groupVolDataOne);
+        dischargeSetVolListOne.add(groupCurrDataOne);
+        dischargeSetVolListOne.addAll(dischargeSetVolListOneOriginal);
+
         //瀹氫綅鍒板厖鐢靛紑濮嬫椂闂�,鐘舵�佸彉涓哄厖鐢电殑璁板綍鏃堕棿
         Date chargeStartTime = battRTDataHisService.getChargeStartTime(battGroupId, dischargeEndTime.getTime());
         //鍏呮弧鍚庤搫鐢垫睜鐨勭數鍘�
         Calendar chargeCalendar = Calendar.getInstance();
         chargeCalendar.setTime(chargeStartTime);
-        List<BattRealTimeDataHistory> fcVolListAfter = battRTDataHisService.getFcVolListAfter(battGroupId, chargeCalendar.getTime());
-        fcVolListAfter.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
-        addStatistics(fcVolListAfter,"vol","tmp");
+        List<BattRealTimeDataHistory> fcVolListAfter = new ArrayList<>();
+        List<BattRealTimeDataHistory> fcVolListAfterOriginal = battRTDataHisService.getFcVolListAfter(battGroupId, chargeCalendar.getTime());
+        fcVolListAfterOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
+        addStatistics(fcVolListAfterOriginal,"vol","tmp");
+        //鎬荤數娴佹�荤數鍘嬪垪鍏�
+        if(fcVolListAfterOriginal.size()>0) {
+            Float groupVolAfter = fcVolListAfterOriginal.get(0).getGroupVol();
+            Float groupCurrAfter = fcVolListAfterOriginal.get(0).getGroupCurr();
 
-        //涓�鍏�104鑺傚崟浣�,鍐嶅姞涓婄粺璁℃暟鎹�4鍒�,涓�鍏�108
-        for(int j = 0; j < 108; j++){
+            BattRealTimeDataHistory groupVolDataAfter = new BattRealTimeDataHistory();
+            groupVolDataAfter.setMonNum(-2);
+            groupVolDataAfter.setGroupVol(groupVolAfter);
+
+            BattRealTimeDataHistory groupCurrDataAfter = new BattRealTimeDataHistory();
+            groupCurrDataAfter.setMonNum(-1);
+            groupCurrDataAfter.setGroupCurr(groupCurrAfter);
+
+            fcVolListAfter.add(groupVolDataAfter);
+            fcVolListAfter.add(groupCurrDataAfter);
+            fcVolListAfter.addAll(fcVolListAfterOriginal);
+        }
+
+        //涓�鍏�104鑺傚崟浣�,鍐嶅姞涓婂墠闈㈡�荤數鍘嬪拰鎬荤數娴�2鍒�,鍚庨潰缁熻鏁版嵁4鍒�,涓�鍏�110
+        for(int j = 0; j < 110; j++){
             XSSFRow rowTemp = sheet.createRow(rowIndex++);
-            if(j<104) {
-                rowTemp.createCell(0).setCellValue((j + 1) + "#");
+            if(j == 0){
+                rowTemp.createCell(0).setCellValue("鎬荤數鍘�");
+            }else if(j == 1){
+                rowTemp.createCell(0).setCellValue("鎬荤數娴�");
+            }
+            else if(j<106) {
+                rowTemp.createCell(0).setCellValue((j - 1) + "#");
             }else{
-                if(j == 104){
+                if(j == 106){
                     rowTemp.createCell(0).setCellValue("鍗曡妭骞冲潎鐢靛帇");
-                }else if (j == 105){
+                }else if (j == 107){
                     rowTemp.createCell(0).setCellValue("鍗曡妭鏈�澶х數鍘�");
-                }else if (j == 106){
+                }else if (j == 108){
                     rowTemp.createCell(0).setCellValue("鍗曡妭鏈�灏忕數鍘�");
                 }else{
                     rowTemp.createCell(0).setCellValue("鍗曡妭鏈�澶у樊鍊�");
@@ -746,10 +835,19 @@
             //rowTemp.createCell(2).setCellValue("钃勭數姹犳诞鍏呮俯搴﹀��:"+(j+1)+"#");
             //rowTemp.createCell(3).setCellValue("鏀剧數鍓嶈搫鐢垫睜寮�璺數鍘嬪�硷紙V锛�:"+(j+1)+"#");
             //rowTemp.createCell(4).setCellValue("鏀剧數鍓嶈搫鐢垫睜寮�璺俯搴﹀��:"+(j+1)+"#");
-            rowTemp.createCell(1).setCellValue(fcVolList.get(j).getMonVol());
-
-            rowTemp.createCell(2).setCellValue(preVolList.get(j).getMonVol());
-            rowTemp.createCell(3).setCellValue(preVolList.get(j).getMonTmp());
+            if(j == 0){
+                rowTemp.createCell(1).setCellValue(fcVolList.get(j).getGroupVol());
+                rowTemp.createCell(2).setCellValue(preVolList.get(j).getGroupVol());
+                rowTemp.createCell(3);
+            }else if (j == 1){
+                rowTemp.createCell(1).setCellValue(fcVolList.get(j).getGroupCurr());
+                rowTemp.createCell(2).setCellValue(preVolList.get(j).getGroupCurr());
+                rowTemp.createCell(3);
+            }else {
+                rowTemp.createCell(1).setCellValue(fcVolList.get(j).getMonVol());
+                rowTemp.createCell(2).setCellValue(preVolList.get(j).getMonVol());
+                rowTemp.createCell(3).setCellValue(preVolList.get(j).getMonTmp());
+            }
 
 
             //鏀剧數鐗瑰畾鐢靛帇鍊�
@@ -760,10 +858,14 @@
                 //鏃堕棿鍦ㄦ祴璇曞紑濮嬫椂闂�+0.5h
                 dischargeCalendar.add(Calendar.MINUTE,30);
                 Date recordTime = dischargeCalendar.getTime();
-                List<BattRealTimeDataHistory> dischargeListOne = battRTDataHisService.getRecordList(battGroupId,recordTime);
+                List<BattRealTimeDataHistory> dischargeListOne  = new ArrayList<>();
+                List<BattRealTimeDataHistory> dischargeListOneOriginal = battRTDataHisService.getRecordList(battGroupId,recordTime);
                 //鎸夊崟浣撶紪鍙锋帓搴�,鎸夌紪鍙峰崌搴�
-                dischargeListOne.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
-                addStatistics(dischargeListOne,"vol");
+                dischargeListOneOriginal.sort(Comparator.comparingInt(BattRealTimeDataHistory::getMonNum));
+                addStatistics(dischargeListOneOriginal,"vol");
+                //鎬荤數娴佹�荤數鍘嬪垪鍏�
+
+
                 //rowTemp.createCell(5).setCellValue("鏀剧數0.5h鐢靛帇鍊硷紙V锛�:"+(j+1)+"#");
                 //rowTemp.createCell(6).setCellValue("鏀剧數0.5h娓╁害鍊�:"+(j+1)+"#");
                 rowTemp.createCell(4).setCellValue(dischargeListOne.get(j).getMonVol());
@@ -804,8 +906,13 @@
             }
 
             //濉厖鏀剧數0.5h鍚庡紑璺數鍘嬪��
-            rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getMonVol());
-
+            if(j == 0){
+                rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getGroupVol());
+            }else if(j == 1){
+                rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getGroupCurr());
+            }else {
+                rowTemp.createCell(++columnIndexTemp).setCellValue(dischargeSetVolListOne.get(j).getMonVol());
+            }
 
             if(chargeColumnCount > 0){
                 chargeCalendar = Calendar.getInstance();
@@ -838,7 +945,13 @@
             //濉厖鍏呮弧鍚庤搫鐢垫睜鐢靛帇
             //rowTemp.createCell(++columnIndexTemp).setCellValue("鍏呮弧鍚庤搫鐢垫睜鐢靛帇鍊硷紙V)锛堢數娴佷负0锛�");
             if (fcVolListAfter.size() > 0){
-                rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getMonVol());
+                if(j ==  0){
+                    rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getGroupVol());
+                }else if(j == 1){
+                    rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getGroupCurr());
+                }else {
+                    rowTemp.createCell(++columnIndexTemp).setCellValue(fcVolListAfter.get(j).getMonVol());
+                }
             }else {
                 rowTemp.createCell(++columnIndexTemp).setCellValue("-");
             }

--
Gitblit v1.9.1