【实训规则地图ID修改为仿真类型】

This commit is contained in:
weizhihong 2022-11-30 16:06:21 +08:00
parent 27a4dbd5b2
commit 1753c0dd12
9 changed files with 82 additions and 66 deletions

View File

@ -8,7 +8,7 @@ import java.util.Date;
public class RtsTraining2Rule {
private Long id;
private Long mapId;
private String simType;
private String locationRule;

View File

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

View File

@ -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)) {
// 清除数据库原有数据

View File

@ -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,7 +31,7 @@ public enum BgSceneStatusRule {
/**
* 解封按钮背景
*/
BUTTON_BG_SCENE("解封按钮背景") {
BUTTON_BLOCK_BG_SCENE("解封按钮背景") {
@Override
public String doHandle(Simulation simulation, MapElement mapElement) {
Signal signal = (Signal) mapElement;

View File

@ -13,25 +13,19 @@ 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)) {
if (CollectionUtils.isEmpty(stationList) || !isRailWay) {
return List.of();
}
Station station = stationList.get(0);
Predicate<Route.Type> predicate = (type) -> {
if (Simulation.Type.RAILWAY.equals(simulation.getBuildParams().getWorkParamVO().getType())) {
return Objects.equals(type, Route.Type.DEPARTURE) || Objects.equals(type, Route.Type.RECEIVING)
|| Objects.equals(type, Route.Type.PASS);
}
return true;
};
// 获取本站的2个进路信息
return simulation.getRepository().getRouteList().stream()
.filter(r -> predicate.test(r.getType()) && station.equals(r.getStart().getStation()))
.filter(r -> Objects.equals(r.getType(), Route.Type.RECEIVING) && station.equals(r.getStart().getStation()))
.limit(2).collect(Collectors.toList());
}
},

View File

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

View File

@ -28,8 +28,6 @@ import java.util.stream.Collectors;
public class Training2Rule {
private Long id;
private Long mapId;
/**
* 地图定位规则
*/
@ -82,7 +80,6 @@ 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();
@ -108,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));

View File

@ -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},

View File

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