Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-zhouyin

This commit is contained in:
tiger_zhou 2022-10-28 13:25:58 +08:00
commit 69f81d56a9
5 changed files with 21 additions and 25 deletions

View File

@ -4,6 +4,10 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import org.springframework.util.CollectionUtils;
import java.util.List;
@ -12,6 +16,10 @@ import java.util.stream.Collectors;
/**
* 筛选人员规则
*/
@Setter
@Getter
@NoArgsConstructor
@AllArgsConstructor
public class MemberRule {
/**

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.vo.training2.rule;
import club.joylink.rtss.simulation.cbtc.ATS.operation.Operation;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.vo.client.training2.ExpressionVO;
import club.joylink.rtss.vo.client.training2.Operation2VO;
import lombok.Getter;
import lombok.NoArgsConstructor;
@ -27,13 +26,13 @@ public abstract class OperationRule {
protected void convertExpressionRule(Operation2VO operation2, Simulation simulation, Object mapElement) {
if (triggerRule != null) {
operation2.setTriggerCondition((ExpressionVO) triggerRule.convert2BO(simulation, mapElement));
operation2.setTriggerCondition(triggerRule.convert2BO(simulation, mapElement));
}
if (completionRule != null) {
operation2.setCompletionCondition((ExpressionVO) completionRule.convert2BO(simulation, mapElement));
operation2.setCompletionCondition(completionRule.convert2BO(simulation, mapElement));
}
if (failureRule != null) {
operation2.setFailureCondition((ExpressionVO) failureRule.convert2BO(simulation, mapElement));
operation2.setFailureCondition(failureRule.convert2BO(simulation, mapElement));
}
}

View File

@ -4,7 +4,6 @@ import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.vo.client.training2.ExpressionVO;
import club.joylink.rtss.vo.client.training2.Operation2VO;
import club.joylink.rtss.vo.client.training2.Step2VO;
import lombok.Getter;
@ -59,13 +58,13 @@ public class StepRule {
copyStep2.setSimCommands(simCommandList);
}
if (triggerRule != null) { // 触发规则
copyStep2.setTriggerCondition((ExpressionVO) triggerRule.convert2BO(simulation, mapElement));
copyStep2.setTriggerCondition(triggerRule.convert2BO(simulation, mapElement));
}
if (completionRule != null) { // 完成规则
copyStep2.setCompletionCondition((ExpressionVO) completionRule.convert2BO(simulation, mapElement));
copyStep2.setCompletionCondition(completionRule.convert2BO(simulation, mapElement));
}
if (failureRule != null) { // 失败规则
copyStep2.setFailureCondition((ExpressionVO) failureRule.convert2BO(simulation, mapElement));
copyStep2.setFailureCondition(failureRule.convert2BO(simulation, mapElement));
}
if (!CollectionUtils.isEmpty(tipPositionRule)) { // 定位信息
tipPositionRule.forEach((k, v) -> {

View File

@ -80,16 +80,6 @@ public class Training2Rule {
*/
private Long creatorId;
/**
* 创建时间
*/
private LocalDateTime createTime;
/**
* 更新时间
*/
private LocalDateTime updateTime;
public DraftTraining2WithBLOBs convert2BO(Simulation simulation, MapNamedElement mapElement) {
DraftTraining2WithBLOBs copyTraining2 = new DraftTraining2WithBLOBs();
// 地图ID
@ -117,8 +107,8 @@ public class Training2Rule {
List<Step2VO> step2VOList = steps.stream().map(s -> s.convert2BO(simulation, mapElement)).collect(Collectors.toList());
copyTraining2.setStepJson(JsonUtils.writeValueAsString(step2VOList));
// 扮演者集合
List<String> playerList = step2VOList.stream().filter(s -> !StringUtils.isEmpty(s.getMemberId())).map(s -> s.getMemberId())
.distinct().collect(Collectors.toList());
List<String> playerList = step2VOList.stream().filter(s -> !StringUtils.isEmpty(s.getMemberId()))
.map(Step2VO::getMemberId).distinct().collect(Collectors.toList());
if (CollectionUtils.isEmpty(playerList)) {
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据:无扮演者");
}
@ -132,8 +122,8 @@ public class Training2Rule {
List<SimulationMemberPO> simulationMemberPOList = SimulationMemberPO.convertFromBOList(simulation.getSimulationMembers());
copyTraining2.setMemberJson(JsonUtils.writeValueAsString(simulationMemberPOList));
copyTraining2.setCreatorId(creatorId);
copyTraining2.setCreateTime(createTime);
copyTraining2.setUpdateTime(updateTime);
copyTraining2.setCreateTime(LocalDateTime.now());
copyTraining2.setUpdateTime(LocalDateTime.now());
return copyTraining2;
}
}

View File

@ -32,7 +32,7 @@ public abstract class ValuableRule {
private PropertyValueRule elementCodeRule;
@Override
public ValuableVO convert2BO(Simulation simulation, Object mapElement) {
public StatusValueVO convert2BO(Simulation simulation, Object mapElement) {
StatusValueVO valuable = JsonUtils.read(JsonUtils.writeValueAsString(this.getValuableVO()), StatusValueVO.class);
if (elementCodeRule != null) {
valuable.setElementCode(elementCodeRule.resolve(simulation, mapElement));
@ -48,7 +48,7 @@ public abstract class ValuableRule {
private ValuableRule[] valueRules;
@Override
public ValuableVO convert2BO(Simulation simulation, Object mapElement) {
public ExpressionVO convert2BO(Simulation simulation, Object mapElement) {
ExpressionVO valuable = JsonUtils.read(JsonUtils.writeValueAsString(this.getValuableVO()), ExpressionVO.class);
if (valueRules != null) {
ValuableVO[] valuables = valuable.getValuables();
@ -67,7 +67,7 @@ public abstract class ValuableRule {
@NoArgsConstructor
public static class ValueVORule extends ValuableRule {
@Override
public ValuableVO convert2BO(Simulation simulation, Object mapElement) {
public ValueVO convert2BO(Simulation simulation, Object mapElement) {
return JsonUtils.read(JsonUtils.writeValueAsString(this.getValuableVO()), ValueVO.class);
}
}