Merge remote-tracking branch 'origin/test' into test
This commit is contained in:
commit
c7a7d7175f
@ -941,15 +941,19 @@ public class Operation {
|
||||
CTC_REMOVE_RUN_PLAN,
|
||||
|
||||
/**
|
||||
* 增加运行计划
|
||||
* 添加运行计划到编辑区
|
||||
*/
|
||||
CTC_ADD_RUN_PLAN,
|
||||
CTC_ADD_RUN_PLAN_LIST_TO_EDIT_AREA,
|
||||
|
||||
/**
|
||||
* 添加运行计划到编辑器
|
||||
* 删除编辑区中的运行计划
|
||||
*/
|
||||
CTC_ADD_RUN_PLAN_TO_EDIT_AREA,
|
||||
CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA,
|
||||
|
||||
/**
|
||||
* 导入覆盖运行计划到编辑区
|
||||
*/
|
||||
CTC_COVER_RUN_PLAN_LIST_TO_EDIT_AREA,
|
||||
/**
|
||||
* 将编辑区行车日志发布至仿真计划中
|
||||
*/
|
||||
|
@ -110,9 +110,9 @@ public class CtcStationRunPlanOperateHandler {
|
||||
* @param simulation 仿真实体
|
||||
* @param runPlanParamList 运行计划
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.CTC_ADD_RUN_PLAN_TO_EDIT_AREA)
|
||||
@OperateHandlerMapping(type = Operation.Type.CTC_ADD_RUN_PLAN_LIST_TO_EDIT_AREA)
|
||||
public void addRunPlanToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) {
|
||||
ctcStationRunPlanLogService.addRunPlanToEditArea(simulation, stationCode, runPlanParamList);
|
||||
ctcStationRunPlanLogService.addRunPlanListToEditArea(simulation, stationCode, runPlanParamList);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -125,4 +125,28 @@ public class CtcStationRunPlanOperateHandler {
|
||||
public void releaseRunPlanToSimulation(Simulation simulation, String stationCode) {
|
||||
ctcStationRunPlanLogService.releaseRunPlanToSimulation(simulation, stationCode);
|
||||
}
|
||||
|
||||
/**
|
||||
* 导入覆盖车站编辑区行车日志
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param runPlanParamList 运行计划列表
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.CTC_COVER_RUN_PLAN_LIST_TO_EDIT_AREA)
|
||||
public void coverRunPlanToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) {
|
||||
ctcStationRunPlanLogService.coverRunPlanToEditArea(simulation, stationCode, runPlanParamList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将车站编辑区中删除车次内容
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param tripNumberList 车次
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.CTC_REMOVE_RUN_PLAN_FROM_EDIT_AREA)
|
||||
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, List<String> tripNumberList) {
|
||||
ctcStationRunPlanLogService.removeRunPlanFromEditArea(simulation, stationCode, tripNumberList);
|
||||
}
|
||||
}
|
||||
|
@ -1,15 +1,18 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.service.runplan;
|
||||
|
||||
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.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.RouteSequence;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Section;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.Station;
|
||||
import club.joylink.rtss.simulation.cbtc.event.SimulationCtcRunPlanChangeEvent;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.util.RandomGenerator;
|
||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.websocket.StompMessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -23,6 +26,7 @@ import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Component
|
||||
@Slf4j
|
||||
@ -34,6 +38,9 @@ public class CtcStationRunPlanLogService {
|
||||
@Autowired
|
||||
private ApplicationContext applicationContext;
|
||||
|
||||
@Autowired
|
||||
private CTCLogicLoop ctcLogicLoop;
|
||||
|
||||
/**
|
||||
* 批量修改运行计划
|
||||
*
|
||||
@ -88,17 +95,18 @@ public class CtcStationRunPlanLogService {
|
||||
runPlanLogList.add(changeRunPlanLog);
|
||||
}
|
||||
});
|
||||
websocketMessageSend(simulation, runPlanLogList);
|
||||
sendRunPlanChangeMessage(simulation, runPlanLogList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 往编辑区添加运行计划
|
||||
* 批量往编辑区添加运行计划
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param runPlanParamList 运行计划列表
|
||||
*/
|
||||
public void addRunPlanToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) {
|
||||
public void addRunPlanListToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) {
|
||||
List<CtcStationRunPlanLog> runPlanLogList = new ArrayList<>(runPlanParamList.size());
|
||||
runPlanParamList.stream().forEach(p -> {
|
||||
CtcStationRunPlanLog changeRunPlanLog = null; // 要发的消息实体
|
||||
String tripNumber = StringUtils.isEmpty(p.getArriveTripNumber()) ? p.getDepartTripNumber() : p.getArriveTripNumber();
|
||||
@ -107,10 +115,50 @@ public class CtcStationRunPlanLogService {
|
||||
changeRunPlanLog = modifyRunPlanInfo(simulation, originRunPlanLog, p);
|
||||
} else {
|
||||
CtcStationRunPlanLog runPlanLog = createRunPlanLog(simulation, stationCode, p);
|
||||
runPlanLog.setOrigin(true);
|
||||
simulation.getCtcRepository().addRunPlanToEditArea(runPlanLog);
|
||||
changeRunPlanLog = runPlanLog;
|
||||
}
|
||||
if (changeRunPlanLog != null && !StringUtils.isEmpty(changeRunPlanLog.getCode())) {
|
||||
runPlanLogList.add(changeRunPlanLog);
|
||||
}
|
||||
});
|
||||
ctcLogicLoop.sendCtcRunPlanMessage(simulation.getId(), runPlanLogList, simulation.getSimulationUserIds()
|
||||
, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_CHANGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 覆盖编辑区中的运行计划
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param runPlanParamList 运行计划列表
|
||||
*/
|
||||
public void coverRunPlanToEditArea(Simulation simulation, String stationCode, List<CtcRunPlanParam> runPlanParamList) {
|
||||
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().remove(stationCode);
|
||||
List<CtcStationRunPlanLog> runPlanLogList = new ArrayList<>(runPlanParamList.size());
|
||||
runPlanParamList.stream().forEach(p -> {
|
||||
CtcStationRunPlanLog runPlanLog = createRunPlanLog(simulation, stationCode, p);
|
||||
runPlanLog.setOrigin(true);
|
||||
simulation.getCtcRepository().addRunPlanToEditArea(runPlanLog);
|
||||
runPlanLogList.add(runPlanLog);
|
||||
});
|
||||
ctcLogicLoop.sendCtcRunPlanMessage(simulation.getId(), runPlanLogList, simulation.getSimulationUserIds()
|
||||
, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_COVER);
|
||||
}
|
||||
|
||||
/**
|
||||
* 将车站编辑区中删除车次内容
|
||||
*
|
||||
* @param simulation 仿真实体
|
||||
* @param stationCode 车站编码
|
||||
* @param tripNumberList 车次
|
||||
*/
|
||||
public void removeRunPlanFromEditArea(Simulation simulation, String stationCode, List<String> tripNumberList) {
|
||||
tripNumberList.forEach(tripNumber -> simulation.getCtcRepository().removeRunPlanFromEditArea(stationCode, tripNumber));
|
||||
SocketMessageVO<List<String>> message =
|
||||
SocketMessageFactory.build(WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN_REMOVE, simulation.getId(), tripNumberList);
|
||||
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -121,6 +169,9 @@ public class CtcStationRunPlanLogService {
|
||||
*/
|
||||
public void releaseRunPlanToSimulation(Simulation simulation, String stationCode) {
|
||||
simulation.getCtcRepository().releaseEditAreaToSimulation(stationCode);
|
||||
List<CtcStationRunPlanLog> runPlanLogList = simulation.getCtcRepository().getOriginRunPlanMap()
|
||||
.get(stationCode).values().stream().collect(Collectors.toList());
|
||||
sendRunPlanChangeMessage(simulation, runPlanLogList);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -176,7 +227,7 @@ public class CtcStationRunPlanLogService {
|
||||
}
|
||||
}
|
||||
if (changeRunPlanLog.getArriveRunPlan() != null || changeRunPlanLog.getDepartRunPlan() != null) {
|
||||
websocketMessageSend(simulation, Arrays.asList(changeRunPlanLog));
|
||||
sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -213,7 +264,7 @@ public class CtcStationRunPlanLogService {
|
||||
}
|
||||
}
|
||||
if (changeRunPlanLog.getArriveRunPlan() != null || changeRunPlanLog.getDepartRunPlan() != null) {
|
||||
websocketMessageSend(simulation, Arrays.asList(changeRunPlanLog));
|
||||
sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -247,7 +298,7 @@ public class CtcStationRunPlanLogService {
|
||||
}
|
||||
}
|
||||
if (changeRunPlanLog.getArriveRunPlan() != null || changeRunPlanLog.getDepartRunPlan() != null) {
|
||||
websocketMessageSend(simulation, Arrays.asList(changeRunPlanLog));
|
||||
sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -284,7 +335,7 @@ public class CtcStationRunPlanLogService {
|
||||
}
|
||||
}
|
||||
if (changeRunPlanLog.getArriveRunPlan() != null || changeRunPlanLog.getDepartRunPlan() != null) {
|
||||
websocketMessageSend(simulation, Arrays.asList(changeRunPlanLog));
|
||||
sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -303,7 +354,7 @@ public class CtcStationRunPlanLogService {
|
||||
CtcStationRunPlanLog changeRunPlanLog = new CtcStationRunPlanLog();
|
||||
changeRunPlanLog.setCode(runPlanCode);
|
||||
changeRunPlanLog.setDelete(true);
|
||||
websocketMessageSend(simulation, Arrays.asList(changeRunPlanLog));
|
||||
sendRunPlanChangeMessage(simulation, Arrays.asList(changeRunPlanLog));
|
||||
}
|
||||
}
|
||||
|
||||
@ -354,7 +405,7 @@ public class CtcStationRunPlanLogService {
|
||||
// 实际时间
|
||||
LocalTime actualTime = arrive ? paramInfo.getArriveTime() : paramInfo.getDepartTime();
|
||||
if (actualTime != null) {
|
||||
change = actualTime.toString().equals(runPlanItem.getActualTime());
|
||||
change = !Objects.equals(actualTime.toString(), runPlanItem.getActualTime());
|
||||
if (change) {
|
||||
changeItem.setActualTime(actualTime.toString());
|
||||
}
|
||||
@ -364,7 +415,7 @@ public class CtcStationRunPlanLogService {
|
||||
String sectionCode = arrive ? paramInfo.getArriveSectionCode() : paramInfo.getDepartSectionCode();
|
||||
if (!StringUtils.isEmpty(sectionCode)) {
|
||||
Section section = simulation.getRepository().getByCode(sectionCode, Section.class);
|
||||
change = section.equals(runPlanItem.getTrackSection());
|
||||
change = !Objects.equals(section, runPlanItem.getTrackSection());
|
||||
if (change) {
|
||||
changeItem.setTrackSection(section);
|
||||
}
|
||||
@ -373,7 +424,7 @@ public class CtcStationRunPlanLogService {
|
||||
// 车次
|
||||
String tripNumber = arrive ? paramInfo.getArriveTripNumber() : paramInfo.getDepartTripNumber();
|
||||
if (!StringUtils.isEmpty(tripNumber)) {
|
||||
change = tripNumber.equals(runPlanItem.getTripNumber());
|
||||
change = !Objects.equals(tripNumber, runPlanItem.getTripNumber());
|
||||
if (change) {
|
||||
changeItem.setTripNumber(tripNumber);
|
||||
}
|
||||
@ -383,7 +434,7 @@ public class CtcStationRunPlanLogService {
|
||||
String stationCode = arrive ? paramInfo.getArriveStationCode() : paramInfo.getDepartStationCode();
|
||||
if (!StringUtils.isEmpty(stationCode)) {
|
||||
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
|
||||
change = station.equals(runPlanItem.getStation());
|
||||
change = !Objects.equals(station, runPlanItem.getStation());
|
||||
if (change) {
|
||||
changeItem.setStation(station);
|
||||
}
|
||||
@ -423,11 +474,10 @@ public class CtcStationRunPlanLogService {
|
||||
* @param simulation 仿真实体
|
||||
* @param ctcStationRunPlanLogList 信息变更的实体列表
|
||||
*/
|
||||
private void websocketMessageSend(Simulation simulation, List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
||||
private void sendRunPlanChangeMessage(Simulation simulation, List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
||||
if (!CollectionUtils.isEmpty(ctcStationRunPlanLogList)) {
|
||||
this.applicationContext.publishEvent(new SimulationCtcRunPlanChangeEvent(this, simulation
|
||||
, ctcStationRunPlanLogList));
|
||||
|
||||
ctcLogicLoop.sendCtcRunPlanMessage(simulation.getId(), ctcStationRunPlanLogList, simulation.getSimulationUserIds()
|
||||
, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_CHANGE);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -3,12 +3,20 @@ package club.joylink.rtss.simulation.cbtc.CTC;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.service.ars.AtsRouteSelectService;
|
||||
import club.joylink.rtss.simulation.cbtc.CI.CiApiService;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.ctc.CtcRunPlanVO;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.websocket.StompMessageService;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
|
||||
@Component
|
||||
public class CTCLogicLoop {
|
||||
public static final String LOGIC_NAME = "CTC"; //逻辑循环任务名称
|
||||
@ -50,4 +58,38 @@ public class CTCLogicLoop {
|
||||
simulation.addJob(LOGIC_NAME, () -> this.run(simulation), LOGIC_RATE);
|
||||
simulation.addFixedRateJob(MESSAGE_NAME, () -> this.sendMessage(simulation), MESSAGE_RATE);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送CTC运行计划消息,多用户
|
||||
*
|
||||
* @param simulationId 仿真ID
|
||||
* @param runPlanLogList 运行计划列表
|
||||
* @param userIds 用户ID列表
|
||||
* @param type 消息类型
|
||||
*/
|
||||
public void sendCtcRunPlanMessage(String simulationId, List<CtcStationRunPlanLog> runPlanLogList, Set<String> userIds
|
||||
, WebSocketMessageType type) {
|
||||
if (!runPlanLogList.isEmpty()) {
|
||||
SocketMessageVO<List<CtcRunPlanVO>> message =
|
||||
SocketMessageFactory.buildCtcRunPlanCommonMessage(simulationId, runPlanLogList, type);
|
||||
stompMessageService.sendToUser(userIds, message);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送CTC运行计划消息,单用户
|
||||
*
|
||||
* @param simulationId 仿真ID
|
||||
* @param runPlanLogList 运行计划列表
|
||||
* @param userId 用户ID
|
||||
* @param type 消息类型
|
||||
*/
|
||||
public void sendCtcRunPlanMessage(String simulationId, List<CtcStationRunPlanLog> runPlanLogList, String userId
|
||||
, WebSocketMessageType type) {
|
||||
if (!runPlanLogList.isEmpty()) {
|
||||
SocketMessageVO<List<CtcRunPlanVO>> message =
|
||||
SocketMessageFactory.buildCtcRunPlanCommonMessage(simulationId, runPlanLogList, type);
|
||||
stompMessageService.sendToUser(userId, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -153,6 +153,20 @@ public class CtcRepository {
|
||||
this.simulationRunPlanEditAreaMap.put(stationCode, stationRunLogTripNumberMap);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除编辑区中的车次内容
|
||||
*
|
||||
* @param stationCode 车站
|
||||
* @param tripNumber 车次
|
||||
*/
|
||||
public void removeRunPlanFromEditArea(String stationCode, String tripNumber) {
|
||||
Map<String, CtcStationRunPlanLog> stationRunLogTripNumberMap =
|
||||
this.simulationRunPlanEditAreaMap.getOrDefault(stationCode, new HashMap<>(64));
|
||||
if (stationRunLogTripNumberMap.containsKey(tripNumber)) {
|
||||
stationRunLogTripNumberMap.remove(tripNumber);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 从编辑区获取运行计划
|
||||
*
|
||||
@ -175,12 +189,12 @@ public class CtcRepository {
|
||||
// 车次添加至仿真中
|
||||
Map<String, CtcStationRunPlanLog> stationRunLogTripNumberMap =
|
||||
this.simulationRunPlanEditAreaMap.getOrDefault(stationCode, new HashMap<>(64));
|
||||
this.simulationRunPlanTripNumberMap.put(stationCode, stationRunLogTripNumberMap);
|
||||
this.originRunPlanTripNumberMap.put(stationCode, stationRunLogTripNumberMap);
|
||||
Map<String, CtcStationRunPlanLog> stationRunLogMap =
|
||||
stationRunLogTripNumberMap.values().stream().collect(Collectors.toMap(CtcStationRunPlanLog::getCode, r -> r));
|
||||
this.simulationRunPlanMap.put(stationCode, stationRunLogMap);
|
||||
this.originRunPlanMap.put(stationCode, stationRunLogMap);
|
||||
this.allRunPlanList = this.allRunPlanList.stream()
|
||||
.filter(runPlanLog -> !runPlanLog.getStation().getCode().equals(stationCode) && !runPlanLog.isOrigin())
|
||||
.filter(runPlanLog -> !runPlanLog.getStation().getCode().equals(stationCode) && runPlanLog.isOrigin())
|
||||
.collect(Collectors.toList());
|
||||
this.allRunPlanList.addAll(stationRunLogTripNumberMap.values());
|
||||
}
|
||||
|
@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc;
|
||||
|
||||
import club.joylink.rtss.event.OrderPaySuccessEvent;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.Conversation;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
|
||||
@ -19,7 +18,6 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
|
||||
import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO;
|
||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.ctc.CtcRunPlanVO;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.vo.client.psl.PslStatus;
|
||||
import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO;
|
||||
@ -435,26 +433,4 @@ public class SimulationMainThread {
|
||||
SocketMessageVO<RunPlanEChartsDataVO> message = SocketMessageFactory.buildTripPlanChangeMessage(event.getSimulation().getId(), event.getChangeTrips());
|
||||
this.stompMessageService.sendToUser(event.getSimulation().getSimulationUserIds(), message);
|
||||
}
|
||||
|
||||
@Async("nsExecutor")
|
||||
@EventListener
|
||||
public void handleCtcRunPlanInitEvent(SimulationCtcRunPlanEvent event) {
|
||||
Simulation simulation = event.getSimulation();
|
||||
List<CtcStationRunPlanLog> runPlanLogList = simulation.getCtcRepository().getAllRunPlanList();
|
||||
if (!runPlanLogList.isEmpty()) {
|
||||
SocketMessageVO<List<CtcRunPlanVO>> message =
|
||||
SocketMessageFactory.buildCtcRunPlanInitMessage(simulation.getId(), runPlanLogList);
|
||||
stompMessageService.sendToUser(event.getUserId(), message);
|
||||
}
|
||||
}
|
||||
|
||||
@EventListener
|
||||
public void handleCtcRunPlanChangeEvent(SimulationCtcRunPlanChangeEvent event) {
|
||||
Simulation simulation = event.getSimulation();
|
||||
if (!CollectionUtils.isEmpty(event.getCtcStationRunPlanLogList())) {
|
||||
SocketMessageVO<List<CtcRunPlanVO>> message =
|
||||
SocketMessageFactory.buildCtcRunPlanChangeMessage(simulation.getId(), event.getCtcStationRunPlanLogList());
|
||||
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,22 +0,0 @@
|
||||
package club.joylink.rtss.simulation.cbtc.event;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* CTC运行计划发生变化
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SimulationCtcRunPlanChangeEvent extends AbstractSimulationEvent {
|
||||
private List<CtcStationRunPlanLog> ctcStationRunPlanLogList;
|
||||
|
||||
public SimulationCtcRunPlanChangeEvent(Object source, Simulation simulation, List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
||||
super(source, simulation);
|
||||
this.ctcStationRunPlanLogList = ctcStationRunPlanLogList;
|
||||
}
|
||||
}
|
@ -1,19 +0,0 @@
|
||||
package club.joylink.rtss.simulation.cbtc.event;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import lombok.Getter;
|
||||
import lombok.Setter;
|
||||
|
||||
/**
|
||||
* 用户上线时发送CTC运行计划
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
public class SimulationCtcRunPlanEvent extends AbstractSimulationEvent {
|
||||
private String userId;
|
||||
|
||||
public SimulationCtcRunPlanEvent(Object source, Simulation simulation, String userId) {
|
||||
super(source, simulation);
|
||||
this.userId = userId;
|
||||
}
|
||||
}
|
@ -15,7 +15,8 @@ public enum SimulationSubscribeTopic {
|
||||
Drive("/queue/simulation/drive/{id}"),
|
||||
PassengerFlow("/queue/simulation/passenger/{id}"),
|
||||
WeChatMini("/topic/simulation/assistant/{id}"),
|
||||
Ctc("/queue/simulation/{id}/ctc") //大铁CTC
|
||||
Ctc("/queue/simulation/{id}/ctc"), //大铁CTC
|
||||
Ctc_Manager("/queue/simulation/ctc/manage/{id}") // 大铁CTC管理端
|
||||
;
|
||||
|
||||
private String destPattern;
|
||||
|
@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.message;
|
||||
import club.joylink.rtss.simulation.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.ATS.data.AtsAlarm;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop;
|
||||
import club.joylink.rtss.simulation.cbtc.CTC.data.CtcStationRunPlanLog;
|
||||
import club.joylink.rtss.simulation.cbtc.data.plan.RealRun;
|
||||
import club.joylink.rtss.simulation.cbtc.data.status.DeviceStatus;
|
||||
import club.joylink.rtss.simulation.cbtc.event.*;
|
||||
@ -25,6 +26,7 @@ import org.springframework.scheduling.annotation.Async;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -107,8 +109,17 @@ public class SimulationUserWsListener {
|
||||
}
|
||||
case Ctc: {
|
||||
// CTC运行日志发消息
|
||||
this.applicationContext.publishEvent(new SimulationCtcRunPlanEvent(this, simulation, userId));
|
||||
ctcLogicLoop.sendCtcRunPlanMessage(simulation.getId(), simulation.getCtcRepository().getAllRunPlanList()
|
||||
, userId, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_INIT);
|
||||
ctcLogicLoop.sendAllMessage(simulation);
|
||||
break;
|
||||
}
|
||||
case Ctc_Manager: { // CTC运行管理端
|
||||
// CTC管理端编辑区发送消息
|
||||
List<CtcStationRunPlanLog> allList = new ArrayList<>();
|
||||
simulation.getCtcRepository().getSimulationRunPlanEditAreaMap().forEach((k, v) -> allList.addAll(v.values()));
|
||||
ctcLogicLoop.sendCtcRunPlanMessage(simulation.getId(), allList, userId, WebSocketMessageType.SIMULATION_CTC_MANAGER_RUN_PLAN);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -361,6 +361,26 @@ public enum WebSocketMessageType {
|
||||
* 仿真CTC运行计划发生变化
|
||||
**/
|
||||
SIMULATION_CTC_RUN_PLAN_CHANGE,
|
||||
|
||||
/**
|
||||
* 仿真CTC管理端
|
||||
*/
|
||||
SIMULATION_CTC_MANAGER_RUN_PLAN,
|
||||
|
||||
/**
|
||||
* 仿真CTC管理端移除操作
|
||||
*/
|
||||
SIMULATION_CTC_MANAGER_RUN_PLAN_REMOVE,
|
||||
|
||||
/**
|
||||
* 仿真编辑区运行计划变化
|
||||
*/
|
||||
SIMULATION_CTC_MANAGER_RUN_PLAN_CHANGE,
|
||||
|
||||
/**
|
||||
* 仿真编辑区运行计划覆盖
|
||||
*/
|
||||
SIMULATION_CTC_MANAGER_RUN_PLAN_COVER,
|
||||
/** ------------ CTC消息信息 ------- */
|
||||
;
|
||||
}
|
||||
|
@ -112,6 +112,13 @@ public class SocketMessageFactory {
|
||||
topicList.add(SimulationSubscribeTopic.Ctc.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case SIMULATION_CTC_MANAGER_RUN_PLAN:
|
||||
case SIMULATION_CTC_MANAGER_RUN_PLAN_COVER:
|
||||
case SIMULATION_CTC_MANAGER_RUN_PLAN_CHANGE:
|
||||
case SIMULATION_CTC_MANAGER_RUN_PLAN_REMOVE: {
|
||||
topicList.add(SimulationSubscribeTopic.Ctc_Manager.buildDestination(group));
|
||||
break;
|
||||
}
|
||||
case Simulation_Member_Change:
|
||||
case Simulation_Start_Conversation:
|
||||
case Simulation_Accept_Conversation:
|
||||
@ -395,25 +402,13 @@ public class SocketMessageFactory {
|
||||
return build(WebSocketMessageType.Simulation_Trip_Plan_Change, simulationId, eChartsDataVO);
|
||||
}
|
||||
|
||||
/**
|
||||
* CTC 列车运行计划初始化消息
|
||||
*/
|
||||
public static SocketMessageVO<List<CtcRunPlanVO>> buildCtcRunPlanInitMessage(String simulationId, List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
||||
return buildCtcRunPlanCommonMessage(simulationId, ctcStationRunPlanLogList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_INIT);
|
||||
}
|
||||
|
||||
/**
|
||||
* CTC 列车运行计划变化消息
|
||||
*/
|
||||
public static SocketMessageVO<List<CtcRunPlanVO>> buildCtcRunPlanChangeMessage(String simulationId, List<CtcStationRunPlanLog> ctcStationRunPlanLogList) {
|
||||
return buildCtcRunPlanCommonMessage(simulationId, ctcStationRunPlanLogList, WebSocketMessageType.SIMULATION_CTC_RUN_PLAN_CHANGE);
|
||||
}
|
||||
|
||||
private static SocketMessageVO<List<CtcRunPlanVO>> buildCtcRunPlanCommonMessage(String simulationId, List<CtcStationRunPlanLog> ctcStationRunPlanLogList, WebSocketMessageType type) {
|
||||
public static SocketMessageVO<List<CtcRunPlanVO>> buildCtcRunPlanCommonMessage(String simulationId
|
||||
, List<CtcStationRunPlanLog> ctcStationRunPlanLogList, WebSocketMessageType type) {
|
||||
List<CtcRunPlanVO> ctcRunPlanVOList = ctcStationRunPlanLogList.stream()
|
||||
.map(ctcStationRunPlanLog -> new CtcRunPlanVO(ctcStationRunPlanLog))
|
||||
.collect(Collectors.toList());
|
||||
.map(ctcStationRunPlanLog -> new CtcRunPlanVO(ctcStationRunPlanLog)).collect(Collectors.toList());
|
||||
return build(type, simulationId, ctcRunPlanVOList);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user