diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java index ba5b9487f..e54d3e08a 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationTrainingV2Controller.java @@ -109,4 +109,14 @@ public class SimulationTrainingV2Controller { public void jumpToStep(@PathVariable String group, @PathVariable Long stepId){ training2Service.jumpToStep(group, stepId); } + + /** + * 实训开始准备,给实训参与人员发送准备开始执行 + * @param group 仿真ID + * @param user 操作人 + */ + @PostMapping("/{group}/prepare/start") + public void prepareStart(@PathVariable String group, @RequestAttribute AccountVO user) { + training2Service.prepareStart(group, user); + } } diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index 2d686062b..24512741d 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -4,6 +4,7 @@ import club.joylink.rtss.dao.DraftTraining2DAO; import club.joylink.rtss.dao.PublishedTraining2DAO; import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs; import club.joylink.rtss.entity.training2.PublishedTraining2WithBLOBs; +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.training2.index.IndexAlgorithmService; import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher; @@ -557,6 +558,21 @@ public class Training2Service { } } + /** + * 实训准备开始 + * @param group 仿真号 + * @param user 操作人 + */ + public void prepareStart(String group, AccountVO user) { + Simulation simulation = groupSimulationCache.getSimulationByGroup(group); + BusinessExceptionAssertEnum.DATA_ERROR.assertTrue(simulation.getTraining2() != null, "未加载实训"); + SocketMessageVO message = SocketMessageFactory.build( + WebSocketMessageType.Simulation_Training_Prepare_Start, simulation.getId(), simulation.getTraining2().getId()); + Set userIdSet = simulation.getSimulationUserIds().stream() + .filter(id -> !Objects.equals(id, user.getId().toString())).collect(Collectors.toSet()); + stompMessageService.sendToUser(userIdSet, message); + } + /** * 实训时创建仿真对象 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java index a52b2aee1..9231d46c9 100644 --- a/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java +++ b/src/main/java/club/joylink/rtss/vo/client/WebSocketMessageType.java @@ -377,6 +377,10 @@ public enum WebSocketMessageType { /** * ------------ 新实训消息 ----------- */ + /** + * 实训准备开始,其他成员加载实训内容消息 + */ + Simulation_Training_Prepare_Start, /** * 步骤开始时提示信息 */ diff --git a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java index 4410b690a..b280d66ac 100644 --- a/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java +++ b/src/main/java/club/joylink/rtss/vo/client/factory/SocketMessageFactory.java @@ -155,6 +155,7 @@ public class SocketMessageFactory { break; } // 20220819 + case Simulation_Training_Prepare_Start: case Simulation_Training_Step_Tip: case Simulation_Training_Step_Finish: case Simulation_Training_Audio_MATCH_RESULT: