Browse Source

Merge branch 'v1.0.0' of http://39.106.8.246:3003/apm/energy-alarm-service into v1.0.0

lixing 3 years ago
parent
commit
a1d20e5c0a

+ 6 - 3
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);
         //保存中台规则
@@ -291,7 +294,7 @@ public class ProjectAlarmRuleServiceImpl extends ServiceImpl<ProjectAlarmRuleMap
             addProjectAlarmRuleObjRelDTO.setProjectAlarmRuleId(id);
             addProjectAlarmRuleObjRelDTO.setObjId(updateAlarmItemDTO.getObjId());
             addProjectAlarmRuleObjRelDTO.setProjectId(projectId);
-            addProjectAlarmRuleObjRelDTO.setOpen(1);
+            addProjectAlarmRuleObjRelDTO.setOpen(updateAlarmItemDTO.getOpen());
             addProjectAlarmRuleObjRelDTO.setObjName(updateAlarmItemDTO.getObjName());
             list.add(addProjectAlarmRuleObjRelDTO);
         }
@@ -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);
     }
 
     /**

+ 6 - 5
src/main/java/com/persagy/apm/alarmservice/project/alarmruleobjrel/model/dto/UpdateAlarmItemDTO.java

@@ -13,13 +13,14 @@ import javax.validation.constraints.NotNull;
 @Data
 @ApiModel(value = "更新项目报警规则与监测对象的关联入参")
 public class UpdateAlarmItemDTO {
-    
-    @ApiModelProperty(value = "报警对象ID", required = true)
-    @NotNull(message = "报警对象名称不能为空") // todo 更新校验规则
+
+    @ApiModelProperty("设备ID")
     private String objId;
 
-    @ApiModelProperty(value = "报警对象ID", required = true)
-    @NotNull(message = "报警对象名称不能为空") // todo 更新校验规则
+    @ApiModelProperty("设备名称")
     private String objName;
+
+    @ApiModelProperty("屏蔽状态 1-open、0- 屏蔽")
+    private Integer open;
     
 }

+ 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);
     }