From a26d883e99f8428cb60d03477d35bff451c62b2d Mon Sep 17 00:00:00 2001 From: weizhihong Date: Fri, 21 Apr 2023 10:41:00 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=BE=A4=E7=BB=84=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E5=A4=A7=E5=B0=8F=E5=86=99=E9=97=AE=E9=A2=98=EF=BC=8C=E4=BA=BA?= =?UTF-8?q?=E5=91=98=E8=BF=9B=E7=BB=84=E6=97=B6=E5=90=8D=E5=AD=97=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ConversationGroupHandlerService.java | 6 +- .../ConversationGroupListener.java | 2 +- .../cbtc/member/SimulationMember.java | 69 ++++++++++++------- 3 files changed, 49 insertions(+), 28 deletions(-) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java index 94f351b89..afba7c0dd 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupHandlerService.java @@ -18,6 +18,7 @@ import club.joylink.rtss.vo.client.voice.VoiceRecognitionResult; import club.joylink.rtss.vo.client.voice.VoiceRecognitionVO; import club.joylink.rtss.websocket.StompMessageService; import lombok.extern.slf4j.Slf4j; +import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationEventPublisher; import org.springframework.context.event.EventListener; @@ -315,8 +316,9 @@ public class ConversationGroupHandlerService { throw new SimulationException(SimulationExceptionType.Illegal_Argument, "非本组成员"); } VoiceRecognitionResult recognitionResult = handleSupplier.get(); - String upperCaseResult = recognitionResult.getResult().toUpperCase(); - String handledContent = simulationVoiceHandler.handle(upperCaseResult); + // 对语音信息进行消息文字处理 + String handledContent = StringUtils.isNotEmpty(recognitionResult.getFilePath()) ? + simulationVoiceHandler.handle(recognitionResult.getResult().toUpperCase()) : recognitionResult.getResult(); // 创建消息信息 String messageId = conversationGroup.generateMessageId(); ConversationGroupMessage message = new ConversationGroupMessage(messageId, member, diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupListener.java b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupListener.java index 5997663ed..e53aec4e8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupListener.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/conversation/ConversationGroupListener.java @@ -81,7 +81,7 @@ public class ConversationGroupListener { if (!m.isRobot()) { newUserIdSet.add(m.getUserId()); } - stringBuilder.append(m.getName()).append("、"); + stringBuilder.append(m.getMemberName()).append("、"); }); // 通知新成员 if (!CollectionUtils.isEmpty(newUserIdSet)) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/member/SimulationMember.java b/src/main/java/club/joylink/rtss/simulation/cbtc/member/SimulationMember.java index 01e293240..fa0c769dc 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/member/SimulationMember.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/member/SimulationMember.java @@ -6,6 +6,7 @@ import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement; import club.joylink.rtss.simulation.vo.SimulationMemberVO; import lombok.Getter; import lombok.Setter; +import org.apache.commons.lang3.StringUtils; import javax.validation.constraints.NotNull; import java.util.Objects; @@ -120,6 +121,20 @@ public class SimulationMember extends club.joylink.rtss.simulation.SimulationMem return String.format("仿真成员[%s][%s][%s]", getId(), getType(), getName()); } + public String getMemberName() { + if (StringUtils.isNotEmpty(this.name)) { + return this.name; + } + StringBuilder memberName = new StringBuilder(); + if (device instanceof MapNamedElement) { + memberName.append(((MapNamedElement) device).getName()); + } + if (this.type != null) { + memberName.append(this.type.getDescription()); + } + return memberName.toString(); + } + @Override public String toString() { String deviceInfo = null; @@ -160,90 +175,94 @@ public class SimulationMember extends club.joylink.rtss.simulation.SimulationMem /** * 仿真成员岗位 */ + @Getter public enum Type { /** * 值班主任 */ - SHIFT_MANAGER(Area.OCC), + SHIFT_MANAGER(Area.OCC, "值班主任"), /** * 中心调度员 */ - DISPATCHER(Area.OCC), + DISPATCHER(Area.OCC, "值班主任"), /** * 电力调度 */ - ELECTRIC_DISPATCHER(Area.OCC), + ELECTRIC_DISPATCHER(Area.OCC, "电力调度"), /** * 环控调度 */ - ENVIRONMENT_DISPATCHER(Area.OCC), + ENVIRONMENT_DISPATCHER(Area.OCC, "环控调度"), /** * 车辆段调度 */ - DEPOT_DISPATCHER(Area.VEHICLE_DEPOT), + DEPOT_DISPATCHER(Area.VEHICLE_DEPOT, "车辆段调度"), /** * 车站值班员 */ - STATION_SUPERVISOR(Area.STATION), + STATION_SUPERVISOR(Area.STATION, "车站值班员"), /** * 司机 */ - DRIVER(Area.TRAIN), + DRIVER(Area.TRAIN, "司机"), /** * 通号 */ - MAINTAINER(Area.STATION), + MAINTAINER(Area.STATION, "通号"), /** * 车辆段/停车场信号楼 */ - SIGNAL_BUILDING(Area.VEHICLE_DEPOT), + SIGNAL_BUILDING(Area.VEHICLE_DEPOT, "车辆段/停车场信号楼"), /** * 上级部门 */ @Deprecated(since = "2022-10-17", forRemoval = true) - PARENT_DEPARTMENT(Area.OCC), + PARENT_DEPARTMENT(Area.OCC, "上级部门"), /** * 派班员 */ @Deprecated(since = "2022-10-17", forRemoval = true) - SCHEDULING(Area.OCC), - - + SCHEDULING(Area.OCC, "派班员"), /** * 车务段段长 */ - TRAIN_MASTER(Area.TRAIN_DEPOT), + TRAIN_MASTER(Area.TRAIN_DEPOT, "车务段段长"), /** * 车站助理 */ - STATION_ASSISTANT(Area.STATION), - /*** 车站站长 */ - STATION_MASTER(Area.STATION), + STATION_ASSISTANT(Area.STATION, "车站助理"), + /** + * 车站站长 + * */ + STATION_MASTER(Area.STATION, "车站站长"), /** * 车站信号员 */ - STATION_SIGNALER(Area.STATION), + STATION_SIGNALER(Area.STATION, "车站信号员"), /** * 车站客运员 */ - STATION_PASSENGER(Area.STATION), + STATION_PASSENGER(Area.STATION, "车站客运员"), /** 车站扳道员 */ - STATION_SWITCH_MAN(Area.STATION), + STATION_SWITCH_MAN(Area.STATION, "车站扳道员"), /** 车站引导员 */ - STATION_FACILITATOR(Area.STATION), + STATION_FACILITATOR(Area.STATION, "车站引导员"), /** 车站工务工*/ - STATION_WORKER(Area.STATION), + STATION_WORKER(Area.STATION, "车站工务工"), /** 设备管理员 */ - DEVICE_MANAGER(Area.STATION), + DEVICE_MANAGER(Area.STATION, "设备管理员"), /** * 电力工务 */ - STATION_ELECTRIC_WORKER(Area.STATION); + STATION_ELECTRIC_WORKER(Area.STATION, "电力工务"); private final int area; - Type(int area) { + private final String description; + + Type(int area, String description) { this.area = area; + this.description = description; } }