|
|
@@ -33,37 +33,20 @@ public class DashboardServiceImpl implements DashboardService {
|
|
|
Long contentAlarms = dashboardMapper.getContentAlarmCount(month);
|
|
|
dashboard.setTotalThresholdAlarms(contentAlarms != null ? contentAlarms : 0L);
|
|
|
|
|
|
-
|
|
|
// 4. 阈值类告警
|
|
|
Long thresholdAlarms = dashboardMapper.getThresholdAlarmCount(month);
|
|
|
dashboard.setToralContentAlarms(thresholdAlarms != null ? thresholdAlarms : 0L);
|
|
|
|
|
|
-
|
|
|
// 5. 存在性告警 - 系统统计和总量统计
|
|
|
- List<SystemExistenceStatsDTO> systemExistenceStats = calculateSystemExistenceAlarms(month);
|
|
|
- Long totalExistenceAlarms = systemExistenceStats.stream()
|
|
|
- .mapToLong(SystemExistenceStatsDTO::getExistenceAlarms)
|
|
|
- .sum();
|
|
|
- dashboard.setExistenceAlarms(totalExistenceAlarms);
|
|
|
- dashboard.setTotalAlarms(totalAlarms+totalExistenceAlarms);
|
|
|
+ Long existenceAlarms = dashboardMapper.getExistenceAlarmsCount(month);
|
|
|
+ dashboard.setExistenceAlarms(existenceAlarms);
|
|
|
+ dashboard.setTotalAlarms(totalAlarms+existenceAlarms);
|
|
|
dashboard.setTotalProcessed(untreatedAndProcessedCounts != null ? untreatedAndProcessedCounts.getProcessed() : 0L);
|
|
|
dashboard.setTotalUntreated(dashboard.getTotalAlarms()-dashboard.getTotalProcessed());
|
|
|
+
|
|
|
// 6. 系统统计列表
|
|
|
List<SystemStatsDetailVO> systemStats = dashboardMapper.getSystemStatsDetail(month);
|
|
|
|
|
|
- // 7. 设置每个系统的存在性告警数量
|
|
|
- Map<String, Long> existenceMap = systemExistenceStats.stream()
|
|
|
- .collect(Collectors.toMap(
|
|
|
- SystemExistenceStatsDTO::getSystemId,
|
|
|
- SystemExistenceStatsDTO::getExistenceAlarms
|
|
|
- ));
|
|
|
-
|
|
|
- for (SystemStatsDetailVO stat : systemStats) {
|
|
|
- stat.setExistenceAlarms(existenceMap.getOrDefault(stat.getSystemId(), 0L));
|
|
|
- stat.setTotalAlarms(stat.getTotalAlarms()+stat.getExistenceAlarms());
|
|
|
- stat.setUntreatedCount(stat.getTotalAlarms()-stat.getProcessedCount());
|
|
|
- }
|
|
|
-
|
|
|
dashboard.setSystemStats(systemStats);
|
|
|
|
|
|
return dashboard;
|
|
|
@@ -217,7 +200,7 @@ public class DashboardServiceImpl implements DashboardService {
|
|
|
}
|
|
|
vo.setDates(dates);
|
|
|
|
|
|
- // 2. 获取内容类和阈值类每日数量
|
|
|
+ // 2. 获取内容类和阈值类 存在性每日数量
|
|
|
List<DateCountVO> contentDaily = dashboardMapper.getContentDailyTrend();
|
|
|
Map<String, Long> contentMap = contentDaily.stream()
|
|
|
.collect(Collectors.toMap(DateCountVO::getDate, DateCountVO::getCount));
|
|
|
@@ -226,22 +209,12 @@ public class DashboardServiceImpl implements DashboardService {
|
|
|
Map<String, Long> thresholdMap = thresholdDaily.stream()
|
|
|
.collect(Collectors.toMap(DateCountVO::getDate, DateCountVO::getCount));
|
|
|
|
|
|
- // 3. 获取所有系统配置的指标
|
|
|
- List<SystemMetricConfigDTO> allMetrics = dashboardMapper.getAllSystemMetrics();
|
|
|
+ List<DateCountVO> existenceDaily = dashboardMapper.getExistenceDailyTrend();
|
|
|
+ Map<String, Long> existenceDailyMap = existenceDaily.stream()
|
|
|
+ .collect(Collectors.toMap(DateCountVO::getDate, DateCountVO::getCount));
|
|
|
|
|
|
- // 4. 获取7天内所有已送达的报送记录
|
|
|
- List<DeliveryRecordDTO> deliveryRecords = dashboardMapper.getDeliveryRecordsLast7Days();
|
|
|
|
|
|
- // 5. 按日期-系统-指标分组统计实发次数
|
|
|
- Map<String, Map<String, Map<String, Long>>> actualSendMap = new HashMap<>();
|
|
|
- for (DeliveryRecordDTO record : deliveryRecords) {
|
|
|
- actualSendMap
|
|
|
- .computeIfAbsent(record.getDate(), k -> new HashMap<>())
|
|
|
- .computeIfAbsent(record.getSystemId(), k -> new HashMap<>())
|
|
|
- .merge(record.getMetricType(), 1L, Long::sum);
|
|
|
- }
|
|
|
-
|
|
|
- // 6. 计算每天的存在性告警数量
|
|
|
+ // 3. 计算内容类和阈值类 存在性告警数量
|
|
|
List<Long> contentCounts = new ArrayList<>();
|
|
|
List<Long> thresholdCounts = new ArrayList<>();
|
|
|
List<Long> existenceCounts = new ArrayList<>();
|
|
|
@@ -254,29 +227,7 @@ public class DashboardServiceImpl implements DashboardService {
|
|
|
thresholdCounts.add(contentMap.getOrDefault(date, 0L));
|
|
|
|
|
|
// 存在性 - 每天应发-实发
|
|
|
- long dailyMissedCount = 0L;
|
|
|
-
|
|
|
- for (SystemMetricConfigDTO metric : allMetrics) {
|
|
|
- Integer reportInterval = metric.getReportInterval();
|
|
|
- if (reportInterval == null || reportInterval <= 0) {
|
|
|
- reportInterval = 60;
|
|
|
- }
|
|
|
-
|
|
|
- // 当天应发次数
|
|
|
- long shouldSendCount = (24 * 60) / reportInterval;
|
|
|
-
|
|
|
- // 当天实际已送达次数
|
|
|
- long actualSendCount = 0L;
|
|
|
- if (actualSendMap.containsKey(date)
|
|
|
- && actualSendMap.get(date).containsKey(metric.getSystemId())
|
|
|
- && actualSendMap.get(date).get(metric.getSystemId()).containsKey(metric.getMetricType())) {
|
|
|
- actualSendCount = actualSendMap.get(date).get(metric.getSystemId()).get(metric.getMetricType());
|
|
|
- }
|
|
|
-
|
|
|
- dailyMissedCount += Math.max(0, shouldSendCount - actualSendCount);
|
|
|
- }
|
|
|
-
|
|
|
- existenceCounts.add(dailyMissedCount);
|
|
|
+ existenceCounts.add(existenceDailyMap.getOrDefault(date, 0L));
|
|
|
}
|
|
|
|
|
|
vo.setContentCounts(contentCounts);
|
|
|
@@ -313,20 +264,13 @@ public class DashboardServiceImpl implements DashboardService {
|
|
|
SystemCategoryVO::getContentCount,
|
|
|
(v1, v2) -> v1));
|
|
|
|
|
|
- // 4. 获取所有系统配置的指标(用于存在性计算)
|
|
|
- List<SystemMetricConfigDTO> allMetrics = dashboardMapper.getAllSystemMetrics();
|
|
|
- Map<String, List<SystemMetricConfigDTO>> metricsBySystem = allMetrics.stream()
|
|
|
- .collect(Collectors.groupingBy(SystemMetricConfigDTO::getSystemId));
|
|
|
-
|
|
|
- // 5. 获取7天内所有已送达的报送记录(存在性实发)
|
|
|
- List<DeliveryRecordDTO> deliveryRecords = dashboardMapper.getDeliveryRecordsLast7Days();
|
|
|
+ // 4. 获取7天内所有已送达的报送记录(存在性实发)
|
|
|
+ List<SystemCategoryVO> existenceAlarms = dashboardMapper.getDeliveryRecordsLast7Days();
|
|
|
+ Map<String, Long> existenceMap = existenceAlarms.stream()
|
|
|
+ .collect(Collectors.toMap(SystemCategoryVO::getSystemId,
|
|
|
+ SystemCategoryVO::getContentCount,
|
|
|
+ (v1, v2) -> v1));
|
|
|
|
|
|
- // 按系统+指标分组统计7天实发次数
|
|
|
- Map<String, Long> actualSendMap = new HashMap<>();
|
|
|
- for (DeliveryRecordDTO record : deliveryRecords) {
|
|
|
- String key = record.getSystemId() + ":" + record.getMetricType();
|
|
|
- actualSendMap.put(key, actualSendMap.getOrDefault(key, 0L) + 1);
|
|
|
- }
|
|
|
|
|
|
// 6. 遍历每个系统
|
|
|
for (SystemInfo system : systems) {
|
|
|
@@ -340,29 +284,8 @@ public class DashboardServiceImpl implements DashboardService {
|
|
|
// 阈值类数量
|
|
|
vo.setThresholdCount(thresholdMap.getOrDefault(system.getSystemId(), 0L));
|
|
|
|
|
|
- // 存在性告警数量 = 7天应发总数 - 7天实发总数
|
|
|
- long existenceCount = 0L;
|
|
|
- List<SystemMetricConfigDTO> systemMetrics = metricsBySystem.getOrDefault(system.getSystemId(), new ArrayList<>());
|
|
|
-
|
|
|
- for (SystemMetricConfigDTO metric : systemMetrics) {
|
|
|
- Integer reportInterval = metric.getReportInterval();
|
|
|
- if (reportInterval == null || reportInterval <= 0) {
|
|
|
- reportInterval = 60; // 默认60分钟
|
|
|
- }
|
|
|
-
|
|
|
- // 7天应发总数 = 每天应发次数 × 7天
|
|
|
- long dailyShouldSend = (24 * 60) / reportInterval;
|
|
|
- long weekShouldSend = dailyShouldSend * 7;
|
|
|
-
|
|
|
- // 7天实发总数
|
|
|
- String key = system.getSystemId() + ":" + metric.getMetricType();
|
|
|
- long weekActualSend = actualSendMap.getOrDefault(key, 0L);
|
|
|
-
|
|
|
- // 未发送数量
|
|
|
- existenceCount += Math.max(0, weekShouldSend - weekActualSend);
|
|
|
- }
|
|
|
-
|
|
|
- vo.setExistenceCount(existenceCount);
|
|
|
+ // 存在性
|
|
|
+ vo.setExistenceCount(existenceMap.getOrDefault(system.getSystemId(), 0L));
|
|
|
result.add(vo);
|
|
|
}
|
|
|
|