|
@@ -176,36 +176,63 @@ public class GroupAlarmRuleServiceImpl extends ServiceImpl<GroupAlarmRuleMapper,
|
|
|
updateById(groupAlarmRule);
|
|
|
//获得报警规则
|
|
|
UpdateAlarmConditionDTO alarmCondition = updateGroupAlarmRuleDTO.getAlarmCondition();
|
|
|
- //更新报警规则
|
|
|
- alarmConditionService.updateAlarmCondition(alarmCondition);
|
|
|
- if (alarmCondition != null) {
|
|
|
- //同步更新设备报警条件 begin
|
|
|
- List<UpdateAlarmConfigDTO> updateAlarmConfigDTOs = new ArrayList();
|
|
|
- String condition = updateGroupAlarmRuleDTO.getCondition();
|
|
|
- String classCode = updateGroupAlarmRuleDTO.getClassCode();
|
|
|
- List<EquipItem> records = this.getAllEquip(classCode, condition);
|
|
|
- Map<String, Object> stringMap = alarmConditionService.frontend2Backend(alarmCondition.getFrontend());
|
|
|
- for (EquipItem record : records) {
|
|
|
- AlarmCondition alarmCondit = new AlarmCondition();
|
|
|
- alarmCondit.setTrigger(alarmCondition.getBackend());
|
|
|
- List<String> infoCodeList = alarmCondition.getInfoCodes();
|
|
|
- alarmCondit.setInfoCode(infoCodeList);
|
|
|
- alarmCondit.setTriggerUphold(alarmCondition.getTriggerUphold());
|
|
|
- alarmCondit.setRules((List<String>) stringMap.get("displayFormula"));
|
|
|
- UpdateAlarmConfigDTO updateAlarmConfigDTO = new UpdateAlarmConfigDTO();
|
|
|
- updateAlarmConfigDTO.setCondition(alarmCondit);
|
|
|
- updateAlarmConfigDTO.setId(record.getId());
|
|
|
- updateAlarmConfigDTO.setLevel(alarmCondition.getAlarmLevel());
|
|
|
- updateAlarmConfigDTOs.add(updateAlarmConfigDTO);
|
|
|
+ Map<String, Object> conditionMap = alarmConditionService.frontend2Backend(alarmCondition.getFrontend());
|
|
|
+ alarmConditionService.updateById(conditionMap,alarmCondition);
|
|
|
+ //删除中台设备的报警条件
|
|
|
+ String condition = updateGroupAlarmRuleDTO.getCondition();
|
|
|
+ String classCode = updateGroupAlarmRuleDTO.getClassCode();
|
|
|
+ deleteEquipCondition(condition,classCode);
|
|
|
+ List<AddAlarmConfigDTO> alarmConfigs = new ArrayList<>();
|
|
|
+ BatchAddAlarmConfigDTO batchAddAlarmConfigDTO = new BatchAddAlarmConfigDTO();
|
|
|
+ //新增中台设备的报警条件
|
|
|
+ //查询所有设备
|
|
|
+ List<ProjectVO> projects = projectAlarmRuleService.getProject();
|
|
|
+ List<EquipItem> records = new ArrayList<>();
|
|
|
+ for (ProjectVO project : projects) {
|
|
|
+ QueryEquipDTO queryEquipDTO = new QueryEquipDTO();
|
|
|
+ queryEquipDTO.setProjectId(project.getProjectId());
|
|
|
+ queryEquipDTO.setClassCode(classCode);
|
|
|
+ queryEquipDTO.setCondition(condition);
|
|
|
+ List<EquipItem> record = groupManagementService.getEquipList(queryEquipDTO);
|
|
|
+ records.addAll(record);
|
|
|
+ }
|
|
|
+ for (EquipItem record : records) {
|
|
|
+ AddAlarmConfigDTO addAlarmConfigDTO = new AddAlarmConfigDTO();
|
|
|
+ String equipId = record.getId();
|
|
|
+ addAlarmConfigDTO.setObjId(equipId);
|
|
|
+ addAlarmConfigDTO.setItemCode(updateGroupAlarmRuleDTO.getAlarmItemCode());
|
|
|
+ addAlarmConfigDTO.setClassCode(classCode);
|
|
|
+ addAlarmConfigDTO.setLevel(alarmCondition.getAlarmLevel());
|
|
|
+ addAlarmConfigDTO.setCategory("Eqdx");
|
|
|
+ addAlarmConfigDTO.setOpen(1);
|
|
|
+ AlarmCondition equipCondition = new AlarmCondition();
|
|
|
+ List<String> infoCodeList = (List<String>) conditionMap.get("infoCode");
|
|
|
+ List<String> infoCodeNew = new ArrayList<>();
|
|
|
+ for (String infoCode : infoCodeList) {
|
|
|
+ String replacement = equipId + "_" + infoCode;
|
|
|
+ infoCodeNew.add(infoCode.replaceAll(infoCode, replacement));
|
|
|
}
|
|
|
- List<List<UpdateAlarmConfigDTO>> lists = averageAssign(updateAlarmConfigDTOs, 200);
|
|
|
- for (List<UpdateAlarmConfigDTO> list : lists) {
|
|
|
- BatchUpdateAlarmConfigDTO batchUpdateAlarmConfigDTO = new BatchUpdateAlarmConfigDTO();
|
|
|
- batchUpdateAlarmConfigDTO.setAlarmConfigs(list);
|
|
|
- alarmConfigService.batchUpdate(batchUpdateAlarmConfigDTO);
|
|
|
+ equipCondition.setInfoCode(infoCodeNew);
|
|
|
+ String backend = (String) conditionMap.get("backend");
|
|
|
+ for (String infoCode : infoCodeList) {
|
|
|
+ String replacement = equipId + "_" + infoCode;
|
|
|
+ backend = backend.replaceAll(infoCode, replacement);
|
|
|
}
|
|
|
- //同步更新设备报警条件 end
|
|
|
+ equipCondition.setEnd("!" + backend);
|
|
|
+ equipCondition.setEndUphold(0);
|
|
|
+ equipCondition.setTrigger(backend);
|
|
|
+ equipCondition.setTriggerUphold(alarmCondition.getTriggerUphold() * 60);
|
|
|
+ equipCondition.setRules((List<String>) conditionMap.get("displayFormula"));
|
|
|
+ JSONArray configs= JSONArray.parseArray(JSON.toJSONString(alarmCondition.getFrontend()));
|
|
|
+ equipCondition.setConfigs(configs);
|
|
|
+ AlarmEffectTime effectTime = new AlarmEffectTime();
|
|
|
+ effectTime.setType("always");
|
|
|
+ equipCondition.setEffectTime(effectTime);
|
|
|
+ addAlarmConfigDTO.setCondition(equipCondition);
|
|
|
+ alarmConfigs.add(addAlarmConfigDTO);
|
|
|
}
|
|
|
+ batchAddAlarmConfigDTO.setAlarmConfigs(alarmConfigs);
|
|
|
+ alarmConfigService.batchCreate(batchAddAlarmConfigDTO);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -325,11 +352,16 @@ public class GroupAlarmRuleServiceImpl extends ServiceImpl<GroupAlarmRuleMapper,
|
|
|
this.deleteGroupAlarmRule(deleteGroupAlarmRuleDTO.getId());
|
|
|
alarmConditionService.deleteAlarmCondition(deleteGroupAlarmRuleDTO.getAlarmConditionId());
|
|
|
projectAlarmRuleObjRelService.deleteBatch();
|
|
|
+ String condition = deleteGroupAlarmRuleDTO.getCondition();
|
|
|
+ String classCode = deleteGroupAlarmRuleDTO.getClassCode();
|
|
|
+ deleteEquipCondition(condition,classCode);
|
|
|
+ }
|
|
|
+
|
|
|
+ public void deleteEquipCondition(String condition,String classCode) throws Exception {
|
|
|
//删除设备报警条件 begin
|
|
|
BatchDeleteAlarmConfigDTO batchDeleteAlarmConfigDTO = new BatchDeleteAlarmConfigDTO();
|
|
|
List<DeleteAlarmConfigDTO> alarmConfigs = new ArrayList<>();
|
|
|
- String condition = deleteGroupAlarmRuleDTO.getCondition();
|
|
|
- String classCode = deleteGroupAlarmRuleDTO.getClassCode();
|
|
|
+
|
|
|
//查询所有设备
|
|
|
List<EquipItem> equips = this.getAllEquip(classCode, condition);
|
|
|
List<String> objIds = equips.stream().map(EquipItem::getId).collect(Collectors.toList());
|