|
|
|
@ -176,30 +176,35 @@ public class AlarmRecordsServiceImpl implements IAlarmRecordsService {
|
|
|
|
|
if ("0".equals(alarmRule.getAlarmType())) { |
|
|
|
|
// 当前是越限事件
|
|
|
|
|
// 查询事件类型查询对应的报警模板内容
|
|
|
|
|
AlarmCode alarmCode = alarmCodeService.selectAlarmCodeByAlarmType(alarmRule.getEventType()); |
|
|
|
|
// 获取当前采集参数值
|
|
|
|
|
CollectionParamsManage collectionParamsManage = collectionParamsManageService.selectCollectionParamsManageById(alarmRule.getCpmId()); |
|
|
|
|
// 判断当前值是否是当前事件
|
|
|
|
|
if (null == collectionParamsManage) { |
|
|
|
|
List<AlarmCode> alarmCodes = alarmCodeService.selectAlarmCodeByAlarmType(alarmRule.getEventType()); |
|
|
|
|
if (alarmCodes == null || alarmCodes.isEmpty()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
AlarmRecords alarmRecords = new AlarmRecords(); |
|
|
|
|
BigDecimal curValue = collectionParamsManage.getCurValue(); |
|
|
|
|
Date curTime = collectionParamsManage.getCurTime(); |
|
|
|
|
// 阈值
|
|
|
|
|
String threshold1 = alarmRule.getThreshold1(); |
|
|
|
|
String threshold2 = alarmRule.getThreshold2(); |
|
|
|
|
// 设置Redis取消标记(有效期略大于延迟时间)
|
|
|
|
|
redisTemplate.deleteObject("alarm:cancel:" + collectionParamsManage.getId()); |
|
|
|
|
if (alarmRule.getTimePeriodSet() == 0 && DateUtils.isSameDay(curTime, new Date())) { |
|
|
|
|
// 执行相关操作
|
|
|
|
|
insertOrUpdateRecord(alarmRule, curValue, threshold1, threshold2, alarmCode, alarmRecords, collectionParamsManage); |
|
|
|
|
} else if (alarmRule.getTimePeriodSet() == 1 |
|
|
|
|
&& DateUtils.isSameDay(collectionParamsManage.getCurTime(), new Date()) |
|
|
|
|
&& DateUtils.isCurrentTimeInRange(alarmRule.getBeginTime(), alarmRule.getEndTime(), curTime) |
|
|
|
|
) { |
|
|
|
|
// 执行相关操作
|
|
|
|
|
insertOrUpdateRecord(alarmRule, curValue, threshold1, threshold2, alarmCode, alarmRecords, collectionParamsManage); |
|
|
|
|
for (AlarmCode alarmCode : alarmCodes) { |
|
|
|
|
// 获取当前采集参数值
|
|
|
|
|
CollectionParamsManage collectionParamsManage = collectionParamsManageService.selectCollectionParamsManageById(alarmRule.getCpmId()); |
|
|
|
|
// 判断当前值是否是当前事件
|
|
|
|
|
if (null == collectionParamsManage) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
AlarmRecords alarmRecords = new AlarmRecords(); |
|
|
|
|
BigDecimal curValue = collectionParamsManage.getCurValue(); |
|
|
|
|
Date curTime = collectionParamsManage.getCurTime(); |
|
|
|
|
// 阈值
|
|
|
|
|
String threshold1 = alarmRule.getThreshold1(); |
|
|
|
|
String threshold2 = alarmRule.getThreshold2(); |
|
|
|
|
// 设置Redis取消标记(有效期略大于延迟时间)
|
|
|
|
|
redisTemplate.deleteObject("alarm:cancel:" + collectionParamsManage.getId()); |
|
|
|
|
if (alarmRule.getTimePeriodSet() == 0 && DateUtils.isSameDay(curTime, new Date())) { |
|
|
|
|
// 执行相关操作
|
|
|
|
|
insertOrUpdateRecord(alarmRule, curValue, threshold1, threshold2, alarmCode, alarmRecords, collectionParamsManage); |
|
|
|
|
} else if (alarmRule.getTimePeriodSet() == 1 |
|
|
|
|
&& DateUtils.isSameDay(collectionParamsManage.getCurTime(), new Date()) |
|
|
|
|
&& DateUtils.isCurrentTimeInRange(alarmRule.getBeginTime(), alarmRule.getEndTime(), curTime) |
|
|
|
|
) { |
|
|
|
|
// 执行相关操作
|
|
|
|
|
insertOrUpdateRecord(alarmRule, curValue, threshold1, threshold2, alarmCode, alarmRecords, collectionParamsManage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
@ -241,7 +246,13 @@ public class AlarmRecordsServiceImpl implements IAlarmRecordsService {
|
|
|
|
|
"true", |
|
|
|
|
2, TimeUnit.MINUTES // 例如:延迟5分钟,设置10分钟过期
|
|
|
|
|
); |
|
|
|
|
insertOrUpdateRecord(alarmRule, curValue, threshold1, threshold2, alarmCodeService.selectAlarmCodeByAlarmType(alarmRule.getEventType()), alarmRecords, collectionParamsManage); |
|
|
|
|
List<AlarmCode> alarmCode = alarmCodeService.selectAlarmCodeByAlarmType(alarmRule.getEventType()); |
|
|
|
|
if (alarmCode == null || alarmCode.isEmpty()) { |
|
|
|
|
continue; |
|
|
|
|
} |
|
|
|
|
for (AlarmCode code : alarmCode) { |
|
|
|
|
insertOrUpdateRecord(alarmRule, curValue, threshold1, threshold2, code, alarmRecords, collectionParamsManage); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|