删除实训数据中的operaJson;增加Valuable新实现

This commit is contained in:
joylink_zhangsai 2022-08-16 13:20:10 +08:00
parent cee7197c70
commit d98fdd15cb
5 changed files with 50 additions and 9 deletions

View File

@ -47,10 +47,10 @@ public class DraftTraining2 {
*/
private Long runPlanId;
/**
* List<Operation2VO>的json
*/
private String operaJson;
// /**
// * List<Operation2VO>的json
// */
// private String operaJson;
/**
* List<Step2VO>的json

View File

@ -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<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);
steps = step2VOS.stream()
.map(vo -> new Step2(vo, simulation.getRepository()))

View File

@ -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);
}
}
}

View File

@ -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);

View File

@ -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);
}
}