【行车日志逻辑修改】
This commit is contained in:
parent
352bcb8dff
commit
a11be60b3f
@ -0,0 +1,30 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.operation.handler;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.service.runplan.CtcStationRunPlanLogService;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
|
||||
/**
|
||||
* Ctc 车站停车日志操作
|
||||
*/
|
||||
@Slf4j
|
||||
@OperateHandler
|
||||
public class CtcStationRunPlanLogOperateHandler {
|
||||
|
||||
@Autowired
|
||||
private CtcStationRunPlanLogService ctcStationRunPlanLogService;
|
||||
|
||||
/**
|
||||
* 修改行车计划股道信息
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param runPlanCode 行车计划编码
|
||||
* @param sectionCode 股道编码
|
||||
*/
|
||||
public void modifyRunPlanTrackSection(Simulation simulation, String stationCode, String runPlanCode, String sectionCode) {
|
||||
ctcStationRunPlanLogService.modifyRunPlanTrackSection(simulation, stationCode, runPlanCode, sectionCode);
|
||||
}
|
||||
}
|
@ -0,0 +1,37 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service.runplan;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
public class CtcStationRunPlanLogService {
|
||||
|
||||
/**
|
||||
* 修改运行股道
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param runPlanCode 运行编码
|
||||
* @param sectionCode 区段编码
|
||||
*/
|
||||
public void modifyRunPlanTrackSection(Simulation simulation, String stationCode, String runPlanCode
|
||||
, String sectionCode) {
|
||||
CtcStationRunPlanLog ctcStationRunPlanLog =
|
||||
simulation.getCtcRepository().getCtcStationRunPlanLog(stationCode, sectionCode);
|
||||
if (ctcStationRunPlanLog != null) {
|
||||
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
||||
if (ctcStationRunPlanLog.getArriveRunPlan() != null
|
||||
&& ctcStationRunPlanLog.getArriveRunPlan().getStationPlan() != null) {
|
||||
ctcStationRunPlanLog.getArriveRunPlan().setTrackSection(section);
|
||||
}
|
||||
if (ctcStationRunPlanLog.getDepartRunPlan() != null
|
||||
&& ctcStationRunPlanLog.getDepartRunPlan().getStationPlan() != null) {
|
||||
ctcStationRunPlanLog.getDepartRunPlan().setTrackSection(section);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -7,6 +7,7 @@ import org.springframework.util.CollectionUtils;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Optional;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
||||
@Getter
|
||||
@ -69,8 +70,29 @@ public class CtcRepository {
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取ctc 行车日志
|
||||
*
|
||||
* @param stationCode 车站编码
|
||||
* @param runPlanCode 行车日志编码
|
||||
* @return 行车日志实体
|
||||
*/
|
||||
public CtcStationRunPlanLog getCtcStationRunPlanLog(String stationCode, String runPlanCode) {
|
||||
List<CtcStationRunPlanLog> ctcStationRunPlanLogList = this.getCtcStationRunPlanLogMap().get(stationCode);
|
||||
CtcStationRunPlanLog ctcStationRunPlanLog = null;
|
||||
if (ctcStationRunPlanLogList != null) {
|
||||
Optional<CtcStationRunPlanLog> ctcStationRunPlanLogOptional = ctcStationRunPlanLogList.stream()
|
||||
.filter(runPlanLog -> runPlanLog.getCode().equals(runPlanCode))
|
||||
.findFirst();
|
||||
if (ctcStationRunPlanLogOptional.isPresent()) {
|
||||
ctcStationRunPlanLog = ctcStationRunPlanLogOptional.get();
|
||||
}
|
||||
}
|
||||
return ctcStationRunPlanLog;
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.ctcStationPlanMap.clear();
|
||||
this.ctcStationRunPlanLogMap.clear();
|
||||
this.ctcStationRunPlanLogMap.forEach((s, ctcStationRunPlanLogs) -> ctcStationRunPlanLogs.forEach(ctcStationRunPlanLog -> ctcStationRunPlanLog.reset()));
|
||||
}
|
||||
}
|
||||
|
@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.CTC.data;
|
||||
|
||||
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.StationDirection;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.StationPlan;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan;
|
||||
import lombok.Data;
|
||||
@ -20,6 +21,7 @@ import java.util.Map;
|
||||
*/
|
||||
@Data
|
||||
public class CtcStationRunPlanLog {
|
||||
private String code;
|
||||
/**
|
||||
* 来源,用于定位
|
||||
*/
|
||||
@ -65,9 +67,27 @@ public class CtcStationRunPlanLog {
|
||||
*/
|
||||
private List<RunPlanTask> runPlanTaskList = new ArrayList<>();
|
||||
|
||||
|
||||
public void reset() {
|
||||
this.remark = null;
|
||||
this.lateReason = null;
|
||||
this.planProperties = null;
|
||||
this.runPlanTaskList = new ArrayList<>();
|
||||
if (this.arriveRunPlan != null) {
|
||||
this.arriveRunPlan.reset();
|
||||
}
|
||||
if (this.departRunPlan != null) {
|
||||
this.departRunPlan.reset();
|
||||
}
|
||||
}
|
||||
|
||||
@Setter
|
||||
@Getter
|
||||
public static class RunPlanItem {
|
||||
private String code;
|
||||
|
||||
private StationPlan stationPlan;
|
||||
|
||||
/**
|
||||
* 运行计划的到达区段,不用于展示
|
||||
*/
|
||||
@ -78,11 +98,6 @@ public class CtcStationRunPlanLog {
|
||||
*/
|
||||
private Section trackSection;
|
||||
|
||||
/**
|
||||
* 是否向右行驶
|
||||
*/
|
||||
private boolean right;
|
||||
|
||||
/**
|
||||
* 车次号
|
||||
*/
|
||||
@ -96,17 +111,17 @@ public class CtcStationRunPlanLog {
|
||||
/**
|
||||
* 实际时间
|
||||
*/
|
||||
private LocalTime actualTime;
|
||||
private String actualTime;
|
||||
|
||||
/**
|
||||
* 是否停车
|
||||
* 同意邻站发车、邻站同意发车
|
||||
*/
|
||||
private boolean park;
|
||||
private String adjacentMessage;
|
||||
|
||||
/**
|
||||
* 是否通过
|
||||
* 邻站发车
|
||||
*/
|
||||
private boolean finished;
|
||||
private boolean adjacentDepart;
|
||||
|
||||
/**
|
||||
* 线路名称
|
||||
@ -119,14 +134,14 @@ public class CtcStationRunPlanLog {
|
||||
private String accessName;
|
||||
|
||||
/**
|
||||
* 邻站
|
||||
* 是否向右行驶
|
||||
*/
|
||||
private Station adjacentStation;
|
||||
private boolean right;
|
||||
|
||||
/**
|
||||
* 进、发车对应方向
|
||||
*/
|
||||
// private StationDirection stationDirection;
|
||||
private StationDirection stationDirection;
|
||||
|
||||
/**
|
||||
* 列车类型
|
||||
@ -144,15 +159,16 @@ public class CtcStationRunPlanLog {
|
||||
private Map<ProcessType, String> processTypeMap;
|
||||
|
||||
public RunPlanItem() {
|
||||
trainTypeMap = new HashMap<>(TrainType.values().length);
|
||||
processTypeMap = new HashMap<>(ProcessType.values().length);
|
||||
this.trainTypeMap = new HashMap<>(TrainType.values().length);
|
||||
this.processTypeMap = new HashMap<>(ProcessType.values().length);
|
||||
}
|
||||
|
||||
public RunPlanItem(StationPlan stationPlan) {
|
||||
this();
|
||||
this.standSection = stationPlan.getSection();
|
||||
this.right = stationPlan.isRight();
|
||||
this.tripNumber = stationPlan.getPlan().getTripNumber();
|
||||
this.stationPlan = stationPlan;
|
||||
this.standSection = stationPlan.getSection(); // 站台区段
|
||||
this.right = stationPlan.isRight(); // 行驶方向
|
||||
this.tripNumber = stationPlan.getPlan().getTripNumber(); // 车次
|
||||
}
|
||||
|
||||
/**
|
||||
@ -161,8 +177,8 @@ public class CtcStationRunPlanLog {
|
||||
public void initPlanLineName() {
|
||||
if (!StringUtils.isEmpty(this.planLineName)) {
|
||||
String adjacentStationName;
|
||||
if (this.adjacentStation != null) {
|
||||
adjacentStationName = "(" + this.adjacentStation.getName() + ")";
|
||||
if (this.stationDirection != null && this.stationDirection.getRelativeStationDirection() != null) {
|
||||
adjacentStationName = "(" + this.stationDirection.getRelativeStationDirection().getStation().getName() + ")";
|
||||
} else {
|
||||
adjacentStationName = "";
|
||||
}
|
||||
@ -170,6 +186,12 @@ public class CtcStationRunPlanLog {
|
||||
this.accessName = this.planLineName + travelType + adjacentStationName;
|
||||
}
|
||||
}
|
||||
|
||||
public void reset() {
|
||||
this.trackSection = null;
|
||||
this.trainTypeMap.clear();
|
||||
this.processTypeMap.clear();
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -27,6 +27,7 @@ import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.function.BiFunction;
|
||||
@ -330,11 +331,10 @@ public class SimulationBuilder {
|
||||
public static void buildCtcStationRunPlanLog(Simulation simulation, Map<String, List<TripPlan>> serverTripMap) {
|
||||
// 线路名
|
||||
BiFunction<String, String, String> planLineNameFunction = (startName, endName) -> {
|
||||
String start = startName.replace("标准", "").replace("站", "");
|
||||
String end = endName.replace("标准", "").replace("站", "");
|
||||
String start = startName.replace("标准", "").replace("站", "").substring(0, 1);
|
||||
String end = endName.replace("标准", "").replace("站", "").substring(0, 1);
|
||||
return start + end;
|
||||
};
|
||||
List<Station> stationList = simulation.getRepository().getStationList();
|
||||
List<CtcStationRunPlanLog> ctcStationRunPlanLogList = new LinkedList<>();
|
||||
serverTripMap.values().forEach(tripPlanList -> {
|
||||
tripPlanList.forEach(tripPlan -> {
|
||||
@ -343,41 +343,35 @@ public class SimulationBuilder {
|
||||
CtcStationRunPlanLog ctcStationRunPlanLog = null;
|
||||
CtcStationRunPlanLog.RunPlanItem arriveRunPlanItem = null, departRunPlanItem = null;
|
||||
StationPlan stationPlan;
|
||||
Station adjacentStation;
|
||||
String adjacentStationCode = null;
|
||||
String codePrefix = tripPlan.getServiceNumber().concat(tripPlan.getTripNumber());
|
||||
for (int index = 0, len = tripPlan.getPlanList().size(); index < len; index++) {
|
||||
ctcStationRunPlanLog = new CtcStationRunPlanLog();
|
||||
ctcStationRunPlanLog.setCode(codePrefix + index);
|
||||
stationPlan = tripPlan.getPlanList().get(index);
|
||||
// 邻站信息
|
||||
int adjacentSn = stationPlan.getStation().getSn();
|
||||
ctcStationRunPlanLog.setTripPlan(tripPlan);
|
||||
ctcStationRunPlanLog.setStation(stationPlan.getStation());
|
||||
ctcStationRunPlanLog.setTripNumber(stationPlan.getPlan().getTripNumber());
|
||||
// 到达
|
||||
// 到达计划,始发站没有到达计划
|
||||
// 邻站
|
||||
if (index > 0) {
|
||||
arriveRunPlanItem = new CtcStationRunPlanLog.RunPlanItem(stationPlan);
|
||||
arriveRunPlanItem.setPlanTime(stationPlan.getArriveTime());
|
||||
// 邻站信息
|
||||
adjacentStation = stationList.stream()
|
||||
.filter(station -> station.getSn() == (!tripPlan.isRight() ? adjacentSn + 1 : adjacentSn - 1))
|
||||
.findFirst().get();
|
||||
arriveRunPlanItem.setAdjacentStation(adjacentStation);
|
||||
arriveRunPlanItem.setPlanLineName(planLineName);
|
||||
arriveRunPlanItem.initPlanLineName();
|
||||
adjacentStationCode = tripPlan.getPlanList().get(index - 1).getStation().getCode();
|
||||
} else {
|
||||
adjacentStationCode = null;
|
||||
}
|
||||
arriveRunPlanItem = createRunPlanItem(index > 0, true, !tripPlan.isRight(), planLineName, stationPlan, adjacentStationCode);
|
||||
arriveRunPlanItem.setCode(codePrefix + index + "arrivePlan");
|
||||
ctcStationRunPlanLog.setArriveRunPlan(arriveRunPlanItem);
|
||||
// 发车计划,终点站没有发车计划
|
||||
// 邻站
|
||||
if (index < len - 1 && index + 1 < len) {
|
||||
adjacentStationCode = tripPlan.getPlanList().get(index + 1).getStation().getCode();
|
||||
} else {
|
||||
adjacentStationCode = null;
|
||||
}
|
||||
// 发车
|
||||
if (index < len - 1) {
|
||||
departRunPlanItem = new CtcStationRunPlanLog.RunPlanItem(stationPlan);
|
||||
departRunPlanItem.setPlanTime(stationPlan.getLeaveTime());
|
||||
// 邻站信息
|
||||
adjacentStation = stationList.stream()
|
||||
.filter(station -> station.getSn() == (tripPlan.isRight() ? adjacentSn + 1 : adjacentSn - 1))
|
||||
.findFirst().get();
|
||||
departRunPlanItem.setAdjacentStation(adjacentStation);
|
||||
departRunPlanItem.setPlanLineName(planLineName);
|
||||
departRunPlanItem.initPlanLineName();
|
||||
departRunPlanItem = createRunPlanItem(index < len - 1, false, tripPlan.isRight(), planLineName, stationPlan, adjacentStationCode);
|
||||
departRunPlanItem.setCode(codePrefix + index + "departPlan");
|
||||
ctcStationRunPlanLog.setDepartRunPlan(departRunPlanItem);
|
||||
}
|
||||
ctcStationRunPlanLogList.add(ctcStationRunPlanLog);
|
||||
}
|
||||
});
|
||||
@ -387,6 +381,51 @@ public class SimulationBuilder {
|
||||
simulation.getCtcRepository().addCtcStationRunPlanLogMap(stationRunPlanLogMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 生成运行计划实体类
|
||||
*
|
||||
* @param initFlag 是否初始化数据,始端的接车、终端的发车不需要初始化
|
||||
* @param arriveFlag 是否到达
|
||||
* @param right 行驶方向
|
||||
* @param planLineName 运行线路名称
|
||||
* @param stationPlan 运行计划
|
||||
* @param adjacentStationCode 邻站编码
|
||||
* @return 运行计划实体
|
||||
*/
|
||||
private static CtcStationRunPlanLog.RunPlanItem createRunPlanItem(boolean initFlag, boolean arriveFlag, boolean right
|
||||
, String planLineName, StationPlan stationPlan, String adjacentStationCode) {
|
||||
CtcStationRunPlanLog.RunPlanItem runPlanItem;
|
||||
if (initFlag) {
|
||||
runPlanItem = new CtcStationRunPlanLog.RunPlanItem(stationPlan);
|
||||
StationDirection.ReceiveAndDeliverModel defaultRunStatus;
|
||||
if (arriveFlag) {
|
||||
defaultRunStatus = StationDirection.ReceiveAndDeliverModel.R;
|
||||
runPlanItem.setPlanTime(stationPlan.getArriveTime());
|
||||
} else {
|
||||
defaultRunStatus = StationDirection.ReceiveAndDeliverModel.D;
|
||||
runPlanItem.setPlanTime(stationPlan.getLeaveTime());
|
||||
}
|
||||
// 获取运行方向,邻站过滤
|
||||
if (!StringUtils.isEmpty(adjacentStationCode)) {
|
||||
// 确定方向条件:相对方向存在、相对方向与运行计划的邻站一致、符合接发状态、线路方向一致
|
||||
Optional<StationDirection> stationDirectionOptional = stationPlan.getStation().getStationDirectionMap().values().stream()
|
||||
.filter(direction -> direction.getRelativeStationDirection() != null
|
||||
&& direction.getRelativeStationDirection().getStation().getCode().equals(adjacentStationCode)
|
||||
&& defaultRunStatus.equals(direction.getDefaultRunStatus())
|
||||
&& Objects.equals(stationPlan.isRight(), direction.getRight()))
|
||||
.findFirst();
|
||||
if (stationDirectionOptional.isPresent()) {
|
||||
runPlanItem.setStationDirection(stationDirectionOptional.get());
|
||||
}
|
||||
}
|
||||
} else {
|
||||
runPlanItem = new CtcStationRunPlanLog.RunPlanItem();
|
||||
}
|
||||
runPlanItem.setPlanLineName(planLineName);
|
||||
runPlanItem.initPlanLineName();
|
||||
return runPlanItem;
|
||||
}
|
||||
|
||||
public static List<String> checkRunPlanAndBuildLostRoutePaths(Map<String, List<TripPlan>> serverTripMap,
|
||||
Map<String, List<RoutePath>> routePathMap) {
|
||||
Map<String, String> errMsgMap = new HashMap<>();
|
||||
|
@ -155,6 +155,11 @@ public class StationDirection extends MapNamedElement {
|
||||
*/
|
||||
private boolean isDataConfig;
|
||||
|
||||
/**
|
||||
* 默认方向
|
||||
*/
|
||||
private Boolean right;
|
||||
|
||||
public StationDirection(String code, String name, DirectionLabelEnum labelEnum) {
|
||||
this(code, name);
|
||||
this.labelEnum = labelEnum;
|
||||
@ -162,6 +167,9 @@ public class StationDirection extends MapNamedElement {
|
||||
this.runStatus = this.getDefaultReceiveAndDeliver();
|
||||
this.defaultRunStatus = this.getDefaultReceiveAndDeliver();
|
||||
this.currentRouteList = getNowRouteList();
|
||||
if (DirectionRunModel.A.equals(this.runModel)) {
|
||||
this.right = this.labelEnum.name().startsWith("S");
|
||||
}
|
||||
}
|
||||
|
||||
public StationDirection(DraftMapStationDirection draftMapStationDirection) {
|
||||
@ -171,6 +179,9 @@ public class StationDirection extends MapNamedElement {
|
||||
this.defaultRunStatus = draftMapStationDirection.getRunStatus();
|
||||
this.runStatus = draftMapStationDirection.getRunStatus();
|
||||
this.isDataConfig = true;
|
||||
if (DirectionRunModel.A.equals(this.runModel)) {
|
||||
this.right = this.labelEnum.name().startsWith("S");
|
||||
}
|
||||
}
|
||||
|
||||
public StationDirection(String code, String name) {
|
||||
|
Loading…
Reference in New Issue
Block a user