|
@@ -283,6 +283,40 @@ public class AlarmRecordController {
|
|
|
return ResultHelper.single(alarmRecordItemVO);
|
|
|
}
|
|
|
|
|
|
+ @ApiOperation(value = "下载全部记录")
|
|
|
+ @PostMapping("/download_all")
|
|
|
+ public void downloadAllAlarmRecord(
|
|
|
+ @Valid @RequestBody DownloadAllAlarmRecordDTO downloadAllAlarmRecordDTO,
|
|
|
+ HttpServletResponse response, HttpServletRequest request) throws Exception {
|
|
|
+ String listType = downloadAllAlarmRecordDTO.getListType();
|
|
|
+ PageQueryAlarmRecordDTO pageQueryAlarmRecordDTO = ConvertAlarmRecordTool.INSTANCE.convert2PageQueryAlarmRecordDTO(downloadAllAlarmRecordDTO);
|
|
|
+ // 去掉分页条件
|
|
|
+ pageQueryAlarmRecordDTO.setSize(Integer.MAX_VALUE);
|
|
|
+ CommonResult<PageList<AlarmRecordListItem>> result = null;
|
|
|
+ if (listType.equals(EnumAlarmListType.CURRENT.getType())) {
|
|
|
+ result = queryCurrentAlarmRecord(pageQueryAlarmRecordDTO);
|
|
|
+ }
|
|
|
+ if (listType.equals(EnumAlarmListType.HISTORY.getType())) {
|
|
|
+ result = queryHistoryAlarmRecord(pageQueryAlarmRecordDTO);
|
|
|
+ }
|
|
|
+ if (listType.equals(EnumAlarmListType.IGNORE.getType())) {
|
|
|
+ result = queryIgnoredAlarmRecord(pageQueryAlarmRecordDTO);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<AlarmRecordListItem> alarmRecordItemList = new ArrayList<>();
|
|
|
+ if (result != null) {
|
|
|
+ alarmRecordItemList = result.getContent().getRecords();
|
|
|
+ }
|
|
|
+
|
|
|
+ List<AlarmRecordItemVO> alarmRecordItemVOList = ConvertAlarmRecordTool.INSTANCE.
|
|
|
+ convert2AlarmRecordItemVOList(alarmRecordItemList);
|
|
|
+ EnumAlarmListType enumAlarmListType = EnumAlarmListType.getByType(listType);
|
|
|
+ if (enumAlarmListType == null) {
|
|
|
+ throw new IllegalArgumentException("列表类型传值错误");
|
|
|
+ }
|
|
|
+ downloadRecordList(response, enumAlarmListType, alarmRecordItemVOList);
|
|
|
+ }
|
|
|
+
|
|
|
@ApiOperation(value = "下载")
|
|
|
@PostMapping("/download")
|
|
|
public void downloadAlarmRecord(
|
|
@@ -298,7 +332,27 @@ public class AlarmRecordController {
|
|
|
}
|
|
|
// 获取报警详情列表
|
|
|
List<AlarmRecordItem> alarmRecordItemList = alarmRecordWrapper.getAlarmRecordList(recordIdList);
|
|
|
+ List<AlarmRecordItemVO> alarmRecordItemVOList = new ArrayList<>();
|
|
|
+ if (!CollectionUtils.isEmpty(alarmRecordItemList)) {
|
|
|
+ for (AlarmRecordItem alarmRecord : alarmRecordItemList) {
|
|
|
+ alarmRecordItemVOList.add(alarmRecordWrapper.convert2AlarmRecordItemVO(alarmRecord));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ downloadRecordList(response, enumAlarmListType, alarmRecordItemVOList);
|
|
|
+ }
|
|
|
|
|
|
+ /**
|
|
|
+ * 下载报警记录列表
|
|
|
+ *
|
|
|
+ * @param response response对象
|
|
|
+ * @param enumAlarmListType 列表类型
|
|
|
+ * @param alarmRecordItemList 要下载的列表
|
|
|
+ * @author lixing
|
|
|
+ * @version V1.0 2021/10/19 7:22 下午
|
|
|
+ */
|
|
|
+ private void downloadRecordList(
|
|
|
+ HttpServletResponse response, EnumAlarmListType enumAlarmListType,
|
|
|
+ List<AlarmRecordItemVO> alarmRecordItemVOList) throws Exception {
|
|
|
// 创建Workbook
|
|
|
XSSFWorkbook wb = new XSSFWorkbook();
|
|
|
XSSFSheet overViewSheet = wb.createSheet();
|
|
@@ -307,11 +361,7 @@ public class AlarmRecordController {
|
|
|
// 处理表头
|
|
|
alarmRecordWrapper.handleExcelTitle(enumAlarmListType, overViewSheet, wb);
|
|
|
|
|
|
- if (!CollectionUtils.isEmpty(alarmRecordItemList) && alarmRecordItemList.size() > 0) {
|
|
|
- List<AlarmRecordItemVO> alarmRecordItemVOList = new ArrayList<>();
|
|
|
- for (AlarmRecordItem alarmRecord : alarmRecordItemList) {
|
|
|
- alarmRecordItemVOList.add(alarmRecordWrapper.convert2AlarmRecordItemVO(alarmRecord));
|
|
|
- }
|
|
|
+ if (!CollectionUtils.isEmpty(alarmRecordItemVOList)) {
|
|
|
// 能耗概览Sheet数据填充
|
|
|
alarmRecordWrapper.fillDataTable(enumAlarmListType, overViewSheet, alarmRecordItemVOList);
|
|
|
}
|
|
@@ -334,5 +384,7 @@ public class AlarmRecordController {
|
|
|
e.printStackTrace();
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|
|
|
|