From ffe8927892cfb1984eb39af68831f77c8bb1b73d Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Fri, 26 May 2023 15:26:52 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9NCC=E6=8A=A5=E8=AD=A6bug?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ATS/service/alarm/NccAlarmService.java | 43 ++++++++++++------- 1 file changed, 27 insertions(+), 16 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/alarm/NccAlarmService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/alarm/NccAlarmService.java index 4d0eaeece..70fdc0fc7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/alarm/NccAlarmService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/alarm/NccAlarmService.java @@ -3,7 +3,9 @@ package club.joylink.rtss.simulation.cbtc.ATS.service.alarm; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice; +import club.joylink.rtss.simulation.cbtc.data.map.MayOutOfOrderDevice.DeviceFault; import club.joylink.rtss.simulation.cbtc.data.map.Section; import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.map.Switch.SwitchFault; @@ -123,23 +125,32 @@ public class NccAlarmService { private String analyzeReason(SimulationDataRepository repository, TrainInfo trainInfo) { List alarmList = repository.getAlarmList(); - if (!CollectionUtils.isEmpty(alarmList)) { - Optional deviceFaultAlarm = alarmList.stream() - .filter(alarm -> AtsAlarm.HandleMethod.ATS.equals(alarm.getHandleMethod())) - .findFirst(); - if (deviceFaultAlarm.isPresent()) { - AtsAlarm atsAlarm = deviceFaultAlarm.get(); - MayOutOfOrderDevice device = repository.getByCode(atsAlarm.getDeviceCode(), - MayOutOfOrderDevice.class); - String fault = device.getFault().toString(); - if (SwitchFault.SPLIT.name().equals(fault)) { - fault = "失表"; - } - return String.format("%s(%s):%s", device.getDeviceType().getName(), device.getName(), - fault); - } + String defaultReason = "其它原因"; + if (CollectionUtils.isEmpty(alarmList)) { + return defaultReason; } - return "其它原因"; + Optional deviceFaultAlarm = alarmList.stream() + .filter(alarm -> AtsAlarm.HandleMethod.ATS.equals(alarm.getHandleMethod())) + .findFirst(); + if (deviceFaultAlarm.isEmpty()) { + return defaultReason; + } + AtsAlarm atsAlarm = deviceFaultAlarm.get(); + MapElement element = repository.getByCode(atsAlarm.getCode()); + if (!(element instanceof MayOutOfOrderDevice)) { + return defaultReason; + } + MayOutOfOrderDevice device = repository.getByCode(atsAlarm.getDeviceCode(), + MayOutOfOrderDevice.class); + DeviceFault deviceFault = device.getFault(); + if (deviceFault == null) { + return defaultReason; + } + String fault = deviceFault.toString(); + if (SwitchFault.SPLIT.name().equals(fault)) { + fault = "失表"; + } + return String.format("%s(%s):%s", device.getDeviceType().getName(), device.getName(), fault); // //列车故障 // VirtualRealityTrain train = repository.queryOnlineTrainBy(trainInfo.getGroupNumber());