From d98fdd15cb3534ac785748814429759edcc83c78 Mon Sep 17 00:00:00 2001 From: joylink_zhangsai <1021828630@qq.com> Date: Tue, 16 Aug 2022 13:20:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=88=A0=E9=99=A4=E5=AE=9E=E8=AE=AD=E6=95=B0?= =?UTF-8?q?=E6=8D=AE=E4=B8=AD=E7=9A=84operaJson=EF=BC=9B=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?Valuable=E6=96=B0=E5=AE=9E=E7=8E=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../rtss/entity/training2/DraftTraining2.java | 8 +++--- .../simulation/cbtc/training2/Training2.java | 5 ---- .../rtss/simulation/cbtc/training2/Value.java | 20 +++++++++++++++ .../rtss/vo/client/training2/ValuableVO.java | 1 + .../rtss/vo/client/training2/ValueVO.java | 25 +++++++++++++++++++ 5 files changed, 50 insertions(+), 9 deletions(-) create mode 100644 src/main/java/club/joylink/rtss/simulation/cbtc/training2/Value.java create mode 100644 src/main/java/club/joylink/rtss/vo/client/training2/ValueVO.java diff --git a/src/main/java/club/joylink/rtss/entity/training2/DraftTraining2.java b/src/main/java/club/joylink/rtss/entity/training2/DraftTraining2.java index d16f2eccc..000e0a073 100644 --- a/src/main/java/club/joylink/rtss/entity/training2/DraftTraining2.java +++ b/src/main/java/club/joylink/rtss/entity/training2/DraftTraining2.java @@ -47,10 +47,10 @@ public class DraftTraining2 { */ private Long runPlanId; - /** - * List的json - */ - private String operaJson; +// /** +// * List的json +// */ +// private String operaJson; /** * List的json diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Training2.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Training2.java index 778d0458a..26a105c8c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Training2.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Training2.java @@ -3,7 +3,6 @@ package club.joylink.rtss.simulation.cbtc.training2; import club.joylink.rtss.entity.training2.DraftTraining2; import club.joylink.rtss.simulation.cbtc.Simulation; import club.joylink.rtss.util.JsonUtils; -import club.joylink.rtss.vo.client.training2.Operation2VO; import club.joylink.rtss.vo.client.training2.ScoringRuleVO; import club.joylink.rtss.vo.client.training2.Step2VO; import lombok.Getter; @@ -54,10 +53,6 @@ public class Training2 { public Training2(DraftTraining2 draftTraining2, Simulation simulation) { labels = JsonUtils.readCollection(draftTraining2.getLabelJson(), List.class, String.class); - List operaVOS = JsonUtils.readCollection(draftTraining2.getOperaJson(), List.class, Operation2VO.class); - operations = operaVOS.stream() - .map(vo -> vo.convert2BO(simulation)) - .collect(Collectors.toList()); List step2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class); steps = step2VOS.stream() .map(vo -> new Step2(vo, simulation.getRepository())) diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Value.java b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Value.java new file mode 100644 index 000000000..6991942f3 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/training2/Value.java @@ -0,0 +1,20 @@ +package club.joylink.rtss.simulation.cbtc.training2; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; + +public class Value implements Valuable{ + private Object v; + + public Value(Object v) { + this.v = v; + } + + @Override + public T getValue(Class cls) { + try { + return cls.cast(v); + } catch (Exception e) { + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e); + } + } +} diff --git a/src/main/java/club/joylink/rtss/vo/client/training2/ValuableVO.java b/src/main/java/club/joylink/rtss/vo/client/training2/ValuableVO.java index d6f40d644..ebb0b8124 100644 --- a/src/main/java/club/joylink/rtss/vo/client/training2/ValuableVO.java +++ b/src/main/java/club/joylink/rtss/vo/client/training2/ValuableVO.java @@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo; @JsonSubTypes({ @JsonSubTypes.Type(value = ExpressionVO.class, name = "E"), @JsonSubTypes.Type(value = StatusValueVO.class, name = "S"), + @JsonSubTypes.Type(value = ValueVO.class, name = "V"), }) public interface ValuableVO { Valuable convert2BO(SimulationDataRepository repository); diff --git a/src/main/java/club/joylink/rtss/vo/client/training2/ValueVO.java b/src/main/java/club/joylink/rtss/vo/client/training2/ValueVO.java new file mode 100644 index 000000000..902137ace --- /dev/null +++ b/src/main/java/club/joylink/rtss/vo/client/training2/ValueVO.java @@ -0,0 +1,25 @@ +package club.joylink.rtss.vo.client.training2; + +import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository; +import club.joylink.rtss.simulation.cbtc.training2.Valuable; +import club.joylink.rtss.simulation.cbtc.training2.Value; +import com.fasterxml.jackson.annotation.JsonTypeInfo; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +/** + * 单值 + */ +@Getter +@Setter +@NoArgsConstructor +public class ValueVO implements ValuableVO { + @JsonTypeInfo(use = JsonTypeInfo.Id.MINIMAL_CLASS) + private Object v; + + @Override + public Valuable convert2BO(SimulationDataRepository repository) { + return new Value(v); + } +}