Merge remote-tracking branch 'origin/test-training2' into test-training2
This commit is contained in:
commit
13a7f01a77
@ -8,7 +8,7 @@ import java.util.Date;
|
||||
public class RtsTraining2Rule {
|
||||
private Long id;
|
||||
|
||||
private Long mapId;
|
||||
private String simType;
|
||||
|
||||
private String locationRule;
|
||||
|
||||
|
@ -165,63 +165,63 @@ public class RtsTraining2RuleExample {
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdIsNull() {
|
||||
addCriterion("map_id is null");
|
||||
public Criteria andSimTypeIsNull() {
|
||||
addCriterion("sim_type is null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdIsNotNull() {
|
||||
addCriterion("map_id is not null");
|
||||
public Criteria andSimTypeIsNotNull() {
|
||||
addCriterion("sim_type is not null");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdEqualTo(Long value) {
|
||||
addCriterion("map_id =", value, "mapId");
|
||||
public Criteria andSimTypeEqualTo(String value) {
|
||||
addCriterion("sim_type =", value, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdNotEqualTo(Long value) {
|
||||
addCriterion("map_id <>", value, "mapId");
|
||||
public Criteria andSimTypeNotEqualTo(String value) {
|
||||
addCriterion("sim_type <>", value, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdGreaterThan(Long value) {
|
||||
addCriterion("map_id >", value, "mapId");
|
||||
public Criteria andSimTypeGreaterThan(String value) {
|
||||
addCriterion("sim_type >", value, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdGreaterThanOrEqualTo(Long value) {
|
||||
addCriterion("map_id >=", value, "mapId");
|
||||
public Criteria andSimTypeGreaterThanOrEqualTo(String value) {
|
||||
addCriterion("sim_type >=", value, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdLessThan(Long value) {
|
||||
addCriterion("map_id <", value, "mapId");
|
||||
public Criteria andSimTypeLessThan(String value) {
|
||||
addCriterion("sim_type <", value, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdLessThanOrEqualTo(Long value) {
|
||||
addCriterion("map_id <=", value, "mapId");
|
||||
public Criteria andSimTypeLessThanOrEqualTo(String value) {
|
||||
addCriterion("sim_type <=", value, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdIn(List<Long> values) {
|
||||
addCriterion("map_id in", values, "mapId");
|
||||
public Criteria andSimTypeIn(List<String> values) {
|
||||
addCriterion("sim_type in", values, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdNotIn(List<Long> values) {
|
||||
addCriterion("map_id not in", values, "mapId");
|
||||
public Criteria andSimTypeNotIn(List<String> values) {
|
||||
addCriterion("sim_type not in", values, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdBetween(Long value1, Long value2) {
|
||||
addCriterion("map_id between", value1, value2, "mapId");
|
||||
public Criteria andSimTypeBetween(String value1, String value2) {
|
||||
addCriterion("sim_type between", value1, value2, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
public Criteria andMapIdNotBetween(Long value1, Long value2) {
|
||||
addCriterion("map_id not between", value1, value2, "mapId");
|
||||
public Criteria andSimTypeNotBetween(String value1, String value2) {
|
||||
addCriterion("sim_type not between", value1, value2, "simType");
|
||||
return (Criteria) this;
|
||||
}
|
||||
|
||||
|
@ -60,7 +60,7 @@ public class Training2RuleService {
|
||||
runningMapIdSet.add(mapId);
|
||||
// 规则列表
|
||||
RtsTraining2RuleExample example = new RtsTraining2RuleExample();
|
||||
example.createCriteria().andMapIdEqualTo(mapId);
|
||||
example.createCriteria().andSimTypeEqualTo(simulation.getBuildParams().getWorkParamVO().getType().name());
|
||||
List<RtsTraining2RuleWithBLOBs> ruleList = rtsTraining2RuleMapper.selectByExampleWithBLOBs(example);
|
||||
if (!CollectionUtils.isEmpty(ruleList)) {
|
||||
// 清除数据库原有数据
|
||||
|
@ -19,9 +19,9 @@ import java.util.Objects;
|
||||
public enum BgSceneStatusRule {
|
||||
|
||||
/**
|
||||
* 设置进路背景
|
||||
* 设置进路背景blockade
|
||||
*/
|
||||
ROUTE_BG_SCENE("进路背景") {
|
||||
ROUTE_CANCEL_BG_SCENE("取消进路背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
openRouteDirect(simulation, (Route) mapElement);
|
||||
@ -31,14 +31,107 @@ public enum BgSceneStatusRule {
|
||||
/**
|
||||
* 解封按钮背景
|
||||
*/
|
||||
BUTTON_BG_SCENE("解封按钮背景") {
|
||||
BUTTON_BLOCK_BG_SCENE("解封按钮背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
signal.setBlockade(true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔定位背景:将道岔设置为反位
|
||||
*/
|
||||
SWITCH_NP_BG_SCENE("道岔定位背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setSingleSwitchPositionDirectly(iSwitch, false);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔反位背景:将道岔设置为定位
|
||||
*/
|
||||
SWITCH_RP_BG_SCENE("道岔反位背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setSingleSwitchPositionDirectly(iSwitch, true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔封锁背景:将道岔设置为未封锁
|
||||
*/
|
||||
SWITCH_BLOCK_BG_SCENE("道岔封锁背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setBlockSwitch(iSwitch, false);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔解封背景:将道岔设置为封锁
|
||||
*/
|
||||
SWITCH_UNBLOCK_BG_SCENE("道岔解封背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setBlockSwitch(iSwitch, true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔单锁背景:将道岔设置为未封锁
|
||||
*/
|
||||
SWITCH_SINGLE_BLOCK_BG_SCENE("道岔单锁背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setSingleLockSwitch(iSwitch, false);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 道岔单解背景:将道岔设置为封锁
|
||||
*/
|
||||
SWITCH_SINGLE_UNBLOCK_BG_SCENE("道岔单解背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Switch iSwitch = (Switch) mapElement;
|
||||
setSingleLockSwitch(iSwitch, true);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 信号机点灯背景
|
||||
*/
|
||||
SIGNAL_TURN_ON_BG_SCENE("信号机点灯背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
signal.setAspect(SignalAspect.No);
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
vrSignal.setAspect(SignalAspect.No);
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
},
|
||||
/**
|
||||
* 信号机灭灯背景
|
||||
*/
|
||||
SIGNAL_TURN_OFF_BG_SCENE("信号机灭灯背景") {
|
||||
@Override
|
||||
public String doHandle(Simulation simulation, MapElement mapElement) {
|
||||
Signal signal = (Signal) mapElement;
|
||||
VirtualRealitySignal vrSignal = signal.getVirtualSignal();
|
||||
signal.setAspect(vrSignal.getModel().getDefaultAspect());
|
||||
vrSignal.setAspect(vrSignal.getModel().getDefaultAspect());
|
||||
return getBgScene(simulation);
|
||||
}
|
||||
}
|
||||
|
||||
;
|
||||
|
||||
/**
|
||||
@ -158,4 +251,25 @@ public enum BgSceneStatusRule {
|
||||
}
|
||||
signal.setAspect(aspect);
|
||||
}
|
||||
|
||||
/**
|
||||
* 封锁、解封道岔
|
||||
* @param aSwitch 道岔
|
||||
*/
|
||||
private static void setBlockSwitch(Switch aSwitch, boolean block) {
|
||||
aSwitch.setBlockade(block);
|
||||
aSwitch.getA().setBlockade(block);
|
||||
aSwitch.getB().setBlockade(block);
|
||||
aSwitch.getC().setBlockade(block);
|
||||
if (block) {
|
||||
aSwitch.setInit(false);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置道岔单锁、单解
|
||||
*/
|
||||
private static void setSingleLockSwitch(Switch aSwitch, boolean block) {
|
||||
aSwitch.setSingleLock(block);
|
||||
}
|
||||
}
|
||||
|
@ -6,23 +6,38 @@ import lombok.Getter;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Predicate;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
@Getter
|
||||
public enum MapDeviceRule {
|
||||
|
||||
ROUTE_LIST("进路列表") {
|
||||
RAILWAY_PICK_ROUTE_LIST("大铁接车进路列表") {
|
||||
@Override
|
||||
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||
boolean isRailWay = Simulation.Type.RAILWAY.equals(simulation.getBuildParams().getWorkParamVO().getType());
|
||||
// 只获取一个车站的
|
||||
List<Station> stationList = simulation.getRepository().getStationList();
|
||||
if (CollectionUtils.isEmpty(stationList) || !isRailWay) {
|
||||
return List.of();
|
||||
}
|
||||
Station station = stationList.get(0);
|
||||
// 获取本站的2个进路信息
|
||||
return simulation.getRepository().getRouteList().stream()
|
||||
.filter(r -> Objects.equals(r.getType(), Route.Type.RECEIVING) && station.equals(r.getStart().getStation()))
|
||||
.limit(2).collect(Collectors.toList());
|
||||
}
|
||||
},
|
||||
STATION_LIST("车站列表") {
|
||||
@Override
|
||||
public List<Station> filterMapDeviceList(Simulation simulation) {
|
||||
// 只获取一个车站的
|
||||
List<Station> stationList = simulation.getRepository().getStationList();
|
||||
if (CollectionUtils.isEmpty(stationList)) {
|
||||
return List.of();
|
||||
}
|
||||
Station station = stationList.get(0);
|
||||
// 获取本站的5个进路信息
|
||||
return simulation.getRepository().getRouteList().stream()
|
||||
.filter(r -> station.equals(r.getInterlockStation())).limit(5).collect(Collectors.toList());
|
||||
return stationList.stream().limit(2).collect(Collectors.toList());
|
||||
}
|
||||
},
|
||||
SWITCH_LIST("道岔列表") {
|
||||
@ -35,7 +50,7 @@ public enum MapDeviceRule {
|
||||
}
|
||||
Station station = stationList.get(0);
|
||||
return simulation.getRepository().getSwitchList().stream()
|
||||
.filter(s -> station.equals(s.getDeviceStation())).limit(5).collect(Collectors.toList());
|
||||
.filter(s -> station.equals(s.getDeviceStation())).limit(2).collect(Collectors.toList());
|
||||
}
|
||||
},
|
||||
SIGNAL_LIST("信号机列表") {
|
||||
@ -48,7 +63,21 @@ public enum MapDeviceRule {
|
||||
}
|
||||
Station station = stationList.get(0);
|
||||
return simulation.getRepository().getSignalList().stream()
|
||||
.filter(s -> station.equals(s.getDeviceStation())).limit(5).collect(Collectors.toList());
|
||||
.filter(s -> station.equals(s.getDeviceStation())).limit(2).collect(Collectors.toList());
|
||||
}
|
||||
},
|
||||
RAILWAY_SIGNAL_LIST("大铁信号机列表") {
|
||||
@Override
|
||||
public List<Signal> filterMapDeviceList(Simulation simulation) {
|
||||
// 只获取一个车站的
|
||||
List<Station> stationList = simulation.getRepository().getStationList();
|
||||
if (CollectionUtils.isEmpty(stationList)) {
|
||||
return List.of();
|
||||
}
|
||||
Station station = stationList.get(0);
|
||||
return simulation.getRepository().getSignalList().stream()
|
||||
.filter(s -> Signal.SignalType.DEPARTURE.equals(s.getType()) && station.equals(s.getDeviceStation()))
|
||||
.limit(2).collect(Collectors.toList());
|
||||
}
|
||||
},
|
||||
SIGNAL_BUTTON_LIST("有按钮的信号机列表") {
|
||||
@ -62,7 +91,7 @@ public enum MapDeviceRule {
|
||||
Station station = stationList.get(0);
|
||||
return simulation.getRepository().getSignalList().stream()
|
||||
.filter(s -> station.equals(s.getDeviceStation()) && Signal.SignalType.RECEIVING.equals(s.getType()))
|
||||
.limit(5).collect(Collectors.toList());
|
||||
.limit(2).collect(Collectors.toList());
|
||||
}
|
||||
};
|
||||
|
||||
|
@ -55,18 +55,37 @@ public enum PropertyValueRule {
|
||||
return null;
|
||||
}
|
||||
},
|
||||
ROUTE_START_NAME("进路起始名称") {
|
||||
ROUTE_START_SIGNAL_NAME("进路起始名称") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
return ((Route) mapElement).getStart().getShowName();
|
||||
}
|
||||
},
|
||||
BUTTON_START_CODE("进路起始按钮编码") {
|
||||
ROUTE_START_SIGNAL_CODE("进路始端信号机编码") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
return ((Route) mapElement).getStart().getCode();
|
||||
}
|
||||
},
|
||||
ROUTE_START_PICK_BUTTON_CODE("进路始端接车按钮编码") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
Route route = (Route) mapElement;
|
||||
List<MapSignalButtonVO> signalButtonList = simulation.getBuildParams().getMap().getGraphDataNew().getSignalButtonList();
|
||||
MapSignalButtonVO buttonVO = signalButtonList.stream().filter(button -> MapSignalButtonVO.Type.PICK.equals(button.getType())
|
||||
&& Objects.equals(button.getSignalCode(), route.getStart().getCode())).findFirst().orElse(null);
|
||||
if (buttonVO == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据");
|
||||
}
|
||||
return buttonVO.getCode();
|
||||
}
|
||||
},
|
||||
ROUTE_START_PASS_BUTTON_CODE("进路始端通过按钮编码") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
Route route = (Route) mapElement;
|
||||
List<MapSignalButtonVO> signalButtonList = simulation.getBuildParams().getMap().getGraphDataNew().getSignalButtonList();
|
||||
MapSignalButtonVO buttonVO = signalButtonList.stream().filter(button -> MapSignalButtonVO.Type.PASS.equals(button.getType())
|
||||
&& Objects.equals(button.getSignalCode(), route.getStart().getCode())).findFirst().orElse(null);
|
||||
if (buttonVO == null) {
|
||||
throw new SimulationException(SimulationExceptionType.Data_Not_Exist, "错误数据");
|
||||
@ -74,13 +93,19 @@ public enum PropertyValueRule {
|
||||
return buttonVO.getCode();
|
||||
}
|
||||
},
|
||||
ROUTE_END_NAME("进路终端名称") {
|
||||
ROUTE_END_SIGNAL_NAME("进路末端名称") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
return ((Route) mapElement).getDestination().getShowName();
|
||||
}
|
||||
},
|
||||
BUTTON_END_CODE("进路终端按钮编码") {
|
||||
ROUTE_END_SIGNAL_CODE("进路末端信号机编码") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
return ((Route) mapElement).getDestination().getCode();
|
||||
}
|
||||
},
|
||||
ROUTE_END_BUTTON_CODE("进路末端按钮编码") {
|
||||
@Override
|
||||
public String resolve(Simulation simulation, Object mapElement) {
|
||||
Route route = (Route) mapElement;
|
||||
|
@ -21,27 +21,27 @@ public class StepRule {
|
||||
|
||||
private Long id;
|
||||
|
||||
private MemberRule memberRule;
|
||||
private MemberRule memberId;
|
||||
|
||||
private String description;
|
||||
|
||||
private List<OperationRule.ClientOperationRule> operationRules;
|
||||
private List<OperationRule.ClientOperationRule> operations;
|
||||
|
||||
private List<OperationRule.SimOperationRule> simCommandRules;
|
||||
private List<OperationRule.SimOperationRule> simCommands;
|
||||
|
||||
private ValuableRule.ExpressionVORule triggerRule;
|
||||
private ValuableRule.ExpressionVORule trigger;
|
||||
|
||||
private ValuableRule.ExpressionVORule completionRule;
|
||||
private ValuableRule.ExpressionVORule completion;
|
||||
|
||||
private ValuableRule.ExpressionVORule failureRule;
|
||||
private ValuableRule.ExpressionVORule failure;
|
||||
|
||||
private Map<String, Object> tipPositionRule;
|
||||
private Map<String, Object> tipPosition;
|
||||
|
||||
public Step2VO convert2BO(Simulation simulation, Object mapElement) {
|
||||
Step2VO copyStep2 = new Step2VO();
|
||||
copyStep2.setId(this.id);
|
||||
if (memberRule != null) {
|
||||
SimulationMember member = memberRule.convert2BO(simulation, mapElement);
|
||||
if (memberId != null) {
|
||||
SimulationMember member = memberId.convert2BO(simulation, mapElement);
|
||||
copyStep2.setMemberId(member.getId());
|
||||
} else {
|
||||
throw new SimulationException(SimulationExceptionType.Illegal_Argument, String.format("未找到角色的成员"));
|
||||
@ -49,32 +49,32 @@ public class StepRule {
|
||||
if (description != null) { // 描述
|
||||
copyStep2.setDescription(PropertyValueRule.resolveContentFormat(description, simulation, mapElement));
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(operationRules)) { // 操作规则
|
||||
List<Operation2VO.ClientOperation2VO> operationList = operationRules.stream()
|
||||
if (!CollectionUtils.isEmpty(operations)) { // 操作规则
|
||||
List<Operation2VO.ClientOperation2VO> operationList = operations.stream()
|
||||
.map(o -> o.convert2BO(simulation, mapElement)).collect(Collectors.toList());
|
||||
copyStep2.setOperations(operationList);
|
||||
} else {
|
||||
copyStep2.setOperations(List.of());
|
||||
}
|
||||
if (!CollectionUtils.isEmpty(simCommandRules)) { // 实训操作列表
|
||||
List<Operation2VO.SimCommand2VO> simCommandList = simCommandRules.stream()
|
||||
if (!CollectionUtils.isEmpty(simCommands)) { // 实训操作列表
|
||||
List<Operation2VO.SimCommand2VO> simCommandList = simCommands.stream()
|
||||
.map(o -> o.convert2BO(simulation, mapElement)).collect(Collectors.toList());
|
||||
copyStep2.setSimCommands(simCommandList);
|
||||
} else {
|
||||
copyStep2.setSimCommands(List.of());
|
||||
}
|
||||
if (triggerRule != null) { // 触发规则
|
||||
copyStep2.setTriggerCondition(triggerRule.convert2BO(simulation, mapElement));
|
||||
if (trigger != null) { // 触发规则
|
||||
copyStep2.setTriggerCondition(trigger.convert2BO(simulation, mapElement));
|
||||
}
|
||||
if (completionRule != null) { // 完成规则
|
||||
copyStep2.setCompletionCondition(completionRule.convert2BO(simulation, mapElement));
|
||||
if (completion != null) { // 完成规则
|
||||
copyStep2.setCompletionCondition(completion.convert2BO(simulation, mapElement));
|
||||
}
|
||||
if (failureRule != null) { // 失败规则
|
||||
copyStep2.setFailureCondition(failureRule.convert2BO(simulation, mapElement));
|
||||
if (failure != null) { // 失败规则
|
||||
copyStep2.setFailureCondition(failure.convert2BO(simulation, mapElement));
|
||||
}
|
||||
copyStep2.setTipPosition(new HashMap<>());
|
||||
if (!CollectionUtils.isEmpty(tipPositionRule)) { // 定位信息
|
||||
tipPositionRule.forEach((k, v) -> {
|
||||
if (!CollectionUtils.isEmpty(tipPosition)) { // 定位信息
|
||||
tipPosition.forEach((k, v) -> {
|
||||
String vStr = String.valueOf(v);
|
||||
if (PropertyValueRule.match(vStr)) {
|
||||
copyStep2.getTipPosition().put(k, PropertyValueRule.valueOf(vStr).resolve(simulation, mapElement));
|
||||
|
@ -28,8 +28,6 @@ import java.util.stream.Collectors;
|
||||
public class Training2Rule {
|
||||
private Long id;
|
||||
|
||||
private Long mapId;
|
||||
|
||||
/**
|
||||
* 地图定位规则
|
||||
*/
|
||||
@ -82,17 +80,20 @@ public class Training2Rule {
|
||||
|
||||
public Training2Rule(RtsTraining2RuleWithBLOBs rule) {
|
||||
this.id = rule.getId();
|
||||
this.mapId = rule.getMapId();
|
||||
this.deviceRule = MapDeviceRule.valueOf(rule.getDeviceRule());
|
||||
this.client = rule.getClient();
|
||||
this.name = rule.getName();
|
||||
this.description = rule.getDescription();
|
||||
this.type = Training2.Type.valueOf(rule.getType());
|
||||
this.locationRule = MapLocationRule.valueOf(rule.getLocationRule());
|
||||
if (StringUtils.hasText(rule.getLocationRule())) {
|
||||
this.locationRule = MapLocationRule.valueOf(rule.getLocationRule());
|
||||
}
|
||||
if (StringUtils.hasText(rule.getLabels())) {
|
||||
this.labels = JsonUtils.readCollection(rule.getLabels(), List.class, String.class);
|
||||
}
|
||||
this.sceneRule = BgSceneStatusRule.valueOf(rule.getSceneRule());
|
||||
if (StringUtils.hasText(rule.getSceneRule())) {
|
||||
this.sceneRule = BgSceneStatusRule.valueOf(rule.getSceneRule());
|
||||
}
|
||||
if (StringUtils.hasText(rule.getSteps())) {
|
||||
this.steps = JsonUtils.readCollection(rule.getSteps(), List.class, StepRule.class);
|
||||
}
|
||||
@ -104,7 +105,7 @@ public class Training2Rule {
|
||||
public PublishedTraining2WithBLOBs convert2BO(Simulation simulation, MapNamedElement mapElement) {
|
||||
PublishedTraining2WithBLOBs copyTraining2 = new PublishedTraining2WithBLOBs();
|
||||
// 地图ID
|
||||
copyTraining2.setMapId(mapId);
|
||||
copyTraining2.setMapId(simulation.getBuildParams().getMap().getId());
|
||||
// 名称
|
||||
if (name != null) {
|
||||
copyTraining2.setName(PropertyValueRule.resolveContentFormat(name, simulation, mapElement));
|
||||
@ -120,7 +121,11 @@ public class Training2Rule {
|
||||
// 实训类型
|
||||
copyTraining2.setType(type.name());
|
||||
// 实训标签
|
||||
copyTraining2.setLabelJson(JsonUtils.writeValueAsString(labels));
|
||||
if (labels != null) {
|
||||
copyTraining2.setLabelJson(JsonUtils.writeValueAsString(labels));
|
||||
} else {
|
||||
copyTraining2.setLabelJson("[]");
|
||||
}
|
||||
// 背景设置
|
||||
if (sceneRule != null) {
|
||||
copyTraining2.setBgSceneJson(sceneRule.doHandle(simulation, mapElement));
|
||||
|
@ -3,7 +3,7 @@
|
||||
<mapper namespace="club.joylink.rtss.dao.training.RtsTraining2RuleMapper" >
|
||||
<resultMap id="BaseResultMap" type="club.joylink.rtss.entity.training2.RtsTraining2Rule" >
|
||||
<id column="id" property="id" jdbcType="BIGINT" />
|
||||
<result column="map_id" property="mapId" jdbcType="BIGINT" />
|
||||
<result column="sim_type" property="simType" jdbcType="VARCHAR" />
|
||||
<result column="device_rule" property="deviceRule" jdbcType="VARCHAR" />
|
||||
<result column="client" property="client" jdbcType="VARCHAR" />
|
||||
<result column="name" property="name" jdbcType="VARCHAR" />
|
||||
@ -82,7 +82,7 @@
|
||||
</sql>
|
||||
|
||||
<sql id="Base_Column_List" >
|
||||
id, map_id, device_rule, client, name, description, type, labels, scene_rule, creator_id, create_time, location_rule
|
||||
id, sim_type, device_rule, client, name, description, type, labels, scene_rule, creator_id, create_time, location_rule
|
||||
</sql>
|
||||
|
||||
<sql id="Blob_Column_List" >
|
||||
@ -138,11 +138,11 @@
|
||||
|
||||
<insert id="insert" parameterType="club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs" >
|
||||
insert into rts_training2_rule (
|
||||
id, map_id, device_rule, client, name, description, type, labels,
|
||||
id, sim_type, device_rule, client, name, description, type, labels,
|
||||
scene_rule, creator_id, create_time, steps, failure_rule, location_rule
|
||||
)
|
||||
values (
|
||||
#{id,jdbcType=BIGINT}, #{mapId,jdbcType=BIGINT}, #{deviceRule,jdbcType=VARCHAR}, #{client,jdbcType=VARCHAR},
|
||||
#{id,jdbcType=BIGINT}, #{simType,jdbcType=VARCHAR}, #{deviceRule,jdbcType=VARCHAR}, #{client,jdbcType=VARCHAR},
|
||||
#{name,jdbcType=VARCHAR}, #{description,jdbcType=VARCHAR}, #{type,jdbcType=VARCHAR}, #{labels,jdbcType=VARCHAR},
|
||||
#{sceneRule,jdbcType=VARCHAR}, #{creatorId,jdbcType=BIGINT}, #{createTime,jdbcType=TIMESTAMP},
|
||||
#{steps,jdbcType=LONGVARCHAR}, #{failureRule,jdbcType=LONGVARCHAR}, #{locationRule,jdbcType=VARCHAR}
|
||||
@ -155,8 +155,8 @@
|
||||
<if test="id != null" >
|
||||
id,
|
||||
</if>
|
||||
<if test="mapId != null" >
|
||||
map_id,
|
||||
<if test="simType != null" >
|
||||
sim_type,
|
||||
</if>
|
||||
<if test="deviceRule != null" >
|
||||
device_rule,
|
||||
@ -199,8 +199,8 @@
|
||||
<if test="id != null" >
|
||||
#{id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="mapId != null" >
|
||||
#{mapId,jdbcType=BIGINT},
|
||||
<if test="simType != null" >
|
||||
#{simType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="deviceRule != null" >
|
||||
#{deviceRule,jdbcType=VARCHAR},
|
||||
@ -247,8 +247,8 @@
|
||||
<if test="record.id != null" >
|
||||
id = #{record.id,jdbcType=BIGINT},
|
||||
</if>
|
||||
<if test="record.mapId != null" >
|
||||
map_id = #{record.mapId,jdbcType=BIGINT},
|
||||
<if test="record.simType != null" >
|
||||
sim_type = #{record.simType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="record.deviceRule != null" >
|
||||
device_rule = #{record.deviceRule,jdbcType=VARCHAR},
|
||||
@ -295,7 +295,7 @@
|
||||
<update id="updateByExampleWithBLOBs" parameterType="map" >
|
||||
update rts_training2_rule
|
||||
set id = #{record.id,jdbcType=BIGINT},
|
||||
map_id = #{record.mapId,jdbcType=BIGINT},
|
||||
sim_type = #{record.simType,jdbcType=VARCHAR},
|
||||
device_rule = #{record.deviceRule,jdbcType=VARCHAR},
|
||||
client = #{record.client,jdbcType=VARCHAR},
|
||||
name = #{record.name,jdbcType=VARCHAR},
|
||||
@ -316,7 +316,7 @@
|
||||
<update id="updateByExample" parameterType="map" >
|
||||
update rts_training2_rule
|
||||
set id = #{record.id,jdbcType=BIGINT},
|
||||
map_id = #{record.mapId,jdbcType=BIGINT},
|
||||
sim_type = #{record.simType,jdbcType=VARCHAR},
|
||||
device_rule = #{record.deviceRule,jdbcType=VARCHAR},
|
||||
client = #{record.client,jdbcType=VARCHAR},
|
||||
name = #{record.name,jdbcType=VARCHAR},
|
||||
@ -335,8 +335,8 @@
|
||||
<update id="updateByPrimaryKeySelective" parameterType="club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs" >
|
||||
update rts_training2_rule
|
||||
<set >
|
||||
<if test="mapId != null" >
|
||||
map_id = #{mapId,jdbcType=BIGINT},
|
||||
<if test="simType != null" >
|
||||
sim_type = #{simType,jdbcType=VARCHAR},
|
||||
</if>
|
||||
<if test="deviceRule != null" >
|
||||
device_rule = #{deviceRule,jdbcType=VARCHAR},
|
||||
@ -380,7 +380,7 @@
|
||||
|
||||
<update id="updateByPrimaryKeyWithBLOBs" parameterType="club.joylink.rtss.entity.training2.RtsTraining2RuleWithBLOBs" >
|
||||
update rts_training2_rule
|
||||
set map_id = #{mapId,jdbcType=BIGINT},
|
||||
set sim_type = #{simType,jdbcType=VARCHAR},
|
||||
device_rule = #{deviceRule,jdbcType=VARCHAR},
|
||||
client = #{client,jdbcType=VARCHAR},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
@ -398,7 +398,7 @@
|
||||
|
||||
<update id="updateByPrimaryKey" parameterType="club.joylink.rtss.entity.training2.RtsTraining2Rule" >
|
||||
update rts_training2_rule
|
||||
set map_id = #{mapId,jdbcType=BIGINT},
|
||||
set sim_type = #{simType,jdbcType=VARCHAR},
|
||||
device_rule = #{deviceRule,jdbcType=VARCHAR},
|
||||
client = #{client,jdbcType=VARCHAR},
|
||||
name = #{name,jdbcType=VARCHAR},
|
||||
|
@ -50,8 +50,8 @@ public class Training2RuleTest {
|
||||
@Transactional
|
||||
@Test
|
||||
public void entityTest() {
|
||||
String trainingRuleStr = "{\"id\":1,\"mapId\":154,\"deviceRule\":\"ROUTE_LIST\",\"name\":\"取消{NAME}进路\",\"description\":\"取消{NAME}进路\",\"type\":\"SINGLE\",\"labels\":null,\"sceneRule\":\"ROUTE_BG_SCENE\",\"steps\":[{\"id\":1,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击总取消\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"userOperationType\":\"leftClick\",\"domId\":\"2994\",\"operationType\":\"\",\"params\":{}}],\"triggerRule\":null,\"completionRule\":null,\"failureRule\":null,\"tipPosition\":{\"domId\":\"2994\",\"operateIndex\":0}},{\"id\":2,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击信号机【{ROUTE_START_NAME}】\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"deviceCode\":\"BUTTON_START_CODE\",\"userOperationType\":\"leftClick\",\"domId\":\"2994\",\"operationType\":\"Signal_Cancel_Route\",\"params\":{}}],\"tipPosition\":{\"domId\":\"2994\",\"deviceCode\":\"BUTTON_START_CODE\",\"operateIndex\":0}}],\"failureRule\":null,\"creatorId\":5710}";
|
||||
String trainingRuleStr2 = "{\"id\":1,\"mapId\":154,\"deviceRule\":\"ROUTE_LIST\",\"name\":\"【{NAME}】办理\",\"description\":\"【{NAME}】办理\",\"type\":\"SINGLE\",\"labels\":null,\"sceneRule\":null,\"steps\":[{\"id\":1,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击信号机【{ROUTE_START_NAME}】按钮\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"deviceCode\":\"BUTTON_START_CODE\",\"userOperationType\":\"leftClick\",\"domId\":\"3010\",\"operationType\":\"\",\"params\":{}}],\"triggerRule\":null,\"completionRule\":null,\"failureRule\":null,\"tipPosition\":{\"domId\":\"3010\",\"deviceCode\":\"BUTTON_START_CODE\",\"operateIndex\":0}},{\"id\":2,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击信号机【{ROUTE_END_NAME}】按钮\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"deviceCode\":\"BUTTON_END_CODE\",\"userOperationType\":\"leftClick\",\"domId\":\"3010\",\"operationType\":\"Signal_Set_Route\",\"params\":{}}],\"tipPosition\":{\"domId\":\"3010\",\"deviceCode\":\"BUTTON_END_CODE\",\"operateIndex\":0}}],\"failureRule\":null,\"creatorId\":5710}";
|
||||
String trainingRuleStr = "{\"id\":1,\"deviceRule\":\"RAILWAY_PICK_ROUTE_LIST\",\"name\":\"取消{NAME}进路\",\"description\":\"取消{NAME}进路\",\"type\":\"SINGLE\",\"labels\":null,\"sceneRule\":\"ROUTE_CANCEL_BG_SCENE\",\"steps\":[{\"id\":1,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击总取消\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"userOperationType\":\"leftClick\",\"domId\":\"2994\",\"operationType\":\"\",\"params\":{}}],\"triggerRule\":null,\"completionRule\":null,\"failureRule\":null,\"tipPosition\":{\"domId\":\"2994\",\"operateIndex\":0}},{\"id\":2,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击信号机【{ROUTE_START_NAME}】\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"deviceCode\":\"BUTTON_START_CODE\",\"userOperationType\":\"leftClick\",\"domId\":\"2994\",\"operationType\":\"Signal_Cancel_Route\",\"params\":{}}],\"tipPosition\":{\"domId\":\"2994\",\"deviceCode\":\"BUTTON_START_CODE\",\"operateIndex\":0}}],\"failureRule\":null,\"creatorId\":5710}";
|
||||
String trainingRuleStr2 = "{\"id\":1,\"deviceRule\":\"RAILWAY_PICK_ROUTE_LIST\",\"name\":\"【{NAME}】办理\",\"description\":\"【{NAME}】办理\",\"type\":\"SINGLE\",\"labels\":null,\"sceneRule\":null,\"steps\":[{\"id\":1,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击信号机【{ROUTE_START_NAME}】按钮\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"deviceCode\":\"BUTTON_START_CODE\",\"userOperationType\":\"leftClick\",\"domId\":\"3010\",\"operationType\":\"\",\"params\":{}}],\"triggerRule\":null,\"completionRule\":null,\"failureRule\":null,\"tipPosition\":{\"domId\":\"3010\",\"deviceCode\":\"BUTTON_START_CODE\",\"operateIndex\":0}},{\"id\":2,\"memberRule\":{\"type\":\"STATION_SUPERVISOR\",\"deviceCodeRule\":\"STATION_CODE\"},\"description\":\"点击信号机【{ROUTE_END_NAME}】按钮\",\"operationRules\":[{\"t\":\"C\",\"id\":0,\"deviceCode\":\"BUTTON_END_CODE\",\"userOperationType\":\"leftClick\",\"domId\":\"3010\",\"operationType\":\"Signal_Set_Route\",\"params\":{}}],\"tipPosition\":{\"domId\":\"3010\",\"deviceCode\":\"BUTTON_END_CODE\",\"operateIndex\":0}}],\"failureRule\":null,\"creatorId\":5710}";
|
||||
Training2Rule training2Rule = JsonUtils.read(trainingRuleStr, Training2Rule.class);
|
||||
Training2Rule training2Rule2 = JsonUtils.read(trainingRuleStr2, Training2Rule.class);
|
||||
// 生成实训
|
||||
@ -61,7 +61,7 @@ public class Training2RuleTest {
|
||||
accountVO.setId(5710L);
|
||||
loginUserInfoVO.setAccountVO(accountVO);
|
||||
SimulationWorkService initService = simulationWorkServiceManager.getWorkService(workParamVO.getType());
|
||||
Simulation simulation = initService.create(training2Rule.getMapId(), workParamVO, loginUserInfoVO);
|
||||
Simulation simulation = initService.create(154, workParamVO, loginUserInfoVO);
|
||||
// 删除旧仿真,保存新仿真
|
||||
club.joylink.rtss.simulation.Simulation oldSimulation = simulationManager.queryByCreatorId(simulation.getCreatorId());
|
||||
if (oldSimulation != null) {
|
||||
|
Loading…
Reference in New Issue
Block a user