diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java index 08a9e692d..08266419e 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/CTCLogicLoop.java @@ -395,18 +395,17 @@ public class CTCLogicLoop { private void loadSignRunPlanTrain(Simulation simulation) { // 没有加载过计划、始发计划、已发送至占线板、计划时间比当前时间相差5分钟 simulation.getCtcRepository().getAllRunPlanList().stream() - .filter(r -> !r.isLoad() && r.isStartRunPlan() && r.isSign() + .filter(r -> !r.isLoad() && r.isStartRunPlan() && r.isSign() && r.getStatus() != -1 && r.getDepartRunPlan().getPlanTime().isBefore(simulation.getCorrectSystemTime().plusMinutes(5))) - .forEach(r -> simulation.getCtcRepository().addRunPlanTrain(r)); - - // 列车上线 - simulation.getCtcRepository().getRunPlanTrainMap().forEach((k, v) -> { - if (v.getTrackSection().isFree() && !v.getTrainList().isEmpty()) { - CtcTrainQueue.RunPlanTrain train = v.getTrainList().poll(); - String tripNumber = train.getTripNumber(); - int lastNum = tripNumber.charAt(tripNumber.length() - 1) - 48; - atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, k, lastNum % 2 == 0); - } - }); + .sorted((r1, r2) -> r1.getDepartRunPlan().getPlanTime().isBefore(r2.getDepartRunPlan().getPlanTime()) ? -1 : 1) + .forEach(r -> { + Section section = r.getDepartRunPlan().getTrackSection(); + if (section.isFree()) { + String tripNumber = r.getDepartRunPlan().getTripNumber(); + int lastNum = tripNumber.charAt(tripNumber.length() - 1) - 48; + atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, section.getCode(), lastNum % 2 == 0); + r.setLoad(true); // 已上线 + } + }); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java index c7bd21c5e..62249de24 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcRepository.java @@ -101,11 +101,6 @@ public class CtcRepository { * 是否需要发送计划消息 */ private Boolean runPlanSendOut; - - /** - * 运行计划列车集合 - */ - private final Map runPlanTrainMap = new ConcurrentHashMap<>(); /******************************************* 以上为车站终端数据:车站为单位 *******************************************/ /** @@ -482,24 +477,4 @@ public class CtcRepository { trackView.addReceivingLine(routeSequenceLine); } } - - /** - * 增加列车至轨道队列 - * - * @param runPlanLog 运行计划日志 - */ - public void addRunPlanTrain(CtcStationRunPlanLog runPlanLog) { - CtcStationRunPlanLog.RunPlanItem departItem = runPlanLog.getDepartRunPlan(); - if (departItem.getTrackSection() != null) { - String sectionCode = departItem.getTrackSection().getCode(); - CtcTrainQueue trainQueue = this.runPlanTrainMap.get(sectionCode); - if (trainQueue == null) { - trainQueue = new CtcTrainQueue(); - trainQueue.setTrackSection(departItem.getTrackSection()); - } - trainQueue.addTrain(runPlanLog); - this.runPlanTrainMap.put(sectionCode, trainQueue); - runPlanLog.setLoad(true); // 已上线 - } - } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java index b06c488fa..7146c528d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcStationRunPlanLog.java @@ -323,7 +323,8 @@ public class CtcStationRunPlanLog { */ public void clearChange() { this.changeType = null; - this.sign = true; + // 删除的去处签收 + this.sign = this.status != -1; } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcTrainQueue.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcTrainQueue.java deleted file mode 100644 index 9e420bbf3..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CTC/data/CtcTrainQueue.java +++ /dev/null @@ -1,79 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.CTC.data; - -import club.joylink.rtss.simulation.cbtc.data.map.Section; -import lombok.Data; - -import java.time.LocalDateTime; -import java.util.PriorityQueue; -import java.util.Queue; - -/** - * Ctc运行计划的列车 - */ -@Data -public class CtcTrainQueue { - /** - * 需要加车轨道 - */ - private Section trackSection; - - /** - * 计划列车队列 - */ - private Queue trainList = new PriorityQueue<>((t1, t2) -> t1.getPlanTime().isBefore(t2.getPlanTime()) ? -1 : 1); - - @Data - public static class RunPlanTrain { - private CtcStationRunPlanLog runPlanLog; - - private String tripNumber; - - private LocalDateTime planTime; - - private Section trackSection; - - public RunPlanTrain(CtcStationRunPlanLog runPlanLog) { - this.runPlanLog = runPlanLog; - this.tripNumber = runPlanLog.getDepartRunPlan().getTripNumber(); - this.planTime = runPlanLog.getDepartRunPlan().getPlanTime(); - this.trackSection = runPlanLog.getDepartRunPlan().getTrackSection(); - } - } - - /** - * 是否已经上线 - * - * @return 不存在已上线 - */ - public boolean isExistOnline(String tripNumber) { - return trainList.stream().anyMatch(t -> tripNumber.equals(t.getTripNumber())); - } - - /** - * 移除已签收未上线的列车 - * - * @param tripNumber 车次 - * @return 是否移除成功 - */ - public boolean removeTrain(String tripNumber) { - if (isExistOnline(tripNumber)) { - RunPlanTrain train = trainList.stream().filter(t -> tripNumber.equals(t.getTripNumber())) - .findFirst().orElseGet(null); - if (train != null) { - this.trainList.remove(train); - return true; - } - } - return false; - } - - /** - * 将列车添加至队列 - * - * @param runPlanLog 运行计划日志 - */ - public void addTrain(CtcStationRunPlanLog runPlanLog) { - RunPlanTrain runPlanTrain = new RunPlanTrain(runPlanLog); - this.trainList.add(runPlanTrain); - } -}