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 e3d191c9e..2f64c2d8c 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -294,7 +294,7 @@ public class Training2Service { } } } catch (InterruptedException e) { - throw new RuntimeException(e); + throw new SimulationException(SimulationExceptionType.System_Fault, e); } finally { completeStepSemaphore.release(); } @@ -338,7 +338,7 @@ public class Training2Service { } } } catch (InterruptedException e) { - throw new RuntimeException(e); + throw new SimulationException(SimulationExceptionType.System_Fault, e); } finally { completeOperationSemaphore.release(); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java index ff1c90427..7b812728c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Route.java @@ -21,7 +21,7 @@ import java.util.*; */ @Getter @Setter -@ExpConditionMaterialSrcAnno(name="Route") +@ExpConditionMaterialSrcAnno(name = "Route", deviceType = MapElement.DeviceType.ROUTE) public class Route extends MapNamedElement { public Route(String code, String name) { @@ -161,31 +161,31 @@ public class Route extends MapNamedElement { /** * ats自动控制 */ - @ExpConditionMaterialAnno(name = "atsControl",type = "boolean",desc = "ats自动控制") + @ExpConditionMaterialAnno(name = "atsControl", type = "boolean", desc = "ats自动控制") private boolean atsControl; /** * 连续通过进路模式(联锁自动进路)开启 */ - @ExpConditionMaterialAnno(name = "fleetMode",type = "boolean",desc = "连续通过进路模式(联锁自动进路)开启") + @ExpConditionMaterialAnno(name = "fleetMode", type = "boolean", desc = "连续通过进路模式(联锁自动进路)开启") private boolean fleetMode; /** * 自动追踪/联锁自动触发模式开启 */ - @ExpConditionMaterialAnno(name = "ciControl",type = "boolean",desc = "自动追踪/联锁自动触发模式开启") + @ExpConditionMaterialAnno(name = "ciControl", type = "boolean", desc = "自动追踪/联锁自动触发模式开启") private boolean ciControl; /** * 进路是否可以排列 */ - @ExpConditionMaterialAnno(name = "settable",type = "boolean",desc = "进路是否可以排列") + @ExpConditionMaterialAnno(name = "settable", type = "boolean", desc = "进路是否可以排列") private boolean settable; /** * 进路是否排列中 */ - @ExpConditionMaterialAnno(name = "setting",type = "boolean",desc = "进路是否排列中") + @ExpConditionMaterialAnno(name = "setting", type = "boolean", desc = "进路是否排列中") private boolean setting; /** * 该进路办理成功后要开放的信号 @@ -201,13 +201,13 @@ public class Route extends MapNamedElement { /** * 是否引导进路排列中 */ - @ExpConditionMaterialAnno(name = "guideSetting",type = "boolean",desc = "是否引导进路排列中") + @ExpConditionMaterialAnno(name = "guideSetting", type = "boolean", desc = "是否引导进路排列中") private boolean guideSetting; /** * 进路是否锁闭 */ - @ExpConditionMaterialAnno(name = "lock",type = "boolean",desc = "进路是否锁闭") + @ExpConditionMaterialAnno(name = "lock", type = "boolean", desc = "进路是否锁闭") private boolean lock; /** @@ -218,7 +218,7 @@ public class Route extends MapNamedElement { /** * 是否正常解锁中 */ - @ExpConditionMaterialAnno(name = "normalUnlock",type = "boolean",desc = "是否正常解锁中") + @ExpConditionMaterialAnno(name = "normalUnlock", type = "boolean", desc = "是否正常解锁中") private boolean normalUnlock; /** @@ -267,13 +267,14 @@ public class Route extends MapNamedElement { this.unlockedSection = null; this.train = null; this.checkConflict = false; - this.settedAspect=null; + this.settedAspect = null; } + /** * 是否是组合进路 */ public boolean isMultiRoute() { - return null!=this.multiRouteAspects&&!this.multiRouteAspects.isEmpty(); + return null != this.multiRouteAspects && !this.multiRouteAspects.isEmpty(); } /** @@ -835,7 +836,7 @@ public class Route extends MapNamedElement { } } } - SignalAspect rt=getSettedAspect()==null?getAspect():getSettedAspect(); + SignalAspect rt = getSettedAspect() == null ? getAspect() : getSettedAspect(); return rt; } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java index 92597b10c..e40622099 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Section.java @@ -21,7 +21,7 @@ import java.util.*; */ @Getter @Setter -@ExpConditionMaterialSrcAnno(name = "Section") +@ExpConditionMaterialSrcAnno(name = "Section", deviceType = MapElement.DeviceType.SECTION) public class Section extends DelayUnlockDevice { public Section(String code, String name) { @@ -186,13 +186,13 @@ public class Section extends DelayUnlockDevice { /** * 是否封锁(封锁后,包含区段的进路不能排列) */ - @ExpConditionMaterialAnno(name = "blockade",type = "boolean",desc = "是否封锁(封锁后,包含区段的进路不能排列)") + @ExpConditionMaterialAnno(name = "blockade", type = "boolean", desc = "是否封锁") private boolean blockade; /** * 是否进路锁闭 */ - @ExpConditionMaterialAnno(name = "routeLock",type = "boolean",desc = "是否进路锁闭") + @ExpConditionMaterialAnno(name = "routeLock", type = "boolean", desc = "是否进路锁闭") private boolean routeLock; /** @@ -208,43 +208,42 @@ public class Section extends DelayUnlockDevice { /** * 进路延续保护锁闭 */ - @ExpConditionMaterialAnno(name = "overlapLock",type = "boolean",desc = "进路延续保护锁闭") + @ExpConditionMaterialAnno(name = "overlapLock", type = "boolean", desc = "是否进路延续保护锁闭") private boolean overlapLock; /** * 通信车占用 */ - @ExpConditionMaterialAnno(name = "ctOccupied",type = "boolean",desc = "通信车占用") + @ExpConditionMaterialAnno(name = "ctOccupied", type = "boolean", desc = "是否通信车占用") private boolean ctOccupied; /** * 计轴占用-非通信车占用 */ - @ExpConditionMaterialAnno(name = "nctOccupied",type = "boolean",desc = "计轴占用-非通信车占用") + @ExpConditionMaterialAnno(name = "nctOccupied", type = "boolean", desc = "是否非通信车占用") private boolean nctOccupied; /** * 占用列车方向 */ - @ExpConditionMaterialAnno(name = "trainRight",type = "boolean",desc = "占用列车方向") private boolean trainRight; /** * 是否切除 */ - @ExpConditionMaterialAnno(name = "cutOff",type = "boolean",desc = "是否切除") + @ExpConditionMaterialAnno(name = "cutOff", type = "boolean", desc = "是否切除") private boolean cutOff; /** * 计轴是否被报失效(ARB故障) */ - @ExpConditionMaterialAnno(name = "invalid",type = "boolean",desc = "计轴是否被报失效(ARB故障)") + @ExpConditionMaterialAnno(name = "invalid", type = "boolean", desc = "是否ARB") private boolean invalid; /** * 故障锁闭 */ - @ExpConditionMaterialAnno(name = "faultLock",type = "boolean",desc = "故障锁闭") + @ExpConditionMaterialAnno(name = "faultLock", type = "boolean", desc = "是否故障锁闭") private boolean faultLock; /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java index 781b71a69..e8bfff7f0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Signal.java @@ -22,7 +22,7 @@ import java.util.stream.Collectors; */ @Getter @Setter -@ExpConditionMaterialSrcAnno(name = "Signal") +@ExpConditionMaterialSrcAnno(name = "Signal", deviceType = MapElement.DeviceType.SIGNAL) public class Signal extends DelayUnlockDevice { public static int GUIDE_DELAY = 15 * 1000; //大铁首区段占用的引导进路的延时关闭时长 @@ -192,7 +192,6 @@ public class Signal extends DelayUnlockDevice { /** * 重复封锁(*后期去掉*) */ - @ExpConditionMaterialAnno(name = "reblockade", type = "boolean", desc = "重复封锁") private boolean reblockade; /** * 侧防锁闭(侧防锁闭后,不能排列此信号机为始端的任何进路) @@ -212,7 +211,6 @@ public class Signal extends DelayUnlockDevice { /** * 是否禁止联锁自动开信号 */ - @ExpConditionMaterialAnno(name = "forbidden", type = "boolean", desc = "是否禁止联锁自动开信号") private boolean forbidden; /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java index 18d69788e..fa8a9210f 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Stand.java @@ -20,7 +20,7 @@ import java.util.concurrent.ConcurrentHashMap; */ @Getter @Setter -@ExpConditionMaterialSrcAnno(name = "StationStand") +@ExpConditionMaterialSrcAnno(name = "StationStand", deviceType = MapElement.DeviceType.STAND) public class Stand extends MayOutOfOrderDevice { public Stand(String code, String name) { diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java index a0e0b06c4..b0904b7cf 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Station.java @@ -24,7 +24,7 @@ import java.util.stream.Collectors; @Getter @Setter -@ExpConditionMaterialSrcAnno(name = "Station") +@ExpConditionMaterialSrcAnno(name = "Station", deviceType = MapElement.DeviceType.STATION) public class Station extends MayOutOfOrderDevice { public Station(String code, String name) { super(code, name, DeviceType.STATION); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java index 7016286df..d5b5ab621 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/map/Switch.java @@ -15,7 +15,7 @@ import java.util.stream.Collectors; */ @Getter @Setter -@ExpConditionMaterialSrcAnno(name = "Switch") +@ExpConditionMaterialSrcAnno(name = "Switch", deviceType = MapElement.DeviceType.SWITCH) public class Switch extends DelayUnlockDevice { public Switch(String code, String name) { super(code, name, DeviceType.SWITCH); @@ -104,7 +104,7 @@ public class Switch extends DelayUnlockDevice { /** * 道岔位置表示 */ - @ExpConditionMaterialAnno(name = "pos", type = "SwitchIndication", desc = "道岔位置表示") + @ExpConditionMaterialAnno(name = "pos", type = "SwitchIndication", desc = "道岔位置") private SwitchIndication pos; /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java index 7374d1e3c..82adba694 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vo/TrainInfo.java @@ -11,6 +11,8 @@ import club.joylink.rtss.simulation.cbtc.data.plan.TripPlan; import club.joylink.rtss.simulation.cbtc.data.storage.vo.StorageTrainInfo; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; +import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno; +import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialSrcAnno; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -30,6 +32,7 @@ import java.util.concurrent.ConcurrentHashMap; */ @Slf4j @Getter +@ExpConditionMaterialSrcAnno(name = "Train", deviceType = MapElement.DeviceType.TRAIN) public class TrainInfo extends MapElement { private String groupNumber; @@ -80,6 +83,7 @@ public class TrainInfo extends MapElement { /** * 所处区段 */ + @ExpConditionMaterialAnno(name = "section", type = "SECTION", desc = "所处位置") private String section; /** @@ -95,6 +99,7 @@ public class TrainInfo extends MapElement { @Setter private Boolean right; + @ExpConditionMaterialAnno(name = "speed", type = "float", desc = "车速") private float speed; private boolean doorOpen; @@ -102,11 +107,13 @@ public class TrainInfo extends MapElement { /** * 跟踪模式 */ + @ExpConditionMaterialAnno(name = "runLevel", type = "RunLevel", desc = "列车运行级别") private RunLevel runLevel; /** * 驾驶模式 */ + @ExpConditionMaterialAnno(name = "driveMode", type = "DriveMode", desc = "驾驶模式") private DriveMode driveMode; /** @@ -116,6 +123,7 @@ public class TrainInfo extends MapElement { private boolean jump; + @ExpConditionMaterialAnno(name = "hold", type = "boolean", desc = "是否扣车") private boolean hold; /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java index d6a0d0002..d2952eb82 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/vr/VirtualRealityTrain.java @@ -13,8 +13,6 @@ import club.joylink.rtss.simulation.cbtc.data.support.MovementAuthority; import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition; import club.joylink.rtss.simulation.cbtc.exception.SimulationException; import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType; -import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno; -import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialSrcAnno; import club.joylink.rtss.vo.client.operation.DriveParamVO; import lombok.Getter; import lombok.Setter; @@ -29,7 +27,6 @@ import java.util.*; @Slf4j @Getter @Setter -@ExpConditionMaterialSrcAnno(name = "Train") public class VirtualRealityTrain extends VirtualRealityDevice { // -----------列车公共属性----------- @@ -125,13 +122,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 列车运行级别 */ - @ExpConditionMaterialAnno(name = "runLevel", type = "RunLevel", desc = "列车运行级别") private RunLevel runLevel; /** * 驾驶模式 */ - @ExpConditionMaterialAnno(name = "driveMode", type = "DriveMode", desc = "驾驶模式") private DriveMode driveMode; /** @@ -265,13 +260,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 是否紧急停车(信号) */ - @ExpConditionMaterialAnno(name = "signalEB", type = "boolean", desc = "是否紧急停车(信号)") private boolean signalEB; /** * 是否紧急停车(电路) */ - @ExpConditionMaterialAnno(name = "circuitEB", type = "boolean", desc = "是否紧急停车(电路)") private boolean circuitEB; /** @@ -282,7 +275,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 下一计划是否停站 */ - @ExpConditionMaterialAnno(name = "nextParking", type = "boolean", desc = "下一计划是否停站") private boolean nextParking; /** @@ -293,7 +285,7 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 是否扣车 */ - @ExpConditionMaterialAnno(name = "hold", type = "boolean", desc = "是否扣车") + private boolean hold; /** @@ -304,13 +296,11 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 是否自动折返中 */ - @ExpConditionMaterialAnno(name = "dtro", type = "boolean", desc = "是否自动折返中") private boolean dtro; /** * 是否换端中 */ - @ExpConditionMaterialAnno(name = "changeEnds", type = "boolean", desc = "是否换端中") private boolean changeEnds; /** @@ -321,19 +311,16 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * ATO是否开启 */ - @ExpConditionMaterialAnno(name = "atoOn", type = "boolean", desc = "ATO是否开启") private boolean atoOn; /** * ATP是否可用 */ - @ExpConditionMaterialAnno(name = "atpOn", type = "boolean", desc = "ATP是否可用") private boolean atpOn; /** * 进路优先排列 */ - @ExpConditionMaterialAnno(name = "priorityRouteSet", type = "boolean", desc = "进路优先排列") private boolean priorityRouteSet; /** @@ -349,7 +336,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 门模式 */ - @ExpConditionMaterialAnno(name = "doorMode", type = "DoorMode", desc = "门模式") private DoorMode doorMode; /** @@ -424,7 +410,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * 运行类型 */ - @ExpConditionMaterialAnno(name = "runType", type = "RunType", desc = "运行类型") private RunType runType; /** @@ -461,7 +446,6 @@ public class VirtualRealityTrain extends VirtualRealityDevice { /** * ato可以开启 */ - @ExpConditionMaterialAnno(name = "atoCanOpen", type = "boolean", desc = "ato可以开启") private boolean atoCanOpen; private VirtualRealityAudio vrAudio; diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialAnno.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialAnno.java index daab00291..2bbc7d6f4 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialAnno.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialAnno.java @@ -11,20 +11,21 @@ import java.lang.annotation.Target; * 设备:区段、道岔、信号机、站台、车站、进路、列车等
* 素材:设备的某些字段 */ -@Target({ ElementType.FIELD}) +@Target({ElementType.FIELD}) @Retention(RetentionPolicy.RUNTIME) public @interface ExpConditionMaterialAnno { /** * 素材名称,即设备类定义中字段的名称 */ - String name(); + String name(); + /** * 素材类型,即即设备类定义中字段值得类型 */ - String type(); + String type(); + /** * 素材描述,即即设备类定义中字段的含义 */ - String desc(); - + String desc(); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialSrcAnno.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialSrcAnno.java index 67370fe0c..9a501c12a 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialSrcAnno.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/anno/ExpConditionMaterialSrcAnno.java @@ -1,5 +1,7 @@ package club.joylink.rtss.simulation.cbtc.training2.ecm.anno; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; + import java.lang.annotation.ElementType; import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; @@ -10,13 +12,15 @@ import java.lang.annotation.Target; *

* 设备类如果被该注解标记,则从被标记的类中收集素材 */ -@Target({ ElementType.TYPE}) +@Target({ElementType.TYPE}) @Retention(RetentionPolicy.RUNTIME) public @interface ExpConditionMaterialSrcAnno { - /** - * 素材来源的名称 - *

- * 值为"null"时默认取素材源类名 - */ - String name() default "null"; + /** + * 素材来源的名称 + *

+ * 值为"null"时默认取素材源类名 + */ + String name() default "null"; + + MapElement.DeviceType deviceType(); } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/collector/ExpConditionMaterialCollector.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/collector/ExpConditionMaterialCollector.java index 7b8b8168f..2cfc79f64 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/collector/ExpConditionMaterialCollector.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/collector/ExpConditionMaterialCollector.java @@ -12,6 +12,7 @@ import org.springframework.context.annotation.ClassPathScanningCandidateComponen import org.springframework.core.type.filter.AnnotationTypeFilter; import org.springframework.stereotype.Component; import org.springframework.util.Assert; + import java.lang.reflect.Field; import java.util.ArrayList; import java.util.LinkedHashSet; @@ -20,12 +21,14 @@ import java.util.Set; @Component public class ExpConditionMaterialCollector extends ClassPathScanningCandidateComponentProvider implements ApplicationContextAware { - private ApplicationContext ioc; + private ApplicationContext ioc; + @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - this.ioc=applicationContext; + this.ioc = applicationContext; this.setEnvironment(this.ioc.getEnvironment()); } + private Set doScan(String... basePackages) { Assert.notEmpty(basePackages, "At least one base package must be specified"); // @@ -38,30 +41,34 @@ public class ExpConditionMaterialCollector extends ClassPathScanningCandidateCom } return beanDefinitions; } - public List doCollect(){ - Set bds = this.doScan("club.joylink.rtss.simulation.cbtc.data.map","club.joylink.rtss.simulation.cbtc.data.vr"); - List list =new ArrayList<>(bds.size()); - bds.forEach(n->{ + + public List doCollect() { + Set bds = this.doScan("club.joylink.rtss.simulation.cbtc.data.map", + "club.joylink.rtss.simulation.cbtc.data.vr", "club.joylink.rtss.simulation.cbtc.data.vo"); + List list = new ArrayList<>(bds.size()); + bds.forEach(n -> { list.add(this.create(n.getBeanClassName())); }); return list; } - private ExpConditionMaterialSrcVo create(String clsName){ + + private ExpConditionMaterialSrcVo create(String clsName) { Class cls = this.getSrcCls(clsName); // - ExpConditionMaterialSrcAnno srcAnno= cls.getAnnotation(ExpConditionMaterialSrcAnno.class); - String srcName=cls.getSimpleName(); - if(!"null".equals(srcAnno.name())){ - srcName=srcAnno.name(); + ExpConditionMaterialSrcAnno srcAnno = cls.getAnnotation(ExpConditionMaterialSrcAnno.class); + String srcName = cls.getSimpleName(); + if (!"null".equals(srcAnno.name())) { + srcName = srcAnno.name(); } // - ExpConditionMaterialSrcVo src = new ExpConditionMaterialSrcVo(); + ExpConditionMaterialSrcVo src = new ExpConditionMaterialSrcVo(); src.setSrcName(srcName); + src.setDeviceType(srcAnno.deviceType()); src.setMaterials(new ArrayList<>()); // - Field[] fds= cls.getDeclaredFields(); - for(Field fd : fds){ - if(fd.isAnnotationPresent(ExpConditionMaterialAnno.class)){ + Field[] fds = cls.getDeclaredFields(); + for (Field fd : fds) { + if (fd.isAnnotationPresent(ExpConditionMaterialAnno.class)) { ExpConditionMaterialAnno ma = fd.getAnnotation(ExpConditionMaterialAnno.class); ExpConditionMaterialVo m = new ExpConditionMaterialVo(); m.setName(ma.name()); @@ -74,7 +81,8 @@ public class ExpConditionMaterialCollector extends ClassPathScanningCandidateCom // return src; } - private Class getSrcCls(String clsName){ + + private Class getSrcCls(String clsName) { Class cls = null; try { cls = Class.forName(clsName); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialSrcVo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialSrcVo.java index eafac5ada..3ebaaaff8 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialSrcVo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialSrcVo.java @@ -1,5 +1,6 @@ package club.joylink.rtss.simulation.cbtc.training2.ecm.vo; +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; import lombok.Data; import java.util.List; @@ -10,6 +11,12 @@ public class ExpConditionMaterialSrcVo { * 设备类名称,条件素材来源的名称 */ private String srcName; + + /** + * 设备类型 + */ + private MapElement.DeviceType deviceType; + /** * 条件素材列表 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialVo.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialVo.java index 80959a307..1bdfc9d90 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialVo.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/ecm/vo/ExpConditionMaterialVo.java @@ -7,13 +7,13 @@ public class ExpConditionMaterialVo { /** * 素材名称,即设备类定义中字段的名称 */ - private String name; + private String name; /** * 素材类型,即即设备类定义中字段值得类型 */ - private String type; + private String type; /** * 素材描述,即即设备类定义中字段的含义 */ - private String desc; + private String desc; }