From 4e07a65b6ac5b6979cd007d08f6b59ec784e799a Mon Sep 17 00:00:00 2001 From: thesai <1021828630@qq.com> Date: Wed, 19 Jan 2022 14:36:13 +0800 Subject: [PATCH] =?UTF-8?q?pa/pis=E7=B3=BB=E7=BB=9F=E6=B6=88=E6=81=AF?= =?UTF-8?q?=E7=B1=BB=E5=9E=8B=E4=BD=9C=E4=B8=BA=E6=93=8D=E4=BD=9C=E5=8F=82?= =?UTF-8?q?=E6=95=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../interactive/IscsInteractiveService.java | 56 +++++++++---------- .../data/SimulationIscsDataRepository.java | 5 +- .../rtss/simulation/cbtc/data/map/Audio.java | 6 +- .../vo/client/iscs/IscsAudioResourceVO.java | 21 ------- .../rtss/vo/client/iscs/PlayParamVO.java | 5 ++ 5 files changed, 37 insertions(+), 56 deletions(-) delete mode 100644 src/main/java/club/joylink/rtss/vo/client/iscs/IscsAudioResourceVO.java diff --git a/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java b/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java index d5e98106f..d1460c10a 100644 --- a/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java +++ b/src/main/java/club/joylink/rtss/services/iscs/interactive/IscsInteractiveService.java @@ -1,6 +1,5 @@ package club.joylink.rtss.services.iscs.interactive; -import club.joylink.rtss.constants.IscsSystem; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.audio.AudioResourcesService; import club.joylink.rtss.services.voice.IVoiceService; @@ -11,7 +10,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityAudio; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.vo.client.audio.AudioResourcesVO; -import club.joylink.rtss.vo.client.iscs.IscsAudioResourceVO; import club.joylink.rtss.vo.client.iscs.PlayParamVO; import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO; import org.springframework.beans.factory.annotation.Autowired; @@ -33,17 +31,17 @@ public class IscsInteractiveService { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(member != null && (member.isDispatcher() || member.isStationSupervisor()), "仅行调和行值可操作"); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(param.getResourceId(), "资源id不能为null"); - IscsAudioResourceVO resourceVO = simulation.getIscsRepository().getIscsAudioResource(param.getResourceId()); + AudioResourcesVO resourceVO = simulation.getIscsRepository().getAudioResource(param.getResourceId()); SimulationDataRepository repository = simulation.getRepository(); for (String code : param.getIscsDeviceCodes()) { MapElement element = repository.getByCode(code); if (element instanceof Audio) { Audio audio = (Audio) element; audio.updateResource(resourceVO); - audio.updateState(getPaState(resourceVO, member)); + audio.updateState(getPaState(param.getType(), member)); audio.updateRemain(Audio.DEFAULT_REMAIN); VirtualRealityAudio vrAudio = audio.getVrAudio(); - vrAudio.updateUrl(resourceVO.getAudioResourcesVO().getUrl()); + vrAudio.updateUrl(resourceVO.getUrl()); vrAudio.control(VirtualRealityAudio.Command.PLAY); } } @@ -66,15 +64,14 @@ public class IscsInteractiveService { public String pisPlay(Simulation simulation, PlayParamVO param, SimulationMember member) { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertTrue(member != null && (member.isDispatcher() || member.isStationSupervisor()), "仅行调和行值可操作"); - IscsAudioResourceVO resourceVO; - if (param.getResourceId() != null) { - resourceVO = simulation.getIscsRepository().getIscsAudioResource(param.getResourceId()); + AudioResourcesVO resourceVO; + if (!IscsSystemResourcesVO.Type.REAL_TIME.equals(param.getType())) { + resourceVO = simulation.getIscsRepository().getAudioResource(param.getResourceId()); } else { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertHasText(param.getName(), "实时消息名称不能为空"); BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertHasText(param.getContent(), "实时消息内容不能为空"); String url = iVoiceService.synthesis(param.getContent(), "0"); - AudioResourcesVO audioResourcesVO = new AudioResourcesVO(param.getName(), param.getContent(), url); - resourceVO = new IscsAudioResourceVO(audioResourcesVO, IscsSystem.PIS, IscsSystemResourcesVO.Type.REAL_TIME); + resourceVO = new AudioResourcesVO(param.getName(), param.getContent(), url); } SimulationDataRepository repository = simulation.getRepository(); boolean play = false; @@ -84,13 +81,13 @@ public class IscsInteractiveService { Audio audio = (Audio) element; audio.updateResource(resourceVO); VirtualRealityAudio vrAudio = audio.getVrAudio(); - vrAudio.updateUrl(resourceVO.getAudioResourcesVO().getUrl()); + vrAudio.updateUrl(resourceVO.getUrl()); vrAudio.control(VirtualRealityAudio.Command.PLAY); play = true; } } if (play) { - return resourceVO.getAudioResourcesVO().getUrl(); + return resourceVO.getUrl(); } return null; } @@ -107,24 +104,25 @@ public class IscsInteractiveService { } } - private String getPaState(IscsAudioResourceVO resourcesVO, SimulationMember member) { + private String getPaState(IscsSystemResourcesVO.Type resourceType, SimulationMember member) { boolean dispatcher = member.isDispatcher(); - if (IscsSystemResourcesVO.Type.BGM.equals(resourcesVO.getType())) { - return Audio.State.BGM; + switch (resourceType) { + case RECORDING: + if (dispatcher) { + return Audio.State.CENTER_NORMAL; + } else { + return Audio.State.STATION_NORMAL; + } + case EMERGENCY_RECORDING: + if (dispatcher) { + return Audio.State.CENTER_EMERGENCY; + } else { + return Audio.State.STATION_EMERGENCY; + } + case BGM: + return Audio.State.BGM; + default: + throw new IllegalStateException("Unexpected value: " + resourceType); } - if (dispatcher) { - if (IscsSystemResourcesVO.Type.RECORDING.equals(resourcesVO.getType())) { - return Audio.State.CENTER_NORMAL; - } else if (IscsSystemResourcesVO.Type.EMERGENCY_RECORDING.equals(resourcesVO.getType())) { - return Audio.State.CENTER_EMERGENCY; - } - } else { - if (IscsSystemResourcesVO.Type.RECORDING.equals(resourcesVO.getType())) { - return Audio.State.STATION_NORMAL; - } else if (IscsSystemResourcesVO.Type.EMERGENCY_RECORDING.equals(resourcesVO.getType())) { - return Audio.State.STATION_EMERGENCY; - } - } - throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("消息类型异常"); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java index f64c41c07..cd2f0f20f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationIscsDataRepository.java @@ -4,7 +4,6 @@ import club.joylink.rtss.constants.IscsSystem; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.data.vo.iscs.IscsStatusVO; import club.joylink.rtss.vo.client.audio.AudioResourcesVO; -import club.joylink.rtss.vo.client.iscs.IscsAudioResourceVO; import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO; import lombok.NoArgsConstructor; import lombok.Setter; @@ -57,12 +56,12 @@ public class SimulationIscsDataRepository { return stream.collect(Collectors.toList()); } - public IscsAudioResourceVO getIscsAudioResource(long resourceId) { + public AudioResourcesVO getAudioResource(long resourceId) { for (IscsSystemResourcesVO systemResource : systemResources) { if (!CollectionUtils.isEmpty(systemResource.getResources())) { for (AudioResourcesVO resource : systemResource.getResources()) { if (Objects.equals(resourceId, resource.getId())) { - return new IscsAudioResourceVO(resource, systemResource.getSystem(), systemResource.getType()); + return resource; } } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Audio.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Audio.java index 195b148ab..30d66af2c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Audio.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Audio.java @@ -2,7 +2,7 @@ package club.joylink.rtss.simulation.cbtc.data.map; import club.joylink.rtss.constants.IscsSystem; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityAudio; -import club.joylink.rtss.vo.client.iscs.IscsAudioResourceVO; +import club.joylink.rtss.vo.client.audio.AudioResourcesVO; import club.joylink.rtss.vo.client.iscs.device.IscsDeviceVO; import com.fasterxml.jackson.annotation.JsonIgnore; import lombok.Getter; @@ -24,7 +24,7 @@ public class Audio extends MapElement{ private String state; - private IscsAudioResourceVO resource; + private AudioResourcesVO resource; /** * 剩余播放时长/ms @@ -50,7 +50,7 @@ public class Audio extends MapElement{ } } - public void updateResource(IscsAudioResourceVO resource) { + public void updateResource(AudioResourcesVO resource) { this.resource = resource; } diff --git a/src/main/java/club/joylink/rtss/vo/client/iscs/IscsAudioResourceVO.java b/src/main/java/club/joylink/rtss/vo/client/iscs/IscsAudioResourceVO.java deleted file mode 100644 index 3bfb1ae06..000000000 --- a/src/main/java/club/joylink/rtss/vo/client/iscs/IscsAudioResourceVO.java +++ /dev/null @@ -1,21 +0,0 @@ -package club.joylink.rtss.vo.client.iscs; - -import club.joylink.rtss.constants.IscsSystem; -import club.joylink.rtss.vo.client.audio.AudioResourcesVO; -import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO; -import lombok.Getter; - -@Getter -public class IscsAudioResourceVO { - private AudioResourcesVO audioResourcesVO; - - private IscsSystem system; - - private IscsSystemResourcesVO.Type type; - - public IscsAudioResourceVO(AudioResourcesVO resource, IscsSystem system, IscsSystemResourcesVO.Type type) { - this.audioResourcesVO = resource; - this.system = system; - this.type = type; - } -} diff --git a/src/main/java/club/joylink/rtss/vo/client/iscs/PlayParamVO.java b/src/main/java/club/joylink/rtss/vo/client/iscs/PlayParamVO.java index a6b3590dc..3f569ea68 100644 --- a/src/main/java/club/joylink/rtss/vo/client/iscs/PlayParamVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/iscs/PlayParamVO.java @@ -1,10 +1,12 @@ package club.joylink.rtss.vo.client.iscs; +import club.joylink.rtss.vo.client.iscs.systemRes.IscsSystemResourcesVO; import lombok.Getter; import lombok.NoArgsConstructor; import lombok.Setter; import javax.validation.constraints.NotEmpty; +import javax.validation.constraints.NotNull; import java.util.List; /** @@ -14,6 +16,9 @@ import java.util.List; @Setter @NoArgsConstructor public class PlayParamVO { + @NotNull(message = "类型不能为null") + private IscsSystemResourcesVO.Type type; + private Long resourceId; @NotEmpty(message = "设备编号不能为空")