diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java index a6c16fd..c287b6f 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java @@ -50,4 +50,17 @@ private Double deviceCountProportion; + /** + * X轴底部月份集合 + */ + @ApiModelProperty(value = "X轴底部月份集合") + private List xAxis; + + + /** + * Y轴底部月份集合 + */ + @ApiModelProperty(value = "Y轴站点个数集合") + private List yAxis; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java index a6c16fd..c287b6f 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/domain/response/WarnMonthAlarmsResponse.java @@ -50,4 +50,17 @@ private Double deviceCountProportion; + /** + * X轴底部月份集合 + */ + @ApiModelProperty(value = "X轴底部月份集合") + private List xAxis; + + + /** + * Y轴底部月份集合 + */ + @ApiModelProperty(value = "Y轴站点个数集合") + private List yAxis; + } diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/StatisticsServiceImpl.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/StatisticsServiceImpl.java index bd75537..cea3398 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/StatisticsServiceImpl.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/impl/StatisticsServiceImpl.java @@ -57,10 +57,6 @@ private IMonitoringWarnRecordService monitoringWarnRecordService; -// @Resource -// private IStatisticsService statisticsService; - - @Override public Map> warnDailySeqStatistic(SiteWarnDailySeqStatisticRequest request) { List deviceMonitoringDataList = deviceMonitoringDataService.selectList(request.getProjectCode(), EExistsAnt.True); @@ -213,9 +209,15 @@ int currentYear = now.getYear(); warnMonthAlarmsResponseInfoList.stream().filter(info -> info.getWarnYear() == currentYear).collect(Collectors.toList()); if(warnMonthAlarmsResponseInfoList.isEmpty()){ - throw new InnerAuthException("该项目下没有告警信息"); + throw new InnerAuthException("该项目下没有告警信息1"); } warnMonthAlarmsResponse.setWarnListInfo(warnMonthAlarmsResponseInfoList); + warnMonthAlarmsResponse.setXAxis(warnMonthAlarmsResponseInfoList.stream() + .map(WarnMonthAlarmsResponseInfo::getWarnMonth) + .collect(Collectors.toList())); + warnMonthAlarmsResponse.setYAxis(warnMonthAlarmsResponseInfoList.stream() + .map(WarnMonthAlarmsResponseInfo::getWarnNumber) + .collect(Collectors.toList())); warnMonthAlarmsResponse.setProjectCode(request.getProjectCode()); Map monthCounts = new TreeMap<>(); long totalSnCount = 0; @@ -250,52 +252,52 @@ WarnMonitoringRequest warnMonitoringRequest = new WarnMonitoringRequest(); warnMonitoringRequest.setProjectCode(request.getProjectCode()); -// List listWarinTotalDays=statisticsService.listWarinTotalDays(warnMonitoringRequest); -// //累计站点个数 -// long uniqueSnCount = listWarinTotalDays.stream().map(WarnMonitoringResponseInfo::getSn).distinct().count(); -// //告警超过15天的站点 -// long count1 = listWarinTotalDays.stream().filter(info -> info.getCount() > 15).map(WarnMonitoringResponseInfo::getSn).distinct().count(); -// -// warnMonitoringResponse.setWarnmoitoringExceedDay(count1); -// warnMonitoringResponse.setWarnmoitoringCountDay(uniqueSnCount); -// warnMonitoringResponse.setProjectCode(request.getProjectCode()); -// warnMonitoringResponse.setWarnmoitoringListInfo(listWarinTotalDays); -// -// -// //累计告警天数统计,并计算百分比 -// Map durationToSnCount = new HashMap<>(); -// listWarinTotalDays.stream() -// .collect(Collectors.groupingBy(WarnMonitoringResponseInfo::getSn, -// Collectors.mapping(WarnMonitoringResponseInfo::getCount, -// Collectors.toList()))) -// .forEach((sn, days) -> { -// days.stream() -// .forEach(day -> { -// String key; -// if (day <= 1) { -// key = "无告警"; -// } else if (day >=2 && day <= 3) { -// key = "2-3天"; -// } else if (day >=4 && day <= 6) { -// key = "4-6天"; -// } else if (day >=7 && day <= 15) { -// key = "7-15天"; -// } else { -// key = ">15天"; -// } -// durationToSnCount.merge(key, 1L, Long::sum); -// }); -// }); -// -// List warnMonitoringResponseDaysInfoList = new ArrayList(); -// -// // 计算百分比并添加到结果列表中 -// durationToSnCount.forEach((durationRange, count) -> { -// double percentage = (double) count / uniqueSnCount * 100; -// warnMonitoringResponseDaysInfoList.add(new WarnMonitoringResponseDaysInfo(durationRange,percentage)); -// -// }); -// warnMonitoringResponse.setWarnmoitoringDaysListInfo(warnMonitoringResponseDaysInfoList); + List listWarinTotalDays=this.listWarinTotalDays(warnMonitoringRequest); + //累计站点个数 + long uniqueSnCount = listWarinTotalDays.stream().map(WarnMonitoringResponseInfo::getSn).distinct().count(); + //告警超过15天的站点 + long count1 = listWarinTotalDays.stream().filter(info -> info.getCount() > 15).map(WarnMonitoringResponseInfo::getSn).distinct().count(); + + warnMonitoringResponse.setWarnmoitoringExceedDay(count1); + warnMonitoringResponse.setWarnmoitoringCountDay(uniqueSnCount); + warnMonitoringResponse.setProjectCode(request.getProjectCode()); + warnMonitoringResponse.setWarnmoitoringListInfo(listWarinTotalDays); + + + //累计告警天数统计,并计算百分比 + Map durationToSnCount = new HashMap<>(); + listWarinTotalDays.stream() + .collect(Collectors.groupingBy(WarnMonitoringResponseInfo::getSn, + Collectors.mapping(WarnMonitoringResponseInfo::getCount, + Collectors.toList()))) + .forEach((sn, days) -> { + days.stream() + .forEach(day -> { + String key; + if (day <= 1) { + key = "无告警"; + } else if (day >=2 && day <= 3) { + key = "2-3天"; + } else if (day >=4 && day <= 6) { + key = "4-6天"; + } else if (day >=7 && day <= 15) { + key = "7-15天"; + } else { + key = ">15天"; + } + durationToSnCount.merge(key, 1L, Long::sum); + }); + }); + + List warnMonitoringResponseDaysInfoList = new ArrayList(); + + // 计算百分比并添加到结果列表中 + durationToSnCount.forEach((durationRange, count) -> { + double percentage = (double) count / uniqueSnCount * 100; + warnMonitoringResponseDaysInfoList.add(new WarnMonitoringResponseDaysInfo(durationRange,percentage)); + + }); + warnMonitoringResponse.setWarnmoitoringDaysListInfo(warnMonitoringResponseDaysInfoList); return new WarnMonitoringResponse(); }