This commit is contained in:
tiger_zhou 2023-12-27 16:55:43 +08:00
parent cec85ded93
commit 4c3c282cf7

View File

@ -34,6 +34,7 @@ import java.util.Map.Entry;
import java.util.Objects; import java.util.Objects;
import java.util.Optional; import java.util.Optional;
import java.util.Set; import java.util.Set;
import java.util.stream.Collectors;
import lombok.Getter; import lombok.Getter;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -65,7 +66,6 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
for (String lineId : lineCollSet) { for (String lineId : lineCollSet) {
InterLockData interLockData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.INTER_LOCK); InterLockData interLockData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.INTER_LOCK);
List<String> interlockOneList = interLockData.findKeysStart(AlertType.INTERLOCK_LEVEL_ONE.name()); List<String> interlockOneList = interLockData.findKeysStart(AlertType.INTERLOCK_LEVEL_ONE.name());
// .stream().filter(d -> StringUtils.endsWith(d, AlertDeviceType.DEVICE_TYPE_TRACK.name())).toList();
for (String lockLevel : interlockOneList) { for (String lockLevel : interlockOneList) {
Map<String, InterLockDetail> detailMap = interLockData.getDetailByInterlockKey(lockLevel); Map<String, InterLockDetail> detailMap = interLockData.getDetailByInterlockKey(lockLevel);
for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) { for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) {
@ -87,6 +87,8 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
Integer lineIdInt = Integer.parseInt(lineId); Integer lineIdInt = Integer.parseInt(lineId);
//收集联锁下的所有所有区段设备 //收集联锁下的所有所有区段设备
List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices()); List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices());
log.info("线路[{}] 联锁区[{}] 需要加载设备数量[{}] 实际加载数量[{}] 区段被占用情况[{}]", lineId, rtuIdJoinStr, deviceCount, resultList.size(),
resultList.stream().filter(d -> d.occupied).map(d -> d.deviceCode).collect(Collectors.joining(",")));
int occupidedSzie = (int) resultList.stream().filter(d -> d.occupied).count(); int occupidedSzie = (int) resultList.stream().filter(d -> d.occupied).count();
String customName = String.format("%s-%s", findWarnAlertType.name(), detail.getAreaConfigId()); String customName = String.format("%s-%s", findWarnAlertType.name(), detail.getAreaConfigId());
if (occupidedSzie >= deviceCount) { if (occupidedSzie >= deviceCount) {
@ -115,14 +117,6 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
List<TrackOccupiedStatus> warnResultList = Lists.newArrayList(); List<TrackOccupiedStatus> warnResultList = Lists.newArrayList();
for (Integer deviceLayoutId : deviceLayoutIds) { for (Integer deviceLayoutId : deviceLayoutIds) {
MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCode(lineIdInt, deviceLayoutId.toString()); MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCode(lineIdInt, deviceLayoutId.toString());
/* if (mb instanceof Section section) {
boolean result = this.checkTrackOccupiedSectionStatus(alertType, section, lineIdInt, deviceStatusData, trainDataSource);
warnResultList.add(new TrackOccupiedStatus(section.getCode(), result, section.getCommon().getId()));
} else if (mb instanceof Turnout turnout) {
String dgCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(lineIdInt, turnout.getCode());
boolean result = this.checkTrackOccupiedTurnoutStatus(alertType, turnout, deviceStatusData, trainDataSource);
warnResultList.add(new TrackOccupiedStatus(dgCode, result, turnout.getCommon().getId()));
}*/
if (mb instanceof Section section) { if (mb instanceof Section section) {
boolean result = this.checkTrackOccupiedStatus(alertType, section, lineIdInt, deviceStatusData, trainDataSource); boolean result = this.checkTrackOccupiedStatus(alertType, section, lineIdInt, deviceStatusData, trainDataSource);
warnResultList.add(new TrackOccupiedStatus(section.getCode(), result, section.getCommon().getId())); warnResultList.add(new TrackOccupiedStatus(section.getCode(), result, section.getCommon().getId()));
@ -131,58 +125,18 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
return warnResultList; return warnResultList;
} }
@Deprecated
private boolean checkTrackOccupiedTurnoutStatus(AlertType alertType, Turnout turnout, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
MessageOrBuilder deviceStatus = deviceStatusData.getDeviceBuild(Switch.getDescriptor().getName(), turnout.getCode());
String trackCode = DeviceNameChangerManage.findMatch(DeviceType.DEVICE_TYPE_SWITCH, turnout.getCode());
String trainGroupId = trainDataSource.findTrainForDeviceName(trackCode);
if (deviceStatus instanceof Switch.Builder switchBuild) {
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied() && !switchBuild.getIpSingleSwitchStusCbtcOccupied() && Objects.isNull(trainGroupId);
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
if (alertType == AlertType.AXLE_LED_RED) {
return ledRed;
} else {
return orange;
}
}
return false;
}
@Deprecated
private boolean checkTrackOccupiedSectionStatus(AlertType alertType, Section section, Integer lineId, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
List<Boolean> alertList = Lists.newArrayList();
if (section.getSectionType() == SectionType.Physical) {
for (Integer childId : section.getChildrenList()) {
MessageOrBuilder childMB = LineGraphicDataRepository.getDeviceByCode(lineId, childId.toString());
String deviceCode = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
MessageOrBuilder deviceStatus = deviceStatusData.getDeviceBuild(Track.getDescriptor().getName(), deviceCode);
String trainGroupId = trainDataSource.findTrainForDeviceName(deviceCode);
if (StringUtils.isNotEmpty(trainGroupId)) {
//车辆占用区段
return false;
}
if (deviceStatus instanceof Track.Builder track) {
if (alertType == AlertType.AXLE_LED_RED) {
boolean red = track.getCiOccupied() && !track.getCbtcOccupied();
alertList.add(red);
} else {
boolean orange = track.getAtcInvalid();
alertList.add(orange);
}
}
}
}
if (CollectionUtils.isEmpty(alertList)) {
return false;
}
return alertList.stream().allMatch(d -> d);
}
private boolean checkTrackOccupiedStatus(AlertType alertType, Section section, Integer lineId, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) { private boolean checkTrackOccupiedStatus(AlertType alertType, Section section, Integer lineId, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
List<Boolean> alertList = Lists.newArrayList();
if (section.getSectionType() == SectionType.Physical) { if (section.getSectionType() == SectionType.Physical) {
return this.checkTrackStatus(lineId, section, alertType, deviceStatusData, trainDataSource);
} else if (section.getSectionType() == SectionType.TurnoutPhysical) {
return this.checkTurnoutStatus(lineId, section, alertType, deviceStatusData, trainDataSource);
}
return false;
}
private boolean checkTrackStatus(Integer lineId, Section section, AlertType alertType, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
List<Boolean> sectionStatusList = Lists.newArrayListWithCapacity(section.getChildrenList().size());
for (Integer childId : section.getChildrenList()) { for (Integer childId : section.getChildrenList()) {
MessageOrBuilder childMB = LineGraphicDataRepository.getDeviceByCode(lineId, childId.toString()); MessageOrBuilder childMB = LineGraphicDataRepository.getDeviceByCode(lineId, childId.toString());
String deviceCode = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class); String deviceCode = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class);
@ -195,21 +149,29 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
if (deviceStatus instanceof Track.Builder track) { if (deviceStatus instanceof Track.Builder track) {
if (alertType == AlertType.AXLE_LED_RED) { if (alertType == AlertType.AXLE_LED_RED) {
boolean red = track.getCiOccupied() && !track.getCbtcOccupied(); boolean red = track.getCiOccupied() && !track.getCbtcOccupied();
alertList.add(red); sectionStatusList.add(red);
} else { } else {
boolean orange = track.getAtcInvalid(); boolean orange = track.getAtcInvalid();
alertList.add(orange); sectionStatusList.add(orange);
} }
} }
} }
} else if (section.getSectionType() == SectionType.TurnoutPhysical) {
return sectionStatusList.stream().allMatch(d -> d);
}
private boolean checkTurnoutStatus(Integer lineId, Section section, AlertType alertType, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) {
List<Boolean> turnoutOccLList = Lists.newArrayListWithCapacity(section.getChildrenList().size()); List<Boolean> turnoutOccLList = Lists.newArrayListWithCapacity(section.getChildrenList().size());
for (Integer refTuronoutId : section.getChildrenList()) { for (Integer refTuronoutId : section.getChildrenList()) {
Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, refTuronoutId.toString(), Turnout.class); Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, refTuronoutId.toString(), Turnout.class);
MessageOrBuilder deviceStatus = deviceStatusData.getDeviceBuild(Switch.getDescriptor().getName(), turnout.getCode()); MessageOrBuilder deviceStatus = deviceStatusData.getDeviceBuild(Switch.getDescriptor().getName(), turnout.getCode());
String trainGroupId = trainDataSource.findTrainForDeviceName(section.getCode()); String trainGroupId = trainDataSource.findTrainForDeviceName(section.getCode());
if (StringUtils.isNotEmpty(trainGroupId)) {
//车辆占用区段
return false;
}
if (deviceStatus instanceof Switch.Builder switchBuild) { if (deviceStatus instanceof Switch.Builder switchBuild) {
boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied() && !switchBuild.getIpSingleSwitchStusCbtcOccupied() && Objects.isNull(trainGroupId); boolean ledRed = switchBuild.getIpSingleSwitchStusCiOccupied() && !switchBuild.getIpSingleSwitchStusCbtcOccupied();
boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid(); boolean orange = switchBuild.getIpSingleSwitchStusAtcInvalid();
if (alertType == AlertType.AXLE_LED_RED) { if (alertType == AlertType.AXLE_LED_RED) {
turnoutOccLList.add(ledRed); turnoutOccLList.add(ledRed);
@ -218,14 +180,9 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
} }
} }
} }
alertList.add(turnoutOccLList.stream().anyMatch(d -> d));
}
if (CollectionUtils.isEmpty(alertList)) {
return false;
}
return alertList.stream().allMatch(d -> d);
}
return turnoutOccLList.stream().anyMatch(d -> d);
}
@Getter @Getter
public static class AxleInterLockSource { public static class AxleInterLockSource {