Przeglądaj źródła

报警对象bug修改

xujiaheng 3 lat temu
rodzic
commit
bd8553010e

+ 5 - 2
src/main/java/com/persagy/apm/alarmservice/project/alarmrule/service/impl/ProjectAlarmRuleServiceImpl.java

@@ -108,7 +108,10 @@ public class ProjectAlarmRuleServiceImpl extends ServiceImpl<ProjectAlarmRuleMap
         save(projectAlarmRule);
 
         List<ProjectAlarmRuleObjRel> addEquipList = addProjectAlarmRuleDTO.getAddEquipList();
-        addEquipList.forEach(addEquip -> addEquip.setProjectAlarmRuleId(projectAlarmRule.getId()));
+        addEquipList.forEach(addEquip -> {
+            addEquip.setProjectAlarmRuleId(projectAlarmRule.getId());
+            addEquip.setProjectId(addProjectAlarmRuleDTO.getProjectId());
+        });
         //保存报警对象
         projectAlarmRuleObjRelService.saveProjectAlarmRule(addEquipList);
         //保存中台规则
@@ -578,7 +581,7 @@ public class ProjectAlarmRuleServiceImpl extends ServiceImpl<ProjectAlarmRuleMap
         List<ProjectAlarmRule> list = list(queryWrapper);
         ProjectAlarmRule projectAlarmRule = new ProjectAlarmRule();
         projectAlarmRule.setValid(ValidEnum.FALSE.getType());
-        update(projectAlarmRule,queryWrapper);
+        update(projectAlarmRule, queryWrapper);
     }
 
     /**

+ 18 - 10
src/main/java/com/persagy/apm/alarmservice/project/alarmruleobjrel/service/impl/ProjectAlarmRuleObjRelServiceImpl.java

@@ -380,17 +380,18 @@ public class ProjectAlarmRuleObjRelServiceImpl extends ServiceImpl<ProjectAlarmR
         List<EquipItem> records = groupManagementService.getEquipList(queryEquipDTO);
         //查询项目下所有已绑定的报警对象
         List<String> projectAlarmRuleIdList = projectAlarmRuleService.queryAlarmRule(queryRuleObjRelDTO);
-        QueryWrapper<ProjectAlarmRuleObjRel> queryWrapper = new QueryWrapper<>();
-        queryWrapper.eq(ProjectAlarmRuleObjRel.PROP_PROJECT_ID, projectId);
-        if (projectAlarmRuleIdList.size() > 0)
+        Map<String, ProjectAlarmRuleObjRel> partitionMap = new HashMap<>();
+        if (projectAlarmRuleIdList.size() > 0){
+            QueryWrapper<ProjectAlarmRuleObjRel> queryWrapper = new QueryWrapper<>();
+            queryWrapper.eq(ProjectAlarmRuleObjRel.PROP_PROJECT_ID, projectId);
             queryWrapper.in(ProjectAlarmRuleObjRel.PROP_PROJECT_ALARM_RULE_ID, projectAlarmRuleIdList);
-        queryWrapper.eq(ProjectAlarmRuleObjRel.PROP_VALID, ValidEnum.TRUE.getType());
-        //新增项目报警,要把屏蔽的查出来
-        if (StringUtils.isBlank(queryRuleObjRelDTO.getProjectAlarmRuleId()))
-            queryWrapper.eq(ProjectAlarmRuleObjRel.PROP_OPEN, 1);
-        List<ProjectAlarmRuleObjRel> list = list(queryWrapper);
-        Map<String, ProjectAlarmRuleObjRel> partitionMap = list.stream().collect(Collectors.toMap(ProjectAlarmRuleObjRel::getObjId, equip -> equip, (k1, k2) -> k1));
-
+            queryWrapper.eq(ProjectAlarmRuleObjRel.PROP_VALID, ValidEnum.TRUE.getType());
+            //新增项目报警,要把屏蔽的查出来
+            if (StringUtils.isBlank(queryRuleObjRelDTO.getProjectAlarmRuleId()))
+                queryWrapper.eq(ProjectAlarmRuleObjRel.PROP_OPEN, 1);
+            List<ProjectAlarmRuleObjRel> list = list(queryWrapper);
+            partitionMap = list.stream().collect(Collectors.toMap(ProjectAlarmRuleObjRel::getObjId, equip -> equip, (k1, k2) -> k1));
+        }
         //筛选未绑定的报警对象
         for (EquipItem record : records) {
             String id = record.getId();
@@ -403,6 +404,13 @@ public class ProjectAlarmRuleObjRelServiceImpl extends ServiceImpl<ProjectAlarmR
                 resultList.add(projectAlarmRuleObjRelVO);
             }
         }
+        //去掉已屏蔽的对象
+        Iterator<ProjectAlarmRuleObjRel> iterator = resultList.iterator();
+        while (iterator.hasNext()) {
+            ProjectAlarmRuleObjRel next = iterator.next();
+            if (next.getOpen() == 0)
+                iterator.remove();
+        }
         return ConvertProjectAlarmRuleObjRelTool.INSTANCE.convert2List(resultList);
     }