Forráskód Böngészése

重新定义报警记录当前列表和历史列表

lixing 3 éve
szülő
commit
6fc527a275

+ 1 - 1
pom.xml

@@ -115,7 +115,7 @@
     <dependency>
         <groupId>com.persagy.apm</groupId>
         <artifactId>alarm-data-starter</artifactId>
-        <version>v1.0.0-SNAPSHOT</version>
+        <version>v2.0.0-SNAPSHOT</version>
     </dependency>
 </dependencies>
 </project>

+ 1 - 1
src/main/java/com/persagy/apm/alarmservice/group/alarmrecord/controller/AlarmCommnetController.java

@@ -11,8 +11,8 @@ import com.persagy.apm.common.response.CommonResult;
 import com.persagy.apm.common.response.PageList;
 import com.persagy.apm.common.utils.ResultHelper;
 import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
+import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmcomment.AddAlarmCommentDTO;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmcomment.QueryAlarmCommentDTO;
-import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmconfig.AddAlarmCommentDTO;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.common.QueryDTO;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.AlarmCommentItem;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.vo.DmpUpsertVO;

+ 19 - 28
src/main/java/com/persagy/apm/alarmservice/group/alarmrecord/controller/AlarmRecordController.java

@@ -2,7 +2,7 @@ package com.persagy.apm.alarmservice.group.alarmrecord.controller;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.persagy.apm.alarmservice.group.alarmrecord.enums.EnumAlarmListType;
+import com.persagy.apm.alarmservice.group.alarmrecord.enums.EnumDownloadAlarmListType;
 import com.persagy.apm.alarmservice.group.alarmrecord.enums.EnumAlarmTreatMode;
 import com.persagy.apm.alarmservice.group.alarmrecord.enums.EnumAlarmTreatState;
 import com.persagy.apm.alarmservice.group.alarmrecord.model.ConvertAlarmRecordTool;
@@ -20,6 +20,7 @@ import com.persagy.apm.common.model.dto.Sort;
 import com.persagy.apm.common.response.CommonResult;
 import com.persagy.apm.common.response.PageList;
 import com.persagy.apm.common.utils.ResultHelper;
+import com.persagy.apm.energyalarmstarter.alarmdata.enums.EnumAlarmListType;
 import com.persagy.apm.energyalarmstarter.alarmdata.feign.DmpResult;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.AddAlarmRecordDTO;
 import com.persagy.apm.energyalarmstarter.alarmdata.model.dto.alarmrecord.BatchUpdateAlarmRecordDTO;
