diff --git a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java index 8546aab..423d923 100644 --- a/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java +++ b/src/main/java/club/joylink/xiannccda/ats/cache/LineGraphicDataRepository.java @@ -23,7 +23,6 @@ import club.joylink.xiannccda.entity.PublishedGi; import club.joylink.xiannccda.exception.BusinessExceptionAssertEnum; import com.baomidou.mybatisplus.core.toolkit.CollectionUtils; import com.google.common.collect.HashBasedTable; -import com.google.common.collect.Lists; import com.google.common.collect.Table; import com.google.protobuf.Descriptors.FieldDescriptor; import com.google.protobuf.GeneratedMessageV3; @@ -75,12 +74,10 @@ public class LineGraphicDataRepository { private static final HashBasedTable line_id_table = HashBasedTable.create(); /** - * 线路id 逻辑 对物理区段的map - *

- * 如果区段是道岔物理区段,那么key 就是对应的道岔code + * 线路id 道岔code 对应的道岔区段 */ - @Deprecated - private static final Table LOGIC_SECTION_TO_SECTION_TABLE = HashBasedTable.create(); + + private static final Table TURNOUT_TO_TURNOUT_TRACK = HashBasedTable.create(); private static final Table LOGIC_SECTION_TO_AXLE_TABLE = HashBasedTable.create(); @@ -127,15 +124,15 @@ public class LineGraphicDataRepository { for (Integer childId : section.getChildrenList()) { Builder b = turnoutMap.get(childId); if (b instanceof DeviceInfoProto.Turnout.Builder logicSection) { - LOGIC_SECTION_TO_SECTION_TABLE.put(publishGi.getLineId(), logicSection.getCode(), section.getCode()); - LOGIC_SECTION_TO_AXLE_TABLE.put(publishGi.getLineId(), section.getCode(), logicSection.getCode()); + TURNOUT_TO_TURNOUT_TRACK.put(publishGi.getLineId(), logicSection.getCode(), section.getCode()); +// LOGIC_SECTION_TO_AXLE_TABLE.put(publishGi.getLineId(), section.getCode(), logicSection.getCode()); } } } else { for (Integer childId : section.getChildrenList()) { Builder b = builderMap.get(childId); if (b instanceof DeviceInfoProto.Section.Builder logicSection) { - LOGIC_SECTION_TO_SECTION_TABLE.put(publishGi.getLineId(), logicSection.getCode(), logicSection.getCode()); +// LOGIC_SECTION_TO_SECTION_TABLE.put(publishGi.getLineId(), logicSection.getCode(), logicSection.getCode()); LOGIC_SECTION_TO_AXLE_TABLE.put(publishGi.getLineId(), logicSection.getCode(), section.getCode()); } } @@ -178,17 +175,13 @@ public class LineGraphicDataRepository { for (Integer childId : section.getChildrenList()) { MessageOrBuilder childMB = getDeviceByCode(lineId, childId.toString()); String deviceCode_ = DeviceStatusDataOperate.findFieldVal(childMB, "code", String.class); - dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue())); interLock.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_TRACK, deviceCode_, rtuId.shortValue())); } } } else if (mb instanceof LayoutGraphicsProto.Signal) { - dsd.addDevice(createMsg(lineId, club.joylink.xiannccda.ats.message.line3.device.DeviceType.DEVICE_TYPE_SIGNAL, deviceCode, rtuId.shortValue())); } - - } } } @@ -281,8 +274,8 @@ public class LineGraphicDataRepository { return mob; } - public static String findSectionFromLogicCode(int lineId, String code) { - return LOGIC_SECTION_TO_SECTION_TABLE.get(lineId, code); + public static String findTurnoutSectionFromTurnoutCode(int lineId, String code) { + return TURNOUT_TO_TURNOUT_TRACK.get(lineId, code); } public static Optional getDeviceOptByCode(int lineId, String code, Class cls) { diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java index aa30992..bde7c9c 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainInitConvertor.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; -import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.List; @@ -28,7 +28,7 @@ public class TrainInitConvertor extends DefaultConvertor { AlertManager alertManager = AlertManager.getDefault(); for (Builder builder : builders) { if (builder instanceof TrainInfo.Builder trainBuild) { - + alertManager.emit(new TrainAlertEvent(trainBuild)); } } diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java index b01c5fa..f5a68f7 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainRemoveConvertor.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; -import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove; import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.List; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java index 507691c..9d37ea4 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/convertor/TrainUpdateConvertor.java @@ -4,7 +4,7 @@ import club.joylink.xiannccda.alert.core.AlertManager; import club.joylink.xiannccda.ats.message.MessageId; import club.joylink.xiannccda.ats.message.collect.DeviceDataRepository.DataTypeEnum; -import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.List; diff --git a/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/InterLockData.java b/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/InterLockData.java index 4338553..2a63d64 100644 --- a/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/InterLockData.java +++ b/src/main/java/club/joylink/xiannccda/ats/message/collect/datasource/InterLockData.java @@ -94,14 +94,14 @@ public class InterLockData extends AbstractData { MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, axleCode); this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId); } else if (builder instanceof Switch.Builder switchs) { -// MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, switchs.getId()); -// this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_SWITCH, interlockArea, min, max, rtuId); + MessageOrBuilder section = LineGraphicDataRepository.getDeviceByCode(lineId, switchs.getId()); + this.put(section, alertType, AlertDeviceType.DEVICE_TYPE_SWITCH, interlockArea, min, max, rtuId); //获取对应的道岔物理区段 - String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, switchs.getId()); - if (StringUtils.isNotEmpty(sectionCode)) { - MessageOrBuilder switchSection = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode); - this.put(switchSection, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId); - } +// String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, switchs.getId()); +// if (StringUtils.isNotEmpty(sectionCode)) { +// MessageOrBuilder switchSection = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode); +// this.put(switchSection, alertType, AlertDeviceType.DEVICE_TYPE_TRACK, interlockArea, min, max, rtuId); +// } } } } diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/TrainAtpCutAlertMonitoringTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainAtpCutAlertMonitoringTask.java similarity index 76% rename from src/main/java/club/joylink/xiannccda/ats/warn/TrainAtpCutAlertMonitoringTask.java rename to src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainAtpCutAlertMonitoringTask.java index 51de425..8dccf77 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/TrainAtpCutAlertMonitoringTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainAtpCutAlertMonitoringTask.java @@ -1,4 +1,4 @@ -package club.joylink.xiannccda.ats.warn; +package club.joylink.xiannccda.ats.warn.atp; import club.joylink.xiannccda.alert.NccAlertInfo; import club.joylink.xiannccda.alert.core.AlertDataSource; @@ -11,6 +11,10 @@ import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode; import club.joylink.xiannccda.dto.protos.GuardConfigProto.GuardConfig; import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.CommonInfo; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.LogicSection; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Section.SectionType; +import club.joylink.xiannccda.dto.protos.LayoutGraphicsProto.Turnout; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo.Builder; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove; @@ -96,17 +100,35 @@ public class TrainAtpCutAlertMonitoringTask implements AlertMonitoringTask { protected void trainAlert(TrainInfo.Builder trainInfo) { - String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName()); - if (StringUtils.isEmpty(sectionCode)) { + MessageOrBuilder mb = LineGraphicDataRepository.getDeviceByCodeNotException(trainInfo.getLineId(), trainInfo.getDevName()); + if (!(mb instanceof LogicSection) && !(mb instanceof Turnout) && !(mb instanceof Section)) { + log.error("线路[{}]列车[{}]所在未知设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName()); + this.trainInfoMap.remove(trainInfo.getGroupId()); return; } - MessageOrBuilder turnoutOrLogicSection = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), sectionCode); - CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(turnoutOrLogicSection, "common", CommonInfo.class); - String deviceCode = DeviceStatusDataOperate.findFieldVal(turnoutOrLogicSection, "code", String.class); + CommonInfo commonInfo = DeviceStatusDataOperate.findFieldVal(mb, "common", CommonInfo.class); Integer layoutDeviceId = commonInfo.getId(); + if (mb instanceof LogicSection) { + String axleCode = LineGraphicDataRepository.findAxleCodeFromLogicCode(trainInfo.getLineId(), trainInfo.getDevName()); + Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), axleCode, Section.class); + layoutDeviceId = section.getCommon().getId(); + } + if (mb instanceof Turnout) { + String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(trainInfo.getLineId(), trainInfo.getDevName()); + Section section = LineGraphicDataRepository.getDeviceByCode(trainInfo.getLineId(), turnoutCode, Section.class); + layoutDeviceId = section.getCommon().getId(); + } + /* if (mb instanceof Section section) { + if (section.getSectionType() == SectionType.Physical) { + + } else { + + } + }*/ + if (alertDataSource.putAlterDevice(trainInfo.getLineId(), this.getName(), trainInfo.getGroupId())) { log.info("列车紧制ATP检测告警 线路[{}] 列车车组号[{}] 所在设备[{}]", trainInfo.getLineId(), trainInfo.getGroupId(), trainInfo.getDevName()); - String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), deviceCode); + String alertMsg = String.format("列车[%s] 紧制导致ATP切除所在区段[%s]", trainInfo.getGroupId(), trainInfo.getDevName()); NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.TRAIN_EB_ATP, AlertDeviceType.DEVICE_TYPE_TRACK, layoutDeviceId, trainInfo, alertMsg, AlertDeviceType.DEVICE_TYPE_TRAIN, false); alertManager.emit(alertInfo); diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainModeAlertListener.java similarity index 86% rename from src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java rename to src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainModeAlertListener.java index 91abae1..e188b73 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/TrainModeAlertListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/atp/TrainModeAlertListener.java @@ -1,11 +1,13 @@ -package club.joylink.xiannccda.ats.warn; +package club.joylink.xiannccda.ats.warn.atp; import club.joylink.xiannccda.alert.core.AlertSourceEventListener; -import club.joylink.xiannccda.ats.warn.TrainModeAlertListener.TrainAlertEvent; +import club.joylink.xiannccda.ats.warn.DeviceAlertEvent; +import club.joylink.xiannccda.ats.warn.atp.TrainModeAlertListener.TrainAlertEvent; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.TrainMode; import club.joylink.xiannccda.dto.protos.TrainProto.TrainInfo; import club.joylink.xiannccda.dto.protos.TrainProto.TrainRemove; import com.google.protobuf.GeneratedMessageV3; +import com.google.protobuf.GeneratedMessageV3.Builder; import java.util.Objects; import lombok.extern.slf4j.Slf4j; import org.springframework.stereotype.Component; @@ -44,7 +46,7 @@ public class TrainModeAlertListener implements AlertSourceEventListener { + public static class TrainAlertEvent extends DeviceAlertEvent { public TrainAlertEvent(GeneratedMessageV3.Builder source) { super(source); diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java b/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java index 3e9cee4..268508b 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedInterlockTask.java @@ -13,6 +13,8 @@ import club.joylink.xiannccda.ats.message.collect.datasource.DeviceStatusData; import club.joylink.xiannccda.ats.message.collect.datasource.InterLockData; import club.joylink.xiannccda.ats.message.collect.datasource.InterLockData.InterLockDetail; import club.joylink.xiannccda.ats.message.collect.datasource.TrainDataSource; +import club.joylink.xiannccda.ats.message.line3.changer.DeviceNameChangerManage; +import club.joylink.xiannccda.ats.message.line3.device.DeviceType; import club.joylink.xiannccda.ats.warn.axle.event.LedMostEvent; import club.joylink.xiannccda.dto.protos.AlertConstProto.AlertType; import club.joylink.xiannccda.dto.protos.DeviceStatusProto.Switch; @@ -62,8 +64,8 @@ public class AxleLedInterlockTask implements AlertMonitoringTask { } for (String lineId : lineCollSet) { InterLockData interLockData = DeviceDataRepository.findDataSouce(lineId, DataTypeEnum.INTER_LOCK); - List interlockOneList = interLockData.findKeysStart(AlertType.INTERLOCK_LEVEL_ONE.name()) - .stream().filter(d -> StringUtils.endsWith(d, AlertDeviceType.DEVICE_TYPE_TRACK.name())).toList(); + List interlockOneList = interLockData.findKeysStart(AlertType.INTERLOCK_LEVEL_ONE.name()); +// .stream().filter(d -> StringUtils.endsWith(d, AlertDeviceType.DEVICE_TYPE_TRACK.name())).toList(); for (String lockLevel : interlockOneList) { Map detailMap = interLockData.getDetailByInterlockKey(lockLevel); for (Entry interLockDetail : detailMap.entrySet()) { @@ -114,13 +116,84 @@ public class AxleLedInterlockTask implements AlertMonitoringTask { for (Integer deviceLayoutId : deviceLayoutIds) { 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) { boolean result = this.checkTrackOccupiedStatus(alertType, section, lineIdInt, deviceStatusData, trainDataSource); warnResultList.add(new TrackOccupiedStatus(section.getCode(), result, section.getCommon().getId())); - } + }*/ } return warnResultList; } + 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; + } + + private boolean checkTrackOccupiedSectionStatus(AlertType alertType, Section section, Integer lineId, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) { + List 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); + } + } + } + }/* else if (section.getSectionType() == SectionType.TurnoutPhysical) { + Integer turnoutId = section.getChildren(0); + Turnout turnout = LineGraphicDataRepository.getDeviceByCode(lineId, turnoutId.toString(), Turnout.class); + + MessageOrBuilder deviceStatus = deviceStatusData.getDeviceBuild(Switch.getDescriptor().getName(), turnout.getCode()); + + String trainGroupId = trainDataSource.findTrainForDeviceName(section.getCode()); + 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) { + alertList.add(ledRed); + } else { + alertList.add(orange); + } + } + }*/ + if (CollectionUtils.isEmpty(alertList)) { + return false; + } + return alertList.stream().allMatch(d -> d); + } + +/* @Deprecated private boolean checkTrackOccupiedStatus(AlertType alertType, Section section, Integer lineId, DeviceStatusData deviceStatusData, TrainDataSource trainDataSource) { List alertList = Lists.newArrayList(); if (section.getSectionType() == SectionType.Physical) { @@ -164,7 +237,7 @@ public class AxleLedInterlockTask implements AlertMonitoringTask { return false; } return alertList.stream().allMatch(d -> d); - } + }*/ @Getter diff --git a/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedMostMonitorListener.java b/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedMostMonitorListener.java index eed85cc..fd3d35e 100644 --- a/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedMostMonitorListener.java +++ b/src/main/java/club/joylink/xiannccda/ats/warn/axle/AxleLedMostMonitorListener.java @@ -68,6 +68,19 @@ public class AxleLedMostMonitorListener implements AlertSourceEventListener warnDeviceList = alertDataSource.findAllWarnDeviceForList(lineIdInt, customName); + /*deviceStatusList.stream().filter(d -> d.saveAlertDataSouce).forEach(d -> { + String alertMsg = String.format("出现%s设备[%s]", ledName, d.deviceCode); + + if (Objects.nonNull(areaConfigVO) && warnDeviceList.size() >= ledThreshold) { + String warnDevices = String.join(",", warnDeviceList); + alertMsg = String.format("%s-出现大面积%s设备[%s]", areaConfigVO.getAreaName(), ledName, warnDevices); + } + String alertMsg = String.format("出现%s设备[%s]", ledName, d.deviceCode); + NccAlertInfo alertInfo = this.alertInfoService.createAlert2(null, lockSource.alertType, lineIdInt, LocalDateTime.now(), alertMsg, String.valueOf(d.layoutId), + AlertDeviceType.DEVICE_TYPE_TRACK, false); + alertManager.emit(alertInfo); + });*/ + if (Objects.nonNull(areaConfigVO) && deviceStatusList.stream().anyMatch(d -> d.saveAlertDataSouce) && warnDeviceList.size() >= ledThreshold) { //发布大面积 String warnDevices = String.join(",", warnDeviceList); @@ -76,6 +89,7 @@ public class AxleLedMostMonitorListener implements AlertSourceEventListener d.saveAlertDataSouce).forEach(d -> { + log.error("---------------" + d.deviceCode); String alertMsg = String.format("出现%s设备[%s]", ledName, d.deviceCode); NccAlertInfo alertInfo = this.alertInfoService.createAlert2(null, lockSource.alertType, lineIdInt, LocalDateTime.now(), alertMsg, String.valueOf(d.layoutId), AlertDeviceType.DEVICE_TYPE_TRACK, false); diff --git a/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java b/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java index 7b32959..f4f0286 100644 --- a/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java +++ b/src/main/java/club/joylink/xiannccda/mock/message/occ/MockOccServer.java @@ -146,6 +146,10 @@ public class MockOccServer { mockDeviceStatusReq.setTime(Instant.ofEpochMilli(System.currentTimeMillis()).getEpochSecond()); list.add(mockDeviceStatusReq); } else if (messageId == MessageId.TRAIN_INDICATION_UPDATE) { + if (di.getDeviceType() == DeviceType.DEVICE_TYPE_SWITCH) { + String turnoutCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(lineId, di.getDeviceName()); + di.setDeviceName(turnoutCode); + } MockTrainUpdateReq req = new MockTrainUpdateReq(messageId, lineId, rtuId_.shortValue(), di.getDeviceType(), di.getDeviceName(), md.deviceStatus(di.getStatus())); req.setTime(Instant.ofEpochMilli(System.currentTimeMillis()).getEpochSecond()); req.setGroup_id(di.getGroupId()); diff --git a/src/main/java/club/joylink/xiannccda/service/AlertMockService.java b/src/main/java/club/joylink/xiannccda/service/AlertMockService.java index 139d6aa..64c645e 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertMockService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertMockService.java @@ -38,7 +38,6 @@ import club.joylink.xiannccda.mock.message.occ.MockOccServer; import club.joylink.xiannccda.vo.AreaConfigVO; import com.alibaba.fastjson2.JSONObject; import com.google.protobuf.GeneratedMessageV3; -import com.google.protobuf.GeneratedMessageV3.Builder; import com.google.protobuf.MessageOrBuilder; import java.time.LocalDateTime; import java.util.Collection; @@ -53,7 +52,6 @@ import lombok.Data; import lombok.NoArgsConstructor; import lombok.extern.slf4j.Slf4j; import org.apache.commons.lang3.StringUtils; -import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; import org.springframework.stereotype.Service; @@ -380,7 +378,7 @@ public class AlertMockService { track.setRtuId(1); track.setId("G0202-A"); track.setLineId(lineId); - String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, "G0202-A"); + String sectionCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(lineId, "G0202-A"); Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class); NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.SWITCH_LOST, AlertDeviceType.DEVICE_TYPE_SWITCH, section.getCommon().getId(), track, track.getId(), AlertDeviceType.DEVICE_TYPE_TRACK, true); @@ -394,7 +392,7 @@ public class AlertMockService { track.setRtuId(1); track.setId("G0202-A"); track.setLineId(lineId); - String sectionCode = LineGraphicDataRepository.findSectionFromLogicCode(lineId, "G0202-A"); + String sectionCode = LineGraphicDataRepository.findTurnoutSectionFromTurnoutCode(lineId, "G0202-A"); Section section = LineGraphicDataRepository.getDeviceByCode(lineId, sectionCode, Section.class); NccAlertInfo alertInfo = this.alertInfoService.createAlert(AlertType.AXLE_LED_ORANGE, AlertDeviceType.DEVICE_TYPE_TRACK, section.getCommon().getId(), track, track.getId(), AlertDeviceType.DEVICE_TYPE_TRACK, true); diff --git a/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java b/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java index db8a88b..28537f1 100644 --- a/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java +++ b/src/main/java/club/joylink/xiannccda/service/AlertRecordService.java @@ -159,7 +159,7 @@ public class AlertRecordService { .set(AlertRecord::getAlertTipId, tip.getId()).set(AlertRecord::getAlarmStatus, AlertStatus.CONFIRM_DO) .set(hasAreaConfigId, AlertRecord::getAlertLocationId, newAreaConfigId) .set(AlertRecord::getAlertType, tipType) - .eq(AlertRecord::getId, recordId).isNull(AlertRecord::getAlarmStatus)); + .eq(AlertRecord::getId, recordId).eq(AlertRecord::getAlarmStatus, AlertStatus.NOT_DO)); } return tip; }