From 9cbfb97d985aa0d9e1b73babd152c2c79fe96292 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 12 Aug 2022 13:53:33 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BC=9A=E8=AF=9D=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E4=B8=8A=E4=BC=A0=E5=90=8E=E5=A2=9E=E5=8A=A0=E8=BF=94=E5=9B=9E?= =?UTF-8?q?=E7=BB=93=E6=9E=9C=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../conversation/ConversationManagerService.java | 14 ++++++++------ .../conversation/ConversationOperateHandler.java | 16 ++++++++-------- 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationManagerService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationManagerService.java index bd58d8dad..5cb611e0d 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationManagerService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationManagerService.java @@ -391,31 +391,33 @@ public class ConversationManagerService { /** * 文件BASE64编码 */ - public void conversationChat(Simulation simulation, SimulationMember member, String fileBase64Str) { + public ConversationMessageVO conversationChat(Simulation simulation, SimulationMember member, String fileBase64Str) { VoiceRecognitionResult recognitionResult = iVoiceService.voiceRecognition(fileBase64Str); String upperCaseResult = recognitionResult.getResult().toUpperCase(); String handledContent = simulationVoiceHandler.handle(upperCaseResult); ConversationMessage conversationMessage = new ConversationMessage(simulation.getIdGenerator().nextConversationMessageId(), member, simulation.getCorrectSystemTime(), handledContent, recognitionResult.getFilePath()); - sendChatMessage(simulation.getId(), simulation.getSimulationUserIds(), conversationMessage); + return sendChatMessage(simulation.getId(), simulation.getSimulationUserIds(), conversationMessage); } /** * 会话操作 */ - public void conversationChat(Simulation simulation, SimulationMember member, String content, String audioPath) { + public ConversationMessageVO conversationChat(Simulation simulation, SimulationMember member, String content, String audioPath) { String path = audioPath; if (StringUtils.isEmpty(audioPath)) { path = iVoiceService.synthesis(content, "0"); } ConversationMessage conversationMessage = new ConversationMessage(simulation.getIdGenerator().nextConversationMessageId(), member, simulation.getCorrectSystemTime(), content, path); - sendChatMessage(simulation.getId(), simulation.getSimulationUserIds(), conversationMessage); + return sendChatMessage(simulation.getId(), simulation.getSimulationUserIds(), conversationMessage); } - private void sendChatMessage(String simulationId, Set userIds, ConversationMessage conversationMessage) { + private ConversationMessageVO sendChatMessage(String simulationId, Set userIds, ConversationMessage conversationMessage) { + ConversationMessageVO conversationMessageVO = new ConversationMessageVO(conversationMessage); SocketMessageVO chatMessage = - SocketMessageFactory.build(WebSocketMessageType.Simulation_Conversation_Operation, simulationId, new ConversationMessageVO(conversationMessage)); + SocketMessageFactory.build(WebSocketMessageType.Simulation_Conversation_Operation, simulationId, conversationMessageVO); stompMessageService.sendToUser(userIds, chatMessage); + return conversationMessageVO; } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationOperateHandler.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationOperateHandler.java index 9b1e720ae..463b6cb79 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationOperateHandler.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationOperateHandler.java @@ -4,6 +4,7 @@ import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandler; import club.joylink.rtss.simulation.cbtc.ATS.operation.annotation.OperateHandlerMapping; import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.data.vo.ConversationMessageVO; import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import lombok.extern.slf4j.Slf4j; @@ -68,24 +69,23 @@ public class ConversationOperateHandler { * 发送会话消息(语音输入) */ @OperateHandlerMapping(type = Operation.Type.Conversation_Chat_Audio) - public void audioChat(Simulation simulation, SimulationMember member, String audioPath, String content) { - conversationManagerService.conversationChat(simulation, member, content, audioPath); + public ConversationMessageVO audioChat(Simulation simulation, SimulationMember member, String audioPath, String content) { + return conversationManagerService.conversationChat(simulation, member, content, audioPath); } /** * 发送会话消息(文字输入) */ @OperateHandlerMapping(type = Operation.Type.Conversation_Chat_Text) - public void textChat(Simulation simulation, SimulationMember member, String content) { - conversationManagerService.conversationChat(simulation, member, content, null); + public ConversationMessageVO textChat(Simulation simulation, SimulationMember member, String content) { + return conversationManagerService.conversationChat(simulation, member, content, null); } - - + /** * 发送会话消息(语音输入)Base64格式 */ @OperateHandlerMapping(type = Operation.Type.Conversation_Chat_Audio_Base64) - public void audioBase64(Simulation simulation, SimulationMember member, String fileBase64Str) { - conversationManagerService.conversationChat(simulation, member, fileBase64Str); + public ConversationMessageVO audioBase64(Simulation simulation, SimulationMember member, String fileBase64Str) { + return conversationManagerService.conversationChat(simulation, member, fileBase64Str); } }