【修改状态判定,解决列车触发条件不生效问题】

This commit is contained in:
weizhihong 2022-09-15 09:09:52 +08:00
parent 1e94f3ae5a
commit 48a28cb7c4
4 changed files with 37 additions and 9 deletions

View File

@ -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())) {

View File

@ -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> T getValue(Class<T> 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);

View File

@ -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);
}
/**

View File

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