代码调整

This commit is contained in:
tiger_zhou 2023-12-26 13:00:43 +08:00
parent 2e485d0de1
commit 7323a6fede

View File

@ -69,8 +69,9 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) { for (Entry<String, InterLockDetail> interLockDetail : detailMap.entrySet()) {
String rtuIdJoinStr = interLockDetail.getKey(); String rtuIdJoinStr = interLockDetail.getKey();
InterLockDetail detail = interLockDetail.getValue(); InterLockDetail detail = interLockDetail.getValue();
Optional<AxleInterLockSource> redOpt = this.handle(lineId, detail, AlertType.AXLE_LED_RED, rtuIdJoinStr);
Optional<AxleInterLockSource> orangeOpt = this.handle(lineId, detail, AlertType.AXLE_LED_ORANGE, rtuIdJoinStr); Optional<AxleInterLockSource> redOpt = this.handle(lineId, detail, AlertType.AXLE_LED_RED, AlertType.AXLE_LED_RED_INTERLOCK_AREA, rtuIdJoinStr);
Optional<AxleInterLockSource> orangeOpt = this.handle(lineId, detail, AlertType.AXLE_LED_ORANGE, AlertType.AXLE_LED_ORANGE_INTERLOCK_AREA, rtuIdJoinStr);
redOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource))); redOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource)));
orangeOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource))); orangeOpt.ifPresent(axleInterLockSource -> this.alertManager.emit(new LedMostEvent(axleInterLockSource)));
@ -81,27 +82,27 @@ public class AxleLedInterlockTask implements AlertMonitoringTask {
} }
} }
private Optional<AxleInterLockSource> handle(String lineId, InterLockDetail detail, AlertType alertType, String rtuIdJoinStr) { private Optional<AxleInterLockSource> handle(String lineId, InterLockDetail detail, AlertType findWarnAlertType, AlertType warnAlertType, String rtuIdJoinStr) {
int deviceCount = detail.getDevices().size(); int deviceCount = detail.getDevices().size();
Integer lineIdInt = Integer.parseInt(lineId); Integer lineIdInt = Integer.parseInt(lineId);
//收集联锁下的所有所有区段设备 //收集联锁下的所有所有区段设备
List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(alertType, lineId, detail.getDevices()); List<TrackOccupiedStatus> resultList = this.collectorLedWarDevices(findWarnAlertType, lineId, detail.getDevices());
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", alertType.name(), detail.getAreaConfigId()); String customName = String.format("%s-%s", findWarnAlertType.name(), detail.getAreaConfigId());
if (occupidedSzie >= deviceCount) { if (occupidedSzie >= deviceCount) {
//联锁报警 //联锁报警
if (alertDataSource.putAlterDevice(lineIdInt, customName, alertType.name())) { if (alertDataSource.putAlterDevice(lineIdInt, customName, warnAlertType.name())) {
NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(detail.getAreaConfigId(), alertType, lineIdInt, LocalDateTime.now(), detail.getAreaConfigName(), null, NccAlertInfo alertInfoMost = this.alertInfoService.createAlert2(detail.getAreaConfigId(), warnAlertType, lineIdInt, LocalDateTime.now(), detail.getAreaConfigName(), null,
AlertDeviceType.DEVICE_TYPE_TRACK, AlertDeviceType.DEVICE_TYPE_TRACK,
false); false);
alertManager.emit(alertInfoMost); alertManager.emit(alertInfoMost);
} }
return Optional.empty(); return Optional.empty();
} }
alertDataSource.removeAlterDevice(lineIdInt, customName, alertType.name()); alertDataSource.removeAlterDevice(lineIdInt, customName, warnAlertType.name());
if (CollectionUtils.isNotEmpty(resultList)) { if (CollectionUtils.isNotEmpty(resultList)) {
//大面积或单个告警 //大面积或单个告警
AxleInterLockSource source = new AxleInterLockSource(lineId, rtuIdJoinStr, resultList, alertType); AxleInterLockSource source = new AxleInterLockSource(lineId, rtuIdJoinStr, resultList, findWarnAlertType);
return Optional.of(source); return Optional.of(source);
} }
return Optional.empty(); return Optional.empty();