LLL 8 місяців тому
батько
коміт
5ab28cdfc9

+ 209 - 157
jeecg-module-interlock/src/main/java/org/jeecg/modules/history/service/impl/InterlockDetailHistoryServiceImpl.java

@@ -22,8 +22,8 @@ import org.springframework.stereotype.Service;
 
 import java.io.IOException;
 import java.text.SimpleDateFormat;
-import java.util.Date;
-import java.util.List;
+import java.util.*;
+import java.util.concurrent.*;
 
 /**
  * @Description: 联锁详细信息历史数据表
@@ -72,13 +72,52 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
      * 定时任务导出
      * 手动导出
      */
-    public Workbook exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz) throws IOException {
+    public Workbook  exportXlsToFile(InterlockHistoryQueryDTO dto, List<InterlockHistoryDistinctZZXTVO> zzxtvoList, Class<InterlockSummaryHistoryVO> clazz) throws IOException {
+        ExecutorService executor = Executors.newFixedThreadPool(5);
 
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
-        String formattedBeginTime = dto.getBeginTime() != null ? sdf.format(dto.getBeginTime()) : "";
-        String formattedEndTime = dto.getEndTime() != null ? sdf.format(dto.getEndTime()) : "";
+        CompletionService<Void> completionService = new ExecutorCompletionService<>(executor);
+
+        SXSSFWorkbook workbook = new SXSSFWorkbook();
+        Map<String,CellStyle> cellStyleMap = getCellStyle(workbook);
+
+        try{
+            if (zzxtvoList != null) {
+
+                for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList) {
+                    String sheetName =generateSheetName(zzxtvo) ;
+
+                    // 提交每个sheet页的处理任务到线程池
+                    completionService.submit(() -> {
+                        try {
+                            processSheet(workbook, cellStyleMap, sheetName, dto, zzxtvo);
+                        } catch (IOException e) {
+                            e.printStackTrace(); // 处理IOException异常
+                        }
+                    }, null);
+                }
 
-        Workbook workbook = new SXSSFWorkbook();
+                // 等待所有任务完成
+                for (int i = 0; i < zzxtvoList.size(); i++) {
+                    try {
+                        completionService.take().get();
+                    } catch (InterruptedException e) {
+                        e.printStackTrace();
+                    } catch (ExecutionException e) {
+                        e.printStackTrace();
+                    }
+                }
+            }
+        }finally {
+            executor.shutdown(); // 关闭线程池
+        }
+
+        return workbook;
+    }
+
+
+    private Map<String,CellStyle> getCellStyle(Workbook workbook){
+
+        Map<String,CellStyle> cellStyleMap = new HashMap<>();
 
         // 创建字体对象
         Font font = workbook.createFont();
@@ -97,7 +136,7 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
         firstStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
         // 设置字体
         firstStyle.setFont(font);
-
+        cellStyleMap.put("firstStyle",firstStyle);
 
         // 创建居中对齐-加边框-字体加粗的样式
         CellStyle centerAlignStyle = workbook.createCellStyle();
@@ -115,6 +154,7 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
         centerAlignStyle.setRightBorderColor(IndexedColors.BLACK.getIndex());
         // 设置字体
         centerAlignStyle.setFont(font);
+        cellStyleMap.put("centerAlignStyle",centerAlignStyle);
 
         // 创建居中对齐-不加边框-字体加粗的样式
         CellStyle centerAlignStyle1 = workbook.createCellStyle();
@@ -122,11 +162,13 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
         centerAlignStyle1.setVerticalAlignment(VerticalAlignment.CENTER);
         // 设置字体
         centerAlignStyle1.setFont(font);
+        cellStyleMap.put("centerAlignStyle1",centerAlignStyle1);
 
         // 创建居中对齐-不加边框-字体不加粗的样式
         CellStyle centerAlignStyle2 = workbook.createCellStyle();
         centerAlignStyle2.setAlignment(HorizontalAlignment.CENTER);
         centerAlignStyle2.setVerticalAlignment(VerticalAlignment.CENTER);
+        cellStyleMap.put("centerAlignStyle2",centerAlignStyle2);
 
         // 创建居中对齐-加边框-字体不加粗的样式
         CellStyle centerAlignStyle3 = workbook.createCellStyle();
@@ -143,177 +185,187 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
         centerAlignStyle3.setLeftBorderColor(IndexedColors.BLACK.getIndex());
         centerAlignStyle3.setRightBorderColor(IndexedColors.BLACK.getIndex());
         centerAlignStyle3.setFont(font1);
+        cellStyleMap.put("centerAlignStyle3",centerAlignStyle3);
 
-        if (zzxtvoList != null) {
-            for (InterlockHistoryDistinctZZXTVO zzxtvo : zzxtvoList) {
-                dto.setInterlockSystemId(zzxtvo.getInterlockSystemId()); // 系统id
-                List<InterlockSummaryHistoryVO> exportList = this.getForExport(dto);
+        return cellStyleMap;
+    }
 
-                System.out.println("系统开始-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
+    private synchronized SXSSFWorkbook processSheet(SXSSFWorkbook workbook, Map<String,CellStyle> cellStyleMap, String sheetName, InterlockHistoryQueryDTO dto, InterlockHistoryDistinctZZXTVO zzxtvo) throws IOException {
 
-                String sheetName = zzxtvo.getInterlockApparatusName() + "-" + zzxtvo.getInterlockSystemName();
-                Sheet sheet = workbook.createSheet(sheetName);
+        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
+        String formattedBeginTime = dto.getBeginTime() != null ? sdf.format(dto.getBeginTime()) : "";
+        String formattedEndTime = dto.getEndTime() != null ? sdf.format(dto.getEndTime()) : "";
 
-                // 设置列宽——30或15个字符宽度
-                int[] columnWidths = {30, 30, 30, 15, 15, 15, 15, 15};
-                for (int j = 0; j < columnWidths.length; j++) {
-                    sheet.setColumnWidth(j, columnWidths[j] * 256);
-                }
+        dto.setInterlockSystemId(zzxtvo.getInterlockSystemId()); // 系统id
+        List<InterlockSummaryHistoryVO> exportList = this.getForExport(dto);
 
-                // 计算投用率
-                InterlockHistoryQueryDTO dto1 = InterlockSummaryHistoryConvert.INSTANCE.toInterlockStatus(dto, "1"); // 1投用
-                int ty = summaryHistoryMapper.cocuntTYOrHL(dto1);
-                dto1.setInterlockStatus("0"); // 0未投用
-                int wty = summaryHistoryMapper.cocuntTYOrHL(dto1);
-                int total = ty + wty; // 总数量
-                double tyl = (double) ty / total * 100;
-                String tylPercentage = String.format("%.2f%%", tyl); // 将百分比转换为百分数形式,保留两位小数
-
-
-                //第一行:联锁历史数据报表
-                int rowNum = 0;
-                Row titleRow = sheet.createRow(rowNum++);
-                titleRow.setHeightInPoints(19.8f);
-                Cell titleCell = titleRow.createCell(0);
-                titleCell.setCellValue("联锁历史数据报表");
-                titleCell.setCellStyle(firstStyle); // 第一行的样式
-                // 合并第一行的前4列
-                sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, 3));
-
-                // 第二行:报表生成时间:
-                Row secondTitleRow = sheet.createRow(rowNum++);
-                // 设置第2行数据
-                String[] s2 = {"报表生成时间:",sdf.format(new Date()),"","","",""};
-                createCellOfRowWithValueStyle(secondTitleRow,s2,centerAlignStyle2);
-                // 合并第2行的后5列
-                sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
-
-                // 第3行:装置名称
-                Row thirdTitleRow = sheet.createRow(rowNum++);
-                // 设置第3行数据
-                String[] s3 = {"装置名称:",zzxtvo.getInterlockApparatusName(),"","","",""};
-                CellStyle[] style3 = {centerAlignStyle,centerAlignStyle3,centerAlignStyle3,centerAlignStyle3,centerAlignStyle3,centerAlignStyle3};
-                createCellOfRowWithValueStyleName(thirdTitleRow,s3,style3);
-                // 合并第3行的后5列
-                sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
-
-                // 第四行:系统名称
-                Row fourthTitleRow = sheet.createRow(rowNum++);
-                // 设置第4行数据
-                String[] s4 = {"系统名称:",zzxtvo.getInterlockSystemName(),"","","",""};
-                CellStyle[] style4 = {centerAlignStyle,centerAlignStyle3,centerAlignStyle3,centerAlignStyle3,centerAlignStyle3,centerAlignStyle3};
-                createCellOfRowWithValueStyleName(fourthTitleRow,s4,style4);
-                // 合并第4行的后5列
-                sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
-
-                //第五行:起始时间、结束时间
-                Row fifthTitleRow = sheet.createRow(rowNum++);
-                //设置第5行数据
-                String[] s5 = {"起始时间:",formattedBeginTime,"","结束时间:",formattedEndTime,""};
-                CellStyle[] style5 = {centerAlignStyle,centerAlignStyle3,centerAlignStyle3,centerAlignStyle,centerAlignStyle3,centerAlignStyle3};
-                createCellOfRowWithValueStyleName(fifthTitleRow,s5,style5);
-                // 分别合并第2、3列 和 第5、6列
-                sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 2));
-                sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 4, 5));
-
-                //第六行:连锁数量、未投用联锁数量、投用率统计
-                Row sixTitleRow = sheet.createRow(rowNum++);
-                String[] s6 = {"联锁数量:", String.valueOf(total),"未投用联锁数量:", String.valueOf(wty),"投用率统计:", String.valueOf(tylPercentage)};
-                CellStyle[] style6 = {centerAlignStyle,centerAlignStyle3,centerAlignStyle,centerAlignStyle3,centerAlignStyle,centerAlignStyle3};
-                createCellOfRowWithValueStyleName(sixTitleRow,s6,style6);
-
-                //第七行空白
-                rowNum++;
-
-                //第8行:历史数据
-                Row eightTitleRow = sheet.createRow(rowNum++);
-                //设置第8行数据
-                createCellWithValueStyle(eightTitleRow, 0, "历史数据:", centerAlignStyle1);
-
-                //第9行:列名
-                Row columnRow= sheet.createRow(rowNum++);
-                String[] s9 = {"采集时间", "联锁名称", "联锁条件点位", "仪表状态", "控制系统状态", "旁路状态", "联锁状态", "回路健康级别"};
-                // 各列索引
-                int tagTimeCol= 0;
-                int interlockNameCol = 1;
-                int interlockStatusCol = 6;
-                int loopHealthLevelCol = 7;
-                createCellOfRowWithValueStyle(columnRow,s9,centerAlignStyle);
-
-
-                // 合并单元格的起始行索引
-                int startTagTimeRow = 0;
-                int startInterlockNameRow = 0;
-                int startInterlockStatusRow = 0;
-                int startLoopHealthLevelRow = 0;
-
-                for (int idx = 0; idx < exportList.size(); idx++)  {
-                    InterlockSummaryHistoryVO record = exportList.get(idx);
-
-                    //创建单元格、设置格式、填充数据
-                    Row row = sheet.createRow(rowNum);
-                    String[] s = {record.getTagTime(), record.getInterlockname(), record.getInterlockConditionTag(), record.getInstrumentStatusName(), record.getControlSystemStatusName(), record.getBypassName(), record.getInterlockStatusName(), record.getLoopHealthLevel()};
-                    createCellOfRowWithValueStyle(row,s,centerAlignStyle3);
-
-                    // 合并 "采集时间" 列单元格
-                    if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime())) {
-                        if (idx > 0 && (rowNum - startTagTimeRow) > 1) {
-                            sheet.addMergedRegion(new CellRangeAddress(startTagTimeRow, rowNum - 1, tagTimeCol, tagTimeCol));
-                        }
-                        startTagTimeRow = rowNum;
-                    }
+        System.out.println("系统开始-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
 
-                    // 合并 "联锁名称" 列单元格,基于 "采集时间"
-                    if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname())) {
-                        if (idx > 0 && (rowNum - startInterlockNameRow) > 1) {
-                            sheet.addMergedRegion(new CellRangeAddress(startInterlockNameRow, rowNum - 1, interlockNameCol, interlockNameCol));
-                        }
-                        startInterlockNameRow = rowNum;
-                    }
 
