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); } }