删除多余的仿真销毁消息

This commit is contained in:
joylink_zhangsai 2023-05-24 17:19:51 +08:00
parent 37e13abe47
commit 4f4377f3b8

View File

@ -8,7 +8,29 @@ import club.joylink.rtss.simulation.cbtc.data.vo.ConversationSocketMessageVO;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainIsAbout2ArriveVO;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.SimulationRealDeviceConnectManager;
import club.joylink.rtss.simulation.cbtc.event.*;
import club.joylink.rtss.simulation.cbtc.event.SimulationCompetitionPracticeFinishEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationConversationChatEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationConversationCreateEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationConversationExitEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationConversationInviteEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationConversationMemberConnectEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationErrorEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationIbpStatusEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationMemberAddEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationPauseEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationPslStatusEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationResetEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationResumeEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationRunPlanReloadEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationScenesReloadEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationScriptActionErrorEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationScriptActionFinishEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationScriptTipEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationTrainIsAbout2ArriveEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationTripPlanChangeEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationUserEnterEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationUserKickOutEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationUserPlayChangeEvent;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.script.ScriptActionBO;
@ -21,17 +43,16 @@ import club.joylink.rtss.vo.client.script.ScriptActionVO;
import club.joylink.rtss.vo.client.simulationv1.SimulationMemberMessageVO;
import club.joylink.rtss.vo.client.simulationv1.SimulationUserMessageVO;
import club.joylink.rtss.websocket.StompMessageService;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.context.event.EventListener;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Map;
import java.util.Set;
/**
* 仿真主线程
*/
@ -39,322 +60,342 @@ import java.util.Set;
@Slf4j
public class SimulationMainThread {
@Autowired
private GroupSimulationCache groupSimulationCache;
@Autowired
private StompMessageService stompMessageService;
@Autowired
private SimulationRealDeviceConnectManager simulationRealDeviceConnectManager;
@Autowired
private GroupSimulationCache groupSimulationCache;
@Autowired
private StompMessageService stompMessageService;
@Autowired
private SimulationRealDeviceConnectManager simulationRealDeviceConnectManager;
@Scheduled(fixedRate = 1000)
public void updatePlcGatewayOnlineStatus() {
Map<String, Simulation> groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap();
for (Simulation simulation : groupSimulationMap.values()) {
this.simulationRealDeviceConnectManager.updatePlcGatewayOnlineStatus(simulation);
}
@Scheduled(fixedRate = 1000)
public void updatePlcGatewayOnlineStatus() {
Map<String, Simulation> groupSimulationMap = this.groupSimulationCache.getGroupSimulationMap();
for (Simulation simulation : groupSimulationMap.values()) {
this.simulationRealDeviceConnectManager.updatePlcGatewayOnlineStatus(simulation);
}
}
@EventListener
public void userPlayChangeNotify(SimulationUserPlayChangeEvent event) {
Simulation simulation = event.getSimulation();
SimulationUser simulationUser = event.getSimulationUser();
log.info(String.format("仿真[%s]用户[%s]扮演角色变更事件通知,当前扮演[%s]",
simulationUser.getUser().getId(), simulation.getId(),
simulationUser.getPlayedMember()));
Set<String> userIds = simulation.getSimulationUserIds();
SocketMessageVO<SimulationUserMessageVO> playChangeMessage = SocketMessageFactory
.buildSimulationUserPlayChangeMessage(simulation, simulationUser);
this.stompMessageService.sendToUser(userIds, playChangeMessage);
}
@EventListener
public void userPlayChangeNotify(SimulationUserPlayChangeEvent event) {
Simulation simulation = event.getSimulation();
SimulationUser simulationUser = event.getSimulationUser();
log.info(String.format("仿真[%s]用户[%s]扮演角色变更事件通知,当前扮演[%s]",
simulationUser.getUser().getId(), simulation.getId(),
simulationUser.getPlayedMember()));
Set<String> userIds = simulation.getSimulationUserIds();
SocketMessageVO<SimulationUserMessageVO> playChangeMessage = SocketMessageFactory
.buildSimulationUserPlayChangeMessage(simulation, simulationUser);
this.stompMessageService.sendToUser(userIds, playChangeMessage);
}
@EventListener
public void userEnterNotify(SimulationUserEnterEvent event) {
Simulation simulation = event.getSimulation();
SimulationUser simulationUser = event.getSimulationUser();
log.info(String.format("用户[%s]进入综合演练仿真[%s]成为仿真成员事件通知",
simulationUser.getUser().getId(), simulation.getId()));
Set<String> userIds = simulation.getSimulationUserIds();
@EventListener
public void userEnterNotify(SimulationUserEnterEvent event) {
Simulation simulation = event.getSimulation();
SimulationUser simulationUser = event.getSimulationUser();
log.info(String.format("用户[%s]进入综合演练仿真[%s]成为仿真成员事件通知",
simulationUser.getUser().getId(), simulation.getId()));
Set<String> userIds = simulation.getSimulationUserIds();
// SocketMessageVO<SimulationVO> inviteMessage = SocketMessageFactory.buildSimulationInviteMessage(simulation);
// this.stompMessageService.sendToUser(simulationUser.getUser().getId().toString(), inviteMessage);
SocketMessageVO<SimulationUserMessageVO> message = SocketMessageFactory
.buildSimulationUserEnterMessage(simulation, simulationUser);
this.stompMessageService.sendToUser(userIds, message);
}
SocketMessageVO<SimulationUserMessageVO> message = SocketMessageFactory
.buildSimulationUserEnterMessage(simulation, simulationUser);
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void kickOutUserNotify(SimulationUserKickOutEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("综合演练仿真[%s]踢出用户[%s]事件通知",
simulation.getId(), event.getSimulationUser().getUser().getId()));
Set<String> userIds = simulation.getSimulationUserIds();
userIds.add(event.getSimulationUser().getUser().getId().toString());
SocketMessageVO<SimulationUserMessageVO> message = SocketMessageFactory
.buildSimulationUserKickOutMessage(simulation, event.getSimulationUser());
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void kickOutUserNotify(SimulationUserKickOutEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("综合演练仿真[%s]踢出用户[%s]事件通知",
simulation.getId(), event.getSimulationUser().getUser().getId()));
Set<String> userIds = simulation.getSimulationUserIds();
userIds.add(event.getSimulationUser().getUser().getId().toString());
SocketMessageVO<SimulationUserMessageVO> message = SocketMessageFactory
.buildSimulationUserKickOutMessage(simulation, event.getSimulationUser());
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void simulationMemberAdd(SimulationMemberAddEvent event) {
Simulation simulation = event.getSimulation();
SimulationMember member = event.getMember();
log.info(String.format("仿真[%s]添加仿真成员[%s]消息通知",
simulation.getId(), member));
Set<String> userIds = simulation.getSimulationUserIds();
SocketMessageVO<SimulationMemberMessageVO> message = SocketMessageFactory
.buildSimulationMemberAddMessage(simulation, member);
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void simulationMemberAdd(SimulationMemberAddEvent event) {
Simulation simulation = event.getSimulation();
SimulationMember member = event.getMember();
log.info(String.format("仿真[%s]添加仿真成员[%s]消息通知",
simulation.getId(), member));
Set<String> userIds = simulation.getSimulationUserIds();
SocketMessageVO<SimulationMemberMessageVO> message = SocketMessageFactory
.buildSimulationMemberAddMessage(simulation, member);
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void conversationCreate(SimulationConversationCreateEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
log.info(String.format("仿真[%s]会话[%s]创建消息发送",
simulation.getId(), conversation.getId()));
Set<String> userIds = simulation.getSimulationUserIds();
SocketMessageVO<ConversationSocketMessageVO> createMessage = SocketMessageFactory.buildSimulationConversationCreateMessage(simulation, conversation);
this.stompMessageService.sendToUser(userIds, createMessage);
}
@EventListener
public void conversationCreate(SimulationConversationCreateEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
log.info(String.format("仿真[%s]会话[%s]创建消息发送",
simulation.getId(), conversation.getId()));
Set<String> userIds = simulation.getSimulationUserIds();
SocketMessageVO<ConversationSocketMessageVO> createMessage = SocketMessageFactory.buildSimulationConversationCreateMessage(
simulation, conversation);
this.stompMessageService.sendToUser(userIds, createMessage);
}
@EventListener
public void conversationInvite(SimulationConversationInviteEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
SimulationMember member = event.getMember();
log.info(String.format("仿真[%s]会话[%s]邀请消息发送",
simulation.getId(), conversation.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory.buildSimulationConversationInviteMessage(simulation, conversation, member);
this.stompMessageService.sendToUser(member.getUserId(), message);
}
@EventListener
public void conversationInvite(SimulationConversationInviteEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
SimulationMember member = event.getMember();
log.info(String.format("仿真[%s]会话[%s]邀请消息发送",
simulation.getId(), conversation.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory.buildSimulationConversationInviteMessage(
simulation, conversation, member);
this.stompMessageService.sendToUser(member.getUserId(), message);
}
@EventListener
public void memberConnectConversation(SimulationConversationMemberConnectEvent event) {
Simulation simulation = event.getSimulation();
SimulationMember member = event.getMember();
Conversation conversation = event.getConversation();
log.info(String.format("仿真[%s]会话[%s]成员[%s]接受邀请进入会话消息发送",
simulation.getId(), conversation.getId(), member.toString()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationMemberConnectConversationMessage(simulation, conversation, member);
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void memberConnectConversation(SimulationConversationMemberConnectEvent event) {
Simulation simulation = event.getSimulation();
SimulationMember member = event.getMember();
Conversation conversation = event.getConversation();
log.info(String.format("仿真[%s]会话[%s]成员[%s]接受邀请进入会话消息发送",
simulation.getId(), conversation.getId(), member.toString()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationMemberConnectConversationMessage(simulation, conversation, member);
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener(SimulationConversationChatEvent.class)
public void conversationChat(SimulationConversationChatEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
ConversationMessage conversationMessage = event.getConversationMessage();
log.info(String.format("仿真[%s]会话[%s]会话消息发送",
simulation.getId(), conversation.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationConversationChatMessage(simulation, conversation, conversationMessage);
if (conversation.hasOtherMemberConnect()) {
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message);
return;
}
this.stompMessageService.sendToUser(String.valueOf(conversationMessage.getMember().getUserId()), message);
@EventListener(SimulationConversationChatEvent.class)
public void conversationChat(SimulationConversationChatEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
ConversationMessage conversationMessage = event.getConversationMessage();
log.info(String.format("仿真[%s]会话[%s]会话消息发送",
simulation.getId(), conversation.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationConversationChatMessage(simulation, conversation, conversationMessage);
if (conversation.hasOtherMemberConnect()) {
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message);
return;
}
this.stompMessageService.sendToUser(String.valueOf(conversationMessage.getMember().getUserId()),
message);
}
@EventListener
public void conversationExit(SimulationConversationExitEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
SimulationMember member = event.getMember();
log.info(String.format("仿真[%s]会话[%s]成员[%s]退出消息发送",
simulation.getId(), conversation.getId(), member.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationConversationExitMessage(simulation, conversation, member);
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message);
}
@EventListener
public void conversationExit(SimulationConversationExitEvent event) {
Simulation simulation = event.getSimulation();
Conversation conversation = event.getConversation();
SimulationMember member = event.getMember();
log.info(String.format("仿真[%s]会话[%s]成员[%s]退出消息发送",
simulation.getId(), conversation.getId(), member.getId()));
SocketMessageVO<ConversationSocketMessageVO> message = SocketMessageFactory
.buildSimulationConversationExitMessage(simulation, conversation, member);
Set<String> userIds = simulation.getSimulationUserIds();
this.stompMessageService.sendToUser(userIds, message);
}
/**
* 仿真暂停消息通知
*/
@EventListener
public void simulationPause(SimulationPauseEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]暂停", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Control_Pause,
simulation.getId(), true);
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真暂停消息通知
*/
@EventListener
public void simulationPause(SimulationPauseEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]暂停", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Control_Pause,
simulation.getId(), true);
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真恢复运行消息通知
*
* @param event
*/
@EventListener
public void simulationResume(SimulationResumeEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]恢复运行", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Control_Pause,
simulation.getId(), false);
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真恢复运行消息通知
*
* @param event
*/
@EventListener
public void simulationResume(SimulationResumeEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]恢复运行", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Control_Pause,
simulation.getId(), false);
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真重置消息通知
*
* @param event
*/
@EventListener
public void simulationReset(SimulationResetEvent event) {
Simulation simulation = event.getSimulation();
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Reset,
simulation.getId(), true);
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真重置消息通知
*
* @param event
*/
@EventListener
public void simulationReset(SimulationResetEvent event) {
Simulation simulation = event.getSimulation();
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Reset,
simulation.getId(), true);
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真运行计划重置消息通知
*/
@EventListener
public void simulationRunPlanReload(SimulationRunPlanReloadEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]加载新的运行计划", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Run_Plan_Reload,
simulation.getId(), "1");
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真运行计划重置消息通知
*/
@EventListener
public void simulationRunPlanReload(SimulationRunPlanReloadEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]加载新的运行计划", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Run_Plan_Reload,
simulation.getId(), "1");
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真背景重新加载
*/
@EventListener
public void simulationScenesReload(SimulationScenesReloadEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]背景重新加载", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.buildSimulationScenesReload(simulation.getId(), simulation.isPlanRunning());
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真背景重新加载
*/
@EventListener
public void simulationScenesReload(SimulationScenesReloadEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]背景重新加载", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<Boolean> message = SocketMessageFactory.buildSimulationScenesReload(
simulation.getId(), simulation.isPlanRunning());
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真运行异常消息通知
*
* @param event
*/
@EventListener
public void simulationError(SimulationErrorEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]运行异常, 时间 [%s]", simulation.getId(), simulation.getCorrectSystemTime().format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss"))));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<String> message = SocketMessageFactory.build(WebSocketMessageType.Simulation_Error,
simulation.getId(), "");
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真运行异常消息通知
*
* @param event
*/
@EventListener
public void simulationError(SimulationErrorEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]运行异常, 时间 [%s]", simulation.getId(),
simulation.getCorrectSystemTime()
.format(DateTimeFormatter.ofPattern("yyyy-mm-dd hh:mm:ss"))));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Error,
simulation.getId(), "");
this.stompMessageService.sendToUser(users, message);
}
/**
* 仿真销毁消息通知
*
* @param event
*/
@EventListener
public void simulationDestroy(SimulationDestroyEvent event) {
Simulation simulation = event.getSimulation();
log.info(String.format("仿真[%s]销毁", simulation.getId()));
Set<String> users = simulation.getSimulationUserIds();
SocketMessageVO<String> message = SocketMessageFactory.build(
WebSocketMessageType.Simulation_Over,
simulation.getId(), "");
this.stompMessageService.sendToUser(users, message);
}
// /**
// * 仿真销毁消息通知
// *
// * @param event
// */
// @EventListener
// public void simulationDestroy(SimulationDestroyEvent event) {
// Simulation simulation = event.getSimulation();
// log.info(String.format("仿真[%s]销毁", simulation.getId()));
// Set<String> users = simulation.getSimulationUserIds();
// SocketMessageVO<String> message = SocketMessageFactory.build(
// WebSocketMessageType.Simulation_Over,
// simulation.getId(), "");
// this.stompMessageService.sendToUser(users, message);
// }
/**
* 仿真剧本提示
*/
@EventListener
public void simulationScriptTip(SimulationScriptTipEvent event) {
Simulation simulation = event.getSimulation();
ScriptActionBO action = event.getAction();
ScriptActionVO actionVO = ScriptActionVO.buildScriptTipVO(action);
if (actionVO.getType().equals(ScriptActionBO.ActionType.Conversation)) {
LocalDateTime correctSystemTime = simulation.getCorrectSystemTime();
String currentTime = correctSystemTime.getHour() + "" + correctSystemTime.getMinute() + "";
actionVO.setContent(String.format(actionVO.getContent(), currentTime));
}
SocketMessageVO<ScriptActionVO> message =
SocketMessageFactory.buildScriptTipMessage(simulation.getId(), actionVO);
stompMessageService.sendToUser(action.getMember().getUserId(), message);
log.info(String.format("仿真[%s]剧本提示成员[%s]执行动作[%s]", simulation.getId(), action.getMember().getId(), action.getId()));
/**
* 仿真剧本提示
*/
@EventListener
public void simulationScriptTip(SimulationScriptTipEvent event) {
Simulation simulation = event.getSimulation();
ScriptActionBO action = event.getAction();
ScriptActionVO actionVO = ScriptActionVO.buildScriptTipVO(action);
if (actionVO.getType().equals(ScriptActionBO.ActionType.Conversation)) {
LocalDateTime correctSystemTime = simulation.getCorrectSystemTime();
String currentTime = correctSystemTime.getHour() + "" + correctSystemTime.getMinute() + "";
actionVO.setContent(String.format(actionVO.getContent(), currentTime));
}
SocketMessageVO<ScriptActionVO> message =
SocketMessageFactory.buildScriptTipMessage(simulation.getId(), actionVO);
stompMessageService.sendToUser(action.getMember().getUserId(), message);
log.info(
String.format("仿真[%s]剧本提示成员[%s]执行动作[%s]", simulation.getId(), action.getMember().getId(),
action.getId()));
}
@EventListener
public void SimulationScriptFinish(SimulationCompetitionPracticeFinishEvent event) {
Simulation simulation = event.getSimulation();
SocketMessageVO<Boolean> message = SocketMessageFactory.buildCompetitionPracticeFinishMessage(simulation.getId());
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
log.info(String.format("仿真[%s]竞赛实操[%s]演出完成", simulation.getId(), simulation.getScript().getId()));
}
@EventListener
public void SimulationScriptFinish(SimulationCompetitionPracticeFinishEvent event) {
Simulation simulation = event.getSimulation();
SocketMessageVO<Boolean> message = SocketMessageFactory.buildCompetitionPracticeFinishMessage(
simulation.getId());
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
log.info(
String.format("仿真[%s]竞赛实操[%s]演出完成", simulation.getId(), simulation.getScript().getId()));
}
@EventListener
public void simulationScriptActionFinish(SimulationScriptActionFinishEvent event) {
Simulation simulation = event.getSimulation();
ScriptActionBO action = event.getScriptActionBO();
ScriptActionVO vo = ScriptActionVO.buildFinishTipVO(action);
SocketMessageVO<ScriptActionVO> message =
SocketMessageFactory.buildSimulationScriptActionFinishMessage(simulation.getId(), vo);
stompMessageService.sendToUser(action.getMember().getUserId(), message);
log.info(String.format("用户[%s]完成仿真[%s]id为[%s]的剧本动作", simulation.getId(), action.getMember().getUserId(), action.getId()));
}
@EventListener
public void simulationScriptActionFinish(SimulationScriptActionFinishEvent event) {
Simulation simulation = event.getSimulation();
ScriptActionBO action = event.getScriptActionBO();
ScriptActionVO vo = ScriptActionVO.buildFinishTipVO(action);
SocketMessageVO<ScriptActionVO> message =
SocketMessageFactory.buildSimulationScriptActionFinishMessage(simulation.getId(), vo);
stompMessageService.sendToUser(action.getMember().getUserId(), message);
log.info(String.format("用户[%s]完成仿真[%s]id为[%s]的剧本动作", simulation.getId(),
action.getMember().getUserId(), action.getId()));
}
@EventListener
public void simulationTrainIsAboutArrive(SimulationTrainIsAbout2ArriveEvent event) {
Simulation simulation = event.getSimulation();
VirtualRealityTrain train = event.getTrain();
if (train.getNextStation() != null) {
TrainIsAbout2ArriveVO arriveVO = new TrainIsAbout2ArriveVO(train.getGroupNumber(), train.getNextStation().getCode());
SocketMessageVO<TrainIsAbout2ArriveVO> message =
SocketMessageFactory.buildTrainIsAbout2ArriveMessage(simulation.getId(), arriveVO);
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
log.info("列车[{}]即将进站", train.getGroupNumber());
}
@EventListener
public void simulationTrainIsAboutArrive(SimulationTrainIsAbout2ArriveEvent event) {
Simulation simulation = event.getSimulation();
VirtualRealityTrain train = event.getTrain();
if (train.getNextStation() != null) {
TrainIsAbout2ArriveVO arriveVO = new TrainIsAbout2ArriveVO(train.getGroupNumber(),
train.getNextStation().getCode());
SocketMessageVO<TrainIsAbout2ArriveVO> message =
SocketMessageFactory.buildTrainIsAbout2ArriveMessage(simulation.getId(), arriveVO);
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
log.info("列车[{}]即将进站", train.getGroupNumber());
}
}
@EventListener
public void simulationScriptActionError(SimulationScriptActionErrorEvent event) {
Simulation simulation = event.getSimulation();
ScriptActionBO action = event.getScriptActionBO();
SocketMessageVO<String> message =
SocketMessageFactory.buildSimulationScriptActionErrorMessage(simulation.getId(), action.getId());
stompMessageService.sendToUser(action.getMember().getUserId(), message);
}
@EventListener
public void simulationScriptActionError(SimulationScriptActionErrorEvent event) {
Simulation simulation = event.getSimulation();
ScriptActionBO action = event.getScriptActionBO();
SocketMessageVO<String> message =
SocketMessageFactory.buildSimulationScriptActionErrorMessage(simulation.getId(),
action.getId());
stompMessageService.sendToUser(action.getMember().getUserId(), message);
}
@EventListener
public void simulationIbpStatus(SimulationIbpStatusEvent event) {
Simulation simulation = event.getSimulation();
SocketMessageVO<Map<String, IbpStatus>> message =
SocketMessageFactory.buildSimulationIbpStatusMessage(simulation.getId(), event.getStatusMap());
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
@EventListener
public void simulationIbpStatus(SimulationIbpStatusEvent event) {
Simulation simulation = event.getSimulation();
SocketMessageVO<Map<String, IbpStatus>> message =
SocketMessageFactory.buildSimulationIbpStatusMessage(simulation.getId(),
event.getStatusMap());
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
@EventListener
public void simulationPslStatus(SimulationPslStatusEvent event) {
Simulation simulation = event.getSimulation();
SocketMessageVO<Map<String, PslStatus>> message =
SocketMessageFactory.buildSimulationPslStatusMessage(simulation.getId(), event.getStatusMap());
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
@EventListener
public void simulationPslStatus(SimulationPslStatusEvent event) {
Simulation simulation = event.getSimulation();
SocketMessageVO<Map<String, PslStatus>> message =
SocketMessageFactory.buildSimulationPslStatusMessage(simulation.getId(),
event.getStatusMap());
stompMessageService.sendToUser(simulation.getSimulationUserIds(), message);
}
@EventListener
public void handleDeviceFaultOverEvent(OrderPaySuccessEvent event) {
SocketMessageVO<String> message = SocketMessageFactory.buildOrderPaySuccessMessage(event.getOrderCode());
this.stompMessageService.sendToUser(event.getUserId(), message);
}
@EventListener
public void handleDeviceFaultOverEvent(OrderPaySuccessEvent event) {
SocketMessageVO<String> message = SocketMessageFactory.buildOrderPaySuccessMessage(
event.getOrderCode());
this.stompMessageService.sendToUser(event.getUserId(), message);
}
@EventListener
public void handleTripPlanChangeEvent(SimulationTripPlanChangeEvent event) {
SocketMessageVO<RunPlanEChartsDataVO> message = SocketMessageFactory.buildTripPlanChangeMessage(event.getSimulation().getId(), event.getChangeTrips());
this.stompMessageService.sendToUser(event.getSimulation().getSimulationUserIds(), message);
}
@EventListener
public void handleTripPlanChangeEvent(SimulationTripPlanChangeEvent event) {
SocketMessageVO<RunPlanEChartsDataVO> message = SocketMessageFactory.buildTripPlanChangeMessage(
event.getSimulation().getId(), event.getChangeTrips());
this.stompMessageService.sendToUser(event.getSimulation().getSimulationUserIds(), message);
}
}