|
|
@ -6,9 +6,7 @@ import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
|
import com.hnac.hzims.operational.report.entity.RunMonthEntity; |
|
|
|
import com.hnac.hzims.operational.report.entity.RunMonthEntity; |
|
|
|
import com.hnac.hzims.operational.report.mapper.RunMonthMapper; |
|
|
|
import com.hnac.hzims.operational.report.mapper.RunMonthMapper; |
|
|
|
import com.hnac.hzims.operational.report.service.RunMonthService; |
|
|
|
import com.hnac.hzims.operational.report.service.RunMonthService; |
|
|
|
import com.hnac.hzims.operational.report.vo.RunAlarmVo; |
|
|
|
import com.hnac.hzims.operational.report.vo.*; |
|
|
|
import com.hnac.hzims.operational.report.vo.RunDataShowVo; |
|
|
|
|
|
|
|
import com.hnac.hzims.operational.report.vo.RunDataVo; |
|
|
|
|
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.AllArgsConstructor; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
|
import org.apache.poi.hssf.usermodel.*; |
|
|
@ -33,7 +31,10 @@ import java.io.IOException; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.BigDecimal; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.math.RoundingMode; |
|
|
|
import java.net.URLEncoder; |
|
|
|
import java.net.URLEncoder; |
|
|
|
|
|
|
|
import java.util.ArrayList; |
|
|
|
|
|
|
|
import java.util.Collections; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* @author ysj |
|
|
|
* @author ysj |
|
|
@ -81,6 +82,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
return data; |
|
|
|
return data; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 导出站点月报文件 |
|
|
|
* 导出站点月报文件 |
|
|
|
* @param mon |
|
|
|
* @param mon |
|
|
@ -130,7 +132,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
// 添加sheet页
|
|
|
|
// 添加sheet页
|
|
|
|
HSSFSheet sheet = hssWB.createSheet(headerName); |
|
|
|
HSSFSheet sheet = hssWB.createSheet(headerName); |
|
|
|
// 绘制表格行标
|
|
|
|
// 绘制表格行标
|
|
|
|
int row = 2; |
|
|
|
int row = 1; |
|
|
|
// 行高
|
|
|
|
// 行高
|
|
|
|
sheet.setDefaultRowHeight((short) (20 * 25)); |
|
|
|
sheet.setDefaultRowHeight((short) (20 * 25)); |
|
|
|
// 列宽
|
|
|
|
// 列宽
|
|
|
@ -139,36 +141,36 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
this.firstHeader(hssWB, sheet , headerName); |
|
|
|
this.firstHeader(hssWB, sheet , headerName); |
|
|
|
// 一、表头格式设置
|
|
|
|
// 一、表头格式设置
|
|
|
|
this.titleHeader(hssWB, sheet,"1、运行数据总汇",row); |
|
|
|
this.titleHeader(hssWB, sheet,"1、运行数据总汇",row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
// 运行数据表头
|
|
|
|
// 运行数据表头
|
|
|
|
this.runDataHeader(hssWB,sheet,row); |
|
|
|
this.runDataHeader(hssWB,sheet,row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
// 运行数据填充
|
|
|
|
// 运行数据填充
|
|
|
|
List<RunDataVo> runData = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){}); |
|
|
|
List<RunDataVo> runData = JSONObject.parseObject(entity.getRunData(),new TypeReference<List<RunDataVo>>(){}); |
|
|
|
row = this.runDataFill(hssWB,sheet,row,runData); |
|
|
|
row = this.runDataFill(hssWB,sheet,row,runData); |
|
|
|
// 二、表头格式设置
|
|
|
|
// 二、表头格式设置
|
|
|
|
this.titleHeader(hssWB, sheet,"2、告警报表",row); |
|
|
|
this.titleHeader(hssWB, sheet,"2、告警报表",row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
// 告警数据表头
|
|
|
|
// 告警数据表头
|
|
|
|
this.alarmHeader(hssWB,sheet,row); |
|
|
|
this.alarmHeader(hssWB,sheet,row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
// 告警数据填充
|
|
|
|
// 告警数据填充
|
|
|
|
List<RunAlarmVo> runAlarm = JSONObject.parseObject(entity.getAlarmData(),new TypeReference<List<RunAlarmVo>>(){}); |
|
|
|
List<RunAlarmVo> runAlarm = JSONObject.parseObject(entity.getAlarmData(),new TypeReference<List<RunAlarmVo>>(){}); |
|
|
|
row = this.alarmDataFill(hssWB,sheet,row,runAlarm); |
|
|
|
row = this.alarmDataFill(hssWB,sheet,row,runAlarm); |
|
|
|
|
|
|
|
|
|
|
|
// 三、表头格式设置
|
|
|
|
// 三、表头格式设置
|
|
|
|
this.titleHeader(hssWB, sheet,"3、机组负荷、温度曲线",row); |
|
|
|
this.titleHeader(hssWB, sheet,"3、机组负荷、温度曲线",row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 四、表头格式设置
|
|
|
|
// 四、表头格式设置
|
|
|
|
this.titleHeader(hssWB, sheet,"4、运行数据分析",row); |
|
|
|
this.titleHeader(hssWB, sheet,"4、运行数据分析",row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 五、表头格式设置
|
|
|
|
// 五、表头格式设置
|
|
|
|
this.titleHeader(hssWB, sheet,"5、运行建议及其他",row); |
|
|
|
this.titleHeader(hssWB, sheet,"5、运行建议及其他",row); |
|
|
|
row =+ 1; |
|
|
|
row += 1; |
|
|
|
return hssWB; |
|
|
|
return hssWB; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -180,12 +182,12 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
private void firstHeader(HSSFWorkbook hssWB, HSSFSheet sheet,String headerName) { |
|
|
|
private void firstHeader(HSSFWorkbook hssWB, HSSFSheet sheet,String headerName) { |
|
|
|
// 第一行
|
|
|
|
// 第一行
|
|
|
|
HSSFRow fisrtRow = sheet.createRow(0); |
|
|
|
HSSFRow fisrtRow = sheet.createRow(0); |
|
|
|
this.setTitileStyle(hssWB, fisrtRow, 8, true,true,HorizontalAlignment.CENTER); |
|
|
|
this.setTitileStyle(hssWB, fisrtRow, 7, true,true,HorizontalAlignment.CENTER); |
|
|
|
// 第一个单元格
|
|
|
|
// 第一个单元格
|
|
|
|
HSSFCell headCell = fisrtRow.getCell(0); |
|
|
|
HSSFCell headCell = fisrtRow.getCell(0); |
|
|
|
headCell.setCellValue(headerName); |
|
|
|
headCell.setCellValue(headerName); |
|
|
|
// 首行合并情况
|
|
|
|
// 首行合并情况
|
|
|
|
CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 8); |
|
|
|
CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 7); |
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -197,11 +199,11 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
private void titleHeader(HSSFWorkbook hssWB, HSSFSheet sheet,String title,int rowNumber) { |
|
|
|
private void titleHeader(HSSFWorkbook hssWB, HSSFSheet sheet,String title,int rowNumber) { |
|
|
|
// 创建行
|
|
|
|
// 创建行
|
|
|
|
HSSFRow row_1 = sheet.createRow(rowNumber); |
|
|
|
HSSFRow row_1 = sheet.createRow(rowNumber); |
|
|
|
this.setTitileStyle(hssWB, row_1, 8, false,true,HorizontalAlignment.LEFT); |
|
|
|
this.setTitileStyle(hssWB, row_1, 7, false,true,HorizontalAlignment.LEFT); |
|
|
|
HSSFCell work_header_row_cell_1 = row_1.getCell(0); |
|
|
|
HSSFCell work_header_row_cell_1 = row_1.getCell(0); |
|
|
|
work_header_row_cell_1.setCellValue(title); |
|
|
|
work_header_row_cell_1.setCellValue(title); |
|
|
|
// 行合并情况
|
|
|
|
// 行合并情况
|
|
|
|
CellRangeAddress region1 = new CellRangeAddress(0, 0, (short) 0, (short) 8); |
|
|
|
CellRangeAddress region1 = new CellRangeAddress(rowNumber, rowNumber, (short) 0, (short) 7); |
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
sheet.addMergedRegion(region1); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -213,7 +215,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
private void runDataHeader(HSSFWorkbook hssWB, HSSFSheet sheet,int rowNumber) { |
|
|
|
private void runDataHeader(HSSFWorkbook hssWB, HSSFSheet sheet,int rowNumber) { |
|
|
|
// 创建行
|
|
|
|
// 创建行
|
|
|
|
HSSFRow row = sheet.createRow(rowNumber); |
|
|
|
HSSFRow row = sheet.createRow(rowNumber); |
|
|
|
this.setTitileStyle(hssWB, row, 8, false,true,HorizontalAlignment.CENTER); |
|
|
|
this.setTitileStyle(hssWB, row, 7, false,true,HorizontalAlignment.CENTER); |
|
|
|
// 第一行
|
|
|
|
// 第一行
|
|
|
|
HSSFCell row_cell_1 = row.getCell(0); |
|
|
|
HSSFCell row_cell_1 = row.getCell(0); |
|
|
|
row_cell_1.setCellValue("组名"); |
|
|
|
row_cell_1.setCellValue("组名"); |
|
|
@ -247,10 +249,10 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
} |
|
|
|
} |
|
|
|
int row = rowNumber; |
|
|
|
int row = rowNumber; |
|
|
|
int endRow = rowNumber + runData.size(); |
|
|
|
int endRow = rowNumber + runData.size(); |
|
|
|
for (;row < endRow ; row ++){ |
|
|
|
for (;row < endRow; row ++){ |
|
|
|
// 创建行
|
|
|
|
// 创建行
|
|
|
|
HSSFRow frow = sheet.createRow(row); |
|
|
|
HSSFRow frow = sheet.createRow(row); |
|
|
|
this.setTitileStyle(hssWB, frow, 8, false,false,HorizontalAlignment.CENTER); |
|
|
|
this.setTitileStyle(hssWB, frow, 7, false,false,HorizontalAlignment.CENTER); |
|
|
|
// 组名
|
|
|
|
// 组名
|
|
|
|
HSSFCell frow_cell_1 = frow.getCell(0); |
|
|
|
HSSFCell frow_cell_1 = frow.getCell(0); |
|
|
|
frow_cell_1.setCellValue(runData.get(row - rowNumber).getDeviceName()); |
|
|
|
frow_cell_1.setCellValue(runData.get(row - rowNumber).getDeviceName()); |
|
|
@ -289,18 +291,18 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
frow_cell_8.setCellValue("0%"); |
|
|
|
frow_cell_8.setCellValue("0%"); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 行合并情况
|
|
|
|
|
|
|
|
CellRangeAddress region3 = new CellRangeAddress(rowNumber, endRow , (short) 3, (short) 3); |
|
|
|
|
|
|
|
CellRangeAddress region4 = new CellRangeAddress(rowNumber, endRow, (short) 4, (short) 4); |
|
|
|
|
|
|
|
CellRangeAddress region5 = new CellRangeAddress(rowNumber, endRow, (short) 5, (short) 5); |
|
|
|
|
|
|
|
CellRangeAddress region6 = new CellRangeAddress(rowNumber, endRow, (short) 6, (short) 6); |
|
|
|
|
|
|
|
CellRangeAddress region7 = new CellRangeAddress(rowNumber, endRow, (short) 7, (short) 7); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region3); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region4); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region5); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region6); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region7); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
// 行合并情况
|
|
|
|
|
|
|
|
CellRangeAddress region3 = new CellRangeAddress(rowNumber, endRow - 1, (short) 3, (short) 3); |
|
|
|
|
|
|
|
CellRangeAddress region4 = new CellRangeAddress(rowNumber, endRow - 1, (short) 4, (short) 4); |
|
|
|
|
|
|
|
CellRangeAddress region5 = new CellRangeAddress(rowNumber, endRow - 1, (short) 5, (short) 5); |
|
|
|
|
|
|
|
CellRangeAddress region6 = new CellRangeAddress(rowNumber, endRow - 1, (short) 6, (short) 6); |
|
|
|
|
|
|
|
CellRangeAddress region7 = new CellRangeAddress(rowNumber, endRow - 1, (short) 7, (short) 7); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region3); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region4); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region5); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region6); |
|
|
|
|
|
|
|
sheet.addMergedRegion(region7); |
|
|
|
return endRow; |
|
|
|
return endRow; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -342,7 +344,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
private void alarmHeader(HSSFWorkbook hssWB, HSSFSheet sheet,int rowNumber) { |
|
|
|
private void alarmHeader(HSSFWorkbook hssWB, HSSFSheet sheet,int rowNumber) { |
|
|
|
// 创建行
|
|
|
|
// 创建行
|
|
|
|
HSSFRow row = sheet.createRow(rowNumber); |
|
|
|
HSSFRow row = sheet.createRow(rowNumber); |
|
|
|
this.setTitileStyle(hssWB, row, 8, false,true,HorizontalAlignment.CENTER); |
|
|
|
this.setTitileStyle(hssWB, row, 7, false,true,HorizontalAlignment.CENTER); |
|
|
|
// 第一行
|
|
|
|
// 第一行
|
|
|
|
HSSFCell row_cell_1 = row.getCell(0); |
|
|
|
HSSFCell row_cell_1 = row.getCell(0); |
|
|
|
row_cell_1.setCellValue("组名"); |
|
|
|
row_cell_1.setCellValue("组名"); |
|
|
@ -381,7 +383,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
for (;row < endRow ; row ++){ |
|
|
|
for (;row < endRow ; row ++){ |
|
|
|
// 创建行
|
|
|
|
// 创建行
|
|
|
|
HSSFRow frow = sheet.createRow(row); |
|
|
|
HSSFRow frow = sheet.createRow(row); |
|
|
|
this.setTitileStyle(hssWB, frow, 8, false,false,HorizontalAlignment.CENTER); |
|
|
|
this.setTitileStyle(hssWB, frow, 7, false,false,HorizontalAlignment.CENTER); |
|
|
|
// 组名
|
|
|
|
// 组名
|
|
|
|
HSSFCell frow_cell_1 = frow.getCell(0); |
|
|
|
HSSFCell frow_cell_1 = frow.getCell(0); |
|
|
|
frow_cell_1.setCellValue(runAlarm.get(row - rowNumber).getDeviceName()); |
|
|
|
frow_cell_1.setCellValue(runAlarm.get(row - rowNumber).getDeviceName()); |
|
|
@ -439,6 +441,7 @@ public class RunMonthServiceImpl extends BaseServiceImpl<RunMonthMapper, RunMont |
|
|
|
headStyle.setBorderRight(BorderStyle.THIN); |
|
|
|
headStyle.setBorderRight(BorderStyle.THIN); |
|
|
|
headStyle.setBorderTop(BorderStyle.THIN); |
|
|
|
headStyle.setBorderTop(BorderStyle.THIN); |
|
|
|
headStyle.setBorderBottom(BorderStyle.THIN); |
|
|
|
headStyle.setBorderBottom(BorderStyle.THIN); |
|
|
|
|
|
|
|
headStyle.setWrapText(true); |
|
|
|
//格式: 居中、居右、居左.....
|
|
|
|
//格式: 居中、居右、居左.....
|
|
|
|
headStyle.setAlignment(alignment); |
|
|
|
headStyle.setAlignment(alignment); |
|
|
|
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中
|
|
|
|
headStyle.setVerticalAlignment(VerticalAlignment.CENTER);// 垂直居中
|
|
|
|