Merge remote-tracking branch 'origin/test-training2' into test-training2
This commit is contained in:
commit
7b9fba8412
@ -35,9 +35,12 @@ import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.format.annotation.DateTimeFormat;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.validation.annotation.Validated;
|
||||
import org.springframework.web.bind.annotation.*;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import javax.servlet.http.HttpServletRequest;
|
||||
import javax.validation.constraints.NotBlank;
|
||||
import javax.validation.constraints.NotNull;
|
||||
import java.time.LocalDateTime;
|
||||
@ -204,6 +207,22 @@ public class SimulationV1Controller {
|
||||
return this.groupSimulationService.operate(group, type, param, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送会话消息(语音输入)操作
|
||||
* 由于文件不能进行json格式化,先将文件处理后再执行操作信息
|
||||
* 电话模式下:必须存在id
|
||||
*/
|
||||
@PostMapping(value = {"/{group}/operate/Conversation_Phone_Audio", "/{group}/operate/Conversation_Chat_Audio"})
|
||||
public Object operateFile(HttpServletRequest request, @PathVariable @NotBlank String group, MultipartFile file
|
||||
, String id, @RequestAttribute AccountVO user) {
|
||||
String uri = request.getRequestURI();
|
||||
String type = uri.substring(uri.lastIndexOf("/") + 1);
|
||||
if ("Conversation_Phone_Audio".equals(type) && StringUtils.isEmpty(id)) {
|
||||
throw BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.exception("会话ID不能为空");
|
||||
}
|
||||
return this.groupSimulationService.operateFile(group, type, file, id, user);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仿真指令
|
||||
*/
|
||||
|
@ -1,14 +1,10 @@
|
||||
package club.joylink.rtss.simulation.cbtc.ATS.operation;
|
||||
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import com.github.pagehelper.util.StringUtil;
|
||||
import lombok.Builder;
|
||||
import lombok.Getter;
|
||||
import org.springframework.util.ObjectUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
/**
|
||||
* 操作
|
||||
@ -1279,25 +1275,26 @@ public class Operation {
|
||||
|
||||
//----------------------------会话信息------------------------------
|
||||
/**
|
||||
* 获取会话信息
|
||||
* 电话:创建电话消息
|
||||
*/
|
||||
Conversation_Get_Info(Operation.CLIENT),
|
||||
Conversation_Phone_Start(Operation.CLIENT),
|
||||
/**
|
||||
* 会话列表信息
|
||||
* 电话:接听电话
|
||||
*/
|
||||
Conversation_List(Operation.CLIENT),
|
||||
Conversation_Phone_Connect(Operation.CLIENT),
|
||||
/**
|
||||
* 发起会话
|
||||
* 电话:语音消息
|
||||
*/
|
||||
Conversation_Start(Operation.CLIENT),
|
||||
Conversation_Phone_Audio(Operation.CLIENT),
|
||||
/**
|
||||
* 接受会话
|
||||
* 电话:文字消息
|
||||
*/
|
||||
Conversation_Accept(Operation.CLIENT),
|
||||
Conversation_Phone_Text(Operation.CLIENT),
|
||||
/**
|
||||
* 结束会话
|
||||
* 电话:挂电话
|
||||
*/
|
||||
Conversation_Over(Operation.CLIENT),
|
||||
Conversation_Phone_Exit(Operation.CLIENT),
|
||||
|
||||
/**
|
||||
* 发送会话消息(语音输入)
|
||||
*/
|
||||
@ -1316,7 +1313,8 @@ public class Operation {
|
||||
public int getName() {
|
||||
return index;
|
||||
}
|
||||
public boolean eq(int indexType){
|
||||
|
||||
public boolean eq(int indexType) {
|
||||
return this.index == indexType;
|
||||
}
|
||||
}
|
||||
|
@ -24,6 +24,7 @@ import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
||||
import club.joylink.rtss.vo.client.simulationv1.*;
|
||||
import club.joylink.rtss.vo.map.MapVO;
|
||||
import club.joylink.rtss.vo.map.graph.MapStationNewVO;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
import java.time.LocalTime;
|
||||
@ -49,10 +50,14 @@ public interface GroupSimulationService {
|
||||
*/
|
||||
String simulation(Long mapId, String prodCode, LoginUserInfoVO loginUserInfoVO);
|
||||
|
||||
/**实训仿真*/
|
||||
/**
|
||||
* 实训仿真
|
||||
*/
|
||||
String trainingSimulation(Long trainingId, LoginUserInfoVO loginUserInfoVO);
|
||||
|
||||
/**考试仿真*/
|
||||
/**
|
||||
* 考试仿真
|
||||
*/
|
||||
String examSimulation(Long examId, LoginUserInfoVO loginUserInfoVO);
|
||||
|
||||
/**
|
||||
@ -75,6 +80,11 @@ public interface GroupSimulationService {
|
||||
*/
|
||||
Object operate(String group, String type, Map<String, Object> param, AccountVO user);
|
||||
|
||||
/**
|
||||
* 文件操作请求
|
||||
*/
|
||||
Object operateFile(String group, String type, MultipartFile file, String id, AccountVO user);
|
||||
|
||||
/**
|
||||
* 根据计划时间获取此时间点可以加载的最大列车数量
|
||||
*/
|
||||
@ -185,10 +195,14 @@ public interface GroupSimulationService {
|
||||
*/
|
||||
PlanTripNumberVO planTripInfoByServiceAndTripNumber(String group, String serviceNumber, String tripNumber);
|
||||
|
||||
/**故障模式设置*/
|
||||
/**
|
||||
* 故障模式设置
|
||||
*/
|
||||
Integer setFaultMode(String group, FaultRuleVO ruleVO);
|
||||
|
||||
/**获取已设置且自动故障*/
|
||||
/**
|
||||
* 获取已设置且自动故障
|
||||
*/
|
||||
Set<FaultRuleVO> getTriggerAutoFaults(String group);
|
||||
|
||||
/**
|
||||
@ -255,6 +269,7 @@ public interface GroupSimulationService {
|
||||
|
||||
/**
|
||||
* 获取所有目的地码
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
List<DestinationCodeVO> getAllDestinationCode(String group);
|
||||
@ -276,6 +291,7 @@ public interface GroupSimulationService {
|
||||
|
||||
/**
|
||||
* 获取仿真日志
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
PageVO<SimulationLog> getLog(String group, SimulationLogPagedQueryVO queryVO);
|
||||
|
@ -27,6 +27,7 @@ import club.joylink.rtss.simulation.cbtc.command.CommandExecuteService;
|
||||
import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO;
|
||||
import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo;
|
||||
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
|
||||
import club.joylink.rtss.simulation.cbtc.conversation.ConversationManagerService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.DestinationCodeDefinition;
|
||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
||||
@ -74,6 +75,7 @@ import org.springframework.context.ApplicationContext;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDate;
|
||||
import java.time.LocalDateTime;
|
||||
@ -148,6 +150,8 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
||||
private CommandExecuteService commandExecuteService;
|
||||
@Autowired
|
||||
private QRCodeManager qrCodeManager;
|
||||
@Autowired
|
||||
private ConversationManagerService conversationManagerService;
|
||||
// /**
|
||||
// * 创建仿真并进行缓存
|
||||
// *
|
||||
@ -442,6 +446,14 @@ public class GroupSimulationServiceImpl implements GroupSimulationService {
|
||||
return this.atsOperationDispatcher.dispatch(simulation, user, type, param);
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object operateFile(String group, String type, MultipartFile file, String id, AccountVO user) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Map<String, Object> params = conversationManagerService.parseAudioInfo(file);
|
||||
params.put("id", id);
|
||||
return this.atsOperationDispatcher.dispatch(simulation, user, type, params);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getGivenTimeCouldLoadedTrainNumber(String group, LocalTime time) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
|
@ -4,6 +4,7 @@ import club.joylink.rtss.services.voice.IVoiceService;
|
||||
import club.joylink.rtss.simulation.cbtc.GroupSimulationCache;
|
||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||
import club.joylink.rtss.simulation.cbtc.competition.ScriptExecuteService;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationMessageVO;
|
||||
import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO;
|
||||
import club.joylink.rtss.simulation.cbtc.event.*;
|
||||
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
|
||||
@ -11,13 +12,18 @@ import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
|
||||
import club.joylink.rtss.vo.AccountVO;
|
||||
import club.joylink.rtss.vo.client.SocketMessageVO;
|
||||
import club.joylink.rtss.vo.client.VoiceRecognitionResult;
|
||||
import club.joylink.rtss.vo.client.WebSocketMessageType;
|
||||
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
|
||||
import club.joylink.rtss.websocket.StompMessageService;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.beans.factory.annotation.Qualifier;
|
||||
import org.springframework.context.ApplicationEventPublisher;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
|
||||
import java.time.LocalDateTime;
|
||||
@ -44,15 +50,18 @@ public class ConversationManagerService {
|
||||
@Autowired
|
||||
private ScriptExecuteService scriptExecuteService;
|
||||
|
||||
@Autowired
|
||||
private StompMessageService stompMessageService;
|
||||
|
||||
public ConversationVO getConversationById(String group, String conversationId) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
Conversation conversation = simulation.getSimulationConversationById(conversationId);
|
||||
ConversationVO conversationVO = new ConversationVO(conversation);
|
||||
return conversationVO;
|
||||
}
|
||||
|
||||
public List<ConversationVO> getAllConversations(String group) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
List<Conversation> allConversations = simulation.queryAllConversations();
|
||||
return ConversationVO.convert2VOList(allConversations);
|
||||
}
|
||||
@ -64,13 +73,13 @@ public class ConversationManagerService {
|
||||
if (CollectionUtils.isEmpty(memberIdList)) {
|
||||
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "一个人不能开启会话");
|
||||
}
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
SimulationUser simulationUser = simulation.getSimulationUserById(accountVO.getId());
|
||||
SimulationMember creator = simulationUser.getPlayedMember();
|
||||
if (Objects.isNull(creator)) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL);
|
||||
}
|
||||
return this.createConversation(simulation, creator, memberIdList);
|
||||
return createConversation(simulation, creator, memberIdList);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -82,7 +91,7 @@ public class ConversationManagerService {
|
||||
List<SimulationMember> invitedList = new ArrayList<>();
|
||||
for (String memberId : memberIdList) {
|
||||
SimulationMember member = simulation.getSimulationMemberById(memberId);
|
||||
if (this.isMemberConnect2Conversation(simulation, member)) {
|
||||
if (isMemberConnect2Conversation(simulation, member)) {
|
||||
throw new SimulationException(SimulationExceptionType.Simulation_Conversation_Member_Busy,
|
||||
memberId);
|
||||
}
|
||||
@ -105,19 +114,19 @@ public class ConversationManagerService {
|
||||
simulation.addConversation(conversation);
|
||||
// 会话创建成功事件
|
||||
SimulationConversationCreateEvent createEvent = new SimulationConversationCreateEvent(this, simulation, conversation);
|
||||
this.applicationEventPublisher.publishEvent(createEvent);
|
||||
applicationEventPublisher.publishEvent(createEvent);
|
||||
return new ConversationVO(conversation);
|
||||
}
|
||||
|
||||
/*---------------------------------- (创建会话)需要被邀请者同意 ----------------------------------*/
|
||||
public ConversationVO createConversation(String group, AccountVO user, CommunicationObject object, List<String> memberIds) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
SimulationUser simulationUser = simulation.getSimulationUserById(user.getId());
|
||||
SimulationMember creator = simulationUser.getPlayedMember();
|
||||
if (Objects.isNull(creator)) {
|
||||
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL);
|
||||
}
|
||||
return this.createConversation(simulation, creator, object, memberIds);
|
||||
return createConversation(simulation, creator, object, memberIds);
|
||||
}
|
||||
|
||||
public ConversationVO createConversation(Simulation simulation, SimulationMember creator, CommunicationObject object, List<String> memberIds) {
|
||||
@ -178,7 +187,7 @@ public class ConversationManagerService {
|
||||
simulation.addConversation(conversation);
|
||||
// 会话创建成功事件
|
||||
SimulationConversationCreateEvent createEvent = new SimulationConversationCreateEvent(this, simulation, conversation);
|
||||
this.applicationEventPublisher.publishEvent(createEvent);
|
||||
applicationEventPublisher.publishEvent(createEvent);
|
||||
// 用户发送会话邀请事件;机器人直接连接
|
||||
List<ConversationMember> memberList = conversation.getMemberList();
|
||||
for (ConversationMember conversationMember : memberList) {
|
||||
@ -189,9 +198,9 @@ public class ConversationManagerService {
|
||||
if (!member.isRobot()) {
|
||||
log.info(String.format("仿真[%s]会话[%s]邀请成员[%s]事件发布",
|
||||
simulation.getId(), conversation.getId(), member.toString()));
|
||||
this.applicationEventPublisher.publishEvent(new SimulationConversationInviteEvent(this, simulation, conversation, member));
|
||||
applicationEventPublisher.publishEvent(new SimulationConversationInviteEvent(this, simulation, conversation, member));
|
||||
} else {
|
||||
this.connect2Conversation(simulation, conversation, member);
|
||||
connect2Conversation(simulation, conversation, member);
|
||||
}
|
||||
}
|
||||
return new ConversationVO(conversation);
|
||||
@ -209,10 +218,10 @@ public class ConversationManagerService {
|
||||
}
|
||||
|
||||
public ConversationVO connect2Conversation(String group, AccountVO accountVO, String conversationId) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
Conversation conversation = simulation.getSimulationConversationById(conversationId);
|
||||
SimulationMember member = simulation.getSimulationMemberByUserId(accountVO.getId());
|
||||
return this.connect2Conversation(simulation, conversation, member);
|
||||
return connect2Conversation(simulation, conversation, member);
|
||||
}
|
||||
|
||||
public ConversationVO connect2Conversation(Simulation simulation, Conversation conversation, SimulationMember member) {
|
||||
@ -224,7 +233,7 @@ public class ConversationManagerService {
|
||||
// 发布用户连接会话事件
|
||||
SimulationConversationMemberConnectEvent connectEvent =
|
||||
new SimulationConversationMemberConnectEvent(this, simulation, conversation, member);
|
||||
this.applicationEventPublisher.publishEvent(connectEvent);
|
||||
applicationEventPublisher.publishEvent(connectEvent);
|
||||
return new ConversationVO(conversation);
|
||||
}
|
||||
|
||||
@ -232,10 +241,10 @@ public class ConversationManagerService {
|
||||
* 结束会话
|
||||
*/
|
||||
public void exitConversation(String group, String conversationId, AccountVO accountVO) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
Conversation conversation = simulation.getSimulationConversationById(conversationId);
|
||||
SimulationMember member = simulation.getSimulationMemberByUserId(accountVO.getId());
|
||||
this.exitConversation(simulation, conversation, member);
|
||||
exitConversation(simulation, conversation, member);
|
||||
}
|
||||
|
||||
public void exitConversation(Simulation simulation, Conversation conversation, SimulationMember member) {
|
||||
@ -245,20 +254,20 @@ public class ConversationManagerService {
|
||||
}
|
||||
// 发布会话成员退出事件
|
||||
SimulationConversationExitEvent overEvent = new SimulationConversationExitEvent(this, simulation, conversation, member);
|
||||
this.applicationEventPublisher.publishEvent(overEvent);
|
||||
applicationEventPublisher.publishEvent(overEvent);
|
||||
}
|
||||
|
||||
/**
|
||||
* 仿真用户会话chat
|
||||
*/
|
||||
public void chat(String group, String conversationId, AccountVO accountVO, MultipartFile file) {
|
||||
Simulation simulation = this.groupSimulationCache.getSimulationByGroup(group);
|
||||
Simulation simulation = groupSimulationCache.getSimulationByGroup(group);
|
||||
Conversation conversation = simulation.getSimulationConversationById(conversationId);
|
||||
SimulationMember member = simulation.getSimulationMemberByUserId(accountVO.getId());
|
||||
VoiceRecognitionResult recognitionResult = this.iVoiceService.voiceRecognition(file, "");
|
||||
VoiceRecognitionResult recognitionResult = iVoiceService.voiceRecognition(file, "");
|
||||
String upperCaseResult = recognitionResult.getResult().toUpperCase();
|
||||
String handledContent = this.simulationVoiceHandler.handle(upperCaseResult);
|
||||
this.chat(simulation, conversation, member, handledContent, recognitionResult.getFilePath());
|
||||
String handledContent = simulationVoiceHandler.handle(upperCaseResult);
|
||||
chat(simulation, conversation, member, handledContent, recognitionResult.getFilePath());
|
||||
}
|
||||
|
||||
public String chat(Simulation simulation, Conversation conversation,
|
||||
@ -269,7 +278,7 @@ public class ConversationManagerService {
|
||||
conversation.addMessage(conversationMessage);
|
||||
// scriptExecuteService.replaceContent4ConversationAction(simulation, conversation, conversationMessage);
|
||||
SimulationConversationChatEvent chatEvent = new SimulationConversationChatEvent(this, simulation, conversation, conversationMessage);
|
||||
this.applicationEventPublisher.publishEvent(chatEvent);
|
||||
applicationEventPublisher.publishEvent(chatEvent);
|
||||
return id;
|
||||
}
|
||||
|
||||
@ -293,4 +302,128 @@ public class ConversationManagerService {
|
||||
String path = iVoiceService.synthesis(content, "0");
|
||||
chat(simulation, conversation, member, content, path);
|
||||
}
|
||||
|
||||
//----------------------------------- 电话会话操作 -------------------------------------
|
||||
|
||||
/**
|
||||
* 打电话
|
||||
*/
|
||||
public ConversationVO phoneStart(Simulation simulation, SimulationMember member, CommunicationObject object, List<String> memberIds) {
|
||||
Set<SimulationMember> members = new LinkedHashSet<>();
|
||||
if (!CollectionUtils.isEmpty(memberIds)) {
|
||||
members.addAll(memberIds.stream().map(simulation::getSimulationMemberById).filter(simulationMember -> {
|
||||
if (Objects.nonNull(simulationMember.getUserId())) {
|
||||
SimulationUser simulationUser = simulation.querySimulationUserById(simulationMember.getUserId());
|
||||
return simulationUser.isOnline();
|
||||
}
|
||||
return true;
|
||||
}).collect(Collectors.toList()));
|
||||
}
|
||||
if (object != null) {
|
||||
switch (object) {
|
||||
case ALL_TRAIN:
|
||||
members.addAll(simulation.getMemberListByType(SimulationMember.Type.DRIVER));
|
||||
break;
|
||||
case ALL_STATION:
|
||||
members.addAll(simulation.getMemberListByType(SimulationMember.Type.STATION_SUPERVISOR));
|
||||
break;
|
||||
default:
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("未知的通讯对象[%s]", object));
|
||||
}
|
||||
}
|
||||
if (CollectionUtils.isEmpty(members)) {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, "会话成员列表为空/成员都不在线");
|
||||
}
|
||||
if (members.stream().anyMatch(simulation::isInValidConversation)) {
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, "有被邀请的成员正在进行其它通话");
|
||||
}
|
||||
Conversation conversation = new Conversation(simulation.getIdGenerator().nextConversationId(),
|
||||
member, simulation.getSystemTime(), new ArrayList<>(members), object);
|
||||
simulation.addConversation(conversation);
|
||||
return new ConversationVO(conversation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接听电话
|
||||
*/
|
||||
public ConversationVO phoneConnect(Simulation simulation, SimulationMember member, String conversationId) {
|
||||
Conversation conversation = simulation.getSimulationConversationById(conversationId);
|
||||
if (!conversation.isConversationMember(member)) {
|
||||
throw new SimulationException(SimulationExceptionType.Simulation_Conversation_Exception,
|
||||
String.format("成员[%s]不是会话[%s]成员", member, conversation.getId()));
|
||||
}
|
||||
conversation.memberConnect(member);
|
||||
return new ConversationVO(conversation);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接听电话,聊天输入
|
||||
*/
|
||||
public void phonePhoneChat(Simulation simulation, SimulationMember member, String id, String content, String audioPath) {
|
||||
Conversation conversation = simulation.getSimulationConversationById(id);
|
||||
if (conversation.isOver()) {
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("会话[%s]已经结束", id));
|
||||
}
|
||||
if (!conversation.contains(member)) {
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("会话[%s]不包含该成员[%s]", id, member.getId()));
|
||||
}
|
||||
String path = audioPath;
|
||||
if (StringUtils.isEmpty(audioPath)) {
|
||||
path = iVoiceService.synthesis(content, "0");
|
||||
}
|
||||
ConversationMessage conversationMessage = new ConversationMessage(simulation.getIdGenerator().nextConversationMessageId(),
|
||||
member, simulation.getCorrectSystemTime(), content, path);
|
||||
conversation.addMessage(conversationMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 电话:挂电话
|
||||
*/
|
||||
public void phoneExit(Simulation simulation, SimulationMember member, String id) {
|
||||
Conversation conversation = simulation.getSimulationConversationById(id);
|
||||
if (conversation.isOver()) {
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("会话[%s]已经结束", id));
|
||||
}
|
||||
if (!conversation.contains(member)) {
|
||||
throw new SimulationException(SimulationExceptionType.System_Fault, String.format("会话[%s]不包含该成员[%s]", id, member.getId()));
|
||||
}
|
||||
conversation.exit(member);
|
||||
if (conversation.isEmpty()) {
|
||||
conversation.over();
|
||||
}
|
||||
}
|
||||
|
||||
//----------------------------------- 消息会话 -------------------------------------
|
||||
|
||||
/**
|
||||
* 会话操作
|
||||
*/
|
||||
public void conversationChat(Simulation simulation, SimulationMember member, String content, String audioPath) {
|
||||
String path = audioPath;
|
||||
if (StringUtils.isEmpty(audioPath)) {
|
||||
path = iVoiceService.synthesis(content, "0");
|
||||
}
|
||||
ConversationMessage conversationMessage = new ConversationMessage(simulation.getIdGenerator().nextConversationMessageId(),
|
||||
member, simulation.getCorrectSystemTime(), content, path);
|
||||
sendChatMessage(simulation.getId(), simulation.getSimulationUserIds(), conversationMessage);
|
||||
}
|
||||
|
||||
/**
|
||||
* 解析语音文件信息
|
||||
*/
|
||||
public Map<String, Object> parseAudioInfo(MultipartFile file) {
|
||||
VoiceRecognitionResult recognitionResult = iVoiceService.voiceRecognition(file, "");
|
||||
String upperCaseResult = recognitionResult.getResult().toUpperCase();
|
||||
String handledContent = simulationVoiceHandler.handle(upperCaseResult);
|
||||
Map<String, Object> resultMap = new HashMap<>();
|
||||
resultMap.put("audioPath", recognitionResult.getFilePath());
|
||||
resultMap.put("content", handledContent);
|
||||
return resultMap;
|
||||
}
|
||||
|
||||
private void sendChatMessage(String simulationId, Set<String> userIds, ConversationMessage conversationMessage) {
|
||||
SocketMessageVO<ConversationMessageVO> chatMessage =
|
||||
SocketMessageFactory.build(WebSocketMessageType.Simulation_Conversation_Operation, simulationId, new ConversationMessageVO(conversationMessage));
|
||||
stompMessageService.sendToUser(userIds, chatMessage);
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,6 @@ import club.joylink.rtss.simulation.cbtc.data.vo.ConversationVO;
|
||||
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
@ -21,62 +20,63 @@ public class ConversationOperateHandler {
|
||||
@Autowired
|
||||
private ConversationManagerService conversationManagerService;
|
||||
|
||||
//-------------------------------- 电话消息操作 ---------------------------------------
|
||||
|
||||
/**
|
||||
* 获取会话信息
|
||||
* 电话:创建电话消息
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Get_Info)
|
||||
public ConversationVO getConversation(Simulation simulation, SimulationMember member, String id){
|
||||
return null;
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Phone_Start)
|
||||
public ConversationVO phoneStart(Simulation simulation, SimulationMember member, CommunicationObject object, List<String> memberIds) {
|
||||
return conversationManagerService.phoneStart(simulation, member, object, memberIds);
|
||||
}
|
||||
|
||||
/**
|
||||
* 会话列表信息
|
||||
* 电话:接听电话
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_List)
|
||||
public List<ConversationVO> getAllConversations(Simulation simulation, SimulationMember member){
|
||||
return null;
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Phone_Connect)
|
||||
public ConversationVO phoneConnect(Simulation simulation, SimulationMember member, String id) {
|
||||
return conversationManagerService.phoneConnect(simulation, member, id);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发起会话
|
||||
* 电话:语音消息
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Start)
|
||||
public ConversationVO startConversation(Simulation simulation, SimulationMember member
|
||||
, CommunicationObject object, List<String> memberIds){
|
||||
|
||||
return null;
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Phone_Audio)
|
||||
public void phonePhoneAudio(Simulation simulation, SimulationMember member, String id, String audioPath, String content) {
|
||||
conversationManagerService.phonePhoneChat(simulation, member, id, content, audioPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 接受会话
|
||||
* 电话:文字消息
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Accept)
|
||||
public ConversationVO acceptConversationInvite(Simulation simulation, SimulationMember member, String id){
|
||||
return null;
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Chat_Text)
|
||||
public void phonePhoneText(Simulation simulation, SimulationMember member, String id, String content) {
|
||||
conversationManagerService.phonePhoneChat(simulation, member, id, content, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* 结束会话
|
||||
* 电话:挂电话
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Over)
|
||||
public ConversationVO overConversation(Simulation simulation, SimulationMember member, String id){
|
||||
return null;
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Phone_Exit)
|
||||
public void phoneExit(Simulation simulation, SimulationMember member, String id) {
|
||||
conversationManagerService.phoneExit(simulation, member, id);
|
||||
}
|
||||
|
||||
//-------------------------------- 消息操作 ---------------------------------------
|
||||
|
||||
/**
|
||||
* 发送会话消息(语音输入)
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Chat_Audio)
|
||||
public ConversationVO audioChat(Simulation simulation, SimulationMember member, String id){
|
||||
return null;
|
||||
public void audioChat(Simulation simulation, SimulationMember member, String audioPath, String content) {
|
||||
conversationManagerService.conversationChat(simulation, member, content, audioPath);
|
||||
}
|
||||
|
||||
/**
|
||||
* 发送会话消息(文字输入)
|
||||
*/
|
||||
@OperateHandlerMapping(type = Operation.Type.Conversation_Chat_Text)
|
||||
public ConversationVO textChat(Simulation simulation, SimulationMember member, String id){
|
||||
return null;
|
||||
public void textChat(Simulation simulation, SimulationMember member, String content) {
|
||||
conversationManagerService.conversationChat(simulation, member, content, null);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -280,6 +280,7 @@ public class Section extends DelayUnlockDevice {
|
||||
this.closeInit = false;
|
||||
this.openInit = false;
|
||||
this.closed = false;
|
||||
this.badShunt = false;
|
||||
this.shuntingTypeList = new ArrayList<>();
|
||||
}
|
||||
|
||||
|
@ -272,6 +272,7 @@ public class SectionStatus extends DeviceStatus {
|
||||
statusVO.setDelayUnlock(delayUnlock);
|
||||
statusVO.setClosed(closed);
|
||||
statusVO.setFault(fault);
|
||||
statusVO.setBadShunt(badShunt);
|
||||
statusVO.setShuntingTypeList(this.shuntingTypeList);
|
||||
return statusVO;
|
||||
}
|
||||
|
@ -64,7 +64,10 @@ public enum WebSocketMessageType {
|
||||
* 仿真-会话消息
|
||||
*/
|
||||
Simulation_Conversation,
|
||||
|
||||
/**
|
||||
* 仿真-会话消息操作
|
||||
*/
|
||||
Simulation_Conversation_Operation,
|
||||
/**
|
||||
* 仿真-时间同步消息
|
||||
*/
|
||||
|
@ -124,6 +124,7 @@ public class SocketMessageFactory {
|
||||
case Simulation_Accept_Conversation:
|
||||
case Simulation_Exist_Conversation:
|
||||
case Simulation_Conversation:
|
||||
case Simulation_Conversation_Operation:
|
||||
case Simulation_Device:
|
||||
case Simulation_Quest_Loaded:
|
||||
case Simulation_Quest_Quit:
|
||||
|
@ -130,7 +130,6 @@ public abstract class Expression {
|
||||
*/
|
||||
@Getter
|
||||
@Setter
|
||||
@NoArgsConstructor
|
||||
public static class RelationalExpression extends Expression {
|
||||
Integer relationalOperator;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user