diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java index 42aa9200b..9d4732ba8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/ATS/service/AtsPlanService.java @@ -55,8 +55,14 @@ public class AtsPlanService { */ public void recordTrainRealRun(Simulation simulation, TrainInfo train, Station arriveStation, Section parkingSection, boolean arrive) { - TripPlan tripPlan = simulation.getRepository().getTripPlan(train.getServiceNumber(), train.getTripNumber()); + SimulationDataRepository repository = simulation.getRepository(); + TripPlan tripPlan = repository.getTripPlan(train.getServiceNumber(), train.getTripNumber()); LocalDateTime systemTime = simulation.getSystemTime(); + Boolean frontTurnBack = null; + RealRun lastRealRun = repository.queryLastRealRun(train.getGroupNumber()); + if (lastRealRun != null && lastRealRun.getRight() != null && !Objects.equals(lastRealRun.getRight(), tripPlan.isRight())) { + frontTurnBack = !arrive; + } RealRun realRun = RealRun.builder(). groupNumber(train.getGroupNumber()). serviceNumber(train.getServiceNumber()). @@ -67,8 +73,9 @@ public class AtsPlanService { right(tripPlan.isRight()). time(systemTime). second(systemTime.toLocalTime().toSecondOfDay()). + frontTurnBack(frontTurnBack). build(); - simulation.getRepository().addRealRunRecord(realRun); + repository.addRealRunRecord(realRun); this.atsMessageCollectAndDispatcher.sendTrainRunData(simulation, realRun); } @@ -649,6 +656,9 @@ public class AtsPlanService { train.getTripNumber(), train.getDestinationCode(), station.getName(), station.getCode(), section.getName(), section.getCode())); + if (train.isPlanTrain()) { //先记录实迹运行图,以免ATS主逻辑改掉服务-车次号 + this.recordTrainRealRun(simulation, train, station, section, true); + } // 列车到站状态 LocalTime systemTime = simulation.getSystemTime().toLocalTime(); int parkTime = this.atsStandService.trainParkingAndGetParkTime(simulation, section); @@ -656,8 +666,6 @@ public class AtsPlanService { if (train.isPlanTrain()) { SimulationDataRepository repository = simulation.getRepository(); TripPlan tripPlan = repository.getTripPlan(train.getServiceNumber(), train.getTripNumber()); - // 记录列车实际运行到站信息 - this.recordTrainRealRun(simulation, train, station, section, true); // 更新追踪列车到站状态 StationPlan stationPlan = tripPlan.queryStationPlanByStation(station); if (parkTime < 0) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index eb1cbe819..75d14a86e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -1068,4 +1068,13 @@ public class SimulationDataRepository { } return list; } + + public RealRun queryLastRealRun(String groupNumber) { + for (int i = this.realRunRecordList.size() - 1; i >= 0; i--) { + RealRun realRun = this.realRunRecordList.get(i); + if (realRun.getGroupNumber().equals(groupNumber)) + return realRun; + } + return null; + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/plan/RealRun.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/plan/RealRun.java index 9ba0b6194..478e2b1f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/plan/RealRun.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/plan/RealRun.java @@ -43,6 +43,8 @@ public class RealRun { @JsonSerialize(using = Boolean2NumSerializer.class) private Boolean right; + private Boolean frontTurnBack; + public String getSTNumber() { return String.format("%s%s", this.serviceNumber, this.tripNumber == null ? "" : this.tripNumber); }