【批量处理机器人已读操作】
This commit is contained in:
parent
a26d883e99
commit
a9559e2455
@ -282,6 +282,34 @@ public class ConversationGroupHandlerService {
|
||||
return ConversationGroupMessageVO.convert2VO(messageList);
|
||||
}
|
||||
|
||||
/**
|
||||
* 机器人批量已读信息
|
||||
* @param simulation 仿真
|
||||
* @param memberList 成员列表
|
||||
* @param id 用户群组ID
|
||||
*/
|
||||
public void robotBatchRead(Simulation simulation, List<SimulationMember> memberList, Long id) {
|
||||
// 查找群组
|
||||
ConversationGroup conversationGroup = simulation.getConversationGroup(id);
|
||||
Set<String> robotMemberIds = memberList.stream().map(SimulationMember::getId).collect(Collectors.toSet());
|
||||
Set<String> allMemberIds = conversationGroup.getMemberList().stream().map(m -> m.getMember().getId()).collect(Collectors.toSet());
|
||||
// 是否全部是群成员
|
||||
if (!allMemberIds.containsAll(robotMemberIds)) {
|
||||
return;
|
||||
}
|
||||
// 获取到所有没有读取的消息
|
||||
List<ConversationGroupMessage> messageList = conversationGroup.getMessageList().stream()
|
||||
.filter(m -> !m.isAllRead()).collect(Collectors.toList());
|
||||
messageList.forEach(message -> {
|
||||
message.getReaderSet().addAll(robotMemberIds);
|
||||
if (allMemberIds.stream().filter(mid -> !Objects.equals(message.getMember().getId(), mid))
|
||||
.allMatch(mid -> message.getReaderSet().contains(mid))) { // 除发送用户外全部已读
|
||||
message.finishRead();
|
||||
}
|
||||
});
|
||||
applicationEventPublisher.publishEvent(new SimulationConversationGroupMessageStatusEvent(this, simulation, conversationGroup, messageList));
|
||||
}
|
||||
|
||||
/**
|
||||
* 对群组操作时基础判断
|
||||
*
|
||||
|
@ -192,8 +192,8 @@ public class ConversationGroupListener {
|
||||
if (CollectionUtils.isEmpty(memberList)) { // 人员全部为真实人员时直接返回
|
||||
return;
|
||||
}
|
||||
// 增加机器人已读操作
|
||||
memberList.forEach(m -> conversationGroupHandlerService.readConversationGroup(simulation, m, conversationGroup.getId()));
|
||||
// 增加机器人已读操作(批量操作)
|
||||
conversationGroupHandlerService.robotBatchRead(simulation, memberList, conversationGroup.getId());
|
||||
// 如果消息来源不为机器人,则执行语音识别,目前先不做语音识别回复
|
||||
// if (!event.getMessage().getMember().isRobot()) {
|
||||
// VoiceDiscriminateService.doAnalysis(event.getSimulation(), conversationGroup.getId(), event.getMessage().getContent(), memberList);
|
||||
|
Loading…
Reference in New Issue
Block a user