Compare commits

...

2 Commits

Author SHA1 Message Date
zq
fb64be5a5a PCS关机先向设备发送给定功率值再发送关机指令 2026-01-15 17:49:03 +08:00
zq
0076872134 解决保护方案告警不触发问题 2026-01-15 17:40:51 +08:00
3 changed files with 45 additions and 21 deletions

View File

@ -89,7 +89,9 @@ public class ProtectionPlanTask {
Long planId = 0L; Long planId = 0L;
try { try {
// 获取所有方案,轮询 // 获取所有方案,轮询
List<EmsFaultProtectionPlan> planList = iEmsFaultProtectionPlanService.selectEmsFaultProtectionPlanList(null); EmsFaultProtectionPlan emsFaultProtectionPlan = new EmsFaultProtectionPlan();
emsFaultProtectionPlan.setSiteId("021_DDS_01");
List<EmsFaultProtectionPlan> planList = iEmsFaultProtectionPlanService.selectEmsFaultProtectionPlanList(emsFaultProtectionPlan);
for (EmsFaultProtectionPlan plan : planList) { for (EmsFaultProtectionPlan plan : planList) {
planId = plan.getId(); planId = plan.getId();
@ -123,6 +125,7 @@ public class ProtectionPlanTask {
// 需要同步云端 // 需要同步云端
@SyncAfterInsert @SyncAfterInsert
private boolean dealWithProtectionPlan(EmsFaultProtectionPlan plan, List<ProtectionSettingVo> protSettings) { private boolean dealWithProtectionPlan(EmsFaultProtectionPlan plan, List<ProtectionSettingVo> protSettings) {
logger.info("<轮询保护方案> 站点:{}方案ID:{}", plan.getSiteId(), plan.getId());
boolean isHighLevel = false; boolean isHighLevel = false;
String siteId = plan.getSiteId(); String siteId = plan.getSiteId();
@ -130,6 +133,7 @@ public class ProtectionPlanTask {
final Long status = plan.getStatus(); final Long status = plan.getStatus();
// 看方案是否启用,走不同判断 // 看方案是否启用,走不同判断
if (Objects.equals(status, ProtPlanStatus.STOP.getCode())) { if (Objects.equals(status, ProtPlanStatus.STOP.getCode())) {
logger.info("<方案未启用> 站点:{}方案ID:{}", siteId, plan.getId());
// 未启用,获取方案的故障值与最新数据判断是否需要下发方案 // 未启用,获取方案的故障值与最新数据判断是否需要下发方案
if(checkIsNeedIssuedPlan(protSettings, siteId)){ if(checkIsNeedIssuedPlan(protSettings, siteId)){
if("3".equals(plan.getFaultLevel())){ if("3".equals(plan.getFaultLevel())){
@ -166,6 +170,7 @@ public class ProtectionPlanTask {
}, faultDelay, TimeUnit.SECONDS); }, faultDelay, TimeUnit.SECONDS);
} }
} else { } else {
logger.info("<方案已启用> 站点:{}方案ID:{}", siteId, plan.getId());
// 已启用,则获取方案的释放值与最新数据判断是否需要取消方案 // 已启用,则获取方案的释放值与最新数据判断是否需要取消方案
if(checkIsNeedCancelPlan(protSettings, siteId)){ if(checkIsNeedCancelPlan(protSettings, siteId)){
// 延时, // 延时,
@ -282,6 +287,7 @@ public class ProtectionPlanTask {
} }
// 获取点位最新值 // 获取点位最新值
BigDecimal lastPointValue = getPointLastValue(deviceId, point, siteId); BigDecimal lastPointValue = getPointLastValue(deviceId, point, siteId);
logger.info("checkIsNeedCancelPlan 点位:{},最新值:{},比较方式:{},释放值:{}", point, lastPointValue, vo.getReleaseOperator(), releaseValue);
if(lastPointValue == null){ if(lastPointValue == null){
return false; return false;
} }
@ -293,11 +299,10 @@ public class ProtectionPlanTask {
conditionSb.append(" ").append(relation).append(" "); conditionSb.append(" ").append(relation).append(" ");
} }
}
// 执行比较语句 // 执行比较语句
return executeWithParser(conditionSb.toString()); return executeWithParser(conditionSb.toString());
} }
return true;
}
// 校验故障值是否需要下发方案 // 校验故障值是否需要下发方案
private boolean checkIsNeedIssuedPlan(List<ProtectionSettingVo> protSettings, String siteId) { private boolean checkIsNeedIssuedPlan(List<ProtectionSettingVo> protSettings, String siteId) {
@ -315,6 +320,7 @@ public class ProtectionPlanTask {
} }
// 获取点位最新值 // 获取点位最新值
BigDecimal lastPointValue = getPointLastValue(deviceId, point, siteId); BigDecimal lastPointValue = getPointLastValue(deviceId, point, siteId);
logger.info("checkIsNeedIssuedPlan 点位:{},最新值:{},比较方式:{},故障值:{}", point, lastPointValue, vo.getFaultOperator(), faultValue);
if(lastPointValue == null){ if(lastPointValue == null){
return false; return false;
} }
@ -326,11 +332,10 @@ public class ProtectionPlanTask {
conditionSb.append(" ").append(relation).append(" "); conditionSb.append(" ").append(relation).append(" ");
} }
}
// 执行比较语句 // 执行比较语句
return executeWithParser(conditionSb.toString()); return executeWithParser(conditionSb.toString());
} }
return true;
}
private BigDecimal getPointLastValue(String deviceId, String point, String siteId) { private BigDecimal getPointLastValue(String deviceId, String point, String siteId) {
JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.SYNC_DATA + siteId + "_" + deviceId); JSONObject mqttJson = redisCache.getCacheObject(RedisKeyConstants.SYNC_DATA + siteId + "_" + deviceId);
@ -461,7 +466,7 @@ public class ProtectionPlanTask {
boolean finalResult = atomicResults.get(0); boolean finalResult = atomicResults.get(0);
for (int i = 0; i < logicRelations.size(); i++) { for (int i = 0; i < logicRelations.size(); i++) {
String relation = logicRelations.get(i); String relation = logicRelations.get(i);
boolean nextResult = atomicResults.get(i + 1); boolean nextResult = atomicResults.get(i+1);
if ("&&".equals(relation)) { if ("&&".equals(relation)) {
finalResult = finalResult && nextResult; finalResult = finalResult && nextResult;
} else if ("||".equals(relation)) { } else if ("||".equals(relation)) {

View File

@ -99,7 +99,10 @@ public class StrategyPoller {
logger.error("运行策略{}轮询异常", strategyVo.getId(), e); logger.error("运行策略{}轮询异常", strategyVo.getId(), e);
return null; return null;
}) })
.thenRun(() -> strategyLocks.remove(strategyId)); .thenRun(() -> {
logger.info("运行策略{}轮询任务执行完成,释放锁", strategyVo.getId());
strategyLocks.remove(strategyId);
});
} catch (Exception e) { } catch (Exception e) {
logger.error("运行策略{}任务失败", strategyVo.getId(), e); logger.error("运行策略{}任务失败", strategyVo.getId(), e);
strategyLocks.remove(strategyId); strategyLocks.remove(strategyId);
@ -306,30 +309,39 @@ public class StrategyPoller {
public List<WriteTagConfig> getSwitchDeviceWriteTags(EmsPcsSetting pcsSetting, String workStatus) { public List<WriteTagConfig> getSwitchDeviceWriteTags(EmsPcsSetting pcsSetting, String workStatus) {
List<WriteTagConfig> writeTags = new ArrayList<>(); List<WriteTagConfig> writeTags = new ArrayList<>();
BigDecimal power; BigDecimal power;
if (WorkStatus.NORMAL.getCode().equals(workStatus)) {
// 开机先发送开机指令再发送有功功率给定值
WriteTagConfig writeTag = new WriteTagConfig(); WriteTagConfig writeTag = new WriteTagConfig();
writeTag.setAddress(pcsSetting.getPointAddress()); writeTag.setAddress(pcsSetting.getPointAddress());
if (WorkStatus.NORMAL.getCode().equals(workStatus)) {
// 开机
writeTag.setValue(pcsSetting.getStartCommand()); writeTag.setValue(pcsSetting.getStartCommand());
writeTags.add(writeTag);
power = pcsSetting.getStartPower(); power = pcsSetting.getStartPower();
} else { } else {
// 关机 // 关机
writeTag.setValue(pcsSetting.getStopCommand());
power = pcsSetting.getStopPower(); power = pcsSetting.getStopPower();
} }
writeTags.add(writeTag);
JSONArray array = JSON.parseArray(pcsSetting.getClusterPointAddress()); JSONArray array = JSON.parseArray(pcsSetting.getClusterPointAddress());
for (int i = 0; i < pcsSetting.getClusterNum(); i++) { for (int i = 0; i < pcsSetting.getClusterNum(); i++) {
Object clusterPointAddress = array.get(i); Object clusterPointAddress = array.get(i);
WriteTagConfig clusterWriteTag = new WriteTagConfig(); WriteTagConfig clusterWriteTag = new WriteTagConfig();
clusterWriteTag.setAddress(String.valueOf(clusterPointAddress)); clusterWriteTag.setAddress(String.valueOf(clusterPointAddress));
// 电池簇PCS有功功率给定置0 // 电池簇PCS有功功率给定默认置0
if (power == null) { if (power == null) {
power = BigDecimal.ZERO; power = BigDecimal.ZERO;
} }
clusterWriteTag.setValue(power); clusterWriteTag.setValue(power);
writeTags.add(clusterWriteTag); writeTags.add(clusterWriteTag);
} }
if (WorkStatus.STOP.getCode().equals(workStatus)) {
// 关机先发送有功功率给定值再发送关机指令
WriteTagConfig writeTag = new WriteTagConfig();
writeTag.setAddress(pcsSetting.getPointAddress());
writeTag.setValue(pcsSetting.getStopCommand());
writeTags.add(writeTag);
}
return writeTags; return writeTags;
} }

View File

@ -564,32 +564,39 @@ public class EmsDeviceSettingServiceImpl implements IEmsDeviceSettingService
public List<WriteTagConfig> getWriteTags(String workStatus, EmsPcsSetting pcsSetting) { public List<WriteTagConfig> getWriteTags(String workStatus, EmsPcsSetting pcsSetting) {
List<WriteTagConfig> writeTags = new ArrayList<>(); List<WriteTagConfig> writeTags = new ArrayList<>();
BigDecimal power; BigDecimal power;
if (WorkStatus.NORMAL.getCode().equals(workStatus)) {
// 开机先发送开机指令再发送有功功率给定值
WriteTagConfig writeTag = new WriteTagConfig(); WriteTagConfig writeTag = new WriteTagConfig();
writeTag.setAddress(pcsSetting.getPointAddress()); writeTag.setAddress(pcsSetting.getPointAddress());
if (WorkStatus.NORMAL.getCode().equals(workStatus)) {
// 开机
writeTag.setValue(pcsSetting.getStartCommand()); writeTag.setValue(pcsSetting.getStartCommand());
writeTags.add(writeTag);
power = pcsSetting.getStartPower(); power = pcsSetting.getStartPower();
} else if (WorkStatus.STOP.getCode().equals(workStatus)) { } else if (WorkStatus.STOP.getCode().equals(workStatus)) {
// 关机 // 关机
writeTag.setValue(pcsSetting.getStopCommand());
power = pcsSetting.getStopPower(); power = pcsSetting.getStopPower();
} else { } else {
throw new ServiceException("工作状态不合法"); throw new ServiceException("工作状态不合法");
} }
writeTags.add(writeTag);
JSONArray array = JSON.parseArray(pcsSetting.getClusterPointAddress()); JSONArray array = JSON.parseArray(pcsSetting.getClusterPointAddress());
for (int i = 0; i < pcsSetting.getClusterNum(); i++) { for (int i = 0; i < pcsSetting.getClusterNum(); i++) {
Object clusterPointAddress = array.get(i); Object clusterPointAddress = array.get(i);
WriteTagConfig clusterWriteTag = new WriteTagConfig(); WriteTagConfig clusterWriteTag = new WriteTagConfig();
clusterWriteTag.setAddress(String.valueOf(clusterPointAddress)); clusterWriteTag.setAddress(String.valueOf(clusterPointAddress));
// 电池簇PCS有功功率给定置0 // 电池簇PCS有功功率给定默认置0
if (power == null) { if (power == null) {
power = BigDecimal.ZERO; power = BigDecimal.ZERO;
} }
clusterWriteTag.setValue(power); clusterWriteTag.setValue(power);
writeTags.add(clusterWriteTag); writeTags.add(clusterWriteTag);
} }
if (WorkStatus.STOP.getCode().equals(workStatus)) {
// 关机先发送有功功率给定值再发送关机指令
WriteTagConfig writeTag = new WriteTagConfig();
writeTag.setAddress(pcsSetting.getPointAddress());
writeTag.setValue(pcsSetting.getStopCommand());
writeTags.add(writeTag);
}
return writeTags; return writeTags;
} }
} }