【群组发送消息】
This commit is contained in:
parent
c88ae2b17b
commit
1eb4e2c6cf
@ -210,13 +210,12 @@ public class ConversationGroupHandlerService {
|
|||||||
* @return 消息信息实体
|
* @return 消息信息实体
|
||||||
*/
|
*/
|
||||||
public ConversationGroupMessageVO audioChat(Simulation simulation, SimulationMember member, Long groupId, String audioPath, String content) {
|
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();
|
VoiceRecognitionResult recognitionResult = new VoiceRecognitionResult();
|
||||||
recognitionResult.setFilePath(audioPath);
|
recognitionResult.setFilePath(audioPath);
|
||||||
recognitionResult.setResult(content);
|
recognitionResult.setResult(content);
|
||||||
return recognitionResult;
|
return recognitionResult;
|
||||||
});
|
});
|
||||||
return new ConversationGroupMessageVO(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -229,12 +228,11 @@ public class ConversationGroupHandlerService {
|
|||||||
* @return 消息信息实体
|
* @return 消息信息实体
|
||||||
*/
|
*/
|
||||||
public ConversationGroupMessageVO textChat(Simulation simulation, SimulationMember member, Long groupId, String content) {
|
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();
|
VoiceRecognitionResult recognitionResult = new VoiceRecognitionResult();
|
||||||
recognitionResult.setResult(content);
|
recognitionResult.setResult(content);
|
||||||
return recognitionResult;
|
return recognitionResult;
|
||||||
});
|
});
|
||||||
return new ConversationGroupMessageVO(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -246,11 +244,10 @@ public class ConversationGroupHandlerService {
|
|||||||
* @return 消息信息实体
|
* @return 消息信息实体
|
||||||
*/
|
*/
|
||||||
public ConversationGroupMessageVO audioBase64(Simulation simulation, SimulationMember member, Long groupId, String fileBase64Str) {
|
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);
|
VoiceRecognitionVO vo = VoiceRecognitionVO.load(fileBase64Str);
|
||||||
return iVoiceService.voiceRecognition(vo);
|
return iVoiceService.voiceRecognition(vo);
|
||||||
});
|
});
|
||||||
return new ConversationGroupMessageVO(message);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -428,27 +425,27 @@ public class ConversationGroupHandlerService {
|
|||||||
* @param handleSupplier 处理消息方法
|
* @param handleSupplier 处理消息方法
|
||||||
* @return 用户组消息
|
* @return 用户组消息
|
||||||
*/
|
*/
|
||||||
private ConversationGroupMessage sendMessage(Simulation simulation, SimulationMember member, Long groupId
|
private ConversationGroupMessageVO sendMessage(Simulation simulation, SimulationMember member, Long groupId
|
||||||
, Supplier<VoiceRecognitionResult> handleSupplier) {
|
, Supplier<VoiceRecognitionResult> handleSupplier) {
|
||||||
ConversationGroup conversationGroup = checkGroupIdAndReturn(simulation, null, groupId);
|
ConversationGroup conversationGroup = checkGroupIdAndReturn(simulation, null, groupId);
|
||||||
if (!conversationGroup.isConversationMember(member)) {
|
if (!conversationGroup.isConversationMember(member)) {
|
||||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员,不能邀请用户");
|
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员");
|
||||||
}
|
}
|
||||||
|
|
||||||
VoiceRecognitionResult recognitionResult = handleSupplier.get();
|
VoiceRecognitionResult recognitionResult = handleSupplier.get();
|
||||||
String upperCaseResult = recognitionResult.getResult().toUpperCase();
|
String upperCaseResult = recognitionResult.getResult().toUpperCase();
|
||||||
String handledContent = simulationVoiceHandler.handle(upperCaseResult);
|
String handledContent = simulationVoiceHandler.handle(upperCaseResult);
|
||||||
|
|
||||||
// 创建消息信息
|
// 创建消息信息
|
||||||
String messageId = conversationGroup.generateMessageId();
|
String messageId = conversationGroup.generateMessageId();
|
||||||
ConversationGroupMessage message = new ConversationGroupMessage(messageId, member,
|
ConversationGroupMessage message = new ConversationGroupMessage(messageId, member,
|
||||||
simulation.getCorrectSystemTime(), handledContent, recognitionResult.getFilePath());
|
simulation.getCorrectSystemTime(), handledContent, recognitionResult.getFilePath());
|
||||||
conversationGroup.addMessage(message);
|
conversationGroup.addMessage(message);
|
||||||
// 发送消息
|
// 发送消息
|
||||||
|
ConversationGroupMessageVO messageVO = new ConversationGroupMessageVO(message);
|
||||||
|
Set<String> userIdSet = conversationGroup.getMemberUserId();
|
||||||
|
if (!CollectionUtils.isEmpty(userIdSet)) {
|
||||||
return message;
|
doSendMessage(simulation, userIdSet, ConversationGroupSocketMessageVO.MessageType.MESSAGE.generateMessageVO(conversationGroup, messageVO));
|
||||||
|
}
|
||||||
|
return messageVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
Loading…
Reference in New Issue
Block a user