Bladeren bron

项目列表返回告警id

lengfaqiang 2 jaren geleden
bovenliggende
commit
07b5f9dfcd

+ 8 - 4
slope-modules/slope-detection/src/main/java/com/sckw/slope/detection/service/ProjectService.java

@@ -1463,7 +1463,7 @@ public class ProjectService {
                                 .eq(KwsAlarmDetail::getStatus, NumberConstant.ZERO)
                 );
                 if (!CollectionUtils.isEmpty(details) && details.size() > 0) {
-                    List<Long> thresholdIds = details.stream().map(KwsAlarmDetail::getPid).collect(Collectors.toList());
+                    List<Long> thresholdIds = details.stream().map(KwsAlarmDetail::getPid).distinct().collect(Collectors.toList());
                     if (!CollectionUtils.isEmpty(thresholdIds)) {
                         List<KwsThreshold> thresholds = thresholdMapper.selectList(
                                 new LambdaQueryWrapper<KwsThreshold>()
@@ -1483,7 +1483,11 @@ public class ProjectService {
                             if (objects.contains(alarmStatus)) {
                                 for (KwsThreshold threshold : thresholds) {
                                     if (alarmStatus.equals(String.valueOf(threshold.getLevel()))) {
-                                        thresholdId = threshold.getId().toString();
+                                        List<KwsAlarmDetail> alarmDetails = alarmDetailMapper.selectList(new LambdaQueryWrapper<KwsAlarmDetail>()
+                                                .eq(KwsAlarmDetail::getPid, threshold.getId()));
+                                        if (!CollectionUtils.isEmpty(alarmDetails) && alarmDetails.size() > 0) {
+                                            thresholdId = alarmDetails.get(0).getPid().toString();
+                                        }
                                     }
                                 }
                             }
@@ -1493,8 +1497,8 @@ public class ProjectService {
             }
         }
         Map<String, String> returnMap = new HashMap<>();
-        returnMap.put("alarmStatus",alarmStatus);
-        returnMap.put("thresholdId",thresholdId);
+        returnMap.put("alarmStatus", alarmStatus);
+        returnMap.put("thresholdId", thresholdId);
         return returnMap;
     }