From 1e94f3ae5aec3eecf5ec223b40dd11b0e399b774 Mon Sep 17 00:00:00 2001 From: weizhihong Date: Wed, 14 Sep 2022 16:11:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E7=94=A8=E6=88=B7=E6=97=A0=E8=A7=92?= =?UTF-8?q?=E8=89=B2=E7=BB=93=E6=9D=9F=E5=AE=9E=E8=AE=AD=E6=93=8D=E4=BD=9C?= =?UTF-8?q?=E3=80=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../services/training2/Training2Service.java | 17 ++++--- .../cbtc/CI/data/StationDirection.java | 10 ---- .../cbtc/CI/data/StationDirectionAuto.java | 47 +++++++++++++++++++ .../cbtc/CI/data/StationDirectionSemi.java | 29 ++++++++++++ .../cbtc/constant/SwitchIndication.java | 2 +- .../ecm/vo/ExpConditionMaterialVo.java | 5 +- 6 files changed, 92 insertions(+), 18 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionAuto.java create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionSemi.java 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 2f64c2d8c..e2ddd6e48 100644 --- a/src/main/java/club/joylink/rtss/services/training2/Training2Service.java +++ b/src/main/java/club/joylink/rtss/services/training2/Training2Service.java @@ -236,20 +236,25 @@ public class Training2Service { if (simulation == null) { throw new SimulationException(SimulationExceptionType.Invalid_Operation, "仿真不存在"); } + boolean participant = simulation.getSimulationMembers().stream().anyMatch(m -> user.getId().equals(m.getUserId())); Training2 training2 = simulation.getTraining2(); - Map scoreMap; + Map scoreMap = new HashMap<>(); if (training2 != null) { // 创建者退出,则清理实训 if (simulation.getCreator().getId().equals(user.getId())) { training2.finish(); removeTrainingJob(simulation); } - scoreMap = training2.mark(); - } else { - scoreMap = new HashMap<>(); + if (participant || simulation.getCreator().getId().equals(user.getId())) { + scoreMap = training2.mark(); + } + } + if (participant) { + SimulationMember member = simulation.getSimulationMemberByUserId(user.getId()); + return scoreMap.get(member.getId()); + } else { + return 0f; } - SimulationMember member = simulation.getSimulationMemberByUserId(user.getId()); - return scoreMap.get(member.getId()); } /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirection.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirection.java index bb7a2afcb..171d26c82 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirection.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirection.java @@ -4,9 +4,6 @@ package club.joylink.rtss.simulation.cbtc.CI.data; import club.joylink.rtss.constants.DirectionLabelEnum; import club.joylink.rtss.entity.DraftMapStationDirection; import club.joylink.rtss.simulation.cbtc.data.map.*; -import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno; -import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialSrcAnno; -import club.joylink.rtss.simulation.cbtc.training2.ecm.vo.ExpTypeCategory; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; @@ -22,7 +19,6 @@ import java.util.concurrent.atomic.AtomicInteger; @Setter @Getter @Slf4j -@ExpConditionMaterialSrcAnno(name = "StationDirection", deviceType = MapElement.DeviceType.STATION_DIRECTION) public class StationDirection extends MayOutOfOrderDevice implements Cloneable { /** * 发辅助默认倒计时 25s @@ -82,7 +78,6 @@ public class StationDirection extends MayOutOfOrderDevice implements Cloneable { /** * 处于接、发状态 */ - @ExpConditionMaterialAnno(name = "runStatus", type = ReceiveAndDeliverModel.class, desc = "接、发状态", category = ExpTypeCategory.ENUM) private ReceiveAndDeliverModel runStatus; /** @@ -121,7 +116,6 @@ public class StationDirection extends MayOutOfOrderDevice implements Cloneable { /** * 改方按钮状态 */ - @ExpConditionMaterialAnno(name = "changeDirectionStatus", type = boolean.class, desc = "改方状态") private boolean changeDirectionStatus; /** @@ -137,19 +131,16 @@ public class StationDirection extends MayOutOfOrderDevice implements Cloneable { /** * 接辅助 */ - @ExpConditionMaterialAnno(name = "receiveAssistStatus", type = boolean.class, desc = "接辅助状态") private boolean receiveAssistStatus; /** * 发辅助 */ - @ExpConditionMaterialAnno(name = "deliverAssistStatus", type = boolean.class, desc = "发辅助状态") private boolean deliverAssistStatus; /** * 辅助准备完毕状态 */ - @ExpConditionMaterialAnno(name = "assistReadyStatus", type = boolean.class, desc = "辅助办理完成") private boolean assistReadyStatus; /** @@ -162,7 +153,6 @@ public class StationDirection extends MayOutOfOrderDevice implements Cloneable { /** * 闭塞 */ - @ExpConditionMaterialAnno(name = "blockStatus", type = boolean.class, desc = "闭塞状态") private boolean blockStatus; /** diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionAuto.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionAuto.java new file mode 100644 index 000000000..f15655c26 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionAuto.java @@ -0,0 +1,47 @@ +package club.joylink.rtss.simulation.cbtc.CI.data; + +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno; +import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialSrcAnno; +import club.joylink.rtss.simulation.cbtc.training2.ecm.vo.ExpTypeCategory; +import lombok.Getter; +import lombok.Setter; + +/** + * 自动闭塞属性,前端需要状态 + */ +@Setter +@Getter +@ExpConditionMaterialSrcAnno(name = "StationDirectionAuto", deviceType = MapElement.DeviceType.STATION_DIRECTION) +public class StationDirectionAuto { + + /** + * 处于接、发状态 + */ + @ExpConditionMaterialAnno(name = "runStatus", type = StationDirection.ReceiveAndDeliverModel.class, desc = "接、发状态", category = ExpTypeCategory.ENUM) + private StationDirection.ReceiveAndDeliverModel runStatus; + + /** + * 改方按钮状态 + */ + @ExpConditionMaterialAnno(name = "changeDirectionStatus", type = boolean.class, desc = "改方状态") + private boolean changeDirectionStatus; + + /** + * 接辅助 + */ + @ExpConditionMaterialAnno(name = "receiveAssistStatus", type = boolean.class, desc = "接辅助状态") + private boolean receiveAssistStatus; + + /** + * 发辅助 + */ + @ExpConditionMaterialAnno(name = "deliverAssistStatus", type = boolean.class, desc = "发辅助状态") + private boolean deliverAssistStatus; + + /** + * 辅助准备完毕状态 + */ + @ExpConditionMaterialAnno(name = "assistReadyStatus", type = boolean.class, desc = "辅助办理完成") + private boolean assistReadyStatus; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionSemi.java b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionSemi.java new file mode 100644 index 000000000..7cb62d636 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/CI/data/StationDirectionSemi.java @@ -0,0 +1,29 @@ +package club.joylink.rtss.simulation.cbtc.CI.data; + +import club.joylink.rtss.simulation.cbtc.data.map.MapElement; +import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno; +import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialSrcAnno; +import club.joylink.rtss.simulation.cbtc.training2.ecm.vo.ExpTypeCategory; +import lombok.Getter; +import lombok.Setter; + +/** + * 由于前端需要区别,先分开处理 + * 半自动闭塞,前端需要状态 + */ +@Setter +@Getter +@ExpConditionMaterialSrcAnno(name = "StationDirectionSemi", deviceType = MapElement.DeviceType.STATION_DIRECTION) +public class StationDirectionSemi { + /** + * 处于接、发状态 + */ + @ExpConditionMaterialAnno(name = "runStatus", type = StationDirection.ReceiveAndDeliverModel.class, desc = "接、发状态", category = ExpTypeCategory.ENUM) + private StationDirection.ReceiveAndDeliverModel runStatus; + + /** + * 闭塞 + */ + @ExpConditionMaterialAnno(name = "blockStatus", type = boolean.class, desc = "闭塞状态") + private boolean blockStatus; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java index 6f48c6d73..663eb94ed 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/constant/SwitchIndication.java @@ -15,7 +15,7 @@ public enum SwitchIndication { /** * 无(失表) */ - NO("反位"), + NO("失表"), /** * 挤叉 */ 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 0ff49f31a..4e73310ff 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 @@ -3,11 +3,13 @@ package club.joylink.rtss.simulation.cbtc.training2.ecm.vo; import club.joylink.rtss.simulation.cbtc.training2.ecm.anno.ExpConditionMaterialAnno; import lombok.Data; import lombok.NoArgsConstructor; +import lombok.extern.slf4j.Slf4j; import java.lang.reflect.Field; import java.util.*; @Data +@Slf4j @NoArgsConstructor public class ExpConditionMaterialVo { /** @@ -67,7 +69,8 @@ public class ExpConditionMaterialVo { } } } catch (NoSuchFieldException | IllegalArgumentException | IllegalAccessException e) { - throw new RuntimeException(e); + resultList = null; + log.error(enumClass.getSimpleName() + "没有label描述字段"); } return resultList; }