|
@@ -33,6 +33,7 @@ import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
+import org.springframework.util.CollectionUtils;
|
|
|
import org.springframework.util.ObjectUtils;
|
|
|
import org.springframework.web.bind.annotation.GetMapping;
|
|
|
import org.springframework.web.bind.annotation.PathVariable;
|
|
@@ -285,9 +286,11 @@ public class MsgAlarmController extends BaseController {
|
|
|
alarmStatisticResVo.getEndMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
List<Integer> numbs = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
|
|
|
List<Integer> list1 = new ArrayList<>();
|
|
|
- list.forEach(l -> {
|
|
|
- list1.add(l.getMonthsta());
|
|
|
- });
|
|
|
+ if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
+ list.forEach(l -> {
|
|
|
+ list1.add(l.getMonthsta());
|
|
|
+ });
|
|
|
+ }
|
|
|
AlarmStatisticMonthDto dto;
|
|
|
for (int i = 0; i < numbs.size(); i++) {
|
|
|
if (!list1.contains(numbs.get(i))) {
|
|
@@ -297,13 +300,15 @@ public class MsgAlarmController extends BaseController {
|
|
|
list.add(dto);
|
|
|
}
|
|
|
}
|
|
|
- Collections.sort(list, new Comparator<AlarmStatisticMonthDto>() {
|
|
|
- @Override
|
|
|
- public int compare(AlarmStatisticMonthDto o1, AlarmStatisticMonthDto o2) {
|
|
|
+ if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
+ Collections.sort(list, new Comparator<AlarmStatisticMonthDto>() {
|
|
|
+ @Override
|
|
|
+ public int compare(AlarmStatisticMonthDto o1, AlarmStatisticMonthDto o2) {
|
|
|
|
|
|
- return o1.getMonthsta().compareTo(o2.getMonthsta());
|
|
|
- }
|
|
|
- });
|
|
|
+ return o1.getMonthsta().compareTo(o2.getMonthsta());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
@@ -330,16 +335,19 @@ public class MsgAlarmController extends BaseController {
|
|
|
}
|
|
|
try {
|
|
|
List<AlarmStatisticDto> list = msgAlarmService.exportExcel(alarmStatisticResVo, userId);
|
|
|
- list.forEach(l -> {
|
|
|
- String alarmType = l.getAlarmType();
|
|
|
- String alarmTypeValue = dictDataService.selectDictLabel("sys_alarm_type", alarmType);
|
|
|
- l.setAlarmTypeValue(alarmTypeValue);
|
|
|
+ if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
+ list.forEach(l -> {
|
|
|
+ String alarmType = l.getAlarmType();
|
|
|
+ String alarmTypeValue = dictDataService.selectDictLabel("sys_alarm_type", alarmType);
|
|
|
+ l.setAlarmTypeValue(alarmTypeValue);
|
|
|
|
|
|
- String lineDir = l.getLineDir();
|
|
|
- String lineDirValue = dictDataService.selectDictLabel("sys_line_dir", lineDir);
|
|
|
- l.setLineDirValue(lineDirValue);
|
|
|
+ String lineDir = l.getLineDir();
|
|
|
+ String lineDirValue = dictDataService.selectDictLabel("sys_line_dir", lineDir);
|
|
|
+ l.setLineDirValue(lineDirValue);
|
|
|
+
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- });
|
|
|
ExcelUtil<AlarmStatisticDto> util = new ExcelUtil<>(AlarmStatisticDto.class);
|
|
|
util.exportExcel(response, list, "报警数据详情");
|
|
|
} catch (Exception e) {
|
|
@@ -372,9 +380,11 @@ public class MsgAlarmController extends BaseController {
|
|
|
List<AlarmStatisticMonthDto> list = msgAlarmService.exportExcelMonth(alarmStatisticResVo, userId);
|
|
|
List<Integer> numbs = new ArrayList<>(Arrays.asList(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12));
|
|
|
List<Integer> list1 = new ArrayList<>();
|
|
|
- list.forEach(l -> {
|
|
|
- list1.add(l.getMonthsta());
|
|
|
- });
|
|
|
+ if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
+ list.forEach(l -> {
|
|
|
+ list1.add(l.getMonthsta());
|
|
|
+ });
|
|
|
+ }
|
|
|
AlarmStatisticMonthDto dto;
|
|
|
for (int i = 0; i < numbs.size(); i++) {
|
|
|
if (!list1.contains(numbs.get(i))) {
|
|
@@ -384,13 +394,15 @@ public class MsgAlarmController extends BaseController {
|
|
|
list.add(dto);
|
|
|
}
|
|
|
}
|
|
|
- Collections.sort(list, new Comparator<AlarmStatisticMonthDto>() {
|
|
|
- @Override
|
|
|
- public int compare(AlarmStatisticMonthDto o1, AlarmStatisticMonthDto o2) {
|
|
|
+ if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
+ Collections.sort(list, new Comparator<AlarmStatisticMonthDto>() {
|
|
|
+ @Override
|
|
|
+ public int compare(AlarmStatisticMonthDto o1, AlarmStatisticMonthDto o2) {
|
|
|
|
|
|
- return o1.getMonthsta().compareTo(o2.getMonthsta());
|
|
|
- }
|
|
|
- });
|
|
|
+ return o1.getMonthsta().compareTo(o2.getMonthsta());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
ExcelUtil<AlarmStatisticMonthDto> util = new ExcelUtil<>(AlarmStatisticMonthDto.class);
|
|
|
util.exportExcel(response, list, "报警月统计数据");
|
|
|
} catch (Exception e) {
|