|
@@ -3,11 +3,14 @@ package com.gyee.alarm.service;
|
|
|
import com.gyee.alarm.init.CacheContext;
|
|
|
import com.gyee.alarm.model.auto.ProEconAlarmConfiguration;
|
|
|
import com.gyee.alarm.model.auto.ProEconAlarmRule;
|
|
|
+import com.gyee.alarm.model.auto.ProEconAlarmType;
|
|
|
import com.gyee.alarm.model.vo.AlarmCustomType;
|
|
|
import com.gyee.alarm.model.vo.AlarmTypeValue;
|
|
|
import com.gyee.alarm.model.vo.AlarmVo;
|
|
|
import com.gyee.alarm.service.auto.IProEconAlarmConfigurationService;
|
|
|
import com.gyee.alarm.service.auto.IProEconAlarmRuleService;
|
|
|
+import com.gyee.alarm.service.auto.IProEconAlarmTypeService;
|
|
|
+import com.gyee.alarm.util.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
@@ -31,7 +34,8 @@ public class AlarmInitalService {
|
|
|
|
|
|
@Resource
|
|
|
private AlarmCtService alarmCtService;
|
|
|
-
|
|
|
+ @Resource
|
|
|
+ private IProEconAlarmTypeService proEconAlarmTypeService;
|
|
|
|
|
|
public void initialAlarm() throws Exception {
|
|
|
|
|
@@ -56,6 +60,20 @@ public class AlarmInitalService {
|
|
|
Map<String, List<ProEconAlarmConfiguration>> inAlarmMap = new HashMap<>();
|
|
|
Map<String, AlarmVo> alarmWtMap = new HashMap<>();
|
|
|
|
|
|
+ Map<String, List<ProEconAlarmRule>> ctAlarmlsMap = new HashMap<>();
|
|
|
+ Map<String, ProEconAlarmType> alarmTypeMap = new HashMap<>();
|
|
|
+ List<ProEconAlarmType> alarmTypeList = new ArrayList<>();
|
|
|
+ Map<String, ProEconAlarmRule> ctAlarmMap = new HashMap<>();
|
|
|
+
|
|
|
+ alarmTypeList = proEconAlarmTypeService.list();
|
|
|
+
|
|
|
+ if (!alarmTypeList.isEmpty()) {
|
|
|
+ for (ProEconAlarmType at : alarmTypeList) {
|
|
|
+ alarmTypeMap.put(at.getNemCode(), at);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
|
|
|
List<ProEconAlarmConfiguration> templs = proEconAlarmConfigurationService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
|
|
|
if (!templs.isEmpty()) {
|
|
@@ -138,28 +156,51 @@ public class AlarmInitalService {
|
|
|
}
|
|
|
|
|
|
//从pg数据库获取自定义报警配置信息
|
|
|
- List<ProEconAlarmRule> customls =proEconAlarmRuleService.list().stream().filter(i -> i.getEnable()).collect(Collectors.toList());
|
|
|
+ List<ProEconAlarmRule> customls = proEconAlarmRuleService.list();
|
|
|
|
|
|
+ if (!customls.isEmpty()) {
|
|
|
+ customls = customls.stream().filter(i -> null != i.getEnable() && i.getEnable()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
List<ProEconAlarmRule> wtCustomls=new ArrayList<>();
|
|
|
List<ProEconAlarmRule> inCustomls=new ArrayList<>();
|
|
|
List<ProEconAlarmRule> btCustomls=new ArrayList<>();
|
|
|
|
|
|
//对自定义报警进行分类
|
|
|
- if(!customls.isEmpty())
|
|
|
- {
|
|
|
- for(ProEconAlarmRule vo: customls)
|
|
|
- {
|
|
|
- if(vo.getCategory().equals(AlarmCustomType.WT.getCode()))
|
|
|
- {
|
|
|
- wtCustomls.add(vo);
|
|
|
- }else if(vo.getCategory().equals(AlarmCustomType.IN.getCode()))
|
|
|
- {
|
|
|
- inCustomls.add(vo);
|
|
|
- }else if(vo.getCategory().equals(AlarmCustomType.BT.getCode()))
|
|
|
- {
|
|
|
- btCustomls.add(vo);
|
|
|
+ if (!customls.isEmpty()) {
|
|
|
+ for (ProEconAlarmRule vo : customls) {
|
|
|
+
|
|
|
+ ctAlarmMap.put(vo.getId(),vo);
|
|
|
+ StringBuilder sb = new StringBuilder();
|
|
|
+ sb.append(vo.getStationId()).append(vo.getModelId());
|
|
|
+ if (StringUtils.notEmp(vo.getCategory())) {
|
|
|
+
|
|
|
+
|
|
|
+ if (vo.getCategory().equals(AlarmCustomType.WT.getCode())) {
|
|
|
+ if (ctAlarmlsMap.containsKey(String.valueOf(sb))) {
|
|
|
+ List<ProEconAlarmRule> ls = ctAlarmlsMap.get(String.valueOf(sb));
|
|
|
+ ls.add(vo);
|
|
|
+ ctAlarmlsMap.put(String.valueOf(sb), ls);
|
|
|
+ } else {
|
|
|
+ List<ProEconAlarmRule> ls = new ArrayList<>();
|
|
|
+ ls.add(vo);
|
|
|
+ ctAlarmlsMap.put(String.valueOf(sb), ls);
|
|
|
+ }
|
|
|
+ wtCustomls.add(vo);
|
|
|
+ }
|
|
|
+ if (vo.getCategory().equals(AlarmCustomType.IN.getCode())) {
|
|
|
+ if (ctAlarmlsMap.containsKey(String.valueOf(sb))) {
|
|
|
+ List<ProEconAlarmRule> ls = ctAlarmlsMap.get(String.valueOf(sb));
|
|
|
+ ls.add(vo);
|
|
|
+ } else {
|
|
|
+ List<ProEconAlarmRule> ls = new ArrayList<>();
|
|
|
+ ls.add(vo);
|
|
|
+ ctAlarmlsMap.put(String.valueOf(sb), ls);
|
|
|
+ }
|
|
|
+ wtCustomls.add(vo);
|
|
|
+ } else if (vo.getCategory().equals(AlarmCustomType.BT.getCode())) {
|
|
|
+ btCustomls.add(vo);
|
|
|
+ }
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -197,5 +238,12 @@ public class AlarmInitalService {
|
|
|
CacheContext.alarmWpMap=alarmWpMap;
|
|
|
CacheContext.inAlarmMap = inAlarmMap;
|
|
|
CacheContext.alarmWtMap = alarmWtMap;
|
|
|
+
|
|
|
+
|
|
|
+
|
|
|
+ CacheContext.ctAlarmlsMap = ctAlarmlsMap;
|
|
|
+ CacheContext.alarmTypeMap = alarmTypeMap;
|
|
|
+ CacheContext.alarmTypeList = alarmTypeList;
|
|
|
+ CacheContext.ctAlarmMap = ctAlarmMap;
|
|
|
}
|
|
|
}
|