Merge remote-tracking branch 'origin/test' into test

This commit is contained in:
joylink_zhangsai 2022-06-15 18:52:02 +08:00
commit 99633887fd
8 changed files with 247 additions and 157 deletions

View File

@ -131,11 +131,11 @@ public class CtcStationRunPlanOperateHandler {
* *
* @param simulation 仿真实体 * @param simulation 仿真实体
* @param stationCode 车站编码 * @param stationCode 车站编码
* @param tripNumber 车次 * @param runPlanCode 车次
*/ */
@OperateHandlerMapping(type = Operation.Type.CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA) @OperateHandlerMapping(type = Operation.Type.CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA)
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String tripNumber) { public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) {
ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, tripNumber); ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, runPlanCode);
} }
/** /**

View File

@ -4,15 +4,18 @@ import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
import lombok.Getter; import lombok.Getter;
import lombok.NoArgsConstructor; import lombok.NoArgsConstructor;
import lombok.Setter; import lombok.Setter;
import org.springframework.util.StringUtils;
import java.time.LocalTime; import java.time.LocalTime;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Objects;
@Getter @Getter
@Setter @Setter
@NoArgsConstructor @NoArgsConstructor
public class CtcRunPlanParam { public class CtcRunPlanParam implements Cloneable {
/** /**
* 运行计划编码 * 运行计划编码
*/ */
@ -136,18 +139,108 @@ public class CtcRunPlanParam {
/** /**
* 删除时构造实体 * 删除时构造实体
* *
* @param stationCode 车站
* @param tripNumber 车次
* @return 实体 * @return 实体
*/ */
public static CtcRunPlanParam buildRemoveParam(String stationCode, String tripNumber) { public CtcRunPlanParam buildRemoveParam() {
CtcRunPlanParam p = new CtcRunPlanParam(); CtcRunPlanParam p = new CtcRunPlanParam();
p.stationCode = stationCode; p.setRunPlanCode(this.runPlanCode);
p.tripNumber = tripNumber; p.setStationCode(this.stationCode);
p.runPlanTaskList = null; p.setTripNumber(this.tripNumber);
p.setRunPlanTaskList(null);
return p; return p;
} }
/**
* 生成主键
*
* @return 主键
*/
public String generateId() {
return this.getTripNumber()
+ (StringUtils.isEmpty(this.arriveDirectionCode) ? "_" : this.arriveDirectionCode)
+ (StringUtils.isEmpty(this.departDirectionCode) ? "_" : this.departDirectionCode);
}
public CtcRunPlanParam compareAndChange(CtcRunPlanParam modify) {
CtcRunPlanParam runPlanParam = new CtcRunPlanParam();
runPlanParam.setRunPlanCode(modify.getRunPlanCode());
boolean change = false;
if (!Objects.equals(this.stationCode, modify.getStationCode())) {
this.stationCode = modify.getStationCode();
runPlanParam.setStationCode(modify.getStationCode());
change = true;
}
if (!Objects.equals(this.tripNumber, modify.getTripNumber())) {
this.tripNumber = modify.getTripNumber();
runPlanParam.setTripNumber(modify.getTripNumber());
change = true;
}
if (!Objects.equals(this.trackSectionCode, modify.getTrackSectionCode())) {
this.trackSectionCode = modify.getTrackSectionCode();
runPlanParam.setTrackSectionCode(modify.getTrackSectionCode());
change = true;
}
if (!Objects.equals(this.arriveSectionCode, modify.getArriveSectionCode())) {
this.arriveSectionCode = modify.getArriveSectionCode();
runPlanParam.setArriveSectionCode(modify.getArriveSectionCode());
change = true;
}
if (!Objects.equals(this.departSectionCode, modify.getDepartSectionCode())) {
this.departSectionCode = modify.getDepartSectionCode();
runPlanParam.setDepartSectionCode(modify.getDepartSectionCode());
change = true;
}
if (!Objects.equals(this.arriveTime, modify.getArriveTime())) {
this.arriveTime = modify.getArriveTime();
runPlanParam.setArriveTime(modify.getArriveTime());
change = true;
}
if (!Objects.equals(this.departTime, modify.getDepartTime())) {
this.departTime = modify.getDepartTime();
runPlanParam.setDepartTime(modify.getDepartTime());
change = true;
}
if (!Objects.equals(this.arriveTripNumber, modify.getArriveTripNumber())) {
this.arriveTripNumber = modify.getArriveTripNumber();
runPlanParam.setArriveTripNumber(modify.getArriveTripNumber());
change = true;
}
if (!Objects.equals(this.departTripNumber, modify.getDepartTripNumber())) {
this.departTripNumber = modify.getDepartTripNumber();
runPlanParam.setDepartTripNumber(modify.getDepartTripNumber());
change = true;
}
if (!Objects.equals(this.arriveStationCode, modify.getArriveStationCode())) {
this.arriveStationCode = modify.getArriveStationCode();
runPlanParam.setArriveStationCode(modify.getArriveStationCode());
change = true;
}
if (!Objects.equals(this.departStationCode, modify.getDepartStationCode())) {
this.departStationCode = modify.getDepartStationCode();
runPlanParam.setDepartStationCode(modify.getDepartStationCode());
change = true;
}
if (!Objects.equals(this.arriveDirectionCode, modify.getArriveDirectionCode())) {
this.arriveDirectionCode = modify.getArriveDirectionCode();
runPlanParam.setArriveDirectionCode(modify.getArriveDirectionCode());
change = true;
}
if (!Objects.equals(this.departDirectionCode, modify.getDepartDirectionCode())) {
this.departDirectionCode = modify.getDepartDirectionCode();
runPlanParam.setDepartDirectionCode(modify.getDepartDirectionCode());
change = true;
}
// 存在不一样的选项
long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !this.runPlanTaskList.contains(task)).count();
if (modifyNum > 0 || (this.runPlanTaskList.size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值
this.runPlanTaskList = modify.getRunPlanTaskList();
runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList());
change = true;
}
return change ? runPlanParam : null;
}
@Override @Override
public String toString() { public String toString() {
return "CtcRunPlanParam{" + return "CtcRunPlanParam{" +
@ -168,4 +261,17 @@ public class CtcRunPlanParam {
", status=" + status + ", status=" + status +
'}'; '}';
} }
@Override
public CtcRunPlanParam clone() {
try {
CtcRunPlanParam clone = (CtcRunPlanParam) super.clone();
List<CtcStationRunPlanLog.RunPlanTask> list = new ArrayList<>(this.runPlanTaskList.size());
Collections.copy(list, this.runPlanTaskList);
clone.setRunPlanTaskList(list);
return clone;
} catch (CloneNotSupportedException e) {
throw new AssertionError();
}
}
} }

