From a3b89f9125e983a3c397aa8aa353c953588dcea9 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Thu, 18 Feb 2021 11:29:57 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E7=BD=AE/=E5=8F=96=E6=B6=88=E5=BC=BA?= =?UTF-8?q?=E5=88=B6=E7=82=B9=E7=81=AF=E6=93=8D=E4=BD=9C=E5=90=88=E5=B9=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../cbtc/ATS/operation/Operation.java | 6 ++--- .../handler/StationOperateHandler.java | 12 +++------ .../cbtc/ATS/service/AtsStationService.java | 27 ++++++++++--------- 3 files changed, 19 insertions(+), 26 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java index 64aeca34a..179dba8df 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/Operation.java @@ -243,10 +243,8 @@ public class Operation { Station_Set_CI_Auto, /** 全站取消自动通过 */ Station_Cancel_CI_Auto, - /** 强制点灯 */ - Station_Force_Set_Signal_Physical, - /** 取消强制点灯 */ - Station_Force_Cancel_Signal_Physical, + /** 设置/取消强制点灯 */ + Station_Set_Or_Cancel_Force_Physical_Signal, //--------------------------- 列车 --------------------------- /** 在指定区段加载一辆计划列车(本地开发使用) */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java index ba68f89cd..23d0e809d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/operation/handler/StationOperateHandler.java @@ -219,15 +219,9 @@ public class StationOperateHandler { this.atsStationService.cancelCIAuto(simulation, repository.getByCode(stationCode, Station.class)); } - @OperateHandlerMapping(type = Operation.Type.Station_Force_Set_Signal_Physical) - public void forceSetSignalPhysical(Simulation simulation, String stationCode) { + @OperateHandlerMapping(type = Operation.Type.Station_Set_Or_Cancel_Force_Physical_Signal) + public void setOrCancelForcePhysicalSignal(Simulation simulation, String stationCode) { SimulationDataRepository repository = simulation.getRepository(); - this.atsStationService.forceSetSignalPhysical(simulation, repository.getByCode(stationCode, Station.class)); - } - - @OperateHandlerMapping(type = Operation.Type.Station_Force_Cancel_Signal_Physical) - public void forceCancelSignalPhysical(Simulation simulation, String stationCode) { - SimulationDataRepository repository = simulation.getRepository(); - this.atsStationService.forceCancelSignalPhysical(simulation, repository.getByCode(stationCode, Station.class)); + this.atsStationService.setOrCancelForcePhysicalSignal(simulation, repository.getByCode(stationCode, Station.class)); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java index c22386062..57c10d632 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsStationService.java @@ -8,6 +8,7 @@ import club.joylink.rtss.simulation.cbtc.command.OperationMessage; import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; import club.joylink.rtss.simulation.cbtc.data.map.Route; +import club.joylink.rtss.simulation.cbtc.data.map.Signal; import club.joylink.rtss.simulation.cbtc.data.map.Station; import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.status.StationStatus; @@ -23,6 +24,7 @@ import org.springframework.stereotype.Component; import org.springframework.util.CollectionUtils; import java.util.*; +import java.util.stream.Collectors; @Component @@ -402,18 +404,17 @@ public class AtsStationService { .forEach(signal -> atsRouteService.cancelCiAuto(simulation, signal.getCode())); } - public void forceSetSignalPhysical(Simulation simulation, @NonNull Station station) { - simulation.getRepository().getSignalList().stream() - .filter(signal -> station.equals(signal.getInterlockStation())) - .forEach(signal -> { - signal.changeLightType(false); - signal.setForcePhysical(true); - }); - } - - public void forceCancelSignalPhysical(Simulation simulation, Station station) { - simulation.getRepository().getSignalList().stream() - .filter(signal -> station.equals(signal.getInterlockStation())) - .forEach(signal -> signal.setForcePhysical(false)); + public void setOrCancelForcePhysicalSignal(Simulation simulation, @NonNull Station station) { + List signalList = simulation.getRepository().getSignalList().stream() + .filter(signal -> station.equals(signal.getInterlockStation())).collect(Collectors.toList()); + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertCollectionNotEmpty(signalList, station.debugStr() + "下无信号机"); + if (!signalList.get(0).isForcePhysical()) { + signalList.forEach(signal -> { + signal.changeLightType(false); + signal.setForcePhysical(true); + }); + } else { + signalList.forEach(signal -> signal.setForcePhysical(false)); + } } }