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

View File

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

View File

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