View File

@ -109,24 +109,42 @@ public class CtcStationRunPlanLogService {
* @param runPlanParamList 运行计划列表 * @param runPlanParamList 运行计划列表
*/ */
public void addRunPlanListToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) { public void addRunPlanListToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) {
List<CtcRunPlanParam> runPlanLogList = new ArrayList<>(runPlanParamList.size());
Map<String, CtcRunPlanParam> stationRunPlanMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap() Map<String, CtcRunPlanParam> stationRunPlanMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap()
.getOrDefault(stationCode, new ConcurrentHashMap<>(64)); .getOrDefault(stationCode, new ConcurrentHashMap<>(64));
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);
if (stationRunPlanMap.containsKey(tripNumber)) { String runPlanCode = p.generateId();
CtcRunPlanParam changeParam = modifyRunPlanParam(stationRunPlanMap.get(tripNumber), p); if (stationRunPlanMap.containsKey(runPlanCode)) {
if (changeParam != null) { modifyRunPlanParam(stationRunPlanMap.get(runPlanCode), p);
runPlanLogList.add(changeParam);
}
} else { } else {
stationRunPlanMap.put(tripNumber, p); p.setRunPlanCode(runPlanCode);
runPlanLogList.add(p); stationRunPlanMap.put(runPlanCode, p);
} }
}); });
// 发送消息 }
ctcLogicLoop.sendCtcManageChangeMessage(simulation, runPlanLogList, simulation.getSimulationUserIds());
/**
* 将车站编辑区中删除车次内容
*
* @param simulation 仿真实体
* @param stationCode 车站编码
* @param tripNumber 车次
*/
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String runPlanCode) {
Map<String, CtcRunPlanParam> stationRunLogTripNumberMap = simulation.getCtcRepository()
.getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>());
stationRunLogTripNumberMap.remove(runPlanCode);
}
/**
* 全部清空
*
* @param simulation 仿真修改
* @param stationCode 车站编码
*/
public void clearRunPlanFromEditArea(Simulation simulation, String stationCode) {
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().remove(stationCode);
} }
/** /**
@ -140,45 +158,13 @@ public class CtcStationRunPlanLogService {
// 移除车站所有运行计划 // 移除车站所有运行计划
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().remove(stationCode); simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().remove(stationCode);
// 运行计划 // 运行计划
Map<String, CtcRunPlanParam> planParamMap = runPlanParamList.stream().collect(Collectors.toMap(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);
return tripNumber; p.setRunPlanCode(p.generateId());
}, (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);
// 发送消息
ctcLogicLoop.sendCtcManageCoverMessage(simulation, runPlanParamList, simulation.getSimulationUserIds());
}
/**
* 将车站编辑区中删除车次内容
*
* @param simulation 仿真实体
* @param stationCode 车站编码
* @param tripNumber 车次
*/
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, String tripNumber) {
Map<String, CtcRunPlanParam> stationRunLogTripNumberMap = simulation.getCtcRepository()
.getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>());
stationRunLogTripNumberMap.remove(tripNumber);
// 发送消息
ctcLogicLoop.sendCtcManageRemoveMessage(simulation, Arrays.asList(CtcRunPlanParam.buildRemoveParam(stationCode, tripNumber)), simulation.getSimulationUserIds());
}
/**
* 全部清空
*
* @param simulation 仿真修改
* @param stationCode 车站编码
*/
public void clearRunPlanFromEditArea(Simulation simulation, String stationCode) {
Map<String, CtcRunPlanParam> stationRunLogTripNumberMap = simulation.getCtcRepository()
.getSimulationRunPlanEditAreaMap().getOrDefault(stationCode, new ConcurrentHashMap<>());
List<CtcRunPlanParam> removeParamList = stationRunLogTripNumberMap.values().stream()
.map(c -> CtcRunPlanParam.buildRemoveParam(c.getStationCode(), c.getTripNumber()))
.collect(Collectors.toList());
// 发送消息
ctcLogicLoop.sendCtcManageRemoveMessage(simulation, removeParamList, simulation.getSimulationUserIds());
} }
/** /**
@ -474,99 +460,68 @@ public class CtcStationRunPlanLogService {
* *
* @param original 原始参数 * @param original 原始参数
* @param modify 修改参数 * @param modify 修改参数
* @return 修改过的属性
*/ */
private CtcRunPlanParam modifyRunPlanParam(CtcRunPlanParam original, CtcRunPlanParam modify) { private void modifyRunPlanParam(CtcRunPlanParam original, CtcRunPlanParam modify) {
CtcRunPlanParam runPlanParam = new CtcRunPlanParam(); if (modify.getStationCode() != null
boolean change = false; && !Objects.equals(original.getStationCode(), modify.getStationCode())) {
if (!Objects.equals(original.getStationCode(), modify.getStationCode())) {
original.setStationCode(modify.getStationCode()); original.setStationCode(modify.getStationCode());
runPlanParam.setStationCode(modify.getStationCode());
change = true;
} }
if (!Objects.equals(original.getTripNumber(), modify.getTripNumber())) { if (modify.getTripNumber() != null
&& !Objects.equals(original.getTripNumber(), modify.getTripNumber())) {
original.setTripNumber(modify.getTripNumber()); original.setTripNumber(modify.getTripNumber());
runPlanParam.setTripNumber(modify.getTripNumber());
change = true;
} }
if (!Objects.equals(original.getTrackSectionCode(), modify.getTrackSectionCode())) { if (modify.getTrackSectionCode() != null
&& !Objects.equals(original.getTrackSectionCode(), modify.getTrackSectionCode())) {
original.setTrackSectionCode(modify.getTrackSectionCode()); original.setTrackSectionCode(modify.getTrackSectionCode());
runPlanParam.setTrackSectionCode(modify.getTrackSectionCode());
change = true;
} }
if (!Objects.equals(original.getArriveSectionCode(), modify.getArriveSectionCode())) { if (modify.getArriveSectionCode() != null
&& !Objects.equals(original.getArriveSectionCode(), modify.getArriveSectionCode())) {
original.setArriveSectionCode(modify.getArriveSectionCode()); original.setArriveSectionCode(modify.getArriveSectionCode());
runPlanParam.setArriveSectionCode(modify.getArriveSectionCode());
change = true;
} }
if (!Objects.equals(original.getDepartSectionCode(), modify.getDepartSectionCode())) { if (modify.getDepartSectionCode() != null
&& !Objects.equals(original.getDepartSectionCode(), modify.getDepartSectionCode())) {
original.setDepartSectionCode(modify.getDepartSectionCode()); original.setDepartSectionCode(modify.getDepartSectionCode());
runPlanParam.setDepartSectionCode(modify.getDepartSectionCode());
change = true;
} }
if (!Objects.equals(original.getArriveTime(), modify.getArriveTime())) { if (modify.getArriveTime() != null
&& !Objects.equals(original.getArriveTime(), modify.getArriveTime())) {
original.setArriveTime(modify.getArriveTime()); original.setArriveTime(modify.getArriveTime());
runPlanParam.setArriveTime(modify.getArriveTime());
change = true;
} }
if (!Objects.equals(original.getDepartTime(), modify.getDepartTime())) { if (modify.getDepartTime() != null
&& !Objects.equals(original.getDepartTime(), modify.getDepartTime())) {
original.setDepartTime(modify.getDepartTime()); original.setDepartTime(modify.getDepartTime());
runPlanParam.setDepartTime(modify.getDepartTime());
change = true;
} }
if (!Objects.equals(original.getArriveTripNumber(), modify.getArriveTripNumber())) { if (modify.getArriveTripNumber() != null
&& !Objects.equals(original.getArriveTripNumber(), modify.getArriveTripNumber())) {
original.setArriveTripNumber(modify.getArriveTripNumber()); original.setArriveTripNumber(modify.getArriveTripNumber());
runPlanParam.setArriveTripNumber(modify.getArriveTripNumber());
change = true;
} }
if (!Objects.equals(original.getDepartTripNumber(), modify.getDepartTripNumber())) { if (modify.getDepartTripNumber() != null
&& !Objects.equals(original.getDepartTripNumber(), modify.getDepartTripNumber())) {
original.setDepartTripNumber(modify.getDepartTripNumber()); original.setDepartTripNumber(modify.getDepartTripNumber());
runPlanParam.setDepartTripNumber(modify.getDepartTripNumber());
change = true;
} }
if (!Objects.equals(original.getArriveStationCode(), modify.getArriveStationCode())) { if (modify.getArriveStationCode() != null
&& !Objects.equals(original.getArriveStationCode(), modify.getArriveStationCode())) {
original.setArriveStationCode(modify.getArriveStationCode()); original.setArriveStationCode(modify.getArriveStationCode());
runPlanParam.setArriveStationCode(modify.getArriveStationCode());
change = true;
} }
if (!Objects.equals(original.getDepartStationCode(), modify.getDepartStationCode())) { if (modify.getDepartStationCode() != null
&& !Objects.equals(original.getDepartStationCode(), modify.getDepartStationCode())) {
original.setDepartStationCode(modify.getDepartStationCode()); original.setDepartStationCode(modify.getDepartStationCode());
runPlanParam.setDepartStationCode(modify.getDepartStationCode());
change = true;
} }
if (!Objects.equals(original.getArriveDirectionCode(), modify.getArriveDirectionCode())) { if (modify.getArriveDirectionCode() != null
&& !Objects.equals(original.getArriveDirectionCode(), modify.getArriveDirectionCode())) {
original.setArriveDirectionCode(modify.getArriveDirectionCode()); original.setArriveDirectionCode(modify.getArriveDirectionCode());
runPlanParam.setArriveDirectionCode(modify.getArriveDirectionCode());
change = true;
} }
if (!Objects.equals(original.getDepartDirectionCode(), modify.getDepartDirectionCode())) { if (modify.getDepartDirectionCode() != null
&& !Objects.equals(original.getDepartDirectionCode(), modify.getDepartDirectionCode())) {
original.setDepartDirectionCode(modify.getDepartDirectionCode()); original.setDepartDirectionCode(modify.getDepartDirectionCode());
runPlanParam.setDepartDirectionCode(modify.getDepartDirectionCode());
change = true;
} }
// 存在不一样的选项 // 存在不一样的选项
long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !original.getRunPlanTaskList().contains(task)).count(); long modifyNum = modify.getRunPlanTaskList().stream().filter(task -> !original.getRunPlanTaskList().contains(task)).count();
if (modifyNum > 0 || (original.getRunPlanTaskList().size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值 if (modifyNum > 0 || (original.getRunPlanTaskList().size() != modify.getRunPlanTaskList().size())) { // 长度不一致直接赋值
original.setRunPlanTaskList(modify.getRunPlanTaskList()); original.setRunPlanTaskList(modify.getRunPlanTaskList());
runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList());
change = true;
} else {
runPlanParam.setRunPlanTaskList(null);
}
if (!Objects.equals(original.getRunPlanTaskList(), modify.getRunPlanTaskList())) {
original.setRunPlanTaskList(modify.getRunPlanTaskList());
runPlanParam.setRunPlanTaskList(modify.getRunPlanTaskList());
change = true;
} }
if (!Objects.equals(original.getStatus(), modify.getStatus())) { if (!Objects.equals(original.getStatus(), modify.getStatus())) {
original.setStatus(modify.getStatus()); original.setStatus(modify.getStatus());
runPlanParam.setStatus(modify.getStatus()); }
change = true;
}
if (!change) {
runPlanParam = null;
}
return runPlanParam;
} }
} }

