Merge remote-tracking branch 'origin/test-training2' into test-training2
This commit is contained in:
commit
aedab56c37
@ -1,6 +1,7 @@
|
|||||||
package club.joylink.rtss.vo.training2.rule;
|
package club.joylink.rtss.vo.training2.rule;
|
||||||
|
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -10,7 +11,7 @@ public enum MapDeviceRule {
|
|||||||
|
|
||||||
ROUTE_LIST("进路列表") {
|
ROUTE_LIST("进路列表") {
|
||||||
@Override
|
@Override
|
||||||
public List<? extends Object> filterMapDeviceList(Simulation simulation) {
|
public List<Route> filterMapDeviceList(Simulation simulation) {
|
||||||
return simulation.getRepository().getRouteList();
|
return simulation.getRepository().getRouteList();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@ -21,5 +22,5 @@ public enum MapDeviceRule {
|
|||||||
this.description = description;
|
this.description = description;
|
||||||
}
|
}
|
||||||
|
|
||||||
public abstract List<? extends Object> filterMapDeviceList(Simulation simulation);
|
public abstract <T> List<T> filterMapDeviceList(Simulation simulation);
|
||||||
}
|
}
|
||||||
|
@ -32,12 +32,18 @@ public enum PropertyValueRule {
|
|||||||
STATION_NAME("地图设备所属车站名称") {
|
STATION_NAME("地图设备所属车站名称") {
|
||||||
@Override
|
@Override
|
||||||
public String resolve(Simulation simulation, Object mapElement) {
|
public String resolve(Simulation simulation, Object mapElement) {
|
||||||
|
if (mapElement instanceof Route) {
|
||||||
|
return ((Route) mapElement).getStart().getStation().getName();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
STATION_CODE("地图设备所属车站编码") {
|
STATION_CODE("地图设备所属车站编码") {
|
||||||
@Override
|
@Override
|
||||||
public String resolve(Simulation simulation, Object mapElement) {
|
public String resolve(Simulation simulation, Object mapElement) {
|
||||||
|
if (mapElement instanceof Route) {
|
||||||
|
return ((Route) mapElement).getStart().getStation().getCode();
|
||||||
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
@ -1,25 +1,26 @@
|
|||||||
package club.joylink.rtss.services.training;
|
package club.joylink.rtss.services.training;
|
||||||
|
|
||||||
import club.joylink.rtss.constants.MapPrdTypeEnum;
|
|
||||||
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
|
import club.joylink.rtss.entity.training2.DraftTraining2WithBLOBs;
|
||||||
import club.joylink.rtss.services.IMapService;
|
import club.joylink.rtss.services.IMapService;
|
||||||
import club.joylink.rtss.services.IRunPlanTemplateService;
|
import club.joylink.rtss.services.IRunPlanTemplateService;
|
||||||
import club.joylink.rtss.services.training.data.GenerateConfig;
|
import club.joylink.rtss.simulation.SimulationManager;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
|
||||||
import club.joylink.rtss.simulation.cbtc.Simulation;
|
import club.joylink.rtss.simulation.cbtc.Simulation;
|
||||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams;
|
import club.joylink.rtss.simulation.cbtc.SimulationService;
|
||||||
import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder;
|
|
||||||
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
import club.joylink.rtss.simulation.cbtc.data.map.Route;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.work.SimulationWorkService;
|
||||||
|
import club.joylink.rtss.simulation.cbtc.work.SimulationWorkServiceManager;
|
||||||
|
import club.joylink.rtss.simulation.messaging.websocket.DefaultMessageSender;
|
||||||
import club.joylink.rtss.util.JsonUtils;
|
import club.joylink.rtss.util.JsonUtils;
|
||||||
import club.joylink.rtss.vo.client.runplan.RunPlanVO;
|
import club.joylink.rtss.vo.AccountVO;
|
||||||
import club.joylink.rtss.vo.map.MapVO;
|
import club.joylink.rtss.vo.LoginUserInfoVO;
|
||||||
import club.joylink.rtss.vo.training2.rule.Training2Rule;
|
import club.joylink.rtss.vo.training2.rule.Training2Rule;
|
||||||
import org.junit.jupiter.api.Test;
|
import org.junit.jupiter.api.Test;
|
||||||
import org.springframework.beans.factory.annotation.Autowired;
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
import org.springframework.boot.test.context.SpringBootTest;
|
import org.springframework.boot.test.context.SpringBootTest;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
|
|
||||||
import java.time.LocalDateTime;
|
|
||||||
|
|
||||||
@SpringBootTest
|
@SpringBootTest
|
||||||
public class Training2RuleTest {
|
public class Training2RuleTest {
|
||||||
|
|
||||||
@ -29,28 +30,47 @@ public class Training2RuleTest {
|
|||||||
@Autowired
|
@Autowired
|
||||||
private IRunPlanTemplateService iRunPlanTemplateService;
|
private IRunPlanTemplateService iRunPlanTemplateService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimulationWorkServiceManager simulationWorkServiceManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimulationService simulationService;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private SimulationManager simulationManager;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private DefaultMessageSender defaultMessageSender;
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private GroupSimulationService groupSimulationService;
|
||||||
|
|
||||||
|
|
||||||
@Transactional
|
@Transactional
|
||||||
@Test
|
@Test
|
||||||
public void entityTest() {
|
public void entityTest() {
|
||||||
String trainingRuleStr = "{\"id\":1,\"mapId\":154,\"deviceType\":\"ROUTE\",\"name\":\"【{NAME}】办理\",\"description\":\"【{NAME}】办理\",\"type\":\"SINGLE\",\"labels\":[],\"sceneRule\":null,\"steps\":[{\"id\":1,\"memberId\":\"3\",\"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,\"memberId\":\"3\",\"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,\"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,\"deviceType\":\"ROUTE\",\"name\":\"取消【{NAME}】进路\",\"description\":\"取消【{NAME}】进路\",\"type\":\"SINGLE\",\"labels\":null,\"sceneRule\": \"ROUTE_BG_SCENE\",\"steps\":[{\"id\":1,\"memberId\":\"3\",\"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,\"memberId\":\"3\",\"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}";
|
||||||
Training2Rule training2Rule = JsonUtils.read(trainingRuleStr, Training2Rule.class);
|
Training2Rule training2Rule = JsonUtils.read(trainingRuleStr, Training2Rule.class);
|
||||||
Training2Rule training2Rule2 = JsonUtils.read(trainingRuleStr2, Training2Rule.class);
|
Training2Rule training2Rule2 = JsonUtils.read(trainingRuleStr2, Training2Rule.class);
|
||||||
// 生成实训
|
// 生成实训
|
||||||
MapVO mapVO = iMapService.getMapDetail(training2Rule.getMapId());
|
SimulationWorkParamVO workParamVO = JsonUtils.read("{\"type\":\"RAILWAY\",\"memberId\":\"1\",\"domConfig\":{\"singleMember\":true,\"singleClient\":false,\"hasTraining\":false,\"hasExam\":false},\"mapId\":154}", SimulationWorkParamVO.class);
|
||||||
// 仿真配置
|
LoginUserInfoVO loginUserInfoVO = new LoginUserInfoVO();
|
||||||
GenerateConfig config = new GenerateConfig();
|
AccountVO accountVO = new AccountVO();
|
||||||
config.setMapId(training2Rule.getMapId());
|
accountVO.setId(5710L);
|
||||||
// 查询通用运行图
|
loginUserInfoVO.setAccountVO(accountVO);
|
||||||
RunPlanVO planVO = this.iRunPlanTemplateService.getFirstRunPlanByMapId(mapVO.getId());
|
SimulationWorkService initService = simulationWorkServiceManager.getInitService(workParamVO.getType());
|
||||||
SimulationBuildParams params = SimulationBuildParams.builder()
|
Simulation simulation = initService.create(training2Rule.getMapId(), workParamVO, loginUserInfoVO);
|
||||||
.createTime(LocalDateTime.now())
|
// 删除旧仿真,保存新仿真
|
||||||
.map(mapVO)
|
club.joylink.rtss.simulation.Simulation oldSimulation = simulationManager.queryByCreatorId(simulation.getCreatorId());
|
||||||
.prodType(MapPrdTypeEnum.getMapPrdTypeEnumByCode(config.getPrdType()))
|
if (oldSimulation != null) {
|
||||||
.runPlan(planVO)
|
groupSimulationService.clearSimulation(oldSimulation.getId());
|
||||||
.build();
|
}
|
||||||
Simulation simulation = SimulationBuilder.build("", params);
|
simulationManager.saveNew(simulation);
|
||||||
Route route = simulation.getRepository().getByCode("Route94", Route.class);
|
initService.loadData(simulation);
|
||||||
|
initService.init(simulation);
|
||||||
|
|
||||||
|
Route route = simulation.getRepository().getByCode("Route1", Route.class);
|
||||||
DraftTraining2WithBLOBs draftTraining2WithBLOBs = training2Rule.convert2BO(simulation, route);
|
DraftTraining2WithBLOBs draftTraining2WithBLOBs = training2Rule.convert2BO(simulation, route);
|
||||||
System.out.println(JsonUtils.writeValueAsString(draftTraining2WithBLOBs));
|
System.out.println(JsonUtils.writeValueAsString(draftTraining2WithBLOBs));
|
||||||
DraftTraining2WithBLOBs draftTraining2WithBLOBs2 = training2Rule2.convert2BO(simulation, route);
|
DraftTraining2WithBLOBs draftTraining2WithBLOBs2 = training2Rule2.convert2BO(simulation, route);
|
||||||
|
Loading…
Reference in New Issue
Block a user