|
@@ -551,8 +551,12 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
|
|
|
int ty = summaryHistoryMapper.cocuntTY11(dto);
|
|
|
int wty = summaryHistoryMapper.cocuntWTY11(dto);
|
|
|
int total = ty + wty; // 总数量
|
|
|
- double tyl = (double) ty / total * 100;
|
|
|
- String tylPercentage = String.format("%.2f%%", tyl); // 将百分比转换为百分数形式,保留两位小数
|
|
|
+ String tylPercentage = "0.00%";//如果没有历史数据,投用率为0
|
|
|
+ if(total!=0){
|
|
|
+ double tyl = (double) ty / total * 100;
|
|
|
+ tylPercentage = String.format("%.2f%%", tyl); // 将百分比转换为百分数形式,保留两位小数
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
//第一行:联锁历史数据报表
|
|
|
int rowNum = 0;
|
|
@@ -627,72 +631,74 @@ public class InterlockDetailHistoryServiceImpl extends ServiceImpl<InterlockDeta
|
|
|
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(exportList.size()!=0){
|
|
|
+ // 合并单元格的起始行索引
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ startTagTimeRow = rowNum;
|
|
|
}
|
|
|
- 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 (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;
|
|
|
}
|
|
|
- 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 (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));
|
|
|
+ }
|
|
|
+ startInterlockStatusRow = rowNum;
|
|
|
}
|
|
|
- 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));
|
|
|
+ // 合并 "回路健康状态" 列单元格,基于 "采集时间"
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ startLoopHealthLevelRow = rowNum;
|
|
|
}
|
|
|
- startLoopHealthLevelRow = rowNum;
|
|
|
- }
|
|
|
|
|
|
- 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));
|
|
|
+ // 最后一组合并区域的处理
|
|
|
+ // 合并 "采集时间" 列的最后一组
|
|
|
+ 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());
|
|
|
|