告警保护方案轮询-调整
This commit is contained in:
@ -14,6 +14,7 @@ import com.xzzn.common.utils.StringUtils;
|
||||
import com.xzzn.ems.domain.EmsAlarmRecords;
|
||||
import com.xzzn.ems.domain.EmsDevicesSetting;
|
||||
import com.xzzn.ems.domain.EmsFaultProtectionPlan;
|
||||
import com.xzzn.ems.domain.EmsStrategyRunning;
|
||||
import com.xzzn.ems.domain.vo.ProtectionPlanVo;
|
||||
import com.xzzn.ems.domain.vo.ProtectionSettingVo;
|
||||
import com.xzzn.ems.mapper.EmsAlarmRecordsMapper;
|
||||
@ -104,7 +105,7 @@ public class ProtectionPlanTask {
|
||||
}
|
||||
}
|
||||
} catch (Exception e) {
|
||||
logger.error("轮询失败,方案id为:", planId, e);
|
||||
logger.error("轮询失败,方案id为:{}", planId, e);
|
||||
}
|
||||
}
|
||||
|
||||
@ -130,7 +131,7 @@ public class ProtectionPlanTask {
|
||||
// 判断是否需要生成告警
|
||||
if (isAlertAlarm == 1) {
|
||||
logger.info("<生成告警> 方案ID:{},站点:{}", plan.getId(), siteId);
|
||||
EmsAlarmRecords alarmRecords = addAlarmRecord(siteId,"PCS", plan.getDescription(),
|
||||
EmsAlarmRecords alarmRecords = addAlarmRecord(siteId,plan.getFaultName(),
|
||||
getAlarmLevel(plan.getFaultLevel()));
|
||||
emsAlarmRecordsMapper.insertEmsAlarmRecords(alarmRecords);
|
||||
}
|
||||
@ -139,7 +140,7 @@ public class ProtectionPlanTask {
|
||||
String protPlanJson = plan.getProtectionPlan();
|
||||
if (protPlanJson != null && !protPlanJson.isEmpty()) {
|
||||
logger.info("<下发保护方案> 方案内容:{}", protPlanJson);
|
||||
executeProtectionActions(protPlanJson,siteId,plan.getId()); // 执行Modbus指令
|
||||
//executeProtectionActions(protPlanJson,siteId,plan.getId()); // 执行Modbus指令
|
||||
}
|
||||
|
||||
// 更新方案状态为“已启用”
|
||||
@ -150,7 +151,6 @@ public class ProtectionPlanTask {
|
||||
}, faultDelay, TimeUnit.SECONDS);
|
||||
}
|
||||
} else {
|
||||
String deviceId = protSettings.get(0).getDeviceId();
|
||||
// 已启用,则获取方案的释放值与最新数据判断是否需要取消方案
|
||||
if(checkIsNeedCancelPlan(protSettings, siteId)){
|
||||
// 延时,
|
||||
@ -159,13 +159,18 @@ public class ProtectionPlanTask {
|
||||
// 判断是否已存在未处理告警,有着取消
|
||||
if(isAlertAlarm == 1){
|
||||
logger.info("<取消告警>");
|
||||
EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getFailedRecord(siteId,deviceId,
|
||||
plan.getDescription(),getAlarmLevel(plan.getFaultLevel()));
|
||||
EmsAlarmRecords emsAlarmRecords = emsAlarmRecordsMapper.getFailedRecord(siteId,
|
||||
plan.getFaultName(),getAlarmLevel(plan.getFaultLevel()));
|
||||
if(emsAlarmRecords != null){
|
||||
emsAlarmRecords.setStatus(AlarmStatus.DONE.getCode());
|
||||
emsAlarmRecordsMapper.updateEmsAlarmRecords(emsAlarmRecords);
|
||||
}
|
||||
}
|
||||
// 更新方案状态为“未启用”
|
||||
logger.info("<方案变更为未启用> 方案ID:{}", plan.getId());
|
||||
plan.setStatus(ProtPlanStatus.STOP.getCode());
|
||||
plan.setUpdateBy("system");
|
||||
emsFaultProtectionPlanMapper.updateEmsFaultProtectionPlan(plan);
|
||||
// 更新该站点策略为启用
|
||||
updateStrategyRunning(siteId);
|
||||
}, releaseDelay, TimeUnit.SECONDS);
|
||||
@ -310,15 +315,19 @@ public class ProtectionPlanTask {
|
||||
|
||||
// 更新站点策略为启用
|
||||
private void updateStrategyRunning(String siteId) {
|
||||
if (!StringUtils.isEmpty(siteId)) {
|
||||
emsStrategyRunningMapper.updateStatusRunning(siteId, StrategyStatus.RUNNING.getCode());
|
||||
// 获取是否有正在运行的策略,如果有则不更改
|
||||
EmsStrategyRunning emsStrategyRunning = emsStrategyRunningMapper.getRunningStrategy(siteId);
|
||||
if (emsStrategyRunning == null) {
|
||||
// 获取已存在并且状态为:未启用和已暂停的最晚一条策略,更新为已启用
|
||||
emsStrategyRunning = emsStrategyRunningMapper.getPendingStrategy(siteId);
|
||||
emsStrategyRunning.setStatus(StrategyStatus.RUNNING.getCode());
|
||||
emsStrategyRunningMapper.updateEmsStrategyRunning(emsStrategyRunning);
|
||||
}
|
||||
}
|
||||
|
||||
private EmsAlarmRecords addAlarmRecord(String siteId, String deviceId,String content,String level) {
|
||||
private EmsAlarmRecords addAlarmRecord(String siteId, String content,String level) {
|
||||
EmsAlarmRecords emsAlarmRecords = new EmsAlarmRecords();
|
||||
emsAlarmRecords.setSiteId(siteId);
|
||||
emsAlarmRecords.setDeviceId(deviceId);
|
||||
emsAlarmRecords.setAlarmContent(content);
|
||||
emsAlarmRecords.setAlarmLevel(level);
|
||||
emsAlarmRecords.setAlarmStartTime(new Date());
|
||||
|
||||
Reference in New Issue
Block a user