|
@@ -88,47 +88,58 @@ public class GroupAlarmRuleServiceImpl extends ServiceImpl<GroupAlarmRuleMapper,
|
|
|
setDefaultValue(groupAlarmRule);
|
|
|
save(groupAlarmRule);
|
|
|
//2、同步创建项目报警
|
|
|
- List<AddProjectAlarmRuleObjRelDTO> addProjectAlarmRuleObjRelDTOS = projectAlarmRuleService.addProjectAlarmRules(addGroupAlarmRuleDTO);
|
|
|
+ projectAlarmRuleService.addProjectAlarmRules(addGroupAlarmRuleDTO);
|
|
|
+ List<ProjectVO> projects = projectAlarmRuleService.getProject();
|
|
|
//3、同步创建设备报警条件
|
|
|
BatchAddAlarmConfigDTO batchAddAlarmConfigDTO = new BatchAddAlarmConfigDTO();
|
|
|
List<AddAlarmConfigDTO> alarmConfigs = new ArrayList<>();
|
|
|
- for (AddProjectAlarmRuleObjRelDTO addProjectAlarmRuleObjRelDTO : addProjectAlarmRuleObjRelDTOS) {
|
|
|
- AddAlarmConfigDTO addAlarmConfigDTO = new AddAlarmConfigDTO();
|
|
|
- String equipId = addProjectAlarmRuleObjRelDTO.getObjId();
|
|
|
- addAlarmConfigDTO.setObjId(equipId);
|
|
|
- addAlarmConfigDTO.setItemCode(addGroupAlarmRuleDTO.getAlarmItemCode());
|
|
|
- addAlarmConfigDTO.setClassCode(addGroupAlarmRuleDTO.getClassCode());
|
|
|
- addAlarmConfigDTO.setLevel(alarmCondition.getAlarmLevel());
|
|
|
- addAlarmConfigDTO.setCategory("Eqdx");
|
|
|
- addAlarmConfigDTO.setOpen(1);
|
|
|
- AlarmCondition condition = 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));
|
|
|
- }
|
|
|
- condition.setInfoCode(infoCodeNew);
|
|
|
- String backend = (String) conditionMap.get("backend");
|
|
|
- for (String infoCode : infoCodeList) {
|
|
|
- String replacement = equipId + "_" + infoCode;
|
|
|
- backend = backend.replaceAll(infoCode, replacement);
|
|
|
+ String condition = addGroupAlarmRuleDTO.getCondition();
|
|
|
+ String classCode = addGroupAlarmRuleDTO.getClassCode();
|
|
|
+ for (ProjectVO project : projects) {
|
|
|
+ QueryEquipDTO queryEquipDTO = new QueryEquipDTO();
|
|
|
+ queryEquipDTO.setProjectId(project.getProjectId());
|
|
|
+ queryEquipDTO.setClassCode(classCode);
|
|
|
+ queryEquipDTO.setCondition(condition);
|
|
|
+ List<EquipItem> record = groupManagementService.getEquipList(queryEquipDTO);
|
|
|
+ for (EquipItem rec : record) {
|
|
|
+ AddAlarmConfigDTO addAlarmConfigDTO = new AddAlarmConfigDTO();
|
|
|
+ String equipId = rec.getId();
|
|
|
+ addAlarmConfigDTO.setObjId(equipId);
|
|
|
+ addAlarmConfigDTO.setItemCode(addGroupAlarmRuleDTO.getAlarmItemCode());
|
|
|
+ addAlarmConfigDTO.setClassCode(addGroupAlarmRuleDTO.getClassCode());
|
|
|
+ addAlarmConfigDTO.setLevel(alarmCondition.getAlarmLevel());
|
|
|
+ addAlarmConfigDTO.setCategory("Eqdx");
|
|
|
+ addAlarmConfigDTO.setOpen(1);
|
|
|
+ AlarmCondition cond = 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));
|
|
|
+ }
|
|
|
+ cond.setInfoCode(infoCodeNew);
|
|
|
+ String backend = (String) conditionMap.get("backend");
|
|
|
+ for (String infoCode : infoCodeList) {
|
|
|
+ String replacement = equipId + "_" + infoCode;
|
|
|
+ backend = backend.replaceAll(infoCode, replacement);
|
|
|
+ }
|
|
|
+ cond.setEnd("!" + backend);
|
|
|
+ cond.setEndUphold(0);
|
|
|
+ cond.setTrigger(backend);
|
|
|
+ cond.setTriggerUphold(alarmCondition.getTriggerUphold() * 60);
|
|
|
+ cond.setRules((List<String>) conditionMap.get("displayFormula"));
|
|
|
+ JSONArray configs= JSONArray.parseArray(JSON.toJSONString(alarmCondition.getFrontend()));
|
|
|
+ cond.setConfigs(configs);
|
|
|
+ AlarmEffectTime effectTime = new AlarmEffectTime();
|
|
|
+ effectTime.setType("always");
|
|
|
+ cond.setEffectTime(effectTime);
|
|
|
+ addAlarmConfigDTO.setCondition(cond);
|
|
|
+ alarmConfigs.add(addAlarmConfigDTO);
|
|
|
}
|
|
|
- condition.setEnd("!" + backend);
|
|
|
- condition.setEndUphold(0);
|
|
|
- condition.setTrigger(backend);
|
|
|
- condition.setTriggerUphold(alarmCondition.getTriggerUphold() * 60);
|
|
|
- condition.setRules((List<String>) conditionMap.get("displayFormula"));
|
|
|
- JSONArray configs= JSONArray.parseArray(JSON.toJSONString(alarmCondition.getFrontend()));
|
|
|
- condition.setConfigs(configs);
|
|
|
- AlarmEffectTime effectTime = new AlarmEffectTime();
|
|
|
- effectTime.setType("always");
|
|
|
- condition.setEffectTime(effectTime);
|
|
|
- addAlarmConfigDTO.setCondition(condition);
|
|
|
- alarmConfigs.add(addAlarmConfigDTO);
|
|
|
+ batchAddAlarmConfigDTO.setAlarmConfigs(alarmConfigs);
|
|
|
+ batchAddAlarmConfigDTO.setProjectId(project.getProjectId());
|
|
|
+ alarmConfigService.batchCreate(batchAddAlarmConfigDTO);
|
|
|
}
|
|
|
- batchAddAlarmConfigDTO.setAlarmConfigs(alarmConfigs);
|
|
|
- alarmConfigService.batchCreate(batchAddAlarmConfigDTO);
|
|
|
return groupAlarmRule.getId();
|
|
|
}
|
|
|
|
|
@@ -187,53 +198,50 @@ public class GroupAlarmRuleServiceImpl extends ServiceImpl<GroupAlarmRuleMapper,
|
|
|
//新增中台设备的报警条件
|
|
|
//查询所有设备
|
|
|
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));
|
|
|
- }
|
|
|
- equipCondition.setInfoCode(infoCodeNew);
|
|
|
- String backend = (String) conditionMap.get("backend");
|
|
|
- for (String infoCode : infoCodeList) {
|
|
|
- String replacement = equipId + "_" + infoCode;
|
|
|
- backend = backend.replaceAll(infoCode, replacement);
|
|
|
+ List<EquipItem> records = groupManagementService.getEquipList(queryEquipDTO);
|
|
|
+ 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));
|
|
|
+ }
|
|
|
+ equipCondition.setInfoCode(infoCodeNew);
|
|
|
+ String backend = (String) conditionMap.get("backend");
|
|
|
+ for (String infoCode : infoCodeList) {
|
|
|
+ String replacement = equipId + "_" + infoCode;
|
|
|
+ backend = backend.replaceAll(infoCode, replacement);
|
|
|
+ }
|
|
|
+ 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);
|
|
|
}
|
|
|
- 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);
|
|
|
}
|
|
|
- batchAddAlarmConfigDTO.setAlarmConfigs(alarmConfigs);
|
|
|
- alarmConfigService.batchCreate(batchAddAlarmConfigDTO);
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|