|
@@ -145,11 +145,11 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
paramMap.put(funcIdArray[i], Double.parseDouble(values[i]));
|
|
|
}
|
|
|
|
|
|
- calculateAlarmConditions(dataTime, meterId, itemCode, paramMap);
|
|
|
+ triggerOrEndAlarm(dataTime, meterId, itemCode, paramMap);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
- * 遍历设备的所有报警条件,计算报警的产生和恢复
|
|
|
+ * 通过报警对象和报警类型找到内存中对应的报警条件,计算报警的产生和恢复
|
|
|
*
|
|
|
* @param dataTime 采集日期
|
|
|
* @param meterId 报警对象id
|
|
@@ -158,7 +158,7 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
* @author lixing
|
|
|
* @version V1.0 2021/10/22 5:19 下午
|
|
|
*/
|
|
|
- private void calculateAlarmConditions(String dataTime, String meterId, String itemCode, HashMap<String, Object> paramMap) throws Exception {
|
|
|
+ private void triggerOrEndAlarm(String dataTime, String meterId, String itemCode, HashMap<String, Object> paramMap) throws Exception {
|
|
|
// 获取设备的报警条件
|
|
|
ObjConditionInfo objConditionInfo = alarmInfoCache.getAlarmConditionsByObjId(meterId);
|
|
|
if (objConditionInfo == null || CollectionUtils.isEmpty(objConditionInfo.getConditions())) {
|
|
@@ -199,16 +199,18 @@ public class AlarmHandleServiceImpl implements AlarmHandleService {
|
|
|
if (triggerResult && endResult) {
|
|
|
log.error("报警触发条件和报警恢复条件同时满足,请检查,报警定义详情【{}】", alarmCondition);
|
|
|
}
|
|
|
+ AlarmDefine alarmDefine = null;
|
|
|
+ try {
|
|
|
+ alarmDefine = AlarmDefine.convert2AlarmDefine(itemCodeCondition.getItemCode(),
|
|
|
+ alarmCondition, meterId, objConditionInfo.getProjectId());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("报警条件转换为报警定义出现异常", e);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
+ // redis加锁 // TODO: 2021/11/15
|
|
|
+ synchronized (alarmDefine.getId().intern()) {
|
|
|
|
|
|
- synchronized (conditionId.intern()) {
|
|
|
- AlarmDefine alarmDefine = null;
|
|
|
- try {
|
|
|
- alarmDefine = AlarmDefine.convert2AlarmDefine(itemCodeCondition.getItemCode(),
|
|
|
- alarmCondition, meterId, objConditionInfo.getProjectId());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("报警条件转换为报警定义出现异常", e);
|
|
|
- return;
|
|
|
- }
|
|
|
//报警产生值满足(这里的满足不考虑报警持续时间)
|
|
|
if (triggerResult) {
|
|
|
log.debug("满足报警条件");
|