【计划阶段消息结构变更】

This commit is contained in:
weizhihong 2022-06-28 10:35:41 +08:00
parent 1909f79101
commit 2c267ebd0c
5 changed files with 154 additions and 13 deletions

View File

@ -547,8 +547,10 @@ public class CtcRunPlanParam implements Cloneable {
* @return 是否存在
*/
public boolean arriveIsExist() {
return this.arriveTime != null || !StringUtils.isEmpty(this.arriveTripNumber) || !StringUtils.isEmpty(this.arriveSectionCode)
|| !StringUtils.isEmpty(this.arriveDirectionCode) || !StringUtils.isEmpty(this.arriveStationCode);
return this.arrivePlanTime != null || !StringUtils.isEmpty(this.arriveTripNumber)
|| !StringUtils.isEmpty(this.arriveSectionCode)
|| !StringUtils.isEmpty(this.arriveDirectionCode)
|| !StringUtils.isEmpty(this.arriveStationCode);
}
/**
@ -557,8 +559,10 @@ public class CtcRunPlanParam implements Cloneable {
* @return 是否存在
*/
public boolean departIsExist() {
return this.departTime != null || !StringUtils.isEmpty(this.departTripNumber) || !StringUtils.isEmpty(this.departSectionCode)
|| !StringUtils.isEmpty(this.departDirectionCode) || !StringUtils.isEmpty(this.departStationCode);
return this.departPlanTime != null || !StringUtils.isEmpty(this.departTripNumber)
|| !StringUtils.isEmpty(this.departSectionCode)
|| !StringUtils.isEmpty(this.departDirectionCode)
|| !StringUtils.isEmpty(this.departStationCode);
}
/**

View File

@ -193,22 +193,47 @@ public class CtcStationRunPlanLogService {
int curVersion = runPlanRepository.getVersion().get(); // 当前生效区版本
Integer oldVersion = effectRepository.getStageRunPlanVersionMap().get(stationCode); // 旧版本
if (oldVersion == null || curVersion != oldVersion) {
List<CtcStationRunPlanLog> runPlanLogList = new ArrayList<>();
runPlanRepository.getCtcRunPlanVOList().forEach(ctcRunPlanVO -> {
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository()
.getRunPlanByRunPlanCodeAndStationCode(stationCode, ctcRunPlanVO.getRunPlanCode());
boolean change = false;
if (runPlanLog != null) {
runPlanLog.setBaseAttribute(ctcRunPlanVO.getRunPlan());
// 到达
modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true);
if (ctcRunPlanVO.getRunPlan().arriveIsExist()) { // 不存在到达信息则直接浮空
change = modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), ctcRunPlanVO.getRunPlan(), true);
} else {
runPlanLog.setArriveRunPlan(null);
}
// 出发
modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), ctcRunPlanVO.getRunPlan(), false);
if (ctcRunPlanVO.getRunPlan().departIsExist()) {
change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), ctcRunPlanVO.getRunPlan(), false);
} else {
runPlanLog.setDepartRunPlan(null);
}
} else {
change = true;
runPlanLog = createRunPlanLog(simulation, stationCode, ctcRunPlanVO.getRunPlan());
simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog);
}
if (change) {
runPlanLogList.add(runPlanLog);
}
});
effectRepository.getStationStageRunPlanMap().remove(stationCode); // 发布成功后,移除阶段计划中车站的数据
effectRepository.getStageRunPlanVersionMap().put(stationCode, curVersion); // 刷新版本
// 编辑过轨道的行车记录
runPlanLogList.stream()
.filter(r -> r.getArriveRunPlan() != null || r.getDepartRunPlan() != null)
.forEach(r -> {
if (r.getArriveRunPlan() != null && r.getArriveRunPlan().getTrackSection() != null) {
ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getArriveRunPlan(), false);
}
if (r.getDepartRunPlan() != null && r.getDepartRunPlan().getTrackSection() != null) {
ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getDepartRunPlan(), true);
}
});
}
}

View File

@ -314,8 +314,7 @@ public class CTCLogicLoop {
* @param simulation 仿真
*/
public void sendZoneRunPlanSend(Simulation simulation) {
List<CtcEffectRepository.CtcStageRunPlanRepository> allList
= simulation.getCtcRepository().getCtcEffectRepository().getChangeStageRunPlan();
List<Map<String, Object>> allList = simulation.getCtcRepository().getCtcEffectRepository().getChangeStageRunPlan();
if (!CollectionUtils.isEmpty(allList)) {
sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_RAILWAY_RUN_PLAN_SEND, simulation.getSimulationUserIds());
}

View File

@ -108,11 +108,17 @@ public class CtcEffectRepository {
*
* @return 变化的车站
*/
public List<CtcStageRunPlanRepository> getChangeStageRunPlan() {
public List<Map<String, Object>> getChangeStageRunPlan() {
if (this.stationStageRunPlanMap.isEmpty()) {
return null;
}
return this.stationStageRunPlanMap.values().stream().collect(Collectors.toList());
return this.stationStageRunPlanMap.values().stream().map(r -> {
Map<String, Object> dataMap = new HashMap<>();
dataMap.put("stationCode", r.stationCode);
dataMap.put("updateTime", r.getUpdateTime());
dataMap.put("dataList", r.getCtcRunPlanVOList().stream().map(CtcRunPlanVO::generateStatus).collect(Collectors.toList()));
return dataMap;
}).collect(Collectors.toList());
}
/**

View File

@ -4,6 +4,8 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam;
import lombok.Getter;
import lombok.Setter;
import java.time.LocalTime;
/**
* 阶段对比
*/
@ -30,9 +32,6 @@ public class CtcRunPlanVO {
*/
private CtcRunPlanParam changeRunPlan;
/**
* 状态-1删除0修改1添加
*/
private int status;
public CtcRunPlanVO(CtcRunPlanParam runPlanParam) {
@ -60,4 +59,112 @@ public class CtcRunPlanVO {
runPlanVO.setChangeRunPlan(changeRunPlan);
return changeRunPlan != null ? runPlanVO : null;
}
public CtcRunPlanStatusVO generateStatus() {
return new CtcRunPlanStatusVO(this);
}
@Setter
@Getter
public static class CtcRunPlanStatusVO {
/**
* 车站编码
*/
private String stationCode;
/**
* 运行编码
*/
private String runPlanCode;
/**
* 铁路局调度台
*/
private String railway;
/**
* 到达车次
*/
private String arriveTripNumber;
/**
* 上一版本的到达车次
*/
private String oldArriveTripNumber;
/**
* 出发车次
*/
private String departTripNumber;
/**
* 上一版本的出发车次
*/
private String oldDepartTripNumber;
/**
* 到达股道
*/
private String arriveSectionCode;
/**
* 上一版本到达股道
*/
private String oldArriveSectionCode;
/**
* 发车计划时间
*/
private LocalTime arrivePlanTime;
/**
* 上一版本发车计划时间
*/
private LocalTime oldArrivePlanTime;
/**
* 出发股道
*/
private String departSectionCode;
/**
* 上一版本出发股道
*/
private String oldDepartSectionCode;
/**
* 发车计划时间
*/
private LocalTime departPlanTime;
/**
* 上一版本发车计划时间
*/
private LocalTime oldDepartPlanTime;
/**
* 状态-1删除0修改1添加
*/
private int status;
public CtcRunPlanStatusVO(CtcRunPlanVO runPlanVO) {
this.stationCode = runPlanVO.getStationCode();
this.runPlanCode = runPlanVO.getRunPlanCode();
this.status = runPlanVO.getStatus();
this.arriveTripNumber = runPlanVO.getRunPlan().getArriveTripNumber();
this.departTripNumber = runPlanVO.getRunPlan().getDepartTripNumber();
this.arriveSectionCode = runPlanVO.getRunPlan().getArriveSectionCode();
this.arrivePlanTime = runPlanVO.getRunPlan().getArrivePlanTime();
this.departSectionCode = runPlanVO.getRunPlan().getDepartSectionCode();
this.departPlanTime = runPlanVO.getRunPlan().getDepartPlanTime();
if (runPlanVO.getChangeRunPlan() != null) {
this.oldArriveTripNumber = runPlanVO.getChangeRunPlan().getArriveTripNumber();
this.oldDepartTripNumber = runPlanVO.getChangeRunPlan().getDepartTripNumber();
this.oldArriveSectionCode = runPlanVO.getChangeRunPlan().getArriveSectionCode();
this.oldArrivePlanTime = runPlanVO.getChangeRunPlan().getArrivePlanTime();
this.oldDepartSectionCode = runPlanVO.getChangeRunPlan().getDepartSectionCode();
this.oldDepartPlanTime = runPlanVO.getChangeRunPlan().getDepartPlanTime();
}
}
}
}