【车务管理端生效区的生效至车站】
This commit is contained in:
parent
7890dc9b70
commit
c6a005c31f
@ -958,6 +958,11 @@ public class Operation {
|
|||||||
* 将编辑区行车日志发布至仿真计划中
|
* 将编辑区行车日志发布至仿真计划中
|
||||||
*/
|
*/
|
||||||
CTC_RELEASE_RUN_PLAN_TO_SIMULATION,
|
CTC_RELEASE_RUN_PLAN_TO_SIMULATION,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将CTC生效区发布至车站
|
||||||
|
*/
|
||||||
|
CTC_RELEASE_EFFECT_AREA_TO_STATION,
|
||||||
//---------------------------- 改方、辅助操作 -------------------------
|
//---------------------------- 改方、辅助操作 -------------------------
|
||||||
/**
|
/**
|
||||||
* 改方按钮操作
|
* 改方按钮操作
|
||||||
|
@ -164,4 +164,16 @@ public class CtcStationRunPlanOperateHandler {
|
|||||||
public void agreeDepartureNotice(Simulation simulation, String stationCode, String runPlanCode) {
|
public void agreeDepartureNotice(Simulation simulation, String stationCode, String runPlanCode) {
|
||||||
ctcService.agreeDepartureNotice(simulation, stationCode, runPlanCode);
|
ctcService.agreeDepartureNotice(simulation, stationCode, runPlanCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 将CTC生效区发布至车站
|
||||||
|
*
|
||||||
|
* @param simulation 仿真实体
|
||||||
|
* @param stationCode 车站编码
|
||||||
|
*/
|
||||||
|
@OperateHandlerMapping(type = Operation.Type.CTC_RELEASE_EFFECT_AREA_TO_STATION)
|
||||||
|
public void effectAreaToStation(Simulation simulation, String stationCode) {
|
||||||
|
ctcStationRunPlanLogService.effectAreaToStation(simulation, stationCode);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,16 +10,19 @@ 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.Station;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||||
import club.joylink.rtss.util.RandomGenerator;
|
|
||||||
import club.joylink.rtss.websocket.StompMessageService;
|
import club.joylink.rtss.websocket.StompMessageService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationContext;
|
import org.springframework.context.ApplicationContext;
|
||||||
import org.springframework.stereotype.Component;
|
import org.springframework.stereotype.Component;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.util.StringUtils;
|
import org.springframework.util.StringUtils;
|
||||||
|
|
||||||
import java.time.LocalTime;
|
import java.time.LocalTime;
|
||||||
import java.util.*;
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Objects;
|
||||||
import java.util.concurrent.ConcurrentHashMap;
|
import java.util.concurrent.ConcurrentHashMap;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
@ -75,27 +78,25 @@ public class CtcStationRunPlanLogService {
|
|||||||
}
|
}
|
||||||
List<CtcStationRunPlanLog> runPlanLogList = new ArrayList<>(planParamList.size());
|
List<CtcStationRunPlanLog> runPlanLogList = new ArrayList<>(planParamList.size());
|
||||||
planParamList.stream().forEach(p -> {
|
planParamList.stream().forEach(p -> {
|
||||||
CtcStationRunPlanLog changeRunPlanLog = null; // 要发的消息实体
|
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, p.getRunPlanCode());
|
||||||
if (p.getStatus() <= 0) { // 修改、删除
|
if (runPlanLog != null) { // 修改、删除
|
||||||
CtcStationRunPlanLog runPlanLog = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, p.getRunPlanCode());
|
if (modifyRunPlanInfo(simulation, runPlanLog, p)) { // 是否修改过股道
|
||||||
changeRunPlanLog = modifyRunPlanInfo(simulation, runPlanLog, p);
|
runPlanLogList.add(runPlanLog);
|
||||||
} else if (p.getStatus() == 1) { // 增加
|
}
|
||||||
CtcStationRunPlanLog runPlanLog = createRunPlanLog(simulation, stationCode, p);
|
} else {
|
||||||
|
runPlanLog = createRunPlanLog(simulation, stationCode, p);
|
||||||
simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog);
|
simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog);
|
||||||
changeRunPlanLog = runPlanLog;
|
runPlanLogList.add(runPlanLog);
|
||||||
}
|
|
||||||
if (changeRunPlanLog != null && !StringUtils.isEmpty(changeRunPlanLog.getCode())) {
|
|
||||||
runPlanLogList.add(changeRunPlanLog);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
// 编辑过轨道的行车记录
|
// 编辑过轨道的行车记录
|
||||||
runPlanLogList.stream().filter(runPlanLog -> runPlanLog.getArriveRunPlan() != null || runPlanLog.getDepartRunPlan() != null)
|
runPlanLogList.stream()
|
||||||
.forEach(runPlanLog -> {
|
.filter(r -> r.getArriveRunPlan() != null || r.getDepartRunPlan() != null)
|
||||||
CtcStationRunPlanLog r = simulation.getCtcRepository().getRunPlanByRunPlanCode(stationCode, runPlanLog.getCode());
|
.forEach(r -> {
|
||||||
if (runPlanLog.getArriveRunPlan() != null && runPlanLog.getArriveRunPlan().getTrackSection() != null) {
|
if (r.getArriveRunPlan() != null && r.getArriveRunPlan().getTrackSection() != null) {
|
||||||
ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getArriveRunPlan(), false);
|
ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getArriveRunPlan(), false);
|
||||||
}
|
}
|
||||||
if (runPlanLog.getDepartRunPlan() != null && runPlanLog.getDepartRunPlan().getTrackSection() != null) {
|
if (r.getDepartRunPlan() != null && r.getDepartRunPlan().getTrackSection() != null) {
|
||||||
ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getDepartRunPlan(), true);
|
ctcService.runPlanItemUpdate(simulation, r.getStation(), r.getDepartRunPlan(), true);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@ -114,7 +115,7 @@ public class CtcStationRunPlanLogService {
|
|||||||
runPlanParamList.stream().forEach(p -> {
|
runPlanParamList.stream().forEach(p -> {
|
||||||
String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber();
|
String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber();
|
||||||
p.setTripNumber(tripNumber);
|
p.setTripNumber(tripNumber);
|
||||||
String runPlanCode = p.generateId();
|
String runPlanCode = tripNumber;
|
||||||
if (stationRunPlanMap.containsKey(runPlanCode)) {
|
if (stationRunPlanMap.containsKey(runPlanCode)) {
|
||||||
modifyRunPlanParam(stationRunPlanMap.get(runPlanCode), p);
|
modifyRunPlanParam(stationRunPlanMap.get(runPlanCode), p);
|
||||||
} else {
|
} else {
|
||||||
@ -129,7 +130,7 @@ public class CtcStationRunPlanLogService {
|
|||||||
*
|
*
|
||||||
* @param simulation 仿真实体
|
* @param simulation 仿真实体
|
||||||
* @param stationCode 车站编码
|
* @param stationCode 车站编码
|
||||||
* @param tripNumber 车次
|
* @param runPlanCode 车次
|
||||||
*/
|
*/
|
||||||
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) {
|
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) {
|
||||||
Map<String, CtcRunPlanParam> stationRunLogTripNumberMap = simulation.getCtcRepository()
|
Map<String, CtcRunPlanParam> stationRunLogTripNumberMap = simulation.getCtcRepository()
|
||||||
@ -161,7 +162,7 @@ public class CtcStationRunPlanLogService {
|
|||||||
runPlanParamList.forEach(p -> {
|
runPlanParamList.forEach(p -> {
|
||||||
String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber();
|
String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber();
|
||||||
p.setTripNumber(tripNumber);
|
p.setTripNumber(tripNumber);
|
||||||
p.setRunPlanCode(p.generateId());
|
p.setRunPlanCode(tripNumber);
|
||||||
});
|
});
|
||||||
Map<String, CtcRunPlanParam> planParamMap = runPlanParamList.stream().collect(Collectors.toMap(p -> p.getRunPlanCode(), (p) -> p));
|
Map<String, CtcRunPlanParam> planParamMap = runPlanParamList.stream().collect(Collectors.toMap(p -> p.getRunPlanCode(), (p) -> p));
|
||||||
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().put(stationCode, planParamMap);
|
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().put(stationCode, planParamMap);
|
||||||
@ -175,29 +176,31 @@ public class CtcStationRunPlanLogService {
|
|||||||
*/
|
*/
|
||||||
public void releaseRunPlanToSimulation(Simulation simulation, String stationCode) {
|
public void releaseRunPlanToSimulation(Simulation simulation, String stationCode) {
|
||||||
// 编辑区信息
|
// 编辑区信息
|
||||||
Map<String, CtcRunPlanParam> planParamMap = simulation.getCtcRepository()
|
Map<String, CtcRunPlanParam> planParamMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap()
|
||||||
.getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>());
|
.getOrDefault(stationCode, new ConcurrentHashMap<>());
|
||||||
// 发布至生效区中
|
|
||||||
simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().put(stationCode, planParamMap);
|
|
||||||
|
|
||||||
// 编辑区版本 + 1
|
// 编辑区版本 + 1
|
||||||
AtomicInteger editVersion = simulation.getCtcRepository().getStationEditAreaVersion()
|
AtomicInteger editVersion = simulation.getCtcRepository().getStationEditAreaVersion()
|
||||||
.getOrDefault(stationCode, new AtomicInteger(0));
|
.getOrDefault(stationCode, new AtomicInteger(0));
|
||||||
editVersion.decrementAndGet();
|
editVersion.decrementAndGet();
|
||||||
simulation.getCtcRepository().getStationEditAreaVersion().put(stationCode, editVersion);
|
simulation.getCtcRepository().getStationEditAreaVersion().put(stationCode, editVersion);
|
||||||
|
// 发布至生效区中
|
||||||
|
simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().put(stationCode, planParamMap);
|
||||||
AtomicInteger effectVersion = new AtomicInteger(editVersion.get()); // 覆盖生效区版本
|
AtomicInteger effectVersion = new AtomicInteger(editVersion.get()); // 覆盖生效区版本
|
||||||
simulation.getCtcRepository().getStationEffectAreaVersion().put(stationCode, effectVersion);
|
simulation.getCtcRepository().getStationEffectAreaVersion().put(stationCode, effectVersion);
|
||||||
//------------------ 下边这一步 --------- 后边需要移动到【生效至车站】操作中
|
}
|
||||||
// 移除生效区中车站的所有计划(包括原始计划)
|
|
||||||
simulation.getCtcRepository().removeRunPlanByStationCode(stationCode);
|
/**
|
||||||
// 添加至仿真CTC运行计划中
|
* 【生效至车站】操作中
|
||||||
List<CtcStationRunPlanLog> runPlanLogList = new LinkedList<>();
|
*
|
||||||
planParamMap.forEach((k, p) -> {
|
* @param simulation 仿真实体
|
||||||
CtcStationRunPlanLog runPlanLog = createRunPlanLog(simulation, stationCode, p);
|
* @param stationCode 车站编码
|
||||||
simulation.getCtcRepository().addRunPlanToSimulationMap(runPlanLog);
|
*/
|
||||||
runPlanLogList.add(runPlanLog);
|
public void effectAreaToStation(Simulation simulation, String stationCode) {
|
||||||
});
|
Map<String, CtcRunPlanParam> runPlanParamMap = simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().get(stationCode);
|
||||||
|
if (!CollectionUtils.isEmpty(runPlanParamMap)) {
|
||||||
|
List<CtcRunPlanParam> runPlanParamList = runPlanParamMap.values().stream().collect(Collectors.toList());
|
||||||
|
modifyBatchRunPlan(simulation, stationCode, runPlanParamList, 1);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -300,80 +303,53 @@ public class CtcStationRunPlanLogService {
|
|||||||
* @param planParam 修改参数
|
* @param planParam 修改参数
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private CtcStationRunPlanLog modifyRunPlanInfo(Simulation simulation, CtcStationRunPlanLog runPlanLog, CtcRunPlanParam planParam) {
|
private boolean modifyRunPlanInfo(Simulation simulation, CtcStationRunPlanLog runPlanLog, CtcRunPlanParam planParam) {
|
||||||
CtcStationRunPlanLog changeRunPlanLog = new CtcStationRunPlanLog();
|
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
if (planParam.getStatus() == -1) {
|
if (planParam.getStatus() == -1) {
|
||||||
runPlanLog.setDelete(Boolean.TRUE);
|
runPlanLog.setDelete(Boolean.TRUE);
|
||||||
changeRunPlanLog.setDelete(Boolean.TRUE);
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
CtcStationRunPlanLog.RunPlanItem changeArriveItem = modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), planParam, true);
|
// 到达
|
||||||
changeRunPlanLog.setArriveRunPlan(changeArriveItem);
|
change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getArriveRunPlan(), planParam, true);
|
||||||
change = change || changeArriveItem != null;
|
// 出发
|
||||||
CtcStationRunPlanLog.RunPlanItem changeDepartItem = modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), planParam, false);
|
change = change || modifyRunPlanItemInfo(simulation, runPlanLog.getDepartRunPlan(), planParam, false);
|
||||||
changeRunPlanLog.setDepartRunPlan(changeDepartItem);
|
|
||||||
change = change || changeDepartItem != null;
|
|
||||||
// 存在不一样的选项
|
// 存在不一样的选项
|
||||||
long modifyNum = planParam.getRunPlanTaskList().stream().filter(task -> !runPlanLog.getRunPlanTaskList().contains(task)).count();
|
long modifyNum = planParam.getRunPlanTaskList().stream().filter(task -> !runPlanLog.getRunPlanTaskList().contains(task)).count();
|
||||||
if (modifyNum > 0 || (planParam.getRunPlanTaskList().size() != runPlanLog.getRunPlanTaskList().size())) { // 长度不一致直接赋值
|
if (modifyNum > 0 || (planParam.getRunPlanTaskList().size() != runPlanLog.getRunPlanTaskList().size())) { // 长度不一致直接赋值
|
||||||
runPlanLog.setRunPlanTaskList(planParam.getRunPlanTaskList());
|
runPlanLog.setRunPlanTaskList(planParam.getRunPlanTaskList());
|
||||||
changeRunPlanLog.setRunPlanTaskList(planParam.getRunPlanTaskList());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 是否客运
|
// 是否客运
|
||||||
if (planParam.getPassenger() != null && !Objects.equals(planParam.getPassenger(), runPlanLog.getPassenger())) {
|
if (planParam.getPassenger() != null && !Objects.equals(planParam.getPassenger(), runPlanLog.getPassenger())) {
|
||||||
runPlanLog.setPassenger(planParam.getPassenger());
|
runPlanLog.setPassenger(planParam.getPassenger());
|
||||||
changeRunPlanLog.setPassenger(planParam.getPassenger());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 重点列车
|
// 重点列车
|
||||||
if (planParam.getKeyTrains() != null && !Objects.equals(planParam.getKeyTrains(), runPlanLog.getKeyTrains())) {
|
if (planParam.getKeyTrains() != null && !Objects.equals(planParam.getKeyTrains(), runPlanLog.getKeyTrains())) {
|
||||||
runPlanLog.setKeyTrains(planParam.getKeyTrains());
|
runPlanLog.setKeyTrains(planParam.getKeyTrains());
|
||||||
changeRunPlanLog.setKeyTrains(planParam.getKeyTrains());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 是否军用
|
// 是否军用
|
||||||
if (planParam.getMilitary() != null && !Objects.equals(planParam.getMilitary(), runPlanLog.getMilitary())) {
|
if (planParam.getMilitary() != null && !Objects.equals(planParam.getMilitary(), runPlanLog.getMilitary())) {
|
||||||
runPlanLog.setMilitary(planParam.getMilitary());
|
runPlanLog.setMilitary(planParam.getMilitary());
|
||||||
changeRunPlanLog.setMilitary(planParam.getMilitary());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 运行股道与基本径路不一致
|
// 运行股道与基本径路不一致
|
||||||
if (planParam.getTrackDiscordant() != null && !Objects.equals(planParam.getTrackDiscordant(), runPlanLog.getTrackDiscordant())) {
|
if (planParam.getTrackDiscordant() != null && !Objects.equals(planParam.getTrackDiscordant(), runPlanLog.getTrackDiscordant())) {
|
||||||
runPlanLog.setTrackSectionCode(planParam.getTrackSectionCode());
|
runPlanLog.setTrackSectionCode(planParam.getTrackSectionCode());
|
||||||
changeRunPlanLog.setTrackSectionCode(planParam.getTrackSectionCode());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 出入口与基本径路不一致
|
// 出入口与基本径路不一致
|
||||||
if (planParam.getEntryOutDiscordant() != null && !Objects.equals(planParam.getEntryOutDiscordant(), runPlanLog.getEntryOutDiscordant())) {
|
if (planParam.getEntryOutDiscordant() != null && !Objects.equals(planParam.getEntryOutDiscordant(), runPlanLog.getEntryOutDiscordant())) {
|
||||||
runPlanLog.setEntryOutDiscordant(planParam.getEntryOutDiscordant());
|
runPlanLog.setEntryOutDiscordant(planParam.getEntryOutDiscordant());
|
||||||
changeRunPlanLog.setEntryOutDiscordant(planParam.getEntryOutDiscordant());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 超限等级
|
// 超限等级
|
||||||
if (planParam.getTransfinite() != null && !Objects.equals(planParam.getTransfinite(), runPlanLog.getTransfinite())) {
|
if (planParam.getTransfinite() != null && !Objects.equals(planParam.getTransfinite(), runPlanLog.getTransfinite())) {
|
||||||
runPlanLog.setTransfinite(planParam.getTransfinite());
|
runPlanLog.setTransfinite(planParam.getTransfinite());
|
||||||
changeRunPlanLog.setTransfinite(planParam.getTransfinite());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 记事
|
// 记事
|
||||||
if (planParam.getRemark() != null && !Objects.equals(planParam.getRemark(), runPlanLog.getRemark())) {
|
if (planParam.getRemark() != null && !Objects.equals(planParam.getRemark(), runPlanLog.getRemark())) {
|
||||||
runPlanLog.setRemark(planParam.getRemark());
|
runPlanLog.setRemark(planParam.getRemark());
|
||||||
changeRunPlanLog.setRemark(planParam.getRemark());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
// 晚点原因
|
// 晚点原因
|
||||||
if (planParam.getLateReason() != null && !Objects.equals(planParam.getLateReason(), runPlanLog.getLateReason())) {
|
if (planParam.getLateReason() != null && !Objects.equals(planParam.getLateReason(), runPlanLog.getLateReason())) {
|
||||||
runPlanLog.setLateReason(planParam.getLateReason());
|
runPlanLog.setLateReason(planParam.getLateReason());
|
||||||
changeRunPlanLog.setLateReason(planParam.getLateReason());
|
|
||||||
change = true;
|
|
||||||
}
|
}
|
||||||
|
return change;
|
||||||
if (change) {
|
|
||||||
changeRunPlanLog.setCode(planParam.getRunPlanCode());
|
|
||||||
}
|
|
||||||
return changeRunPlanLog;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -384,19 +360,12 @@ public class CtcStationRunPlanLogService {
|
|||||||
* @param paramInfo 参数
|
* @param paramInfo 参数
|
||||||
* @param arrive 是否到达
|
* @param arrive 是否到达
|
||||||
*/
|
*/
|
||||||
private CtcStationRunPlanLog.RunPlanItem modifyRunPlanItemInfo(Simulation simulation, CtcStationRunPlanLog.RunPlanItem runPlanItem
|
private boolean modifyRunPlanItemInfo(Simulation simulation, CtcStationRunPlanLog.RunPlanItem runPlanItem, CtcRunPlanParam paramInfo, boolean arrive) {
|
||||||
, CtcRunPlanParam paramInfo, boolean arrive) {
|
|
||||||
CtcStationRunPlanLog.RunPlanItem changeItem = null;
|
|
||||||
boolean change = false;
|
boolean change = false;
|
||||||
if (runPlanItem != null) {
|
if (runPlanItem != null) {
|
||||||
changeItem = new CtcStationRunPlanLog.RunPlanItem(); // 返回改变的实体
|
|
||||||
// 实际时间
|
// 实际时间
|
||||||
LocalTime actualTime = arrive ? paramInfo.getArriveTime() : paramInfo.getDepartTime();
|
LocalTime actualTime = arrive ? paramInfo.getArriveTime() : paramInfo.getDepartTime();
|
||||||
if (actualTime != null) {
|
if (actualTime != null && !Objects.equals(actualTime.toString(), runPlanItem.getActualTime())) {
|
||||||
change = !Objects.equals(actualTime.toString(), runPlanItem.getActualTime());
|
|
||||||
if (change) {
|
|
||||||
changeItem.setActualTime(actualTime.toString());
|
|
||||||
}
|
|
||||||
runPlanItem.setActualTime(actualTime.toString());
|
runPlanItem.setActualTime(actualTime.toString());
|
||||||
}
|
}
|
||||||
// 股道编码
|
// 股道编码
|
||||||
@ -405,17 +374,12 @@ public class CtcStationRunPlanLogService {
|
|||||||
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
||||||
change = !Objects.equals(section, runPlanItem.getTrackSection());
|
change = !Objects.equals(section, runPlanItem.getTrackSection());
|
||||||
if (change) {
|
if (change) {
|
||||||
changeItem.setTrackSection(section);
|
runPlanItem.setTrackSection(section);
|
||||||
}
|
}
|
||||||
runPlanItem.setTrackSection(section);
|
|
||||||
}
|
}
|
||||||
// 车次
|
// 车次
|
||||||
String tripNumber = arrive ? paramInfo.getArriveTripNumber() : paramInfo.getDepartTripNumber();
|
String tripNumber = arrive ? paramInfo.getArriveTripNumber() : paramInfo.getDepartTripNumber();
|
||||||
if (!StringUtils.isEmpty(tripNumber)) {
|
if (!StringUtils.isEmpty(tripNumber) && !Objects.equals(tripNumber, runPlanItem.getTripNumber())) {
|
||||||
change = !Objects.equals(tripNumber, runPlanItem.getTripNumber());
|
|
||||||
if (change) {
|
|
||||||
changeItem.setTripNumber(tripNumber);
|
|
||||||
}
|
|
||||||
runPlanItem.setTripNumber(tripNumber);
|
runPlanItem.setTripNumber(tripNumber);
|
||||||
}
|
}
|
||||||
// 车站
|
// 车站
|
||||||
@ -424,12 +388,11 @@ public class CtcStationRunPlanLogService {
|
|||||||
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
||||||
change = !Objects.equals(station, runPlanItem.getStation());
|
change = !Objects.equals(station, runPlanItem.getStation());
|
||||||
if (change) {
|
if (change) {
|
||||||
changeItem.setStation(station);
|
runPlanItem.setStation(station);
|
||||||
}
|
}
|
||||||
runPlanItem.setStation(station);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return change ? changeItem : null;
|
return change;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -441,15 +404,15 @@ public class CtcStationRunPlanLogService {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private CtcStationRunPlanLog createRunPlanLog(Simulation simulation, String stationCode, CtcRunPlanParam paramInfo) {
|
private CtcStationRunPlanLog createRunPlanLog(Simulation simulation, String stationCode, CtcRunPlanParam paramInfo) {
|
||||||
CtcStationRunPlanLog ctcStationRunPlanLog = new CtcStationRunPlanLog(paramInfo);
|
|
||||||
ctcStationRunPlanLog.setCode(RandomGenerator.uuid());
|
|
||||||
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
|
||||||
ctcStationRunPlanLog.setStation(station);
|
|
||||||
String tripNumber = paramInfo.getTripNumber();
|
String tripNumber = paramInfo.getTripNumber();
|
||||||
if (StringUtils.isEmpty(tripNumber)) {
|
if (StringUtils.isEmpty(tripNumber)) {
|
||||||
tripNumber = StringUtils.isEmpty(paramInfo.getArriveTripNumber()) ? paramInfo.getDepartTripNumber() : paramInfo.getArriveTripNumber();
|
tripNumber = StringUtils.isEmpty(paramInfo.getArriveTripNumber()) ? paramInfo.getDepartTripNumber() : paramInfo.getArriveTripNumber();
|
||||||
}
|
}
|
||||||
ctcStationRunPlanLog.setTripNumber(tripNumber);
|
paramInfo.setTripNumber(tripNumber);
|
||||||
|
CtcStationRunPlanLog ctcStationRunPlanLog = new CtcStationRunPlanLog(paramInfo);
|
||||||
|
ctcStationRunPlanLog.setCode(tripNumber);
|
||||||
|
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
||||||
|
ctcStationRunPlanLog.setStation(station);
|
||||||
ctcStationRunPlanLog.setArriveRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, paramInfo, true));
|
ctcStationRunPlanLog.setArriveRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, paramInfo, true));
|
||||||
ctcStationRunPlanLog.setDepartRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, paramInfo, false));
|
ctcStationRunPlanLog.setDepartRunPlan(CtcStationRunPlanLog.createRunPlanItem(simulation, paramInfo, false));
|
||||||
return ctcStationRunPlanLog;
|
return ctcStationRunPlanLog;
|
||||||
|
@ -46,9 +46,12 @@ public class CTCLogicLoop {
|
|||||||
// 发送运行计划变化消息
|
// 发送运行计划变化消息
|
||||||
sendRunPlanChangeMessage(simulation);
|
sendRunPlanChangeMessage(simulation);
|
||||||
sendRunPlanRemoveMessage(simulation);
|
sendRunPlanRemoveMessage(simulation);
|
||||||
// 发送车务管理端消息
|
// 发送车务管理端消息(编辑区)
|
||||||
sendCtcManageChangeMessage(simulation);
|
sendCtcManageChangeMessage(simulation);
|
||||||
sendCtcManageRemoveMessage(simulation);
|
sendCtcManageRemoveMessage(simulation);
|
||||||
|
// 车务管理端消息(生效区)
|
||||||
|
sendCtcManageEffectChangeMessage(simulation);
|
||||||
|
sendCtcManageEffectRemoveMessage(simulation);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void sendAllMessage(Simulation simulation) {
|
public void sendAllMessage(Simulation simulation) {
|
||||||
@ -249,7 +252,8 @@ public class CTCLogicLoop {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
if (!CollectionUtils.isEmpty(messageList)) {
|
if (!CollectionUtils.isEmpty(messageList)) {
|
||||||
sendCtcMessage(simulation.getId(), messageList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_CHANGE, simulation.getSimulationUserIds());
|
sendCtcMessage(simulation.getId(), messageList
|
||||||
|
, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_CHANGE, simulation.getSimulationUserIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -267,7 +271,8 @@ public class CTCLogicLoop {
|
|||||||
if (!CollectionUtils.isEmpty(ctcRunPlanVOList)) {
|
if (!CollectionUtils.isEmpty(ctcRunPlanVOList)) {
|
||||||
// 移除已删除的数据
|
// 移除已删除的数据
|
||||||
ctcRunPlanVOList.forEach(vo -> ctcRunPlanVOMap.remove(vo.getStationCode() + "_" + vo.getCode()));
|
ctcRunPlanVOList.forEach(vo -> ctcRunPlanVOMap.remove(vo.getStationCode() + "_" + vo.getCode()));
|
||||||
sendCtcMessage(simulation.getId(), ctcRunPlanVOList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_REMOVE, simulation.getSimulationUserIds());
|
sendCtcMessage(simulation.getId(), ctcRunPlanVOList
|
||||||
|
, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_REMOVE, simulation.getSimulationUserIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -291,7 +296,8 @@ public class CTCLogicLoop {
|
|||||||
allList.addAll(editAreaStatusVOMap.values());
|
allList.addAll(editAreaStatusVOMap.values());
|
||||||
}
|
}
|
||||||
if (!CollectionUtils.isEmpty(allList)) {
|
if (!CollectionUtils.isEmpty(allList)) {
|
||||||
sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds);
|
sendCtcMessage(simulation.getId(), allList
|
||||||
|
, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -322,7 +328,8 @@ public class CTCLogicLoop {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
if (!CollectionUtils.isEmpty(allList)) {
|
if (!CollectionUtils.isEmpty(allList)) {
|
||||||
sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, simulation.getSimulationUserIds());
|
sendCtcMessage(simulation.getId(), allList
|
||||||
|
, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, simulation.getSimulationUserIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -332,7 +339,9 @@ public class CTCLogicLoop {
|
|||||||
* @param simulation 仿真实体
|
* @param simulation 仿真实体
|
||||||
*/
|
*/
|
||||||
public void sendCtcManageRemoveMessage(Simulation simulation) {
|
public void sendCtcManageRemoveMessage(Simulation simulation) {
|
||||||
|
// 状态,key:车站_车次
|
||||||
Map<String, CtcRunPlanParam> editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap();
|
Map<String, CtcRunPlanParam> editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap();
|
||||||
|
// 编辑区,key:车站 key:车次
|
||||||
Map<String, Map<String, CtcRunPlanParam>> editeAreaMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap();
|
Map<String, Map<String, CtcRunPlanParam>> editeAreaMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap();
|
||||||
List<CtcRunPlanParam> messageInfo = editAreaStatusVOMap.values().stream().filter(vo -> {
|
List<CtcRunPlanParam> messageInfo = editAreaStatusVOMap.values().stream().filter(vo -> {
|
||||||
Map<String, CtcRunPlanParam> map = editeAreaMap.get(vo.getStationCode());
|
Map<String, CtcRunPlanParam> map = editeAreaMap.get(vo.getStationCode());
|
||||||
@ -346,7 +355,68 @@ public class CTCLogicLoop {
|
|||||||
return false;
|
return false;
|
||||||
}).map(vo -> vo.buildRemoveParam()).collect(Collectors.toList());
|
}).map(vo -> vo.buildRemoveParam()).collect(Collectors.toList());
|
||||||
if (messageInfo != null && !messageInfo.isEmpty()) {
|
if (messageInfo != null && !messageInfo.isEmpty()) {
|
||||||
sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, simulation.getSimulationUserIds());
|
// 移除已删除状态
|
||||||
|
messageInfo.forEach(vo -> editAreaStatusVOMap.remove(vo.getStationCode() + "_" + vo.getRunPlanCode()));
|
||||||
|
sendCtcMessage(simulation.getId(), messageInfo
|
||||||
|
, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, simulation.getSimulationUserIds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送生效区变化消息
|
||||||
|
*
|
||||||
|
* @param simulation 仿真实体
|
||||||
|
*/
|
||||||
|
public void sendCtcManageEffectChangeMessage(Simulation simulation) {
|
||||||
|
Map<String, CtcRunPlanParam> editAreaStatusVOMap = simulation.getCtcRepository().getEffectAreaStatusVOMap();
|
||||||
|
List<CtcRunPlanParam> allList = new ArrayList<>();
|
||||||
|
simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap().forEach((k, v) -> {
|
||||||
|
v.values().stream().forEach(p -> {
|
||||||
|
String mapKey = p.getStationCode() + "_" + p.getRunPlanCode();
|
||||||
|
CtcRunPlanParam param = editAreaStatusVOMap.get(mapKey);
|
||||||
|
CtcRunPlanParam changeCtcRunPlanVo = null;
|
||||||
|
if (param == null) {
|
||||||
|
changeCtcRunPlanVo = p.clone();
|
||||||
|
editAreaStatusVOMap.put(mapKey, changeCtcRunPlanVo);
|
||||||
|
allList.add(editAreaStatusVOMap.get(mapKey));
|
||||||
|
} else {
|
||||||
|
changeCtcRunPlanVo = param.compareAndChange(p);
|
||||||
|
if (changeCtcRunPlanVo != null) {
|
||||||
|
allList.add(changeCtcRunPlanVo);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
});
|
||||||
|
if (!CollectionUtils.isEmpty(allList)) {
|
||||||
|
sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_CHANGE
|
||||||
|
, simulation.getSimulationUserIds());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送生效区移除消息
|
||||||
|
*
|
||||||
|
* @param simulation 仿真实体
|
||||||
|
*/
|
||||||
|
public void sendCtcManageEffectRemoveMessage(Simulation simulation) {
|
||||||
|
Map<String, CtcRunPlanParam> effectAreaStatusVOMap = simulation.getCtcRepository().getEffectAreaStatusVOMap();
|
||||||
|
Map<String, Map<String, CtcRunPlanParam>> effectAreaMap = simulation.getCtcRepository().getSimulationRunPlanEffectAreaMap();
|
||||||
|
List<CtcRunPlanParam> messageInfo = effectAreaStatusVOMap.values().stream().filter(vo -> {
|
||||||
|
Map<String, CtcRunPlanParam> map = effectAreaMap.get(vo.getStationCode());
|
||||||
|
if (map == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
CtcRunPlanParam p = map.get(vo.getRunPlanCode());
|
||||||
|
if (p == null) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}).map(vo -> vo.buildRemoveParam()).collect(Collectors.toList());
|
||||||
|
if (!CollectionUtils.isEmpty(messageInfo)) {
|
||||||
|
// 移除已删除状态
|
||||||
|
messageInfo.forEach(vo -> effectAreaStatusVOMap.remove(vo.getStationCode() + "_" + vo.getRunPlanCode()));
|
||||||
|
sendCtcMessage(simulation.getId(), messageInfo
|
||||||
|
, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE, simulation.getSimulationUserIds());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -78,6 +78,11 @@ public class CtcRepository {
|
|||||||
*/
|
*/
|
||||||
private final Map<String, CtcRunPlanParam> editAreaStatusVOMap = new HashMap<>();
|
private final Map<String, CtcRunPlanParam> editAreaStatusVOMap = new HashMap<>();
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 车务管理端生效区运行计划状态
|
||||||
|
*/
|
||||||
|
private final Map<String, CtcRunPlanParam> effectAreaStatusVOMap = new HashMap<>();
|
||||||
|
|
||||||
|
|
||||||
public void reset() {
|
public void reset() {
|
||||||
routeSequenceMap.clear();
|
routeSequenceMap.clear();
|
||||||
@ -85,6 +90,8 @@ public class CtcRepository {
|
|||||||
trackViewVOMap.clear();
|
trackViewVOMap.clear();
|
||||||
// 编辑区清空
|
// 编辑区清空
|
||||||
this.simulationRunPlanEditAreaMap.clear();
|
this.simulationRunPlanEditAreaMap.clear();
|
||||||
|
// 生效区清空
|
||||||
|
this.simulationRunPlanEffectAreaMap.clear();
|
||||||
// 仿真运行数据直接清空
|
// 仿真运行数据直接清空
|
||||||
this.simulationRunPlanMap.clear();
|
this.simulationRunPlanMap.clear();
|
||||||
this.allRunPlanList.clear();
|
this.allRunPlanList.clear();
|
||||||
@ -96,6 +103,7 @@ public class CtcRepository {
|
|||||||
// 运行计划状态清除
|
// 运行计划状态清除
|
||||||
this.runPlanStatusVOMap.clear();
|
this.runPlanStatusVOMap.clear();
|
||||||
this.editAreaStatusVOMap.clear();
|
this.editAreaStatusVOMap.clear();
|
||||||
|
this.effectAreaStatusVOMap.clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -391,6 +391,16 @@ public enum WebSocketMessageType {
|
|||||||
* 仿真编辑区运行计划变化
|
* 仿真编辑区运行计划变化
|
||||||
*/
|
*/
|
||||||
SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE,
|
SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仿真生效区运行计划变化
|
||||||
|
*/
|
||||||
|
SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_CHANGE,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仿真CTC管理端生效区移除操作
|
||||||
|
*/
|
||||||
|
SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE,
|
||||||
/** ------------ CTC消息信息 ----------- */
|
/** ------------ CTC消息信息 ----------- */
|
||||||
;
|
;
|
||||||
}
|
}
|
||||||
|
@ -115,7 +115,9 @@ public class SocketMessageFactory {
|
|||||||
}
|
}
|
||||||
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT:
|
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT:
|
||||||
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE:
|
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE:
|
||||||
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE: {
|
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE:
|
||||||
|
case SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_CHANGE:
|
||||||
|
case SIMULATION_CTC_MANAGER_RUN_PLAN_EFFECT_REMOVE: {
|
||||||
topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group));
|
topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user