删除实训数据中的operaJson;增加Valuable新实现
This commit is contained in:
parent
cee7197c70
commit
d98fdd15cb
@ -47,10 +47,10 @@ public class DraftTraining2 {
|
|||||||
*/
|
*/
|
||||||
private Long runPlanId;
|
private Long runPlanId;
|
||||||
|
|
||||||
/**
|
// /**
|
||||||
* List<Operation2VO>的json
|
// * List<Operation2VO>的json
|
||||||
*/
|
// */
|
||||||
private String operaJson;
|
// private String operaJson;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* List<Step2VO>的json
|
* List<Step2VO>的json
|
||||||
|
@ -3,7 +3,6 @@ package club.joylink.rtss.simulation.cbtc.training2;
|
|||||||
import club.joylink.rtss.entity.training2.DraftTraining2;
|
import club.joylink.rtss.entity.training2.DraftTraining2;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
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.ScoringRuleVO;
|
||||||
import club.joylink.rtss.vo.client.training2.Step2VO;
|
import club.joylink.rtss.vo.client.training2.Step2VO;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -54,10 +53,6 @@ public class Training2 {
|
|||||||
|
|
||||||
public Training2(DraftTraining2 draftTraining2, Simulation simulation) {
|
public Training2(DraftTraining2 draftTraining2, Simulation simulation) {
|
||||||
labels = JsonUtils.readCollection(draftTraining2.getLabelJson(), List.class, String.class);
|
labels = JsonUtils.readCollection(draftTraining2.getLabelJson(), List.class, String.class);
|
||||||
List<Operation2VO> operaVOS = JsonUtils.readCollection(draftTraining2.getOperaJson(), List.class, Operation2VO.class);
|
|
||||||
operations = operaVOS.stream()
|
|
||||||
.map(vo -> vo.convert2BO(simulation))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
List<Step2VO> step2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class);
|
List<Step2VO> step2VOS = JsonUtils.readCollection(draftTraining2.getStepJson(), List.class, Step2VO.class);
|
||||||
steps = step2VOS.stream()
|
steps = step2VOS.stream()
|
||||||
.map(vo -> new Step2(vo, simulation.getRepository()))
|
.map(vo -> new Step2(vo, simulation.getRepository()))
|
||||||
|
@ -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> T getValue(Class<T> cls) {
|
||||||
|
try {
|
||||||
|
return cls.cast(v);
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -9,6 +9,7 @@ import com.fasterxml.jackson.annotation.JsonTypeInfo;
|
|||||||
@JsonSubTypes({
|
@JsonSubTypes({
|
||||||
@JsonSubTypes.Type(value = ExpressionVO.class, name = "E"),
|
@JsonSubTypes.Type(value = ExpressionVO.class, name = "E"),
|
||||||
@JsonSubTypes.Type(value = StatusValueVO.class, name = "S"),
|
@JsonSubTypes.Type(value = StatusValueVO.class, name = "S"),
|
||||||
|
@JsonSubTypes.Type(value = ValueVO.class, name = "V"),
|
||||||
})
|
})
|
||||||
public interface ValuableVO {
|
public interface ValuableVO {
|
||||||
Valuable convert2BO(SimulationDataRepository repository);
|
Valuable convert2BO(SimulationDataRepository repository);
|
||||||
|
@ -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);
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user