|
@@ -3,11 +3,11 @@ package com.persagy.apm.alarmservice.group.alarmrecord.service;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.persagy.apm.alarmservice.group.alarmrecord.enums.*;
|
|
|
-import com.persagy.apm.alarmservice.project.alarmcondition.model.vo.AlarmConditionStrItem;
|
|
|
import com.persagy.apm.alarmservice.group.alarmrecord.model.vo.AlarmRecordItemVO;
|
|
|
import com.persagy.apm.alarmservice.group.alarmrecord.model.vo.AlarmRecordListItem;
|
|
|
import com.persagy.apm.alarmservice.group.management.model.equip.vo.EquipItem;
|
|
|
import com.persagy.apm.alarmservice.group.management.service.GroupManagementService;
|
|
|
+import com.persagy.apm.alarmservice.project.alarmcondition.model.vo.AlarmConditionStrItem;
|
|
|
import com.persagy.apm.common.model.vo.SimpleObjVO;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmitem.QueryAlarmItemDTO;
|
|
@@ -19,6 +19,8 @@ import com.persagy.apm.energyalarmstarter.alarmdata.service.AlarmRecordServiceIm
|
|
|
import com.persagy.apm.energyalarmstarter.alarmdata.utils.DateUtils;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.apache.poi.ss.usermodel.Cell;
|
|
|
+import org.apache.poi.ss.usermodel.FillPatternType;
|
|
|
+import org.apache.poi.ss.usermodel.IndexedColors;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFCellStyle;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFRow;
|
|
|
import org.apache.poi.xssf.usermodel.XSSFSheet;
|
|
@@ -28,9 +30,6 @@ import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
-import javax.servlet.http.HttpServletResponse;
|
|
|
-import java.io.FileOutputStream;
|
|
|
-import java.io.OutputStream;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.math.RoundingMode;
|
|
|
import java.util.*;
|
|
@@ -362,7 +361,7 @@ public class AlarmRecordWrapper {
|
|
|
* @version V1.0 2021/9/21 3:54 下午
|
|
|
*/
|
|
|
public List<AlarmRecordItem> getAlarmRecordList(List<String> recordIdList) throws Exception {
|
|
|
- if (CollectionUtils.isEmpty(recordIdList) || recordIdList.size() == 0){
|
|
|
+ if (CollectionUtils.isEmpty(recordIdList) || recordIdList.size() == 0) {
|
|
|
return null;
|
|
|
}
|
|
|
QueryAlarmRecordDTO queryAlarmRecordDTO = new QueryAlarmRecordDTO();
|
|
@@ -375,104 +374,96 @@ public class AlarmRecordWrapper {
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 构造EXCEl文件
|
|
|
- * @param enumAlarmListType 报警列表类型
|
|
|
- * @param alarmRecordItemVOList 数据列表
|
|
|
- */
|
|
|
- public void initExcel(EnumAlarmListType enumAlarmListType, List<AlarmRecordItemVO> alarmRecordItemVOList){
|
|
|
- try {
|
|
|
- //创建Workbook
|
|
|
- XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
- XSSFSheet overViewSheet = wb.createSheet();
|
|
|
- wb.setSheetName(0,enumAlarmListType.getDesc());//设置sheet页标题
|
|
|
- handleExcelTitle(enumAlarmListType,overViewSheet,wb);// 处理表头
|
|
|
- //能耗概览Sheet数据填充
|
|
|
- fillDataTable(enumAlarmListType,overViewSheet,alarmRecordItemVOList);
|
|
|
- //本地自测
|
|
|
- String time = DateUtils.date2Str(new Date(),DateUtils.SDFSECOND);
|
|
|
- String excelName =enumAlarmListType.getDesc()+"-"+time+".xlsx";
|
|
|
-
|
|
|
-// 本地测试
|
|
|
-// FileOutputStream out = new FileOutputStream("D:\\exl\\"+excelName);
|
|
|
-// wb.write(out);
|
|
|
-// out.flush();
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
* 填充 excel文件数据行
|
|
|
- * @param enumAlarmListType 报警列表类型
|
|
|
- * @param sheet 文件sheet
|
|
|
+ *
|
|
|
+ * @param enumAlarmListType 报警列表类型
|
|
|
+ * @param sheet 文件sheet
|
|
|
* @param alarmRecordItemVOList 数据列表
|
|
|
*/
|
|
|
- public void fillDataTable(EnumAlarmListType enumAlarmListType,XSSFSheet sheet,List<AlarmRecordItemVO> alarmRecordItemVOList) {
|
|
|
+ public void fillDataTable(EnumAlarmListType enumAlarmListType, XSSFSheet sheet, List<AlarmRecordItemVO> alarmRecordItemVOList) {
|
|
|
try {
|
|
|
for (int i = 0; i < alarmRecordItemVOList.size(); i++) {
|
|
|
AlarmRecordItemVO alarmRecordItemVO = alarmRecordItemVOList.get(i);
|
|
|
- XSSFRow row = sheet.createRow(i+1);
|
|
|
+ XSSFRow row = sheet.createRow(i + 1);
|
|
|
String groupName = "";//分组名称
|
|
|
- if (null != alarmRecordItemVO.getGroup() && null != alarmRecordItemVO.getGroup().getName()){
|
|
|
+ if (null != alarmRecordItemVO.getGroup() && null != alarmRecordItemVO.getGroup().getName()) {
|
|
|
groupName = alarmRecordItemVO.getGroup().getName();
|
|
|
}
|
|
|
- Cell cell = row.createCell(0);cell.setCellValue(groupName);
|
|
|
+ Cell cell = row.createCell(0);
|
|
|
+ cell.setCellValue(groupName);
|
|
|
String objName = "";//对象名称
|
|
|
- if (null != alarmRecordItemVO.getObj() && null != alarmRecordItemVO.getObj().getName()){
|
|
|
+ if (null != alarmRecordItemVO.getObj() && null != alarmRecordItemVO.getObj().getName()) {
|
|
|
objName = alarmRecordItemVO.getObj().getName();
|
|
|
}
|
|
|
- cell = row.createCell(1);cell.setCellValue(objName);
|
|
|
+ cell = row.createCell(1);
|
|
|
+ cell.setCellValue(objName);
|
|
|
String itemName = "";//报警类型
|
|
|
- if (null != alarmRecordItemVO.getAlarmItem() && null != alarmRecordItemVO.getAlarmItem().getName()){
|
|
|
+ if (null != alarmRecordItemVO.getAlarmItem() && null != alarmRecordItemVO.getAlarmItem().getName()) {
|
|
|
itemName = alarmRecordItemVO.getAlarmItem().getName();
|
|
|
}
|
|
|
- cell = row.createCell(2);cell.setCellValue(itemName);
|
|
|
+ cell = row.createCell(2);
|
|
|
+ cell.setCellValue(itemName);
|
|
|
String levelName = "";//报警级别
|
|
|
- if (null != alarmRecordItemVO.getAlarmLevel() && null != alarmRecordItemVO.getAlarmLevel().getName()){
|
|
|
+ if (null != alarmRecordItemVO.getAlarmLevel() && null != alarmRecordItemVO.getAlarmLevel().getName()) {
|
|
|
levelName = alarmRecordItemVO.getAlarmLevel().getName();
|
|
|
}
|
|
|
String stateName = "";//报警状态
|
|
|
- if (null != alarmRecordItemVO.getAlarmState() && null != alarmRecordItemVO.getAlarmState().getName()){
|
|
|
+ if (null != alarmRecordItemVO.getAlarmState() && null != alarmRecordItemVO.getAlarmState().getName()) {
|
|
|
stateName = alarmRecordItemVO.getAlarmState().getName();
|
|
|
}
|
|
|
String treatStateName = "";//报警处理状态
|
|
|
- if (null != alarmRecordItemVO.getAlarmTreatState() && null != alarmRecordItemVO.getAlarmTreatState().getName()){
|
|
|
+ if (null != alarmRecordItemVO.getAlarmTreatState() && null != alarmRecordItemVO.getAlarmTreatState().getName()) {
|
|
|
treatStateName = alarmRecordItemVO.getAlarmTreatState().getName();
|
|
|
}
|
|
|
String triggerTime = "";
|
|
|
- if (null != alarmRecordItemVO.getTriggerTime()){
|
|
|
- triggerTime = DateUtils.date2Str(alarmRecordItemVO.getTriggerTime(),DateUtils.SDF_SECOND);
|
|
|
+ if (null != alarmRecordItemVO.getTriggerTime()) {
|
|
|
+ triggerTime = DateUtils.date2Str(alarmRecordItemVO.getTriggerTime(), DateUtils.SDF_SECOND);
|
|
|
}
|
|
|
String treatEndTime = "";
|
|
|
- if (null != alarmRecordItemVO.getTreatEndTime()){
|
|
|
- treatEndTime = DateUtils.date2Str(alarmRecordItemVO.getTreatEndTime(),DateUtils.SDF_SECOND);
|
|
|
+ if (null != alarmRecordItemVO.getTreatEndTime()) {
|
|
|
+ treatEndTime = DateUtils.date2Str(alarmRecordItemVO.getTreatEndTime(), DateUtils.SDF_SECOND);
|
|
|
}
|
|
|
String ignoreTime = "";
|
|
|
- if (null != alarmRecordItemVO.getIgnoreTime()){
|
|
|
- ignoreTime = DateUtils.date2Str(alarmRecordItemVO.getIgnoreTime(),DateUtils.SDF_SECOND);
|
|
|
+ if (null != alarmRecordItemVO.getIgnoreTime()) {
|
|
|
+ ignoreTime = DateUtils.date2Str(alarmRecordItemVO.getIgnoreTime(), DateUtils.SDF_SECOND);
|
|
|
}
|
|
|
String duration = "";
|
|
|
- if (null != alarmRecordItemVO.getDuration()){
|
|
|
+ if (null != alarmRecordItemVO.getDuration()) {
|
|
|
duration = alarmRecordItemVO.getDuration();
|
|
|
}
|
|
|
- cell = row.createCell(3);cell.setCellValue(triggerTime);
|
|
|
- if (EnumAlarmListType.CURRENT.getType().equals(enumAlarmListType.getType())){
|
|
|
- cell = row.createCell(4);cell.setCellValue(duration);
|
|
|
- cell = row.createCell(5);cell.setCellValue(levelName);
|
|
|
- cell = row.createCell(6);cell.setCellValue(stateName);
|
|
|
- cell = row.createCell(7);cell.setCellValue(treatStateName);
|
|
|
- }else if (EnumAlarmListType.HISTORY.getType().equals(enumAlarmListType.getType())){
|
|
|
- cell = row.createCell(4);cell.setCellValue(treatEndTime);
|
|
|
- cell = row.createCell(5);cell.setCellValue(duration);
|
|
|
- cell = row.createCell(6);cell.setCellValue(levelName);
|
|
|
- cell = row.createCell(7);cell.setCellValue(stateName);
|
|
|
- cell = row.createCell(8);cell.setCellValue(treatStateName);
|
|
|
- }else if (EnumAlarmListType.IGNORE.getType().equals(enumAlarmListType.getType())){
|
|
|
- cell = row.createCell(4);cell.setCellValue(ignoreTime);
|
|
|
- cell = row.createCell(5);cell.setCellValue(duration);
|
|
|
- cell = row.createCell(6);cell.setCellValue(levelName);
|
|
|
- cell = row.createCell(7);cell.setCellValue(stateName);
|
|
|
- cell = row.createCell(8);cell.setCellValue(treatStateName);
|
|
|
+ cell = row.createCell(3);
|
|
|
+ cell.setCellValue(triggerTime);
|
|
|
+ if (EnumAlarmListType.CURRENT.getType().equals(enumAlarmListType.getType())) {
|
|
|
+ cell = row.createCell(4);
|
|
|
+ cell.setCellValue(duration);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue(levelName);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ cell.setCellValue(stateName);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ cell.setCellValue(treatStateName);
|
|
|
+ } else if (EnumAlarmListType.HISTORY.getType().equals(enumAlarmListType.getType())) {
|
|
|
+ cell = row.createCell(4);
|
|
|
+ cell.setCellValue(treatEndTime);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue(duration);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ cell.setCellValue(levelName);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ cell.setCellValue(stateName);
|
|
|
+ cell = row.createCell(8);
|
|
|
+ cell.setCellValue(treatStateName);
|
|
|
+ } else if (EnumAlarmListType.IGNORE.getType().equals(enumAlarmListType.getType())) {
|
|
|
+ cell = row.createCell(4);
|
|
|
+ cell.setCellValue(ignoreTime);
|
|
|
+ cell = row.createCell(5);
|
|
|
+ cell.setCellValue(duration);
|
|
|
+ cell = row.createCell(6);
|
|
|
+ cell.setCellValue(levelName);
|
|
|
+ cell = row.createCell(7);
|
|
|
+ cell.setCellValue(stateName);
|
|
|
+ cell = row.createCell(8);
|
|
|
+ cell.setCellValue(treatStateName);
|
|
|
}
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
@@ -483,47 +474,94 @@ public class AlarmRecordWrapper {
|
|
|
|
|
|
/**
|
|
|
* 处理文件标题行
|
|
|
- * @param enumAlarmListType 报警列表类型
|
|
|
- * @param sheet 文件sheet
|
|
|
- * @param wb 文件wb
|
|
|
+ *
|
|
|
+ * @param enumAlarmListType 报警列表类型
|
|
|
+ * @param sheet 文件sheet
|
|
|
+ * @param wb 文件wb
|
|
|
*/
|
|
|
- public void handleExcelTitle(EnumAlarmListType enumAlarmListType,XSSFSheet sheet, XSSFWorkbook wb){
|
|
|
+ public void handleExcelTitle(EnumAlarmListType enumAlarmListType, XSSFSheet sheet, XSSFWorkbook wb) {
|
|
|
XSSFCellStyle cellStyle = wb.createCellStyle();
|
|
|
cellStyle.setWrapText(true);
|
|
|
+ cellStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
|
|
|
+ cellStyle.setFillPattern(FillPatternType.SOLID_FOREGROUND);
|
|
|
//设置行宽
|
|
|
- sheet.setColumnWidth(0, 5000);sheet.setColumnWidth(1, 5000);
|
|
|
- sheet.setColumnWidth(2, 7000);sheet.setColumnWidth(3, 5000);
|
|
|
+ sheet.setColumnWidth(0, 5000);
|
|
|
+ sheet.setColumnWidth(1, 5000);
|
|
|
+ sheet.setColumnWidth(2, 7000);
|
|
|
+ sheet.setColumnWidth(3, 5000);
|
|
|
//行
|
|
|
XSSFRow Row1 = sheet.createRow(0);
|
|
|
- Cell cell = Row1.createCell(0);cell.setCellStyle(cellStyle);cell.setCellValue("分组名称");
|
|
|
- cell = Row1.createCell(1);cell.setCellStyle(cellStyle);cell.setCellValue("报警对象");
|
|
|
- cell = Row1.createCell(2);cell.setCellStyle(cellStyle);cell.setCellValue("报警类型");
|
|
|
- cell = Row1.createCell(3);cell.setCellStyle(cellStyle);cell.setCellValue("报警开始时间");
|
|
|
- if (EnumAlarmListType.CURRENT.getType().equals(enumAlarmListType.getType())){
|
|
|
- sheet.setColumnWidth(4, 3500);sheet.setColumnWidth(5, 3000);
|
|
|
- sheet.setColumnWidth(6, 3000);sheet.setColumnWidth(7, 5000);
|
|
|
- cell = Row1.createCell(4);cell.setCellStyle(cellStyle);cell.setCellValue("报警持续时长(h)");
|
|
|
- cell = Row1.createCell(5);cell.setCellStyle(cellStyle);cell.setCellValue("报警等级");
|
|
|
- cell = Row1.createCell(6);cell.setCellStyle(cellStyle);cell.setCellValue("报警状态");
|
|
|
- cell = Row1.createCell(7);cell.setCellStyle(cellStyle);cell.setCellValue("报警处理状态");
|
|
|
- }else if (EnumAlarmListType.HISTORY.getType().equals(enumAlarmListType.getType())){
|
|
|
- sheet.setColumnWidth(4, 5000);sheet.setColumnWidth(5, 3500);
|
|
|
- sheet.setColumnWidth(6, 3000);sheet.setColumnWidth(7, 3000);
|
|
|
+ Cell cell = Row1.createCell(0);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("分组名称");
|
|
|
+ cell = Row1.createCell(1);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警对象");
|
|
|
+ cell = Row1.createCell(2);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警类型");
|
|
|
+ cell = Row1.createCell(3);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警开始时间");
|
|
|
+ if (EnumAlarmListType.CURRENT.getType().equals(enumAlarmListType.getType())) {
|
|
|
+ sheet.setColumnWidth(4, 4500);
|
|
|
+ sheet.setColumnWidth(5, 3000);
|
|
|
+ sheet.setColumnWidth(6, 3000);
|
|
|
+ sheet.setColumnWidth(7, 5000);
|
|
|
+ cell = Row1.createCell(4);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警持续时长(h)");
|
|
|
+ cell = Row1.createCell(5);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警等级");
|
|
|
+ cell = Row1.createCell(6);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警状态");
|
|
|
+ cell = Row1.createCell(7);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警处理状态");
|
|
|
+ } else if (EnumAlarmListType.HISTORY.getType().equals(enumAlarmListType.getType())) {
|
|
|
+ sheet.setColumnWidth(4, 5000);
|
|
|
+ sheet.setColumnWidth(5, 3500);
|
|
|
+ sheet.setColumnWidth(6, 3000);
|
|
|
+ sheet.setColumnWidth(7, 3000);
|
|
|
sheet.setColumnWidth(8, 5000);
|
|
|
- cell = Row1.createCell(4);cell.setCellStyle(cellStyle);cell.setCellValue("处理完成时间");
|
|
|
- cell = Row1.createCell(5);cell.setCellStyle(cellStyle);cell.setCellValue("异常持续时长(h)");
|
|
|
- cell = Row1.createCell(6);cell.setCellStyle(cellStyle);cell.setCellValue("报警等级");
|
|
|
- cell = Row1.createCell(7);cell.setCellStyle(cellStyle);cell.setCellValue("报警状态");
|
|
|
- cell = Row1.createCell(8);cell.setCellStyle(cellStyle);cell.setCellValue("报警处理状态");
|
|
|
- }else if (EnumAlarmListType.IGNORE.getType().equals(enumAlarmListType.getType())){
|
|
|
- sheet.setColumnWidth(4, 5000);sheet.setColumnWidth(5, 3500);
|
|
|
- sheet.setColumnWidth(6, 3000);sheet.setColumnWidth(7, 3000);
|
|
|
+ cell = Row1.createCell(4);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("处理完成时间");
|
|
|
+ cell = Row1.createCell(5);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("异常持续时长(h)");
|
|
|
+ cell = Row1.createCell(6);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警等级");
|
|
|
+ cell = Row1.createCell(7);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警状态");
|
|
|
+ cell = Row1.createCell(8);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警处理状态");
|
|
|
+ } else if (EnumAlarmListType.IGNORE.getType().equals(enumAlarmListType.getType())) {
|
|
|
+ sheet.setColumnWidth(4, 5000);
|
|
|
+ sheet.setColumnWidth(5, 3500);
|
|
|
+ sheet.setColumnWidth(6, 3000);
|
|
|
+ sheet.setColumnWidth(7, 3000);
|
|
|
sheet.setColumnWidth(8, 5000);
|
|
|
- cell = Row1.createCell(4);cell.setCellStyle(cellStyle);cell.setCellValue("忽略时间");
|
|
|
- cell = Row1.createCell(5);cell.setCellStyle(cellStyle);cell.setCellValue("异常持续时长(h)");
|
|
|
- cell = Row1.createCell(6);cell.setCellStyle(cellStyle);cell.setCellValue("报警等级");
|
|
|
- cell = Row1.createCell(7);cell.setCellStyle(cellStyle);cell.setCellValue("报警状态");
|
|
|
- cell = Row1.createCell(8);cell.setCellStyle(cellStyle);cell.setCellValue("报警处理状态");
|
|
|
+ cell = Row1.createCell(4);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("忽略时间");
|
|
|
+ cell = Row1.createCell(5);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("异常持续时长(h)");
|
|
|
+ cell = Row1.createCell(6);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警等级");
|
|
|
+ cell = Row1.createCell(7);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警状态");
|
|
|
+ cell = Row1.createCell(8);
|
|
|
+ cell.setCellStyle(cellStyle);
|
|
|
+ cell.setCellValue("报警处理状态");
|
|
|
}
|
|
|
}
|
|
|
|