feat: 实时数据也用规则校验告警

dev
huangfeng 2 months ago
parent 0a77c0afc4
commit 494cac6c0e

@ -26,6 +26,7 @@ public class StaticVariable {
public static List<Jg> jg_Cache = null;
public static List<Zsb> zsb_Cache = null;
public static ConcurrentHashMap<Integer, WarnRule> rule_Cache = new ConcurrentHashMap<>();
public static HashMap<String, Integer> ruleRelationMap = new HashMap<>();
// 更新服务端
@ -49,6 +50,19 @@ public class StaticVariable {
if (time != null) {
map.put("acquisitionTime", time);
}
// 规则触发
String key = eqmid + "_" + colname;
if (StaticVariable.ruleRelationMap.containsKey(key)) {
Integer ruleId = StaticVariable.ruleRelationMap.get(key);
WarnRule rule = StaticVariable.rule_Cache.get(ruleId);
if (rule != null) {
boolean r = rule.triggerRule(value);
if (r) {
map.put(colname, value + ",1");
}
}
}
}
// 更新最新数据缓存

@ -24,6 +24,7 @@ public class CacheTask {
StaticVariable.jg_Cache = null;
StaticVariable.zsb_Cache = null;
StaticVariable.rule_Cache.clear();
StaticVariable.ruleRelationMap.clear();
StaticVariable.paramRelationMap.clear();
}
@ -42,6 +43,8 @@ public class CacheTask {
item.initComparator(item.getComparator(), item.getOperator());
StaticVariable.rule_Cache.put(item.getId(), item);
}
String key = item.getNSensor().getDevId() + "_" + item.getTypePoint().getField();
StaticVariable.ruleRelationMap.put(key, item.getId());
}
} catch (Exception e) {
log.error("CacheTask.refreshRule error.", e);

Loading…
Cancel
Save