@@ -81,14 +82,7 @@ public class AlarmRecordController {
     @PostMapping("/current_list")
     public CommonResult<PageList<AlarmRecordListItem>> queryCurrentAlarmRecord(
             @Valid @RequestBody PageQueryAlarmRecordDTO pageQueryAlarmRecordDTO) throws Exception {
-        if (pageQueryAlarmRecordDTO.getAlarmTreatState() == null) {
-            // 当前报警的默认查询条件为:报警处理状态为未处理和处理中
-            pageQueryAlarmRecordDTO.setAlarmTreatState(Lists.newArrayList(
-                    EnumAlarmTreatState.UN_HANDLE.getType(),
-                    EnumAlarmTreatState.HANDLING.getType()
-            ));
-        }
-
+        pageQueryAlarmRecordDTO.setListType(EnumAlarmListType.CURRENT);
         return queryAlarmRecord(pageQueryAlarmRecordDTO);
     }
 
@@ -187,10 +181,7 @@ public class AlarmRecordController {
     @PostMapping("/history_list")
     public CommonResult<PageList<AlarmRecordListItem>> queryHistoryAlarmRecord(
             @Valid @RequestBody PageQueryAlarmRecordDTO pageQueryAlarmRecordDTO) throws Exception {
-        // 历史报警的默认查询条件为:报警处理状态为处理完成
-        pageQueryAlarmRecordDTO.setAlarmTreatState(Lists.newArrayList(
-                EnumAlarmTreatState.DONE.getType()
-        ));
+        pageQueryAlarmRecordDTO.setListType(EnumAlarmListType.HISTORY);
         return queryAlarmRecord(pageQueryAlarmRecordDTO);
     }
 
@@ -302,13 +293,13 @@ public class AlarmRecordController {
         // 去掉分页条件
         pageQueryAlarmRecordDTO.setSize(Integer.MAX_VALUE);
         CommonResult<PageList<AlarmRecordListItem>> result = null;
-        if (listType.equals(EnumAlarmListType.CURRENT.getType())) {
+        if (listType.equals(EnumDownloadAlarmListType.CURRENT.getType())) {
             result = queryCurrentAlarmRecord(pageQueryAlarmRecordDTO);
         }
-        if (listType.equals(EnumAlarmListType.HISTORY.getType())) {
+        if (listType.equals(EnumDownloadAlarmListType.HISTORY.getType())) {
             result = queryHistoryAlarmRecord(pageQueryAlarmRecordDTO);
         }
-        if (listType.equals(EnumAlarmListType.IGNORE.getType())) {
+        if (listType.equals(EnumDownloadAlarmListType.IGNORE.getType())) {
             result = queryIgnoredAlarmRecord(pageQueryAlarmRecordDTO);
         }
 
@@ -319,11 +310,11 @@ public class AlarmRecordController {
 
         List<AlarmRecordItemVO> alarmRecordItemVOList = ConvertAlarmRecordTool.INSTANCE.
                 convert2AlarmRecordItemVOList(alarmRecordItemList);
-        EnumAlarmListType enumAlarmListType = EnumAlarmListType.getByType(listType);
-        if (enumAlarmListType == null) {
+        EnumDownloadAlarmListType enumDownloadAlarmListType = EnumDownloadAlarmListType.getByType(listType);
+        if (enumDownloadAlarmListType == null) {
             throw new IllegalArgumentException("列表类型传值错误");
         }
-        downloadRecordList(response, enumAlarmListType, alarmRecordItemVOList);
+        downloadRecordList(response, enumDownloadAlarmListType, alarmRecordItemVOList);
     }
 
     @ApiOperation(value = "下载")
@@ -335,8 +326,8 @@ public class AlarmRecordController {
         List<String> recordIdList = downloadAlarmRecordDTO.getIds();
         //列表类型
         String listType = downloadAlarmRecordDTO.getListType();
-        EnumAlarmListType enumAlarmListType = EnumAlarmListType.getByType(listType);
-        if (enumAlarmListType == null) {
+        EnumDownloadAlarmListType enumDownloadAlarmListType = EnumDownloadAlarmListType.getByType(listType);
+        if (enumDownloadAlarmListType == null) {
             throw new IllegalArgumentException("列表类型传值错误");
         }
         // 获取报警详情列表
@@ -347,35 +338,35 @@ public class AlarmRecordController {
                 alarmRecordItemVOList.add(alarmRecordWrapper.convert2AlarmRecordItemVO(alarmRecord));
             }
         }
-        downloadRecordList(response, enumAlarmListType, alarmRecordItemVOList);
+        downloadRecordList(response, enumDownloadAlarmListType, alarmRecordItemVOList);
     }
 
     /**
      * 下载报警记录列表
      *
      * @param response            response对象
-     * @param enumAlarmListType   列表类型
+     * @param enumDownloadAlarmListType   列表类型
      * @param alarmRecordItemVOList 要下载的列表
      * @author lixing
      * @version V1.0 2021/10/19 7:22 下午
      */
     private void downloadRecordList(
-            HttpServletResponse response, EnumAlarmListType enumAlarmListType,
+            HttpServletResponse response, EnumDownloadAlarmListType enumDownloadAlarmListType,
             List<AlarmRecordItemVO> alarmRecordItemVOList) throws Exception {
         // 创建Workbook
         XSSFWorkbook wb = new XSSFWorkbook();
         XSSFSheet overViewSheet = wb.createSheet();
         // 设置sheet页标题
-        wb.setSheetName(0, enumAlarmListType.getDesc());
+        wb.setSheetName(0, enumDownloadAlarmListType.getDesc());
         // 处理表头
-        alarmRecordWrapper.handleExcelTitle(enumAlarmListType, overViewSheet, wb);
+        alarmRecordWrapper.handleExcelTitle(enumDownloadAlarmListType, overViewSheet, wb);
 
         if (!CollectionUtils.isEmpty(alarmRecordItemVOList)) {
             // 能耗概览Sheet数据填充
-            alarmRecordWrapper.fillDataTable(enumAlarmListType, overViewSheet, alarmRecordItemVOList);
+            alarmRecordWrapper.fillDataTable(enumDownloadAlarmListType, overViewSheet, alarmRecordItemVOList);
         }
         String time = DateUtils.date2Str(new Date(), DateUtils.SDFSECOND);
-        String excelName = enumAlarmListType.getDesc() + "-" + time + ".xlsx";
+        String excelName = enumDownloadAlarmListType.getDesc() + "-" + time + ".xlsx";
 
         response.reset();
         response.setContentType("application/msexcel;charset=UTF-8");

+ 4 - 4
src/main/java/com/persagy/apm/alarmservice/group/alarmrecord/enums/EnumAlarmListType.java

@@ -10,7 +10,7 @@ import org.apache.commons.lang.StringUtils;
  *
  **/
 @AllArgsConstructor
-public enum EnumAlarmListType {
+public enum EnumDownloadAlarmListType {
     /**
      * 报警列表类型
      */
@@ -26,12 +26,12 @@ public enum EnumAlarmListType {
     @Getter
     private String desc;
 
-    public static EnumAlarmListType getByType(String type) {
+    public static EnumDownloadAlarmListType getByType(String type) {
         if (StringUtils.isBlank(type)) {
             return null;
         }
-        EnumAlarmListType[] enums = EnumAlarmListType.values();
-        for (EnumAlarmListType item : enums) {
+        EnumDownloadAlarmListType[] enums = EnumDownloadAlarmListType.values();
+        for (EnumDownloadAlarmListType item : enums) {
             if (type.equals(item.getType())) {
                 return item;
             }

+ 3 - 0
src/main/java/com/persagy/apm/alarmservice/group/alarmrecord/model/dto/PageQueryAlarmRecordDTO.java

@@ -1,6 +1,7 @@
 package com.persagy.apm.alarmservice.group.alarmrecord.model.dto;
 
 import com.persagy.apm.common.model.dto.PageDTO;
+import com.persagy.apm.energyalarmstarter.alarmdata.enums.EnumAlarmListType;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
 import lombok.Data;
@@ -39,4 +40,6 @@ public class PageQueryAlarmRecordDTO extends PageDTO {
     private List<String> category;
     @ApiModelProperty(value = "项目id")
     private List<String> projectIds;
+    // 报警列表类型
+    private EnumAlarmListType listType;
 }

+ 10 - 10
src/main/java/com/persagy/apm/alarmservice/group/alarmrecord/service/AlarmRecordWrapper.java

@@ -384,11 +384,11 @@ public class AlarmRecordWrapper {
     /**
      * 填充 excel文件数据行
      *
-     * @param enumAlarmListType     报警列表类型
+     * @param enumDownloadAlarmListType     报警列表类型
      * @param sheet                 文件sheet
      * @param alarmRecordItemVOList 数据列表
      */
-    public void fillDataTable(EnumAlarmListType enumAlarmListType, XSSFSheet sheet, List<AlarmRecordItemVO> alarmRecordItemVOList) {
+    public void fillDataTable(EnumDownloadAlarmListType enumDownloadAlarmListType, XSSFSheet sheet, List<AlarmRecordItemVO> alarmRecordItemVOList) {
         try {
             for (int i = 0; i < alarmRecordItemVOList.size(); i++) {
                 AlarmRecordItemVO alarmRecordItemVO = alarmRecordItemVOList.get(i);
@@ -441,7 +441,7 @@ public class AlarmRecordWrapper {
                 }
                 cell = row.createCell(3);
                 cell.setCellValue(triggerTime);
-                if (EnumAlarmListType.CURRENT.getType().equals(enumAlarmListType.getType())) {
+                if (EnumDownloadAlarmListType.CURRENT.getType().equals(enumDownloadAlarmListType.getType())) {
                     cell = row.createCell(4);
                     cell.setCellValue(duration);
                     cell = row.createCell(5);
@@ -450,7 +450,7 @@ public class AlarmRecordWrapper {
                     cell.setCellValue(stateName);
                     cell = row.createCell(7);
                     cell.setCellValue(treatStateName);
-                } else if (EnumAlarmListType.HISTORY.getType().equals(enumAlarmListType.getType())) {
+                } else if (EnumDownloadAlarmListType.HISTORY.getType().equals(enumDownloadAlarmListType.getType())) {
                     cell = row.createCell(4);
                     cell.setCellValue(treatEndTime);
                     cell = row.createCell(5);
@@ -461,7 +461,7 @@ public class AlarmRecordWrapper {
                     cell.setCellValue(stateName);
                     cell = row.createCell(8);
                     cell.setCellValue(treatStateName);
-                } else if (EnumAlarmListType.IGNORE.getType().equals(enumAlarmListType.getType())) {
+                } else if (EnumDownloadAlarmListType.IGNORE.getType().equals(enumDownloadAlarmListType.getType())) {
                     cell = row.createCell(4);
                     cell.setCellValue(ignoreTime);
                     cell = row.createCell(5);
@@ -483,11 +483,11 @@ public class AlarmRecordWrapper {
     /**
      * 处理文件标题行
      *
-     * @param enumAlarmListType 报警列表类型
+     * @param enumDownloadAlarmListType 报警列表类型
      * @param sheet             文件sheet
      * @param wb                文件wb
      */
-    public void handleExcelTitle(EnumAlarmListType enumAlarmListType, XSSFSheet sheet, XSSFWorkbook wb) {
+    public void handleExcelTitle(EnumDownloadAlarmListType enumDownloadAlarmListType, XSSFSheet sheet, XSSFWorkbook wb) {
         XSSFCellStyle cellStyle = wb.createCellStyle();
         cellStyle.setWrapText(true);
         cellStyle.setFillForegroundColor(IndexedColors.GREY_50_PERCENT.getIndex());
@@ -511,7 +511,7 @@ public class AlarmRecordWrapper {
         cell = Row1.createCell(3);
         cell.setCellStyle(cellStyle);
         cell.setCellValue("报警开始时间");
-        if (EnumAlarmListType.CURRENT.getType().equals(enumAlarmListType.getType())) {
+        if (EnumDownloadAlarmListType.CURRENT.getType().equals(enumDownloadAlarmListType.getType())) {
             sheet.setColumnWidth(4, 4500);
             sheet.setColumnWidth(5, 3000);
             sheet.setColumnWidth(6, 3000);
@@ -528,7 +528,7 @@ public class AlarmRecordWrapper {
             cell = Row1.createCell(7);
             cell.setCellStyle(cellStyle);
             cell.setCellValue("报警处理状态");
-        } else if (EnumAlarmListType.HISTORY.getType().equals(enumAlarmListType.getType())) {
+        } else if (EnumDownloadAlarmListType.HISTORY.getType().equals(enumDownloadAlarmListType.getType())) {
             sheet.setColumnWidth(4, 5000);
             sheet.setColumnWidth(5, 3500);
             sheet.setColumnWidth(6, 3000);
@@ -549,7 +549,7 @@ public class AlarmRecordWrapper {
             cell = Row1.createCell(8);
             cell.setCellStyle(cellStyle);
             cell.setCellValue("报警处理状态");
-        } else if (EnumAlarmListType.IGNORE.getType().equals(enumAlarmListType.getType())) {
+        } else if (EnumDownloadAlarmListType.IGNORE.getType().equals(enumDownloadAlarmListType.getType())) {
             sheet.setColumnWidth(4, 5000);
             sheet.setColumnWidth(5, 3500);
             sheet.setColumnWidth(6, 3000);