From 1eb4e2c6cf041e594f8b1100d6017b34cf4387a1 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Mon, 17 Apr 2023 16:58:12 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=BE=A4=E7=BB=84=E5=8F=91=E9=80=81?= =?UTF-8?q?=E6=B6=88=E6=81=AF=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConversationGroupHandlerService.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java index b90babcf1..a7623fe97 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java @@ -210,13 +210,12 @@ public class ConversationGroupHandlerService { * @return 消息信息实体 */ public ConversationGroupMessageVO audioChat(Simulation simulation, SimulationMember member, Long groupId, String audioPath, String content) { - ConversationGroupMessage message = sendMessage(simulation, member, groupId, () -> { + return sendMessage(simulation, member, groupId, () -> { VoiceRecognitionResult recognitionResult = new VoiceRecognitionResult(); recognitionResult.setFilePath(audioPath); recognitionResult.setResult(content); return recognitionResult; }); - return new ConversationGroupMessageVO(message); } /** @@ -229,12 +228,11 @@ public class ConversationGroupHandlerService { * @return 消息信息实体 */ public ConversationGroupMessageVO textChat(Simulation simulation, SimulationMember member, Long groupId, String content) { - ConversationGroupMessage message = sendMessage(simulation, member, groupId, () -> { + return sendMessage(simulation, member, groupId, () -> { VoiceRecognitionResult recognitionResult = new VoiceRecognitionResult(); recognitionResult.setResult(content); return recognitionResult; }); - return new ConversationGroupMessageVO(message); } /** @@ -246,11 +244,10 @@ public class ConversationGroupHandlerService { * @return 消息信息实体 */ public ConversationGroupMessageVO audioBase64(Simulation simulation, SimulationMember member, Long groupId, String fileBase64Str) { - ConversationGroupMessage message = sendMessage(simulation, member, groupId, () -> { + return sendMessage(simulation, member, groupId, () -> { VoiceRecognitionVO vo = VoiceRecognitionVO.load(fileBase64Str); return iVoiceService.voiceRecognition(vo); }); - return new ConversationGroupMessageVO(message); } /** @@ -428,27 +425,27 @@ public class ConversationGroupHandlerService { * @param handleSupplier 处理消息方法 * @return 用户组消息 */ - private ConversationGroupMessage sendMessage(Simulation simulation, SimulationMember member, Long groupId + private ConversationGroupMessageVO sendMessage(Simulation simulation, SimulationMember member, Long groupId , Supplier handleSupplier) { ConversationGroup conversationGroup = checkGroupIdAndReturn(simulation, null, groupId); if (!conversationGroup.isConversationMember(member)) { - throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员,不能邀请用户"); + throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员"); } - VoiceRecognitionResult recognitionResult = handleSupplier.get(); String upperCaseResult = recognitionResult.getResult().toUpperCase(); String handledContent = simulationVoiceHandler.handle(upperCaseResult); - // 创建消息信息 String messageId = conversationGroup.generateMessageId(); ConversationGroupMessage message = new ConversationGroupMessage(messageId, member, simulation.getCorrectSystemTime(), handledContent, recognitionResult.getFilePath()); conversationGroup.addMessage(message); // 发送消息 - - - - return message; + ConversationGroupMessageVO messageVO = new ConversationGroupMessageVO(message); + Set userIdSet = conversationGroup.getMemberUserId(); + if (!CollectionUtils.isEmpty(userIdSet)) { + doSendMessage(simulation, userIdSet, ConversationGroupSocketMessageVO.MessageType.MESSAGE.generateMessageVO(conversationGroup, messageVO)); + } + return messageVO; } /**