Merge branch 'test' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-zy
This commit is contained in:
commit
a51a09c23b
@ -44,11 +44,16 @@ public class OperateParseServiceImpl implements VoiceTransactionalService {
|
|||||||
if (operateRule == null) {
|
if (operateRule == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
// 参数解析
|
|
||||||
List<ParamExtractResult> paramExtractResults = result.getParamExtractResultList();
|
List<ParamExtractResult> paramExtractResults = result.getParamExtractResultList();
|
||||||
Map<Integer,ParamExtractResult> paramExtractResultMap = IntStream.range(0,paramExtractResults.size()).boxed().collect(Collectors.toMap(i->++i,paramExtractResults::get));
|
Map<Integer,ParamExtractResult> paramExtractResultMap = IntStream.range(0,paramExtractResults.size()).boxed().collect(Collectors.toMap(i->++i,paramExtractResults::get));
|
||||||
OperateResult operateResult = new OperateResult(operateRule.getType());
|
OperateResult operateResult = new OperateResult(operateRule.getType());
|
||||||
int paramSize = paramExtractResults.size();
|
int paramSize = paramExtractResults.size();
|
||||||
|
// 成员解析
|
||||||
|
List<SimulationMember> simulationMemberList = filterSimulationMember(simulation, result, paramExtractResultMap, operateRule.getMemberRule());
|
||||||
|
if (CollectionUtils.isEmpty(simulationMemberList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 参数解析
|
||||||
for (CommandParamRule paramRule : operateRule.getParamRules()) {
|
for (CommandParamRule paramRule : operateRule.getParamRules()) {
|
||||||
ParamExtractResult[] paramArr = new ParamExtractResult[paramRule.getIndexArr().length];
|
ParamExtractResult[] paramArr = new ParamExtractResult[paramRule.getIndexArr().length];
|
||||||
for (int index = 0, len = paramArr.length; index < len; index ++) {
|
for (int index = 0, len = paramArr.length; index < len; index ++) {
|
||||||
@ -67,33 +72,18 @@ public class OperateParseServiceImpl implements VoiceTransactionalService {
|
|||||||
operateResult.putParam(getMethodParamName(paramRule.getParamIndex(), operateRule.getType().name()), val);
|
operateResult.putParam(getMethodParamName(paramRule.getParamIndex(), operateRule.getType().name()), val);
|
||||||
} else {
|
} else {
|
||||||
// 参数位置未指定
|
// 参数位置未指定
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// 成员解析
|
|
||||||
MemberRule memberRule = operateRule.getMemberRule();
|
|
||||||
if (memberRule != null) {
|
|
||||||
List<SimulationMember> simulationMemberList = null;
|
|
||||||
if (memberRule.getIndex() == null) {
|
|
||||||
simulationMemberList = memberRule.getParseRule().matchMember(simulation, null);
|
|
||||||
} else if (memberRule.getIndex() < paramExtractResults.size()) {
|
|
||||||
simulationMemberList = memberRule.getParseRule().matchMember(simulation, paramExtractResultMap.get(memberRule.getIndex()));
|
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
if (CollectionUtils.isEmpty(simulationMemberList)) {
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
operateResult.setMember(simulationMemberList.get(0));
|
|
||||||
}
|
|
||||||
// 执行操作
|
// 执行操作
|
||||||
try {
|
simulationMemberList.forEach(member -> {
|
||||||
atsOperationDispatcher.execute(simulation, operateResult.getMember(), operateResult.getType().name(), operateResult.getParams());
|
try {
|
||||||
log.info("执行语音指令操作成功,操作[{}] 源指令[{}]",operateResult.getType().name(),result.getOriginContent());
|
atsOperationDispatcher.execute(simulation, member, operateResult.getType().name(), operateResult.getParams());
|
||||||
} catch (Exception e) {
|
log.info("[{}]执行语音指令操作成功,操作[{}] 源指令[{}]", member.getName(), operateResult.getType().name(), result.getOriginContent());
|
||||||
log.error("执行操作失败[{}] 输入源指令[{}] msg[{}]",operateResult.getType().name(),result.getOriginContent(),e.getMessage(),e);
|
} catch (Exception e) {
|
||||||
}
|
log.error("[{}]执行操作失败[{}] 输入源指令[{}] msg[{}]", member.getName(), operateResult.getType().name(), result.getOriginContent(),e.getMessage(),e);
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -115,7 +105,7 @@ public class OperateParseServiceImpl implements VoiceTransactionalService {
|
|||||||
* @param operateName 操作名称
|
* @param operateName 操作名称
|
||||||
* @return 参数名称
|
* @return 参数名称
|
||||||
*/
|
*/
|
||||||
public String getMethodParamName(int index, String operateName) {
|
private String getMethodParamName(int index, String operateName) {
|
||||||
OperateMethod handlerMethod = this.atsManager.getHandlerMethod(operateName);
|
OperateMethod handlerMethod = this.atsManager.getHandlerMethod(operateName);
|
||||||
Parameter[] parameters = handlerMethod.getMethod().getParameters();
|
Parameter[] parameters = handlerMethod.getMethod().getParameters();
|
||||||
if (parameters.length < index) {
|
if (parameters.length < index) {
|
||||||
@ -123,4 +113,29 @@ public class OperateParseServiceImpl implements VoiceTransactionalService {
|
|||||||
}
|
}
|
||||||
return parameters[index].getName();
|
return parameters[index].getName();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取执行操作的人员
|
||||||
|
* @return 人员列表
|
||||||
|
*/
|
||||||
|
private List<SimulationMember> filterSimulationMember(Simulation simulation, VoiceDiscriminateResult result
|
||||||
|
, Map<Integer,ParamExtractResult> paramExtractResultMap, MemberRule memberRule) {
|
||||||
|
int paramSize = result.getParamExtractResultList().size();
|
||||||
|
List<SimulationMember> simulationMemberList = null;
|
||||||
|
if (memberRule != null) { // 如果有指定成员解析规则,使用此规则解析
|
||||||
|
if (memberRule.getIndex() == null) {
|
||||||
|
simulationMemberList = memberRule.getParseRule().matchMember(simulation, null);
|
||||||
|
} else if (memberRule.getIndex() < paramSize) {
|
||||||
|
simulationMemberList = memberRule.getParseRule().matchMember(simulation, paramExtractResultMap.get(memberRule.getIndex()));
|
||||||
|
}
|
||||||
|
return simulationMemberList; // 返回解析结果
|
||||||
|
} else {
|
||||||
|
simulationMemberList = result.getSimulationMemberList(); // 获取群组成员对象
|
||||||
|
if (CollectionUtils.isEmpty(simulationMemberList) || simulationMemberList.size() > 1) {
|
||||||
|
return List.of();
|
||||||
|
} else {
|
||||||
|
return simulationMemberList;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -30,10 +30,16 @@ public class ReplyParseServiceImpl implements VoiceTransactionalService {
|
|||||||
if (replyRule == null) {
|
if (replyRule == null) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
// 回复成员
|
||||||
|
List<SimulationMember> simulationMemberList = filterSimulationMember(simulation, result, replyRule.getMemberRule());
|
||||||
|
if (CollectionUtils.isEmpty(simulationMemberList)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 格式化回复语句
|
||||||
List<ParamExtractResult> paramExtractResults = result.getParamExtractResultList();
|
List<ParamExtractResult> paramExtractResults = result.getParamExtractResultList();
|
||||||
ReplyResult replyResult = new ReplyResult(replyRule.getParamRules().size());
|
ReplyResult replyResult = new ReplyResult(replyRule.getParamRules().size());
|
||||||
ParamExtractResult[] paramArr = null;
|
|
||||||
int paramSize = paramExtractResults.size();
|
int paramSize = paramExtractResults.size();
|
||||||
|
ParamExtractResult[] paramArr = null;
|
||||||
for (CommandParamRule paramRule : replyRule.getParamRules()) {
|
for (CommandParamRule paramRule : replyRule.getParamRules()) {
|
||||||
paramArr = new ParamExtractResult[paramRule.getIndexArr().length];
|
paramArr = new ParamExtractResult[paramRule.getIndexArr().length];
|
||||||
for (int index = 0, len = paramArr.length; index < len; index ++) {
|
for (int index = 0, len = paramArr.length; index < len; index ++) {
|
||||||
@ -45,31 +51,33 @@ public class ReplyParseServiceImpl implements VoiceTransactionalService {
|
|||||||
}
|
}
|
||||||
replyResult.addParams(paramRule.getParseRule().extractParam(simulation, paramArr));
|
replyResult.addParams(paramRule.getParseRule().extractParam(simulation, paramArr));
|
||||||
}
|
}
|
||||||
|
|
||||||
// 格式化回复语句
|
|
||||||
Object[] objArr = new Object[replyResult.getParamList().size()];
|
Object[] objArr = new Object[replyResult.getParamList().size()];
|
||||||
replyResult.getParamList().toArray(objArr);
|
replyResult.getParamList().toArray(objArr);
|
||||||
replyResult.setContent(String.format(replyRule.getMessageFormat(), objArr));
|
replyResult.setContent(String.format(replyRule.getMessageFormat(), objArr));
|
||||||
// 匹配回复人员
|
// 执行回复
|
||||||
MemberRule memberRule = replyRule.getMemberRule();
|
simulationMemberList.forEach(member -> conversationManagerService.conversationChat(simulation, member, replyResult.getContent(), null));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取回复成员列表
|
||||||
|
*
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param result 封装的结果信息
|
||||||
|
* @param memberRule 成员解析规则
|
||||||
|
* @return 回复成员列表
|
||||||
|
*/
|
||||||
|
private List<SimulationMember> filterSimulationMember(Simulation simulation, VoiceDiscriminateResult result, MemberRule memberRule) {
|
||||||
|
List<ParamExtractResult> paramExtractResults = result.getParamExtractResultList();
|
||||||
|
List<SimulationMember> simulationMemberList = null;
|
||||||
if (memberRule != null) {
|
if (memberRule != null) {
|
||||||
List<SimulationMember> simulationMemberList = null;
|
|
||||||
if (memberRule.getIndex() == null) {
|
if (memberRule.getIndex() == null) {
|
||||||
simulationMemberList = memberRule.getParseRule().matchMember(simulation, null);
|
simulationMemberList = memberRule.getParseRule().matchMember(simulation, null);
|
||||||
} else if (memberRule.getIndex() < paramExtractResults.size()) {
|
} else if (memberRule.getIndex() < paramExtractResults.size()) {
|
||||||
simulationMemberList = memberRule.getParseRule().matchMember(simulation, paramExtractResults.get(memberRule.getIndex() - 1));
|
simulationMemberList = memberRule.getParseRule().matchMember(simulation, paramExtractResults.get(memberRule.getIndex() - 1));
|
||||||
} else {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
if (CollectionUtils.isEmpty(simulationMemberList)) {
|
return simulationMemberList;
|
||||||
return;
|
} else {
|
||||||
}
|
return result.getSimulationMemberList();
|
||||||
replyResult.setSimulationMemberList(simulationMemberList);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 执行回复
|
|
||||||
replyResult.getSimulationMemberList().forEach(member -> {
|
|
||||||
conversationManagerService.conversationChat(simulation, member, replyResult.getContent(), null);
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,27 @@
|
|||||||
package club.joylink.rtss.services.voice.discriminate;
|
package club.joylink.rtss.services.voice.discriminate;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember;
|
||||||
import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateResult;
|
import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateResult;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.event.conversation.SimulationConversationGroupDissolveEvent;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.event.conversation.SimulationConversationGroupMessageEvent;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.beans.factory.annotation.Qualifier;
|
import org.springframework.beans.factory.annotation.Qualifier;
|
||||||
|
import org.springframework.context.event.EventListener;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.util.CollectionUtils;
|
||||||
import org.springframework.web.multipart.MultipartFile;
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Objects;
|
||||||
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 语音识别服务类(多例)
|
* 语音识别服务类
|
||||||
*/
|
*/
|
||||||
@Slf4j
|
@Slf4j
|
||||||
@Service
|
@Service
|
||||||
@ -50,4 +61,33 @@ public class VoiceDiscriminateService {
|
|||||||
replyParseService.doExec(result, simulation); // 回复执行
|
replyParseService.doExec(result, simulation); // 回复执行
|
||||||
correctSourceService.doExec(result, simulation);// 原信息纠错
|
correctSourceService.doExec(result, simulation);// 原信息纠错
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 接受语音文件、资源等必要条件,解析开始
|
||||||
|
*/
|
||||||
|
public void doAnalysis(Simulation simulation, String content, List<SimulationMember> memberList) {
|
||||||
|
VoiceDiscriminateResult result = voiceParseService.doParse(simulation, content);
|
||||||
|
result.setSimulationMemberList(memberList); // 匹配到人员集合
|
||||||
|
operateParseService.doExec(result, simulation); // 指令执行
|
||||||
|
replyParseService.doExec(result, simulation); // 回复执行
|
||||||
|
correctSourceService.doExec(result, simulation);// 原信息纠错
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理聊天信息
|
||||||
|
* @param event 聊天事件信息
|
||||||
|
*/
|
||||||
|
@EventListener
|
||||||
|
public void handleMessage(SimulationConversationGroupMessageEvent event) {
|
||||||
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
SimulationMember member = event.getMember();
|
||||||
|
List<SimulationMember> memberList = conversationGroup.getMemberList().stream()
|
||||||
|
.filter(cm -> cm.isRobot() && !Objects.equals(cm.getMember(), member))
|
||||||
|
.map(ConversationMember::getMember).collect(Collectors.toList());
|
||||||
|
if (CollectionUtils.isEmpty(memberList)) { // 人员全部为真实人员时直接返回
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 执行语音识别
|
||||||
|
doAnalysis(event.getSimulation(), event.getContent(), memberList);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -322,29 +322,56 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
|||||||
return new ArrayList<>(this.simulationConversationMap.values());
|
return new ArrayList<>(this.simulationConversationMap.values());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 添加群组
|
||||||
|
* @param group 群组信息
|
||||||
|
*/
|
||||||
public void addConversationGroup(ConversationGroup group) {
|
public void addConversationGroup(ConversationGroup group) {
|
||||||
this.simulationConversationGroupMap.put(group.getId(), group);
|
this.simulationConversationGroupMap.put(group.getId(), group);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 移除群组
|
||||||
|
* @param group 群组信息
|
||||||
|
*/
|
||||||
public void removeConversionGroup(ConversationGroup group) {
|
public void removeConversionGroup(ConversationGroup group) {
|
||||||
this.simulationConversationGroupMap.remove(group.getId());
|
this.simulationConversationGroupMap.remove(group.getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 初始化群组信息
|
||||||
|
* @param map 群组信息Map
|
||||||
|
*/
|
||||||
public void initDefaultConversationGroupMap(Map<Long, ConversationGroup> map) {
|
public void initDefaultConversationGroupMap(Map<Long, ConversationGroup> map) {
|
||||||
|
this.simulationConversationGroupMap.clear();
|
||||||
this.simulationConversationGroupMap.putAll(map);
|
this.simulationConversationGroupMap.putAll(map);
|
||||||
Long groupId = map.keySet().stream().max(Comparator.comparing(Long::longValue)).orElse(0L);
|
Long groupId = map.keySet().stream().max(Comparator.comparing(Long::longValue)).orElse(0L);
|
||||||
this.conversationGroupId.set(groupId);
|
this.conversationGroupId.set(groupId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据名称查找群组
|
||||||
|
* @param name 名称
|
||||||
|
* @return 群组信息
|
||||||
|
*/
|
||||||
public ConversationGroup getConversationGroupByName(String name) {
|
public ConversationGroup getConversationGroupByName(String name) {
|
||||||
return this.simulationConversationGroupMap.values().stream().filter(group -> Objects.equals(group.getName(), name))
|
return this.simulationConversationGroupMap.values().stream().filter(group -> Objects.equals(group.getName(), name))
|
||||||
.findAny().orElse(null);
|
.findAny().orElse(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取下一个群组ID
|
||||||
|
* @return ID
|
||||||
|
*/
|
||||||
public Long getMaxConversationGroupId() {
|
public Long getMaxConversationGroupId() {
|
||||||
return conversationGroupId.incrementAndGet();
|
return conversationGroupId.incrementAndGet();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 根据ID获取群组信息
|
||||||
|
* @param id 群组ID
|
||||||
|
* @return 群组
|
||||||
|
*/
|
||||||
public ConversationGroup getConversationGroup(Long id) {
|
public ConversationGroup getConversationGroup(Long id) {
|
||||||
ConversationGroup group = this.simulationConversationGroupMap.get(id);
|
ConversationGroup group = this.simulationConversationGroupMap.get(id);
|
||||||
if (Objects.isNull(group)) {
|
if (Objects.isNull(group)) {
|
||||||
@ -354,6 +381,10 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
|
|||||||
return group;
|
return group;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取群组列表
|
||||||
|
* @return 群组列表
|
||||||
|
*/
|
||||||
public List<ConversationGroup> queryAllConversationGroup(){
|
public List<ConversationGroup> queryAllConversationGroup(){
|
||||||
return new ArrayList<>(this.simulationConversationGroupMap.values());
|
return new ArrayList<>(this.simulationConversationGroupMap.values());
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ import java.time.LocalDateTime;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Objects;
|
import java.util.Objects;
|
||||||
|
import java.util.Set;
|
||||||
import java.util.concurrent.atomic.AtomicInteger;
|
import java.util.concurrent.atomic.AtomicInteger;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
@ -31,11 +32,6 @@ public class ConversationGroup extends Chat {
|
|||||||
*/
|
*/
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
/**
|
|
||||||
* 群主
|
|
||||||
*/
|
|
||||||
private SimulationMember leader;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 群消息列表
|
* 群消息列表
|
||||||
*/
|
*/
|
||||||
@ -56,33 +52,39 @@ public class ConversationGroup extends Chat {
|
|||||||
this.id = info.getId();
|
this.id = info.getId();
|
||||||
this.name = info.getName();
|
this.name = info.getName();
|
||||||
setTime(simulation.getCorrectSystemTime());
|
setTime(simulation.getCorrectSystemTime());
|
||||||
if (info.getLeaderId() != null) { // 设置群主
|
// 成员中放入群主
|
||||||
this.leader = simulation.getSimulationMemberById(info.getLeaderId());
|
SimulationMember leader = simulation.getSimulationMemberById(info.getLeaderId());
|
||||||
setCreator(this.leader);
|
setCreator(leader);
|
||||||
}
|
int size = CollectionUtils.isEmpty(info.getMemberIds()) ? 1 : info.getMemberIds().size() + 1;
|
||||||
setTime(simulation.getCorrectSystemTime());
|
List<ConversationMember> memberList = new ArrayList<>(size);
|
||||||
List<ConversationMember> memberList = null;
|
ConversationMember conversationLeader = new ConversationMember(leader);
|
||||||
if (!CollectionUtils.isEmpty(info.getMemberIds())) {
|
conversationLeader.setLeader();
|
||||||
memberList = info.getMemberIds().stream().distinct().map(simulation::getSimulationMemberById)
|
memberList.add(conversationLeader);
|
||||||
.map(ConversationMember::new).collect(Collectors.toList());
|
// 处理群成员
|
||||||
setMemberList(memberList);
|
if (size > 1) {
|
||||||
|
info.getMemberIds().stream().filter(id -> !Objects.equals(id, info.getLeaderId())).distinct()
|
||||||
|
.map(simulation::getSimulationMemberById)
|
||||||
|
.forEach(member -> memberList.add(new ConversationMember(member)));
|
||||||
}
|
}
|
||||||
|
setMemberList(memberList);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ConversationGroup(Long id, String name, LocalDateTime time, SimulationMember leader, List<SimulationMember> simulationMembers){
|
public ConversationGroup(Long id, String name, LocalDateTime time, SimulationMember leader, List<SimulationMember> simulationMembers){
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.leader = leader;
|
|
||||||
setTime(time);
|
setTime(time);
|
||||||
setCreator(leader);
|
setCreator(leader);
|
||||||
if (!CollectionUtils.isEmpty(simulationMembers)) {
|
int size = CollectionUtils.isEmpty(simulationMembers) ? 1 : simulationMembers.size() + 1;
|
||||||
List<ConversationMember> memberList = simulationMembers.stream().map(member -> {
|
List<ConversationMember> memberList = new ArrayList<>(size);
|
||||||
ConversationMember conversationMember = new ConversationMember(member);
|
ConversationMember conversationLeader = new ConversationMember(leader);
|
||||||
conversationMember.setTime(time);
|
conversationLeader.setLeader();
|
||||||
return conversationMember;
|
memberList.add(conversationLeader);
|
||||||
}).collect(Collectors.toList());
|
// 处理群成员
|
||||||
setMemberList(memberList);
|
if (size > 1) {
|
||||||
|
simulationMembers.stream().filter(member -> !Objects.equals(member.getId(), leader.getId())).distinct()
|
||||||
|
.forEach(member -> memberList.add(new ConversationMember(member)));
|
||||||
}
|
}
|
||||||
|
setMemberList(memberList);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -142,12 +144,69 @@ public class ConversationGroup extends Chat {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置群主
|
||||||
|
* @param member 角色
|
||||||
|
*/
|
||||||
|
public void setLeader(SimulationMember member) {
|
||||||
|
ConversationMember leader = getMemberList().stream().filter(ConversationMember::isLeader).findFirst().orElse(null);
|
||||||
|
if (leader != null) {
|
||||||
|
leader.setMember();
|
||||||
|
}
|
||||||
|
ConversationMember conversationMember = getConversionMember(member);
|
||||||
|
conversationMember.setLeader();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否群主
|
* 是否群主
|
||||||
* @param member 成员
|
* @param member 成员
|
||||||
* @return 结果
|
* @return 结果
|
||||||
*/
|
*/
|
||||||
public boolean isLeader(SimulationMember member) {
|
public boolean isLeader(SimulationMember member) {
|
||||||
return Objects.equals(member, this.leader);
|
ConversationMember conversationMember = getConversionMember(member);
|
||||||
|
return conversationMember != null && conversationMember.isLeader();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成员用户ID
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public Set<String> getMemberUserId() {
|
||||||
|
return getMemberList().stream().filter(member -> !member.isRobot())
|
||||||
|
.map(member -> member.getMember().getUserId()).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取不含群组的用户ID
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public Set<String> getMemberUserIdWithOutLeader() {
|
||||||
|
return getMemberList().stream().filter(member -> !member.isRobot() && !member.isLeader())
|
||||||
|
.map(member -> member.getMember().getUserId()).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取成员用户ID
|
||||||
|
* @param memberIds 指定角色ID
|
||||||
|
* @return 用户ID
|
||||||
|
*/
|
||||||
|
public Set<String> getMemberUserId(List<String> memberIds) {
|
||||||
|
if (CollectionUtils.isEmpty(memberIds)) {
|
||||||
|
return Set.of();
|
||||||
|
}
|
||||||
|
return getMemberList().stream().filter(m -> !m.isRobot() && memberIds.contains(m.getMember().getId()))
|
||||||
|
.map(member -> member.getMember().getUserId()).collect(Collectors.toSet());
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取群主信息
|
||||||
|
* @return 群主角色
|
||||||
|
*/
|
||||||
|
public SimulationMember getLeader() {
|
||||||
|
ConversationMember member = getMemberList().stream().filter(ConversationMember::isLeader).findFirst().orElse(null);
|
||||||
|
if (member == null) {
|
||||||
|
throw new IllegalArgumentException("不存在群主");
|
||||||
|
}
|
||||||
|
return member.getMember();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,22 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.conversation;
|
package club.joylink.rtss.simulation.cbtc.conversation;
|
||||||
|
|
||||||
import club.joylink.rtss.services.voice.VoiceService;
|
import club.joylink.rtss.services.voice.VoiceService;
|
||||||
|
import club.joylink.rtss.services.voice.discriminate.VoiceDiscriminateService;
|
||||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupMessageVO;
|
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupMessageVO;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupSocketMessageVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO;
|
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.event.conversation.*;
|
import club.joylink.rtss.simulation.cbtc.event.conversation.*;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||||
|
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||||
|
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult;
|
||||||
import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO;
|
import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO;
|
||||||
|
import club.joylink.rtss.websocket.StompMessageService;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.context.ApplicationEventPublisher;
|
import org.springframework.context.ApplicationEventPublisher;
|
||||||
@ -38,6 +44,9 @@ public class ConversationGroupHandlerService {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private ApplicationEventPublisher applicationEventPublisher;
|
private ApplicationEventPublisher applicationEventPublisher;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private StompMessageService stompMessageService;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取所有群组信息
|
* 获取所有群组信息
|
||||||
* @param group 仿真ID
|
* @param group 仿真ID
|
||||||
@ -90,7 +99,7 @@ public class ConversationGroupHandlerService {
|
|||||||
}
|
}
|
||||||
conversationGroup.setName(name);
|
conversationGroup.setName(name);
|
||||||
// 通知其他用户群名变更
|
// 通知其他用户群名变更
|
||||||
applicationEventPublisher.publishEvent(new SimulationConversationGroupUpdateEvent(this, simulation, conversationGroup));
|
applicationEventPublisher.publishEvent(new SimulationConversationGroupUpdateEvent(this, simulation, conversationGroup, ConversationGroupSocketMessageVO.MessageType.UPDATE_NAME));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -108,9 +117,9 @@ public class ConversationGroupHandlerService {
|
|||||||
conversationGroup.addSimulationMember(simulationMember, simulation.getCorrectSystemTime());
|
conversationGroup.addSimulationMember(simulationMember, simulation.getCorrectSystemTime());
|
||||||
}
|
}
|
||||||
// 设置群组
|
// 设置群组
|
||||||
conversationGroup.setCreator(simulationMember);
|
conversationGroup.setLeader(simulationMember);
|
||||||
// 发送通知消息
|
// 发送通知消息
|
||||||
applicationEventPublisher.publishEvent(new SimulationConversationGroupUpdateEvent(this, simulation, conversationGroup));
|
applicationEventPublisher.publishEvent(new SimulationConversationGroupUpdateEvent(this, simulation, conversationGroup, ConversationGroupSocketMessageVO.MessageType.UPDATE_MEMBER));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -127,12 +136,14 @@ public class ConversationGroupHandlerService {
|
|||||||
}
|
}
|
||||||
List<String> groupMemberIds = conversationGroup.getSimulationMemberIds();
|
List<String> groupMemberIds = conversationGroup.getSimulationMemberIds();
|
||||||
List<String> newMemberIds = memberIds.stream().filter(mid -> !groupMemberIds.contains(mid)).collect(Collectors.toList());
|
List<String> newMemberIds = memberIds.stream().filter(mid -> !groupMemberIds.contains(mid)).collect(Collectors.toList());
|
||||||
|
List<SimulationMember> newSimulationMemberList = new ArrayList<>(newMemberIds.size());
|
||||||
newMemberIds.forEach(memberId -> {
|
newMemberIds.forEach(memberId -> {
|
||||||
SimulationMember newMember = simulation.getSimulationMemberById(memberId);
|
SimulationMember newMember = simulation.getSimulationMemberById(memberId);
|
||||||
|
newSimulationMemberList.add(newMember);
|
||||||
conversationGroup.addSimulationMember(newMember, simulation.getCorrectSystemTime());
|
conversationGroup.addSimulationMember(newMember, simulation.getCorrectSystemTime());
|
||||||
});
|
});
|
||||||
// 给新加入的用户发送消息
|
// 给新加入的用户发送消息
|
||||||
applicationEventPublisher.publishEvent(new SimulationConversationGroupInviteEvent(this, simulation, conversationGroup, groupMemberIds, newMemberIds));
|
applicationEventPublisher.publishEvent(new SimulationConversationGroupInviteEvent(this, simulation, conversationGroup, groupMemberIds, newSimulationMemberList));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -200,13 +211,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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -219,12 +229,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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -236,11 +245,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);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -275,7 +283,18 @@ public class ConversationGroupHandlerService {
|
|||||||
@EventListener
|
@EventListener
|
||||||
public void handleCreate(SimulationConversationGroupCreateEvent event) {
|
public void handleCreate(SimulationConversationGroupCreateEvent event) {
|
||||||
ConversationGroup conversationGroup = event.getConversationGroup();
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
SimulationMember leader = conversationGroup.getLeader();
|
||||||
|
ConversationGroupSocketMessageVO messageVO = ConversationGroupSocketMessageVO.MessageType.JOIN.generateMessageVO(conversationGroup, null);
|
||||||
|
if (!leader.isRobot()) {
|
||||||
|
doSendMessage(event.getSimulation(), Set.of(leader.getUserId()), messageVO);
|
||||||
|
}
|
||||||
|
Set<String> userIds = conversationGroup.getMemberUserIdWithOutLeader();
|
||||||
|
if (CollectionUtils.isEmpty(userIds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
// 给非群主的群人员发送消息、添加tips信息
|
||||||
|
messageVO.setMessageTips(String.format("你加入了【%s】", conversationGroup.getName()));
|
||||||
|
doSendMessage(event.getSimulation(), userIds, messageVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -284,7 +303,13 @@ public class ConversationGroupHandlerService {
|
|||||||
*/
|
*/
|
||||||
@EventListener
|
@EventListener
|
||||||
public void handleUpdate(SimulationConversationGroupUpdateEvent event) {
|
public void handleUpdate(SimulationConversationGroupUpdateEvent event) {
|
||||||
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
Set<String> userIds = conversationGroup.getMemberUserId();
|
||||||
|
if (CollectionUtils.isEmpty(userIds)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConversationGroupSocketMessageVO messageVO = event.getMessageType().generateMessageVO(conversationGroup, null);
|
||||||
|
doSendMessage(event.getSimulation(), userIds, messageVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -293,7 +318,29 @@ public class ConversationGroupHandlerService {
|
|||||||
*/
|
*/
|
||||||
@EventListener
|
@EventListener
|
||||||
public void handleInvite(SimulationConversationGroupInviteEvent event) {
|
public void handleInvite(SimulationConversationGroupInviteEvent event) {
|
||||||
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
Set<String> newUserIdSet = new HashSet<>(); // 发送加入信息的用户列表
|
||||||
|
StringBuilder stringBuilder = new StringBuilder();
|
||||||
|
event.getNewMemberList().forEach(m -> {
|
||||||
|
if (!m.isRobot()) {
|
||||||
|
newUserIdSet.add(m.getUserId());
|
||||||
|
}
|
||||||
|
stringBuilder.append(m.getName()).append("、");
|
||||||
|
});
|
||||||
|
// 通知新成员
|
||||||
|
if (!CollectionUtils.isEmpty(newUserIdSet)) {
|
||||||
|
ConversationGroupSocketMessageVO joinMessageVO = ConversationGroupSocketMessageVO.MessageType.JOIN.generateMessageVO(conversationGroup, null);
|
||||||
|
// 添加tips信息
|
||||||
|
joinMessageVO.setMessageTips(String.format("你加入了【%s】", conversationGroup.getName()));
|
||||||
|
doSendMessage(event.getSimulation(), newUserIdSet, joinMessageVO);
|
||||||
|
}
|
||||||
|
Set<String> oldUserIdSet = conversationGroup.getMemberUserId(event.getGroupMemberIds());
|
||||||
|
// 通知老成员
|
||||||
|
if (!CollectionUtils.isEmpty(oldUserIdSet)) {
|
||||||
|
ConversationGroupSocketMessageVO updateMessageVO = ConversationGroupSocketMessageVO.MessageType.UPDATE_MEMBER.generateMessageVO(conversationGroup, null);
|
||||||
|
updateMessageVO.setMessageTips("欢迎【" + stringBuilder.substring(0, stringBuilder.length() - 1) + "】加入本群");
|
||||||
|
doSendMessage(event.getSimulation(), conversationGroup.getMemberUserId(event.getGroupMemberIds()), updateMessageVO);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -303,7 +350,22 @@ public class ConversationGroupHandlerService {
|
|||||||
*/
|
*/
|
||||||
@EventListener
|
@EventListener
|
||||||
public void handleRemove(SimulationConversationGroupRemoveEvent event) {
|
public void handleRemove(SimulationConversationGroupRemoveEvent event) {
|
||||||
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
Set<String> removeUserIdSet = event.getRemoveGroupMember().stream().filter(m -> !m.isRobot()).map(SimulationMember::getUserId).collect(Collectors.toSet());
|
||||||
|
// 通知移除
|
||||||
|
if (!CollectionUtils.isEmpty(removeUserIdSet)) {
|
||||||
|
ConversationGroupSocketMessageVO exitMessageVO = ConversationGroupSocketMessageVO.MessageType.EXIT.generateMessageVO(conversationGroup, null);
|
||||||
|
// 添加tips信息
|
||||||
|
exitMessageVO.setMessageTips(String.format("你被移出了【%s】", conversationGroup.getName()));
|
||||||
|
doSendMessage(event.getSimulation(), removeUserIdSet, exitMessageVO);
|
||||||
|
}
|
||||||
|
// 更新其他用户的成员列表
|
||||||
|
Set<String> userIdSet = conversationGroup.getMemberUserId();
|
||||||
|
if (CollectionUtils.isEmpty(userIdSet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConversationGroupSocketMessageVO updateMessageVO = ConversationGroupSocketMessageVO.MessageType.UPDATE_MEMBER.generateMessageVO(conversationGroup, null);
|
||||||
|
doSendMessage(event.getSimulation(), userIdSet, updateMessageVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -312,7 +374,12 @@ public class ConversationGroupHandlerService {
|
|||||||
*/
|
*/
|
||||||
@EventListener
|
@EventListener
|
||||||
public void handleExit(SimulationConversationGroupExitEvent event) {
|
public void handleExit(SimulationConversationGroupExitEvent event) {
|
||||||
|
if (event.getMember().isRobot()) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
ConversationGroupSocketMessageVO exitMessageVO = ConversationGroupSocketMessageVO.MessageType.EXIT.generateMessageVO(conversationGroup, null);
|
||||||
|
doSendMessage(event.getSimulation(), Set.of(event.getMember().getUserId()), exitMessageVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -321,7 +388,15 @@ public class ConversationGroupHandlerService {
|
|||||||
*/
|
*/
|
||||||
@EventListener
|
@EventListener
|
||||||
public void handleDissolve(SimulationConversationGroupDissolveEvent event) {
|
public void handleDissolve(SimulationConversationGroupDissolveEvent event) {
|
||||||
|
ConversationGroup conversationGroup = event.getConversationGroup();
|
||||||
|
// 更新其他用户的成员列表
|
||||||
|
Set<String> userIdSet = conversationGroup.getMemberUserId();
|
||||||
|
if (CollectionUtils.isEmpty(userIdSet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
ConversationGroupSocketMessageVO exitMessageVO = ConversationGroupSocketMessageVO.MessageType.EXIT.generateMessageVO(conversationGroup, null);
|
||||||
|
exitMessageVO.setMessageTips(String.format("【%s】解散了", conversationGroup.getName()));
|
||||||
|
doSendMessage(event.getSimulation(), userIdSet, exitMessageVO);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -351,29 +426,44 @@ 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));
|
||||||
|
}
|
||||||
|
// 语音识别开始
|
||||||
|
applicationEventPublisher.publishEvent(new SimulationConversationGroupMessageEvent(this, simulation, conversationGroup, member, message.getContent()));
|
||||||
|
return messageVO;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 发送消息
|
||||||
|
*
|
||||||
|
* @param simulation 仿真
|
||||||
|
* @param userSet 用户列表
|
||||||
|
* @param messageVO 消息体
|
||||||
|
*/
|
||||||
|
private void doSendMessage(Simulation simulation, Set<String> userSet, ConversationGroupSocketMessageVO messageVO) {
|
||||||
|
if (CollectionUtils.isEmpty(userSet)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
SocketMessageVO<ConversationGroupSocketMessageVO> chatMessage =
|
||||||
|
SocketMessageFactory.build(WebSocketMessageType.Simulation_Conversation_Group, simulation.getId(), messageVO);
|
||||||
|
stompMessageService.sendToUser(userSet, chatMessage);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,7 +4,6 @@ import club.joylink.rtss.services.voice.VoiceService;
|
|||||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService;
|
import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupVO;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationMessageVO;
|
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationMessageVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO;
|
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.event.*;
|
import club.joylink.rtss.simulation.cbtc.event.*;
|
||||||
|
@ -5,6 +5,7 @@ import lombok.Getter;
|
|||||||
import lombok.Setter;
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
|
import java.util.Objects;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class ConversationMember {
|
public class ConversationMember {
|
||||||
@ -19,16 +20,58 @@ public class ConversationMember {
|
|||||||
@Setter
|
@Setter
|
||||||
private LocalDateTime time;
|
private LocalDateTime time;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 角色
|
||||||
|
*/
|
||||||
|
@Setter
|
||||||
|
private Role role;
|
||||||
|
|
||||||
public ConversationMember(SimulationMember member) {
|
public ConversationMember(SimulationMember member) {
|
||||||
this.member = member;
|
this.member = member;
|
||||||
this.connect = false;
|
this.connect = false;
|
||||||
|
this.role = Role.Member;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRobot() {
|
public boolean isRobot() {
|
||||||
return member.isRobot();
|
return member.isRobot();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否群主
|
||||||
|
*/
|
||||||
|
public boolean isLeader() {
|
||||||
|
return Objects.equals(this.role, Role.Leader);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置群主
|
||||||
|
*/
|
||||||
|
public void setLeader() {
|
||||||
|
this.role = Role.Leader;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 设置成员
|
||||||
|
*/
|
||||||
|
public void setMember() {
|
||||||
|
this.role = Role.Member;
|
||||||
|
}
|
||||||
|
|
||||||
public void connect() {
|
public void connect() {
|
||||||
this.connect = true;
|
this.connect = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 成员角色
|
||||||
|
*/
|
||||||
|
public enum Role {
|
||||||
|
/**
|
||||||
|
* 群主
|
||||||
|
*/
|
||||||
|
Leader,
|
||||||
|
/**
|
||||||
|
* 成员
|
||||||
|
*/
|
||||||
|
Member;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,15 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.data.vo;
|
package club.joylink.rtss.simulation.cbtc.data.vo;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.conversation.Conversation;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMessage;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.discriminate.ParamExtractResult;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
import lombok.Setter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群组socket消息内容
|
||||||
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
public class ConversationGroupSocketMessageVO {
|
public class ConversationGroupSocketMessageVO {
|
||||||
|
|
||||||
@ -26,11 +25,6 @@ public class ConversationGroupSocketMessageVO {
|
|||||||
*/
|
*/
|
||||||
private String creatorId;
|
private String creatorId;
|
||||||
|
|
||||||
/**
|
|
||||||
* 群主
|
|
||||||
*/
|
|
||||||
private String leaderId;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 成员列表
|
* 成员列表
|
||||||
*/
|
*/
|
||||||
@ -46,25 +40,27 @@ public class ConversationGroupSocketMessageVO {
|
|||||||
*/
|
*/
|
||||||
private MessageType messageType;
|
private MessageType messageType;
|
||||||
|
|
||||||
|
@Setter
|
||||||
|
private String messageTips;
|
||||||
|
|
||||||
public enum MessageType {
|
public enum MessageType {
|
||||||
/**
|
/**
|
||||||
* 会话组创建
|
* 会话组创建
|
||||||
*/
|
*/
|
||||||
CREATE {
|
JOIN {
|
||||||
@Override
|
@Override
|
||||||
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
||||||
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
||||||
messageVO.id = group.getId();
|
messageVO.id = group.getId();
|
||||||
messageVO.name = group.getName();
|
messageVO.name = group.getName();
|
||||||
messageVO.creatorId = group.getCreator() != null ? group.getCreator().getId() : null;
|
messageVO.creatorId = group.getCreator() != null ? group.getCreator().getId() : null;
|
||||||
messageVO.leaderId = group.getLeader() != null ? group.getLeader().getId() : null;
|
|
||||||
messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList());
|
messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList());
|
||||||
messageVO.messageType = MessageType.CREATE;
|
messageVO.messageType = MessageType.JOIN;
|
||||||
return messageVO;
|
return messageVO;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/**
|
/**
|
||||||
* 会话组更新
|
* 会话组全量更新
|
||||||
*/
|
*/
|
||||||
UPDATE {
|
UPDATE {
|
||||||
@Override
|
@Override
|
||||||
@ -72,37 +68,59 @@ public class ConversationGroupSocketMessageVO {
|
|||||||
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
||||||
messageVO.id = group.getId();
|
messageVO.id = group.getId();
|
||||||
messageVO.name = group.getName();
|
messageVO.name = group.getName();
|
||||||
messageVO.leaderId = group.getLeader() != null ? group.getLeader().getId() : null;
|
|
||||||
messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList());
|
messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList());
|
||||||
messageVO.messageType = MessageType.UPDATE;
|
messageVO.messageType = MessageType.UPDATE;
|
||||||
return messageVO;
|
return messageVO;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
/**
|
||||||
|
* 修改名称
|
||||||
/** 会话组邀请 */
|
*/
|
||||||
INVITE {
|
UPDATE_NAME {
|
||||||
@Override
|
@Override
|
||||||
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
||||||
return null;
|
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
||||||
|
messageVO.id = group.getId();
|
||||||
|
messageVO.name = group.getName();
|
||||||
|
messageVO.messageType = MessageType.UPDATE_NAME;
|
||||||
|
return messageVO;
|
||||||
|
}
|
||||||
|
},
|
||||||
|
/**
|
||||||
|
* 修改人员信息
|
||||||
|
*/
|
||||||
|
UPDATE_MEMBER {
|
||||||
|
@Override
|
||||||
|
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
||||||
|
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
||||||
|
messageVO.id = group.getId();
|
||||||
|
messageVO.memberList = group.getMemberList().stream().map(ConversationMemberVO::new).collect(Collectors.toList());
|
||||||
|
messageVO.messageType = MessageType.UPDATE_MEMBER;
|
||||||
|
return messageVO;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 成员发送消息 */
|
/** 成员发送消息 */
|
||||||
MESSAGE {
|
MESSAGE {
|
||||||
@Override
|
@Override
|
||||||
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
||||||
return null;
|
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
||||||
|
messageVO.id = group.getId();
|
||||||
|
messageVO.message = message;
|
||||||
|
messageVO.messageType = MessageType.MESSAGE;
|
||||||
|
return messageVO;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
/** 会话结束 */
|
/** 会话组解散 */
|
||||||
EXIT {
|
EXIT {
|
||||||
@Override
|
@Override
|
||||||
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
public ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message) {
|
||||||
return null;
|
ConversationGroupSocketMessageVO messageVO = new ConversationGroupSocketMessageVO();
|
||||||
|
messageVO.id = group.getId();
|
||||||
|
messageVO.messageType = MessageType.EXIT;
|
||||||
|
return messageVO;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public abstract ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message);
|
public abstract ConversationGroupSocketMessageVO generateMessageVO(ConversationGroup group, ConversationGroupMessageVO message);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,6 +20,8 @@ public class ConversationGroupVO {
|
|||||||
|
|
||||||
private String creatorId;
|
private String creatorId;
|
||||||
|
|
||||||
|
private String leaderId;
|
||||||
|
|
||||||
private List<ConversationMemberVO> memberList;
|
private List<ConversationMemberVO> memberList;
|
||||||
|
|
||||||
private List<ConversationGroupMessageVO> messageList;
|
private List<ConversationGroupMessageVO> messageList;
|
||||||
@ -27,27 +29,12 @@ public class ConversationGroupVO {
|
|||||||
public ConversationGroupVO(ConversationGroup conversation) {
|
public ConversationGroupVO(ConversationGroup conversation) {
|
||||||
this.id = conversation.getId();
|
this.id = conversation.getId();
|
||||||
this.name = conversation.getName();
|
this.name = conversation.getName();
|
||||||
if (conversation.getCreator() != null) {
|
this.creatorId = conversation.getCreator() != null ? conversation.getCreator().getId() : null;
|
||||||
this.creatorId = conversation.getCreator().getId();
|
this.leaderId = conversation.getLeader() != null ? conversation.getLeader().getId() : null;
|
||||||
}
|
|
||||||
this.memberList = ConversationMemberVO.convert2VOList(conversation.getMemberList());
|
this.memberList = ConversationMemberVO.convert2VOList(conversation.getMemberList());
|
||||||
this.messageList = ConversationGroupMessageVO.convert2VO(conversation.getMessageList());
|
this.messageList = ConversationGroupMessageVO.convert2VO(conversation.getMessageList());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
|
||||||
* 生成不带消息的VO对象
|
|
||||||
* @param conversation
|
|
||||||
*/
|
|
||||||
public void generateConversationGroupVOWithOutMessage(ConversationGroup conversation) {
|
|
||||||
this.id = conversation.getId();
|
|
||||||
this.name = conversation.getName();
|
|
||||||
if (conversation.getCreator() != null) {
|
|
||||||
this.creatorId = conversation.getCreator().getId();
|
|
||||||
}
|
|
||||||
this.memberList = ConversationMemberVO.convert2VOList(conversation.getMemberList());
|
|
||||||
}
|
|
||||||
|
|
||||||
public static List<ConversationGroupVO> convert2VOList(List<ConversationGroup> list) {
|
public static List<ConversationGroupVO> convert2VOList(List<ConversationGroup> list) {
|
||||||
List<ConversationGroupVO> voList = new ArrayList<>();
|
List<ConversationGroupVO> voList = new ArrayList<>();
|
||||||
if (!CollectionUtils.isEmpty(list)) {
|
if (!CollectionUtils.isEmpty(list)) {
|
||||||
|
@ -16,9 +16,12 @@ public class ConversationMemberVO {
|
|||||||
|
|
||||||
private boolean connect;
|
private boolean connect;
|
||||||
|
|
||||||
|
private ConversationMember.Role role;
|
||||||
|
|
||||||
public ConversationMemberVO(ConversationMember conversationMember) {
|
public ConversationMemberVO(ConversationMember conversationMember) {
|
||||||
this.memberId = conversationMember.getMember().getId();
|
this.memberId = conversationMember.getMember().getId();
|
||||||
this.connect = conversationMember.isConnect();
|
this.connect = conversationMember.isConnect();
|
||||||
|
this.role = conversationMember.getRole();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static List<ConversationMemberVO> convert2VOList(List<ConversationMember> list) {
|
public static List<ConversationMemberVO> convert2VOList(List<ConversationMember> list) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package club.joylink.rtss.simulation.cbtc.discriminate;
|
package club.joylink.rtss.simulation.cbtc.discriminate;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
|
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
|
||||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
@ -18,24 +17,15 @@ public class OperateResult {
|
|||||||
*/
|
*/
|
||||||
private Operation.Type type;
|
private Operation.Type type;
|
||||||
|
|
||||||
// private Boolean operationResult;
|
|
||||||
// private String errResultMsg;
|
|
||||||
/**
|
/**
|
||||||
* 指令参数
|
* 指令参数
|
||||||
*/
|
*/
|
||||||
private Map<String, Object> params = new HashMap<>();
|
private Map<String, Object> params = new HashMap<>();
|
||||||
|
|
||||||
/**
|
|
||||||
* 角色ID
|
|
||||||
*/
|
|
||||||
private SimulationMember member;
|
|
||||||
|
|
||||||
public OperateResult(Operation.Type type) {
|
public OperateResult(Operation.Type type) {
|
||||||
this.type = type;
|
this.type = type;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 参数放入集合
|
* 参数放入集合
|
||||||
* @param key 集合key
|
* @param key 集合key
|
||||||
|
@ -3,6 +3,7 @@ package club.joylink.rtss.simulation.cbtc.event.conversation;
|
|||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||||
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
|
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -23,13 +24,13 @@ public class SimulationConversationGroupInviteEvent extends AbstractSimulationEv
|
|||||||
/**
|
/**
|
||||||
* 新加入的组员
|
* 新加入的组员
|
||||||
*/
|
*/
|
||||||
private List<String> newGroupMemberIds;
|
private List<SimulationMember> newMemberList;
|
||||||
|
|
||||||
public SimulationConversationGroupInviteEvent(Object source, Simulation simulation, ConversationGroup conversationGroup
|
public SimulationConversationGroupInviteEvent(Object source, Simulation simulation, ConversationGroup conversationGroup
|
||||||
, List<String> groupMemberIds, List<String> newGroupMemberIds) {
|
, List<String> groupMemberIds, List<SimulationMember> newMemberList) {
|
||||||
super(source, simulation);
|
super(source, simulation);
|
||||||
this.conversationGroup = conversationGroup;
|
this.conversationGroup = conversationGroup;
|
||||||
this.groupMemberIds = groupMemberIds;
|
this.groupMemberIds = groupMemberIds;
|
||||||
this.newGroupMemberIds = newGroupMemberIds;
|
this.newMemberList = newMemberList;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,37 @@
|
|||||||
|
package club.joylink.rtss.simulation.cbtc.event.conversation;
|
||||||
|
|
||||||
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||||
|
import lombok.Getter;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 群组退群事件
|
||||||
|
*/
|
||||||
|
@Getter
|
||||||
|
public class SimulationConversationGroupMessageEvent extends AbstractSimulationEvent {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 会话对象
|
||||||
|
*/
|
||||||
|
private ConversationGroup conversationGroup;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 操作用户
|
||||||
|
*/
|
||||||
|
private SimulationMember member;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 消息内容
|
||||||
|
*/
|
||||||
|
private String content;
|
||||||
|
|
||||||
|
public SimulationConversationGroupMessageEvent(Object source, Simulation simulation, ConversationGroup conversationGroup
|
||||||
|
, SimulationMember member, String content) {
|
||||||
|
super(source, simulation);
|
||||||
|
this.conversationGroup = conversationGroup;
|
||||||
|
this.member = member;
|
||||||
|
this.content = content;
|
||||||
|
}
|
||||||
|
}
|
@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc.event.conversation;
|
|||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationGroupSocketMessageVO;
|
||||||
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
|
import club.joylink.rtss.simulation.cbtc.event.AbstractSimulationEvent;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
@ -13,8 +14,12 @@ public class SimulationConversationGroupUpdateEvent extends AbstractSimulationEv
|
|||||||
|
|
||||||
private ConversationGroup conversationGroup;
|
private ConversationGroup conversationGroup;
|
||||||
|
|
||||||
public SimulationConversationGroupUpdateEvent(Object source, Simulation simulation, ConversationGroup conversationGroup) {
|
private ConversationGroupSocketMessageVO.MessageType messageType;
|
||||||
|
|
||||||
|
public SimulationConversationGroupUpdateEvent(Object source, Simulation simulation, ConversationGroup conversationGroup
|
||||||
|
, ConversationGroupSocketMessageVO.MessageType messageType) {
|
||||||
super(source, simulation);
|
super(source, simulation);
|
||||||
this.conversationGroup = conversationGroup;
|
this.conversationGroup = conversationGroup;
|
||||||
|
this.messageType = messageType;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -168,6 +168,11 @@ public enum WebSocketMessageType {
|
|||||||
*/
|
*/
|
||||||
Simulation_Operation_Mode_Apply,
|
Simulation_Operation_Mode_Apply,
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 仿真群组消息
|
||||||
|
*/
|
||||||
|
Simulation_Conversation_Group,
|
||||||
|
|
||||||
//------------------ 仿真剧本 ------------------
|
//------------------ 仿真剧本 ------------------
|
||||||
/**
|
/**
|
||||||
* 仿真-剧本已加载
|
* 仿真-剧本已加载
|
||||||
|
@ -99,7 +99,8 @@ public class SocketMessageFactory {
|
|||||||
case Competition_Practical:
|
case Competition_Practical:
|
||||||
case SIMULATION_RAIL_TICKET:
|
case SIMULATION_RAIL_TICKET:
|
||||||
case Simulation_Alarm:
|
case Simulation_Alarm:
|
||||||
case Simulation_Operation_Mode_Apply: {
|
case Simulation_Operation_Mode_Apply:
|
||||||
|
case Simulation_Conversation_Group: {
|
||||||
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
|
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user