|
@@ -689,17 +689,67 @@ public class MsgAlarmController extends BaseController {
|
|
|
if (user.isAdmin(user.getId())) {
|
|
|
userId = "";
|
|
|
}
|
|
|
-
|
|
|
+ String sheetName = "报警年统计数据";
|
|
|
+ List<Integer> numbs = new ArrayList<>();
|
|
|
+ Integer listSize;
|
|
|
List<AlarmStatisticMonthDto> list = null;
|
|
|
if (ObjectUtils.isEmpty(alarmStatisticResVo.getCurrentMonth())) {
|
|
|
list = msgAlarmService.getCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
alarmStatisticResVo.getCurrentMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
+ listSize = 12;
|
|
|
} else {
|
|
|
+ sheetName = "报警月统计数据";
|
|
|
+ if (alarmStatisticResVo.getCurrentMonth().equals(2)) {//2
|
|
|
+ listSize = 28;
|
|
|
+ } else if (alarmStatisticResVo.getCurrentMonth().equals(4) || alarmStatisticResVo.getCurrentMonth().equals(6) ||
|
|
|
+ alarmStatisticResVo.getCurrentMonth().equals(9) || alarmStatisticResVo.getCurrentMonth().equals(11)) {//4,6,9,11
|
|
|
+ listSize = 30;
|
|
|
+ } else {//1,3,5,7,8,10,12
|
|
|
+ listSize = 31;
|
|
|
+ }
|
|
|
list = msgAlarmService.getDayCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
alarmStatisticResVo.getCurrentMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
}
|
|
|
+ if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
+ for (int i = 1; i <= listSize; i++) {
|
|
|
+ numbs.add(i);
|
|
|
+ }
|
|
|
+ List<Integer> list1 = new ArrayList<>();
|
|
|
+ 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))) {
|
|
|
+ dto = new AlarmStatisticMonthDto();
|
|
|
+ String split = numbs.get(i).toString();
|
|
|
+ if (numbs.get(i) <= 9) {
|
|
|
+ split = "0" + numbs.get(i);
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isEmpty(alarmStatisticResVo.getCurrentMonth())) {//年数据
|
|
|
+ dto.setMonthstaString(list.get(0).getMonthstaString().substring(0, 5) + split + "月");
|
|
|
+ } else {//月数据
|
|
|
+ dto.setMonthstaString(list.get(0).getMonthstaString().substring(0, 8) + split + "日");
|
|
|
+ }
|
|
|
+ dto.setMonthsta(numbs.get(i));
|
|
|
+ dto.setFrequency(0);
|
|
|
+ list.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
ExcelUtil<AlarmStatisticMonthDto> util = new ExcelUtil<>(AlarmStatisticMonthDto.class);
|
|
|
- util.exportExcel(response, list, "报警月统计数据");
|
|
|
+ util.exportExcel(response, list, sheetName);
|
|
|
}
|
|
|
}
|
|
|
|