【修改状态判定,解决列车触发条件不生效问题】
This commit is contained in:
parent
1e94f3ae5a
commit
48a28cb7c4
@ -527,11 +527,11 @@ public class Training2Service {
|
|||||||
* 加载实训数据
|
* 加载实训数据
|
||||||
*/
|
*/
|
||||||
private void loadTraining(Simulation simulation, DraftTraining2WithBLOBs draftTraining2, LoginUserInfoVO loginUserInfoVO) {
|
private void loadTraining(Simulation simulation, DraftTraining2WithBLOBs draftTraining2, LoginUserInfoVO loginUserInfoVO) {
|
||||||
Training2 training2 = new Training2(draftTraining2, simulation);
|
|
||||||
// 没有背景不做加载
|
// 没有背景不做加载
|
||||||
if (!StringUtils.isEmpty(training2.getBgSceneJson())) {
|
if (!StringUtils.isEmpty(draftTraining2.getBgSceneJson())) {
|
||||||
groupSimulationService.loadScenes(simulation.getId(), training2.getBgSceneJson());
|
groupSimulationService.loadScenes(simulation.getId(), draftTraining2.getBgSceneJson());
|
||||||
}
|
}
|
||||||
|
Training2 training2 = new Training2(draftTraining2, simulation);
|
||||||
simulation.setTraining2(training2);
|
simulation.setTraining2(training2);
|
||||||
// 如果是单操,设置为步骤指定角色
|
// 如果是单操,设置为步骤指定角色
|
||||||
if (Training2.Type.SINGLE.equals(training2.getType())) {
|
if (Training2.Type.SINGLE.equals(training2.getType())) {
|
||||||
|
@ -2,10 +2,12 @@ package club.joylink.rtss.simulation.cbtc.training2;
|
|||||||
|
|
||||||
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
|
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;
|
import java.lang.reflect.Field;
|
||||||
|
|
||||||
public class StatusValue implements Valuable{
|
public class StatusValue implements Valuable {
|
||||||
private MapElement element;
|
private MapElement element;
|
||||||
|
|
||||||
private String fieldName;
|
private String fieldName;
|
||||||
@ -15,7 +17,12 @@ public class StatusValue implements Valuable{
|
|||||||
public StatusValue(MapElement element, String fieldName) {
|
public StatusValue(MapElement element, String fieldName) {
|
||||||
this.element = element;
|
this.element = element;
|
||||||
this.fieldName = fieldName;
|
this.fieldName = fieldName;
|
||||||
Class<?> aClass = element.getClass();
|
Class<?> aClass;
|
||||||
|
if (element instanceof VirtualRealityTrain) {
|
||||||
|
aClass = TrainInfo.class;
|
||||||
|
} else {
|
||||||
|
aClass = element.getClass();
|
||||||
|
}
|
||||||
while (true) {
|
while (true) {
|
||||||
try {
|
try {
|
||||||
field = aClass.getDeclaredField(fieldName);
|
field = aClass.getDeclaredField(fieldName);
|
||||||
@ -34,7 +41,16 @@ public class StatusValue implements Valuable{
|
|||||||
@Override
|
@Override
|
||||||
public <T> T getValue(Class<T> cls) {
|
public <T> T getValue(Class<T> cls) {
|
||||||
try {
|
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;
|
return (T) o;
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
|
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
|
||||||
|
@ -229,7 +229,7 @@ public class Step2 {
|
|||||||
* 是否早已触发
|
* 是否早已触发
|
||||||
*/
|
*/
|
||||||
public static boolean isAlreadyTrigger(StepStatus status) {
|
public static boolean isAlreadyTrigger(StepStatus status) {
|
||||||
return status != null && (status.sort >= TRIGGER.sort);
|
return status != null && (status.sort > TRIGGER.sort);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,6 +1,9 @@
|
|||||||
package club.joylink.rtss.vo.client.training2;
|
package club.joylink.rtss.vo.client.training2;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
|
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.StatusValue;
|
||||||
import club.joylink.rtss.simulation.cbtc.training2.Valuable;
|
import club.joylink.rtss.simulation.cbtc.training2.Valuable;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -10,13 +13,22 @@ import lombok.Setter;
|
|||||||
@Getter
|
@Getter
|
||||||
@Setter
|
@Setter
|
||||||
@NoArgsConstructor
|
@NoArgsConstructor
|
||||||
public class StatusValueVO implements ValuableVO{
|
public class StatusValueVO implements ValuableVO {
|
||||||
private String elementCode;
|
private String elementCode;
|
||||||
|
|
||||||
private String filedName;
|
private String filedName;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Valuable convert2BO(SimulationDataRepository repository) {
|
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);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user