View File

@ -46,6 +46,9 @@ public class CTCLogicLoop {
// 发送运行计划变化消息 // 发送运行计划变化消息
sendRunPlanChangeMessage(simulation); sendRunPlanChangeMessage(simulation);
sendRunPlanRemoveMessage(simulation); sendRunPlanRemoveMessage(simulation);
// 发送车务管理端消息
sendCtcManageChangeMessage(simulation);
sendCtcManageRemoveMessage(simulation);
} }
public void sendAllMessage(Simulation simulation) { public void sendAllMessage(Simulation simulation) {
@ -269,52 +272,81 @@ public class CTCLogicLoop {
} }
/** /**
* @param simulation * @param simulation 仿真实体
* @param messageInfo * @param userIds 用户ID
* @param userIds
*/ */
public void initCtcManageMessage(Simulation simulation, List<CtcRunPlanParam> messageInfo, Set<String> userIds) { public void initCtcManageMessage(Simulation simulation, Set<String> userIds) {
if (!CollectionUtils.isEmpty(messageInfo)) { synchronized (this) {
sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds); Map<String, CtcRunPlanParam> editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap();
List<CtcRunPlanParam> allList = new ArrayList<>();
if (CollectionUtils.isEmpty(editAreaStatusVOMap)) {
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().forEach((k, v) -> {
v.values().stream().forEach(p -> {
String mapKey = p.getStationCode() + "_" + p.getRunPlanCode();
editAreaStatusVOMap.put(mapKey, p.clone());
allList.add(p);
});
});
} else {
allList.addAll(editAreaStatusVOMap.values());
}
if (!CollectionUtils.isEmpty(allList)) {
sendCtcMessage(simulation.getId(), allList, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT, userIds);
}
} }
} }
/** /**
* 发送管理端信息变更消息 * 发送管理端信息变更消息
* *
* @param simulation 仿真ID * @param simulation 仿真实体
* @param messageInfo 消息
* @param userIds 用户ID
*/ */
public void sendCtcManageChangeMessage(Simulation simulation, List<CtcRunPlanParam> messageInfo, Set<String> userIds) { public void sendCtcManageChangeMessage(Simulation simulation) {
if (messageInfo != null && !messageInfo.isEmpty()) { Map<String, CtcRunPlanParam> editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap();
sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, userIds); List<CtcRunPlanParam> allList = new ArrayList<>();
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().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_EDIT_CHANGE, simulation.getSimulationUserIds());
* @param simulation 仿真ID
* @param messageInfo 消息
* @param userIds 用户ID
*/
public void sendCtcManageCoverMessage(Simulation simulation, List<CtcRunPlanParam> messageInfo, Set<String> userIds) {
if (messageInfo != null && !messageInfo.isEmpty()) {
sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_COVER, userIds);
} }
} }
/** /**
* 发送管理端信息删除消息 * 发送管理端信息删除消息
* *
* @param simulation 仿真ID * @param simulation 仿真实体
* @param messageInfo 消息
* @param userIds 用户ID
*/ */
public void sendCtcManageRemoveMessage(Simulation simulation, List<CtcRunPlanParam> messageInfo, Set<String> userIds) { public void sendCtcManageRemoveMessage(Simulation simulation) {
Map<String, CtcRunPlanParam> editAreaStatusVOMap = simulation.getCtcRepository().getEditAreaStatusVOMap();
Map<String, Map<String, CtcRunPlanParam>> editeAreaMap = simulation.getCtcRepository().getSimulationRunPlanEditAreaMap();
List<CtcRunPlanParam> messageInfo = editAreaStatusVOMap.values().stream().filter(vo -> {
Map<String, CtcRunPlanParam> map = editeAreaMap.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 (messageInfo != null && !messageInfo.isEmpty()) { if (messageInfo != null && !messageInfo.isEmpty()) {
sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, userIds); sendCtcMessage(simulation.getId(), messageInfo, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_REMOVE, simulation.getSimulationUserIds());
} }
} }

View File

@ -77,10 +77,15 @@ public class CtcRepository {
private final Map<String, Map<String, CtcRunPlanParam>> simulationRunPlanEffectAreaMap = new ConcurrentHashMap<>(); private final Map<String, Map<String, CtcRunPlanParam>> simulationRunPlanEffectAreaMap = new ConcurrentHashMap<>();
/** /**
* 消息状态 * 运行日志消息状态
*/ */
private final Map<String, CtcRunPlanVO> runPlanStatusVOMap = new HashMap<>(); private final Map<String, CtcRunPlanVO> runPlanStatusVOMap = new HashMap<>();
/**
* 车务管理端运行计划状态
*/
private final Map<String, CtcRunPlanParam> editAreaStatusVOMap = new HashMap<>();
public void reset() { public void reset() {
routeSequenceMap.clear(); routeSequenceMap.clear();
@ -99,6 +104,7 @@ public class CtcRepository {
})); }));
// 运行计划状态清除 // 运行计划状态清除
this.runPlanStatusVOMap.clear(); this.runPlanStatusVOMap.clear();
this.editAreaStatusVOMap.clear();
} }
/** /**

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc.message;
import club.joylink.rtss.simulation.Simulation; import club.joylink.rtss.simulation.Simulation;
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm; import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
import club.joylink.rtss.simulation.cbtc.ATS.operation.vo.CtcRunPlanParam;
import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop; import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop;
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun; import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
import club.joylink.rtss.simulation.cbtc.data.status.DeviceStatus; import club.joylink.rtss.simulation.cbtc.data.status.DeviceStatus;
@ -26,7 +25,6 @@ import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils; import org.springframework.util.CollectionUtils;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.stream.Collectors; import java.util.stream.Collectors;
import java.util.stream.Stream; import java.util.stream.Stream;
@ -117,9 +115,7 @@ public class SimulationUserWsListener {
} }
case Ctc_Manager: { // CTC运行管理端 case Ctc_Manager: { // CTC运行管理端
// CTC管理端编辑区发送消息 // CTC管理端编辑区发送消息
List<CtcRunPlanParam> allList = new ArrayList<>(); ctcLogicLoop.initCtcManageMessage(simulation, Stream.of(userId).collect(Collectors.toSet()));
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().forEach((k, v) -> allList.addAll(v.values()));
ctcLogicLoop.initCtcManageMessage(simulation, allList, Stream.of(userId).collect(Collectors.toSet()));
break; break;
} }
} }

View File

@ -391,11 +391,6 @@ public enum WebSocketMessageType {
* 仿真编辑区运行计划变化 * 仿真编辑区运行计划变化
*/ */
SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE, SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_CHANGE,
/**
* 仿真编辑区运行计划覆盖
*/
SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_COVER,
/** ------------ CTC消息信息 ----------- */ /** ------------ CTC消息信息 ----------- */
; ;
} }

View File

@ -107,13 +107,13 @@ public class SocketMessageFactory {
break; break;
} }
case SIMULATION_CTC_RUN_PLAN_INIT: case SIMULATION_CTC_RUN_PLAN_INIT:
case SIMULATION_CTC_RUN_PLAN_CHANGE: { case SIMULATION_CTC_RUN_PLAN_CHANGE:
case SIMULATION_CTC_RUN_PLAN_REMOVE: {
topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group)); topicList.add(String.format(WebSocketSubscribeTopic.Simulation, group));
topicList.add(SimulationSubscribeTopic.Ctc.buildDestination(group)); topicList.add(SimulationSubscribeTopic.Ctc.buildDestination(group));
break; break;
} }
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT: case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_INIT:
case SIMULATION_CTC_MANAGER_RUN_PLAN_EDIT_COVER:
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: {
topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group)); topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group));