【状态类型为枚举时,判断做处理】

This commit is contained in:
weizhihong 2022-09-15 10:52:30 +08:00
parent 48a28cb7c4
commit 1ab2452c70
2 changed files with 11 additions and 5 deletions

View File

@ -412,7 +412,7 @@ public class TrainInfo extends MapElement {
this.runLevel = config.getRunMode(); this.runLevel = config.getRunMode();
} }
public void tracking(VirtualRealityTrain train) { public TrainInfo tracking(VirtualRealityTrain train) {
this.runLevel = train.getRunLevel(); this.runLevel = train.getRunLevel();
SectionPosition headPosition = train.getHeadPosition(); SectionPosition headPosition = train.getHeadPosition();
this.physicalSection = headPosition.getSection().getCode(); this.physicalSection = headPosition.getSection().getCode();
@ -450,6 +450,12 @@ public class TrainInfo extends MapElement {
} }
this.preselectionMode = train.getPreselectionMode(); this.preselectionMode = train.getPreselectionMode();
this.beAbout2Arrival = train.isBeAbout2Arrive(); this.beAbout2Arrival = train.isBeAbout2Arrive();
return this;
}
public static TrainInfo virtualTrainTracking(VirtualRealityTrain train) {
TrainInfo trainInfo = new TrainInfo(train.getGroupNumber());
return trainInfo.tracking(train);
} }
public boolean isCtcLevel() { public boolean isCtcLevel() {

View File

@ -43,14 +43,14 @@ public class StatusValue implements Valuable {
try { try {
MapElement mapElement; MapElement mapElement;
if (element instanceof VirtualRealityTrain) { if (element instanceof VirtualRealityTrain) {
VirtualRealityTrain virtualRealityTrain = (VirtualRealityTrain) element; mapElement = TrainInfo.virtualTrainTracking((VirtualRealityTrain) element);
TrainInfo trainInfo = new TrainInfo(virtualRealityTrain.getGroupNumber());
trainInfo.tracking(virtualRealityTrain);
mapElement = trainInfo;
} else { } else {
mapElement = element; mapElement = element;
} }
Object o = field.get(mapElement); Object o = field.get(mapElement);
if (o.getClass().isEnum()) { // 枚举类型转为字符串
o = o.toString();
}
return (T) o; return (T) o;
} catch (Exception e) { } catch (Exception e) {
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e); throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);