From 48a28cb7c43ac70aa90db608b1ae1c26f44f39d8 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Thu, 15 Sep 2022 09:09:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E7=8A=B6=E6=80=81?= =?UTF-8?q?=E5=88=A4=E5=AE=9A=EF=BC=8C=E8=A7=A3=E5=86=B3=E5=88=97=E8=BD=A6?= =?UTF-8?q?=E8=A7=A6=E5=8F=91=E6=9D=A1=E4=BB=B6=E4=B8=8D=E7=94=9F=E6=95=88?= =?UTF-8?q?=E9=97=AE=E9=A2=98=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/training2/Training2Service.java | 6 ++--- .../cbtc/training2/StatusValue.java | 22 ++++++++++++++++--- .../rtss/simulation/cbtc/training2/Step2.java | 2 +- .../vo/client/training2/StatusValueVO.java | 16 ++++++++++++-- 4 files changed, 37 insertions(+), 9 deletions(-) diff --git a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java index e2ddd6e48..616af420c 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -527,11 +527,11 @@ public class Training2Service { * 加载实训数据 */ private void loadTraining(Simulation simulation, DraftTraining2WithBLOBs draftTraining2, LoginUserInfoVO loginUserInfoVO) { - Training2 training2 = new Training2(draftTraining2, simulation); // 没有背景不做加载 - if (!StringUtils.isEmpty(training2.getBgSceneJson())) { - groupSimulationService.loadScenes(simulation.getId(), training2.getBgSceneJson()); + if (!StringUtils.isEmpty(draftTraining2.getBgSceneJson())) { + groupSimulationService.loadScenes(simulation.getId(), draftTraining2.getBgSceneJson()); } + Training2 training2 = new Training2(draftTraining2, simulation); simulation.setTraining2(training2); // 如果是单操,设置为步骤指定角色 if (Training2.Type.SINGLE.equals(training2.getType())) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/StatusValue.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/StatusValue.java index 897185b59..24368dad9 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/StatusValue.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/StatusValue.java @@ -2,10 +2,12 @@ package club.joylink.rtss.simulation.cbtc.training2; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; +import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import java.lang.reflect.Field; -public class StatusValue implements Valuable{ +public class StatusValue implements Valuable { private MapElement element; private String fieldName; @@ -15,7 +17,12 @@ public class StatusValue implements Valuable{ public StatusValue(MapElement element, String fieldName) { this.element = element; this.fieldName = fieldName; - Class aClass = element.getClass(); + Class aClass; + if (element instanceof VirtualRealityTrain) { + aClass = TrainInfo.class; + } else { + aClass = element.getClass(); + } while (true) { try { field = aClass.getDeclaredField(fieldName); @@ -34,7 +41,16 @@ public class StatusValue implements Valuable{ @Override public T getValue(Class cls) { try { - Object o = field.get(element); + MapElement mapElement; + if (element instanceof VirtualRealityTrain) { + VirtualRealityTrain virtualRealityTrain = (VirtualRealityTrain) element; + TrainInfo trainInfo = new TrainInfo(virtualRealityTrain.getGroupNumber()); + trainInfo.tracking(virtualRealityTrain); + mapElement = trainInfo; + } else { + mapElement = element; + } + Object o = field.get(mapElement); return (T) o; } catch (Exception e) { throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java index 8247b8b4a..c2fd829a7 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Step2.java @@ -229,7 +229,7 @@ public class Step2 { * 是否早已触发 */ public static boolean isAlreadyTrigger(StepStatus status) { - return status != null && (status.sort >= TRIGGER.sort); + return status != null && (status.sort > TRIGGER.sort); } /** diff --git a/src/main/java/club/joylink/rtss/vo/client/training2/StatusValueVO.java b/src/main/java/club/joylink/rtss/vo/client/training2/StatusValueVO.java index b97d57656..9a1ef4711 100644 --- a/src/main/java/club/joylink/rtss/vo/client/training2/StatusValueVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/training2/StatusValueVO.java @@ -1,6 +1,9 @@ package club.joylink.rtss.vo.client.training2; import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.exception.SimulationException; +import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; import club.joylink.rtss.simulation.cbtc.training2.StatusValue; import club.joylink.rtss.simulation.cbtc.training2.Valuable; import lombok.Getter; @@ -10,13 +13,22 @@ import lombok.Setter; @Getter @Setter @NoArgsConstructor -public class StatusValueVO implements ValuableVO{ +public class StatusValueVO implements ValuableVO { private String elementCode; private String filedName; @Override public Valuable convert2BO(SimulationDataRepository repository) { - return new StatusValue(repository.getByCode(elementCode), filedName); + MapElement mapElement = null; + if (repository.getDeviceMap().containsKey(elementCode)) { + mapElement = repository.getDeviceMap().get(elementCode); + } else if (repository.getVrDeviceMap().containsKey(elementCode)) { + mapElement = repository.getVrDeviceMap().get(elementCode); + } else { + throw new SimulationException(SimulationExceptionType.System_Fault + , String.format("地图数据异常:不存在code为[%s]的数据", elementCode)); + } + return new StatusValue(mapElement, filedName); } }