diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java index 317838b..488474c 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java @@ -79,11 +79,19 @@ @GetMapping("/warn_month_alarms") @ApiOperation(value = "告警分析", position = 50) + //此接口暂留不再使用,使用下面的WarnMonthAlarmsStatistics接口 public Result warnMonthAlarms(WarnMonthAlarmsRequest request){ WarnMonthAlarmsResponse response = statisticsService.warnMonthAlarms(request); return success(response); } + @GetMapping("/WarnMonthAlarmsStatistics") + @ApiOperation(value = "告警分析统计", position = 50) + public Result WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request){ + WarnMonthAlarmsResponse response = statisticsService.WarnMonthAlarmsStatistics(request); + return success(response); + } + @GetMapping("/warn_monitoring") @ApiOperation(value = "监测预警", position = 50) @@ -104,7 +112,7 @@ /** - * SN查询累计告警天数 + * SN查询连续告警天数 */ @GetMapping("/SnWarinTotalDays") @ApiOperation(value = "查询设备累计告警天数", position = 60) diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java index 317838b..488474c 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java @@ -79,11 +79,19 @@ @GetMapping("/warn_month_alarms") @ApiOperation(value = "告警分析", position = 50) + //此接口暂留不再使用,使用下面的WarnMonthAlarmsStatistics接口 public Result warnMonthAlarms(WarnMonthAlarmsRequest request){ WarnMonthAlarmsResponse response = statisticsService.warnMonthAlarms(request); return success(response); } + @GetMapping("/WarnMonthAlarmsStatistics") + @ApiOperation(value = "告警分析统计", position = 50) + public Result WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request){ + WarnMonthAlarmsResponse response = statisticsService.WarnMonthAlarmsStatistics(request); + return success(response); + } + @GetMapping("/warn_monitoring") @ApiOperation(value = "监测预警", position = 50) @@ -104,7 +112,7 @@ /** - * SN查询累计告警天数 + * SN查询连续告警天数 */ @GetMapping("/SnWarinTotalDays") @ApiOperation(value = "查询设备累计告警天数", position = 60) diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java index 62a2662..3700216 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java @@ -31,6 +31,8 @@ WarnMonthAlarmsResponse warnMonthAlarms(WarnMonthAlarmsRequest request); + WarnMonthAlarmsResponse WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request); + WarnMonitoringResponse warnMonitoring(WarnMonitoringRequest request); List listWarinTotalDays(WarnMonitoringRequest request); diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java index 317838b..488474c 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/controller/StatisticsController.java @@ -79,11 +79,19 @@ @GetMapping("/warn_month_alarms") @ApiOperation(value = "告警分析", position = 50) + //此接口暂留不再使用,使用下面的WarnMonthAlarmsStatistics接口 public Result warnMonthAlarms(WarnMonthAlarmsRequest request){ WarnMonthAlarmsResponse response = statisticsService.warnMonthAlarms(request); return success(response); } + @GetMapping("/WarnMonthAlarmsStatistics") + @ApiOperation(value = "告警分析统计", position = 50) + public Result WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request){ + WarnMonthAlarmsResponse response = statisticsService.WarnMonthAlarmsStatistics(request); + return success(response); + } + @GetMapping("/warn_monitoring") @ApiOperation(value = "监测预警", position = 50) @@ -104,7 +112,7 @@ /** - * SN查询累计告警天数 + * SN查询连续告警天数 */ @GetMapping("/SnWarinTotalDays") @ApiOperation(value = "查询设备累计告警天数", position = 60) diff --git a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java index 62a2662..3700216 100644 --- a/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java +++ b/newfiber-termites/newfiber-termites-dataup/src/main/java/com/newfiber/termite/service/IStatisticsService.java @@ -31,6 +31,8 @@ WarnMonthAlarmsResponse warnMonthAlarms(WarnMonthAlarmsRequest request); + WarnMonthAlarmsResponse WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request); + WarnMonitoringResponse warnMonitoring(WarnMonitoringRequest request); List listWarinTotalDays(WarnMonitoringRequest request); 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 81d206c..90f7565 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 @@ -268,6 +268,59 @@ } @Override + public WarnMonthAlarmsResponse WarnMonthAlarmsStatistics(WarnMonthAlarmsRequest request) { + WarnMonthAlarmsResponse warnMonthAlarmsResponse = new WarnMonthAlarmsResponse(); + List warnMonthAlarmsResponseInfoList = monitoringWarnRecordService.selectWarnMonthListTotal(request.getProjectCode()); + WarnMonitoringRequest warnMonitoringRequest = new WarnMonitoringRequest(); + warnMonitoringRequest.setProjectCode(request.getProjectCode()); + WarnMonitoringResponse warnMonitoringResponse = this.warnMonitoring(warnMonitoringRequest); + //累计告警站点数 + Long countDay = (warnMonitoringResponse.getWarnmoitoringCountDay() != null) ? warnMonitoringResponse.getWarnmoitoringCountDay() : 0L; + LocalDate now = LocalDate.now(); + int currentYear = now.getYear(); + List stringx = new ArrayList<>(); + List stringy = new ArrayList<>(); + warnMonthAlarmsResponseInfoList.stream().filter(info -> info.getWarnYear() == currentYear).collect(Collectors.toList()); + if(warnMonthAlarmsResponseInfoList.isEmpty()){ + warnMonthAlarmsResponse.setXAxis(stringx); + warnMonthAlarmsResponse.setYAxis(stringy); + return warnMonthAlarmsResponse; + } + warnMonthAlarmsResponse.setWarnListInfo(warnMonthAlarmsResponseInfoList); + warnMonthAlarmsResponse.setXAxis(warnMonthAlarmsResponseInfoList.stream() + .map(info -> info.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; + for (WarnMonthAlarmsResponseInfo info : warnMonthAlarmsResponseInfoList) { + Integer key = info.getWarnMonth(); + monthCounts.merge(key, info.getWarnNumber(), Long::sum); + totalSnCount += info.getWarnNumber(); + } + List> sortedEntries = new ArrayList<>(monthCounts.entrySet()); + sortedEntries.sort(Map.Entry.comparingByValue(Comparator.reverseOrder())); + //计算百分比以及告警站点个数 + BigDecimal percentage; + if(countDay==0){ + percentage = BigDecimal.ZERO; + warnMonthAlarmsResponse.setDeviceCountProportion(percentage.doubleValue()); + }else{ + percentage = new BigDecimal(((double) countDay) / warnMonitoringResponse.getWarnmoitoringListInfo().size()) + .multiply(BigDecimal.valueOf(100)) + .setScale(2, RoundingMode.HALF_UP); + warnMonthAlarmsResponse.setDeviceCountProportion(percentage.doubleValue()); + } + long warnMonitorlong=warnMonitoringResponse.getWarnmoitoringListInfo().size(); + warnMonthAlarmsResponse.setWarnDeviceCount(warnMonitorlong); + + return warnMonthAlarmsResponse; + } + + @Override public WarnMonitoringResponse warnMonitoring(WarnMonitoringRequest request) { WarnMonitoringResponse warnMonitoringResponse = new WarnMonitoringResponse(); @@ -320,6 +373,11 @@ warnMonitoringResponseDaysInfoList.add(new WarnMonitoringResponseDaysInfo(durationRange,percentage.doubleValue())); } }); + + warnMonitoringResponseDaysInfoList.sort(Comparator.comparingInt(info -> { + int index = allDurationRanges.indexOf(info.getWarnMonth()); + return index != -1 ? index : Integer.MAX_VALUE; + })); warnMonitoringResponse.setWarnmoitoringDaysListInfo(warnMonitoringResponseDaysInfoList); return warnMonitoringResponse; }