-                    // 合并 "联锁状态" 列单元格,基于 "采集时间"
-                    if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime())) {
-                        if (idx > 0 && (rowNum - startInterlockStatusRow) > 1) {
-                            sheet.addMergedRegion(new CellRangeAddress(startInterlockStatusRow, rowNum - 1, interlockStatusCol, interlockStatusCol));
-                        }
-                        startInterlockStatusRow = rowNum;
-                    }
-
-                    // 合并 "回路健康状态" 列单元格,基于 "采集时间"
-                    if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime())) {
-                        if (idx > 0 && (rowNum - startLoopHealthLevelRow) > 1) {
-                            sheet.addMergedRegion(new CellRangeAddress(startLoopHealthLevelRow, rowNum - 1, loopHealthLevelCol, loopHealthLevelCol));
-                        }
-                        startLoopHealthLevelRow = rowNum;
-                    }
+        Sheet sheet = workbook.createSheet(sheetName);
 
-                    rowNum++;
-                }
+        // 设置列宽——30或15个字符宽度
+        int[] columnWidths = {30, 30, 30, 15, 15, 15, 15, 15};
+        for (int j = 0; j < columnWidths.length; j++) {
+            sheet.setColumnWidth(j, columnWidths[j] * 256);
+        }
 
-                // 最后一组合并区域的处理
-                // 合并 "采集时间" 列的最后一组
-                if ((rowNum - startTagTimeRow) > 1) {
+        // 计算投用率
+        InterlockHistoryQueryDTO dto1 = InterlockSummaryHistoryConvert.INSTANCE.toInterlockStatus(dto, "1"); // 1投用
+        int ty = summaryHistoryMapper.cocuntTYOrHL(dto1);
+        dto1.setInterlockStatus("0"); // 0未投用
+        int wty = summaryHistoryMapper.cocuntTYOrHL(dto1);
+        int total = ty + wty; // 总数量
+        double tyl = (double) ty / total * 100;
+        String tylPercentage = String.format("%.2f%%", tyl); // 将百分比转换为百分数形式,保留两位小数
+
+
+        //第一行:联锁历史数据报表
+        int rowNum = 0;
+        Row titleRow = sheet.createRow(rowNum++);
+        titleRow.setHeightInPoints(19.8f);
+        Cell titleCell = titleRow.createCell(0);
+        titleCell.setCellValue("联锁历史数据报表");
+        titleCell.setCellStyle(cellStyleMap.get("firstStyle")); // 第一行的样式
+        // 合并第一行的前4列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 0, 3));
+
+        // 第二行:报表生成时间:
+        Row secondTitleRow = sheet.createRow(rowNum++);
+        // 设置第2行数据
+        String[] s2 = {"报表生成时间:",sdf.format(new Date()),"","","",""};
+        createCellOfRowWithValueStyle(secondTitleRow,s2,cellStyleMap.get("centerAlignStyle2"));
+        // 合并第2行的后5列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
+
+        // 第3行:装置名称
+        Row thirdTitleRow = sheet.createRow(rowNum++);
+        // 设置第3行数据
+        String[] s3 = {"装置名称:",zzxtvo.getInterlockApparatusName(),"","","",""};
+        CellStyle[] style3 = {cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3")};
+        createCellOfRowWithValueStyleName(thirdTitleRow,s3,style3);
+        // 合并第3行的后5列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
+
+        // 第四行:系统名称
+        Row fourthTitleRow = sheet.createRow(rowNum++);
+        // 设置第4行数据
+        String[] s4 = {"系统名称:",zzxtvo.getInterlockSystemName(),"","","",""};
+        createCellOfRowWithValueStyleName(fourthTitleRow,s4,style3); //与第三行样式相同style3
+        // 合并第4行的后5列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 5));
+
+        //第五行:起始时间、结束时间
+        Row fifthTitleRow = sheet.createRow(rowNum++);
+        //设置第5行数据
+        String[] s5 = {"起始时间:",formattedBeginTime,"","结束时间:",formattedEndTime,""};
+        CellStyle[] style5 = {cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle3")};
+        createCellOfRowWithValueStyleName(fifthTitleRow,s5,style5);
+        // 分别合并第2、3列 和 第5、6列
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 1, 2));
+        sheet.addMergedRegion(new CellRangeAddress(rowNum-1, rowNum-1, 4, 5));
+
+        //第六行:连锁数量、未投用联锁数量、投用率统计
+        Row sixTitleRow = sheet.createRow(rowNum++);
+        String[] s6 = {"联锁数量:", String.valueOf(total),"未投用联锁数量:", String.valueOf(wty),"投用率统计:", String.valueOf(tylPercentage)};
+        CellStyle[] style6 = {cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3"),cellStyleMap.get("centerAlignStyle"),cellStyleMap.get("centerAlignStyle3")};
+        createCellOfRowWithValueStyleName(sixTitleRow,s6,style6);
+
+        //第七行空白
+        rowNum++;
+
+        //第8行:历史数据
+        Row eightTitleRow = sheet.createRow(rowNum++);
+        //设置第8行数据
+        createCellWithValueStyle(eightTitleRow, 0, "历史数据:", cellStyleMap.get("centerAlignStyle1"));
+
+        //第9行:列名
+        Row columnRow= sheet.createRow(rowNum++);
+        String[] s9 = {"采集时间", "联锁名称", "联锁条件点位", "仪表状态", "控制系统状态", "旁路状态", "联锁状态", "回路健康级别"};
+        // 各列索引
+        int tagTimeCol= 0;
+        int interlockNameCol = 1;
+        int interlockStatusCol = 6;
+        int loopHealthLevelCol = 7;
+        createCellOfRowWithValueStyle(columnRow,s9,cellStyleMap.get("centerAlignStyle"));
+
+
+        // 合并单元格的起始行索引
+        int startTagTimeRow = 0;
+        int startInterlockNameRow = 0;
+        int startInterlockStatusRow = 0;
+        int startLoopHealthLevelRow = 0;
+
+        for (int idx = 0; idx < exportList.size(); idx++)  {
+            InterlockSummaryHistoryVO record = exportList.get(idx);
+
+            //创建单元格、设置格式、填充数据
+            Row row = sheet.createRow(rowNum);
+            String[] s = {record.getTagTime(), record.getInterlockname(), record.getInterlockConditionTag(), record.getInstrumentStatusName(), record.getControlSystemStatusName(), record.getBypassName(), record.getInterlockStatusName(), record.getLoopHealthLevel()};
+            createCellOfRowWithValueStyle(row,s,cellStyleMap.get("centerAlignStyle3"));
+
+            // 合并 "采集时间" 列单元格
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname()) ) {
+                if (idx > 0 && (rowNum - startTagTimeRow) > 1) {
                     sheet.addMergedRegion(new CellRangeAddress(startTagTimeRow, rowNum - 1, tagTimeCol, tagTimeCol));
                 }
-                // 合并 "联锁名称" 列的最后一组
-                if ((rowNum - startInterlockNameRow) > 1) {
+                startTagTimeRow = rowNum;
+            }
+
+            // 合并 "联锁名称" 列单元格,基于 "采集时间"
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname()) ) {
+                if (idx > 0 && (rowNum - startInterlockNameRow) > 1) {
                     sheet.addMergedRegion(new CellRangeAddress(startInterlockNameRow, rowNum - 1, interlockNameCol, interlockNameCol));
                 }
-                // 合并 "联锁状态" 列的最后一组
-                if ((rowNum - startInterlockStatusRow) > 1) {
+                startInterlockNameRow = rowNum;
+            }
+
+            // 合并 "联锁状态" 列单元格,基于 "采集时间"
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname())) {
+                if (idx > 0 && (rowNum - startInterlockStatusRow) > 1) {
                     sheet.addMergedRegion(new CellRangeAddress(startInterlockStatusRow, rowNum - 1, interlockStatusCol, interlockStatusCol));
                 }
-                // 合并 "回路健康状态" 列的最后一组
-                if ((rowNum - startLoopHealthLevelRow) > 1) {
+                startInterlockStatusRow = rowNum;
+            }
+
+            // 合并 "回路健康状态" 列单元格,基于 "采集时间"
+            if (idx == 0 || !record.getTagTime().equals(exportList.get(idx - 1).getTagTime()) || !record.getInterlockname().equals(exportList.get(idx - 1).getInterlockname())) {
+                if (idx > 0 && (rowNum - startLoopHealthLevelRow) > 1) {
                     sheet.addMergedRegion(new CellRangeAddress(startLoopHealthLevelRow, rowNum - 1, loopHealthLevelCol, loopHealthLevelCol));
                 }
-                System.out.println("系统结束-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
-
+                startLoopHealthLevelRow = rowNum;
             }
+
+            rowNum++;
+        }
+
+        // 最后一组合并区域的处理
+        // 合并 "采集时间" 列的最后一组
+        if ((rowNum - startTagTimeRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startTagTimeRow, rowNum - 1, tagTimeCol, tagTimeCol));
+        }
+        // 合并 "联锁名称" 列的最后一组
+        if ((rowNum - startInterlockNameRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startInterlockNameRow, rowNum - 1, interlockNameCol, interlockNameCol));
         }
+        // 合并 "联锁状态" 列的最后一组
+        if ((rowNum - startInterlockStatusRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startInterlockStatusRow, rowNum - 1, interlockStatusCol, interlockStatusCol));
+        }
+        // 合并 "回路健康状态" 列的最后一组
+        if ((rowNum - startLoopHealthLevelRow) > 1) {
+            sheet.addMergedRegion(new CellRangeAddress(startLoopHealthLevelRow, rowNum - 1, loopHealthLevelCol, loopHealthLevelCol));
+        }
+        System.out.println("系统结束-----------------------------------------------------------------------------------"+zzxtvo.getInterlockSystemName());
+
         return workbook;
     }
 
+
+    private String generateSheetName(InterlockHistoryDistinctZZXTVO zzxtvo){
+        return zzxtvo.getInterlockApparatusName() + "-" + zzxtvo.getInterlockSystemName();
+    }
+
     //创建单元格,每个单元格都有自己的样式
     private static void createCellOfRowWithValueStyleName(Row row, String[] s1, CellStyle[] style) {
         int i = 0;