【修改加车逻辑,删除多余代码】
This commit is contained in:
parent
21f02c218b
commit
43036bc6a5
@ -395,18 +395,17 @@ public class CTCLogicLoop {
|
|||||||
private void loadSignRunPlanTrain(Simulation simulation) {
|
private void loadSignRunPlanTrain(Simulation simulation) {
|
||||||
// 没有加载过计划、始发计划、已发送至占线板、计划时间比当前时间相差5分钟
|
// 没有加载过计划、始发计划、已发送至占线板、计划时间比当前时间相差5分钟
|
||||||
simulation.getCtcRepository().getAllRunPlanList().stream()
|
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)))
|
&& r.getDepartRunPlan().getPlanTime().isBefore(simulation.getCorrectSystemTime().plusMinutes(5)))
|
||||||
.forEach(r -> simulation.getCtcRepository().addRunPlanTrain(r));
|
.sorted((r1, r2) -> r1.getDepartRunPlan().getPlanTime().isBefore(r2.getDepartRunPlan().getPlanTime()) ? -1 : 1)
|
||||||
|
.forEach(r -> {
|
||||||
// 列车上线
|
Section section = r.getDepartRunPlan().getTrackSection();
|
||||||
simulation.getCtcRepository().getRunPlanTrainMap().forEach((k, v) -> {
|
if (section.isFree()) {
|
||||||
if (v.getTrackSection().isFree() && !v.getTrainList().isEmpty()) {
|
String tripNumber = r.getDepartRunPlan().getTripNumber();
|
||||||
CtcTrainQueue.RunPlanTrain train = v.getTrainList().poll();
|
int lastNum = tripNumber.charAt(tripNumber.length() - 1) - 48;
|
||||||
String tripNumber = train.getTripNumber();
|
atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, section.getCode(), lastNum % 2 == 0);
|
||||||
int lastNum = tripNumber.charAt(tripNumber.length() - 1) - 48;
|
r.setLoad(true); // 已上线
|
||||||
atsTrainLoadService.loadTripNumberTrain(simulation, tripNumber, k, lastNum % 2 == 0);
|
}
|
||||||
}
|
});
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -101,11 +101,6 @@ public class CtcRepository {
|
|||||||
* 是否需要发送计划消息
|
* 是否需要发送计划消息
|
||||||
*/
|
*/
|
||||||
private Boolean runPlanSendOut;
|
private Boolean runPlanSendOut;
|
||||||
|
|
||||||
/**
|
|
||||||
* 运行计划列车集合
|
|
||||||
*/
|
|
||||||
private final Map<String, CtcTrainQueue> runPlanTrainMap = new ConcurrentHashMap<>();
|
|
||||||
/******************************************* 以上为车站终端数据:车站为单位 *******************************************/
|
/******************************************* 以上为车站终端数据:车站为单位 *******************************************/
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -482,24 +477,4 @@ public class CtcRepository {
|
|||||||
trackView.addReceivingLine(routeSequenceLine);
|
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); // 已上线
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -323,7 +323,8 @@ public class CtcStationRunPlanLog {
|
|||||||
*/
|
*/
|
||||||
public void clearChange() {
|
public void clearChange() {
|
||||||
this.changeType = null;
|
this.changeType = null;
|
||||||
this.sign = true;
|
// 删除的去处签收
|
||||||
|
this.sign = this.status != -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -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<RunPlanTrain> 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);
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue
Block a user