实训时,用户的会话操作匹配失败后,机器人成员会发送“请重复”语音

This commit is contained in:
joylink_zhangsai 2023-11-23 17:03:00 +08:00
parent 6c6e254751
commit 3e8ed7095e

View File

@ -16,6 +16,8 @@ import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService; import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService;
import club.joylink.rtss.simulation.cbtc.SimulationService; import club.joylink.rtss.simulation.cbtc.SimulationService;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationGroup;
import club.joylink.rtss.simulation.cbtc.conversation.ConversationMember;
import club.joylink.rtss.simulation.cbtc.data.map.Switch; import club.joylink.rtss.simulation.cbtc.data.map.Switch;
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.Training2MessageVO; import club.joylink.rtss.simulation.cbtc.data.vo.Training2MessageVO;
@ -96,6 +98,12 @@ public class Training2Service {
Operation.Type.Conversation_Group_Private_Text_Chat.name() Operation.Type.Conversation_Group_Private_Text_Chat.name()
); );
private static final List<String> PRIVATE_CONVERSATION_LIST = Arrays.asList(
Type.Conversation_Group_Private_Audio_Base64.name(),
Type.Conversation_Group_Private_Text_Chat.name(),
Type.Conversation_Group_Private_Audio_Chat.name()
);
/** /**
* 实训步骤执行道岔联动元素存在当前步骤元素 * 实训步骤执行道岔联动元素存在当前步骤元素
*/ */
@ -953,6 +961,32 @@ public class Training2Service {
if (!simulation.getTraining2().isJumpStep(step) && !step.getSimulationMember().isRobot()) { if (!simulation.getTraining2().isJumpStep(step) && !step.getSimulationMember().isRobot()) {
applicationContext.publishEvent( applicationContext.publishEvent(
new SimulationTrainingAudioEvent(this, simulation, step, simOperation2, doCompletion)); new SimulationTrainingAudioEvent(this, simulation, step, simOperation2, doCompletion));
if (!doCompletion) {
Operation.Type operationType;
HashMap<String, Object> params = new HashMap<>(event.getParams());
SimulationMember member = null;
if (PRIVATE_CONVERSATION_LIST.contains(event.getOperate())) {
operationType = Type.Conversation_Group_Private_Audio_Chat;
Object memberId = params.put("memberId", event.getMember().getId());
member = simulation.getSimulationMemberById((String) memberId);
} else {
operationType = Type.Conversation_Group_Audio_Chat;
ConversationGroup cg = simulation.getConversationGroup(
Long.valueOf(params.get("id").toString()));
for (ConversationMember cm : cg.getMemberList()) {
if (!Objects.equals(cm.getMember(), event.getMember())) {
member = cm.getMember();
break;
}
}
}
if (member != null) {
VoiceCompose compose = voiceService.synthesis(new BaseVoiceSynthesisVO("请重复"));
params.put("audioPath", compose.getFilePath());
params.put("content", compose.getMessage());
atsOperationDispatcher.execute(simulation, member, operationType.name(), params);
}
}
} }
} }