|
@@ -388,34 +388,82 @@ public class MsgAlarmController extends BaseController {
|
|
|
if (user.isAdmin(user.getId())) {
|
|
|
userId = "";
|
|
|
}
|
|
|
- List<AlarmStatisticMonthDto> list = msgAlarmService.getCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
- alarmStatisticResVo.getCurrentMonth(), 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<>();
|
|
|
- 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();
|
|
|
- dto.setMonthsta(numbs.get(i));
|
|
|
- dto.setFrequency(0);
|
|
|
- list.add(dto);
|
|
|
+ List<Integer> numbs = new ArrayList<>();
|
|
|
+ Integer listSize;
|
|
|
+ List<AlarmStatisticMonthDto> list = null;
|
|
|
+ List<AlarmStatisticDayDto> listDay = null;
|
|
|
+ if (ObjectUtils.isEmpty(alarmStatisticResVo.getCurrentMonth())) {
|
|
|
+ list = msgAlarmService.getCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
+ alarmStatisticResVo.getCurrentMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
+ listSize = 12;
|
|
|
+ } else {
|
|
|
+ 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;
|
|
|
}
|
|
|
+ listDay = msgAlarmService.getDayCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
+ alarmStatisticResVo.getCurrentMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= listSize; i++) {
|
|
|
+ numbs.add(i);
|
|
|
}
|
|
|
- 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());
|
|
|
+ List<Integer> list1 = new ArrayList<>();
|
|
|
+ if (ObjectUtils.isEmpty(alarmStatisticResVo.getCurrentMonth())) {
|
|
|
+ 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();
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return AjaxResult.success(list);
|
|
|
+ } else {
|
|
|
+ if (!CollectionUtils.isEmpty(listDay) && Objects.nonNull(listDay.get(0))) {
|
|
|
+ listDay.forEach(l -> {
|
|
|
+ list1.add(l.getDaysta());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ AlarmStatisticDayDto dto;
|
|
|
+ for (int i = 0; i < numbs.size(); i++) {
|
|
|
+ if (!list1.contains(numbs.get(i))) {
|
|
|
+ dto = new AlarmStatisticDayDto();
|
|
|
+ dto.setDaysta(numbs.get(i));
|
|
|
+ dto.setFrequency(0);
|
|
|
+ listDay.add(dto);
|
|
|
}
|
|
|
- });
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(listDay) && Objects.nonNull(listDay.get(0))) {
|
|
|
+ Collections.sort(listDay, new Comparator<AlarmStatisticDayDto>() {
|
|
|
+ @Override
|
|
|
+ public int compare(AlarmStatisticDayDto o1, AlarmStatisticDayDto o2) {
|
|
|
+
|
|
|
+ return o1.getDaysta().compareTo(o2.getDaysta());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ return AjaxResult.success(listDay);
|
|
|
}
|
|
|
- return AjaxResult.success(list);
|
|
|
}
|
|
|
|
|
|
|
|
@@ -484,10 +532,32 @@ public class MsgAlarmController extends BaseController {
|
|
|
if (user.isAdmin(user.getId())) {
|
|
|
userId = "";
|
|
|
}
|
|
|
- try {
|
|
|
- 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<Integer> numbs = new ArrayList<>();
|
|
|
+ Integer listSize;
|
|
|
+ List<AlarmStatisticMonthDto> list = null;
|
|
|
+ List<AlarmStatisticDayDto> listDay = null;
|
|
|
+ if (ObjectUtils.isEmpty(alarmStatisticResVo.getCurrentMonth())) {
|
|
|
+ list = msgAlarmService.getCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
+ alarmStatisticResVo.getCurrentMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
+ listSize = 12;
|
|
|
+ } else {
|
|
|
+ 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;
|
|
|
+ }
|
|
|
+ listDay = msgAlarmService.getDayCount(alarmStatisticResVo.getRailwayCode(), alarmStatisticResVo.getCurrentYear(),
|
|
|
+ alarmStatisticResVo.getCurrentMonth(), alarmStatisticResVo.getAlarmType(), userId);
|
|
|
+ }
|
|
|
+ for (int i = 1; i <= listSize; i++) {
|
|
|
+ numbs.add(i);
|
|
|
+ }
|
|
|
+
|
|
|
+ List<Integer> list1 = new ArrayList<>();
|
|
|
+ if (ObjectUtils.isEmpty(alarmStatisticResVo.getCurrentMonth())) {
|
|
|
if (!CollectionUtils.isEmpty(list) && Objects.nonNull(list.get(0))) {
|
|
|
list.forEach(l -> {
|
|
|
list1.add(l.getMonthsta());
|
|
@@ -513,9 +583,32 @@ public class MsgAlarmController extends BaseController {
|
|
|
}
|
|
|
ExcelUtil<AlarmStatisticMonthDto> util = new ExcelUtil<>(AlarmStatisticMonthDto.class);
|
|
|
util.exportExcel(response, list, "报警月统计数据");
|
|
|
- } catch (Exception e) {
|
|
|
- e.printStackTrace();
|
|
|
- log.info(e.getMessage());
|
|
|
+ } else {
|
|
|
+ if (!CollectionUtils.isEmpty(listDay) && Objects.nonNull(listDay.get(0))) {
|
|
|
+ listDay.forEach(l -> {
|
|
|
+ list1.add(l.getDaysta());
|
|
|
+ });
|
|
|
+ }
|
|
|
+ AlarmStatisticDayDto dto;
|
|
|
+ for (int i = 0; i < numbs.size(); i++) {
|
|
|
+ if (!list1.contains(numbs.get(i))) {
|
|
|
+ dto = new AlarmStatisticDayDto();
|
|
|
+ dto.setDaysta(numbs.get(i));
|
|
|
+ dto.setFrequency(0);
|
|
|
+ listDay.add(dto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(listDay) && Objects.nonNull(listDay.get(0))) {
|
|
|
+ Collections.sort(listDay, new Comparator<AlarmStatisticDayDto>() {
|
|
|
+ @Override
|
|
|
+ public int compare(AlarmStatisticDayDto o1, AlarmStatisticDayDto o2) {
|
|
|
+
|
|
|
+ return o1.getDaysta().compareTo(o2.getDaysta());
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ ExcelUtil<AlarmStatisticDayDto> util = new ExcelUtil<>(AlarmStatisticDayDto.class);
|
|
|
+ util.exportExcel(response, listDay, "报警月统计数据");
|
|
|
}
|
|
|
}
|
|
|
}
|