【操作执行事件增加结果】【实训语音结果校验结果返回】
This commit is contained in:
parent
f3dd343a1c
commit
6527d042ea
@ -68,7 +68,15 @@ public class Training2Service {
|
||||
*/
|
||||
private static final List<String> CONVERSATION_LIST = Arrays.asList(
|
||||
Operation.Type.Conversation_Chat_Audio.name(), Operation.Type.Conversation_Chat_Text.name(),
|
||||
Operation.Type.Conversation_Chat_Audio_Base64.name()
|
||||
Operation.Type.Conversation_Chat_Audio_Base64.name(),
|
||||
Operation.Type.Conversation_Group_Audio_Chat.name(), Operation.Type.Conversation_Group_Text_Chat.name(),
|
||||
Operation.Type.Conversation_Group_Audio_Base64.name(),
|
||||
Operation.Type.Conversation_Group_Private_Text_Chat.name(), Operation.Type.Conversation_Group_Private_Audio_Base64.name()
|
||||
);
|
||||
|
||||
private static final List<String> CONVERSATION_TEXT_LIST = Arrays.asList(
|
||||
Operation.Type.Conversation_Chat_Text.name(), Operation.Type.Conversation_Group_Text_Chat.name(),
|
||||
Operation.Type.Conversation_Group_Private_Text_Chat.name()
|
||||
);
|
||||
|
||||
/**
|
||||
@ -400,7 +408,7 @@ public class Training2Service {
|
||||
// 为会话操作
|
||||
boolean startFlag = Boolean.FALSE;
|
||||
if (CONVERSATION_LIST.contains(simCommand2.getOperationType().name()) && CONVERSATION_LIST.contains(event.getOperate())) {
|
||||
checkSimOperationConversation(simCommand2, simulation, step, event.getOperate());
|
||||
checkSimOperationConversation(simCommand2, step, event);
|
||||
startFlag = Boolean.TRUE;
|
||||
} else if (simCommand2.getOperationType().name().equals(event.getOperate()) && compareParams(event.getParams(), simCommand2.getParams())) {
|
||||
simCommand2.doOperated(); // 标识已操作过
|
||||
@ -747,18 +755,16 @@ public class Training2Service {
|
||||
/**
|
||||
* 检验语音输入是否正确
|
||||
*/
|
||||
private void checkSimOperationConversation(Operation2.SimCommand2 simOperation2, Simulation simulation, Step2 step, String eventOperation) {
|
||||
Conversation conversation = simulation.getSimulationConversationMap().get(ConversationManagerService.CHAT_ROOM_KEY);
|
||||
if (conversation == null || CollectionUtils.isEmpty(simOperation2.getParams())) {
|
||||
private void checkSimOperationConversation(Operation2.SimCommand2 simOperation2, Step2 step, SimulationOperationEvent event) {
|
||||
Simulation simulation = event.getSimulation();
|
||||
if (CollectionUtils.isEmpty(simOperation2.getParams()) || event.getResult() == null) {
|
||||
return;
|
||||
}
|
||||
// 获取本角色的最后一次会话信息
|
||||
ConversationMessage message = conversation.getMessageList().stream()
|
||||
.filter(m -> m.getMember().equals(step.getSimulationMember()))
|
||||
.reduce((m1, m2) -> m2).orElse(null);
|
||||
ConversationMessageVO message = (ConversationMessageVO) event.getResult();
|
||||
String source = String.valueOf(simOperation2.getParams().get("content"));
|
||||
String target = message.getContent();
|
||||
if (Operation.Type.Conversation_Chat_Text.name().equals(eventOperation)) {
|
||||
if (CONVERSATION_TEXT_LIST.contains(event.getOperate())) {
|
||||
if (Objects.equals(source,target)) {
|
||||
simOperation2.doOperated();
|
||||
}
|
||||
|
@ -34,7 +34,7 @@ public class AtsOperationDispatcher {
|
||||
|
||||
public Object execute(Simulation simulation, SimulationMember member, String operate, Map<String, Object> params) {
|
||||
applicationContext.publishEvent(new SimulationOperationEvent(this, simulation, member, operate, params,
|
||||
simulation.getSystemTime(), null));
|
||||
simulation.getSystemTime(), null, null));
|
||||
// 获取操作定义
|
||||
log.debug(String.format("待执行操作【%s】", operate));
|
||||
// 根据操作定义获取操作处理方法
|
||||
@ -55,7 +55,7 @@ public class AtsOperationDispatcher {
|
||||
String.format("操作【%s】执行失败:%s", operate, e.getMessage()), e);
|
||||
}
|
||||
applicationContext.publishEvent(new SimulationOperationEvent(this, simulation, member, operate, params,
|
||||
simulation.getSystemTime(), true));
|
||||
simulation.getSystemTime(), true, result));
|
||||
log.debug(String.format("操作【%s】执行成功", operate));
|
||||
return result;
|
||||
}
|
||||
|
@ -29,13 +29,19 @@ public class SimulationOperationEvent extends AbstractSimulationEvent {
|
||||
/** 是否成功 */
|
||||
private Boolean successful;
|
||||
|
||||
/**
|
||||
* 处理结果
|
||||
*/
|
||||
private Object result;
|
||||
|
||||
public SimulationOperationEvent(Object source, Simulation simulation, SimulationMember member, String operate,
|
||||
Map<String, Object> params, LocalDateTime simulationTime, Boolean successful) {
|
||||
Map<String, Object> params, LocalDateTime simulationTime, Boolean successful, Object result) {
|
||||
super(source, simulation);
|
||||
this.member = member;
|
||||
this.operate = operate;
|
||||
this.params = params;
|
||||
this.simulationTime = simulationTime;
|
||||
this.successful = successful;
|
||||
this.result = result;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user