diff --git a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java index 3e1c9ddda..aa716b303 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -490,6 +490,14 @@ public class SimulationV1Controller { return simulationService.createSimulation(mapId, paramVO, loginUserInfoVO); } + /** + * 根据地图功能id创建仿真 + */ + @PostMapping("/new/mapFunction/{mapFunctionId}") + public String createSimulationByMapFunction(@PathVariable long mapFunctionId, @RequestAttribute LoginUserInfoVO loginInfo) { + return simulationService.createSimulation(mapFunctionId, loginInfo); + } + /** * 按计划行车(新) */ diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java index e271431ef..7d03d2a60 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionService.java @@ -12,6 +12,8 @@ public interface RtsMapFunctionService { void update(long id, RtsMapFunctionUpdateVO updateVO, long updaterId); + RtsMapFunctionVO get(long id); + /** * 列表查询地图子系统 */ diff --git a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java index 6f791cfaf..61996bbb7 100644 --- a/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/mapFunction/RtsMapFunctionServiceImpl.java @@ -56,6 +56,12 @@ public class RtsMapFunctionServiceImpl implements RtsMapFunctionService { rtsMapFunctionDAO.updateByPrimaryKeyWithBLOBs(entity); } + @Override + public RtsMapFunctionVO get(long id) { + RtsMapFunction entity = getEntity(id); + return new RtsMapFunctionVO(entity); + } + @Override public List listQuery(RtsMapFunctionQueryVO queryVO) { RtsMapFunctionExample example = new RtsMapFunctionExample(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationService.java index 2dbe55dca..74f55ef14 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationService.java @@ -14,6 +14,8 @@ public interface SimulationService { */ String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO); + String createSimulation(long mapFunctionId, LoginUserInfoVO loginInfo); + /** * 给仿真添加功能 */ diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java index 67f286dae..deedec6e5 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java @@ -1,6 +1,7 @@ package club.joylink.rtss.simulation.cbtc; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.mapFunction.RtsMapFunctionService; import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.cbtc.event.SimulationCreateSuccessEvent; import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; @@ -8,6 +9,7 @@ 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.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.client.mapFunction.RtsMapFunctionVO; import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; @@ -32,6 +34,8 @@ public class SimulationServiceImpl implements SimulationService { private ApplicationContext applicationContext; @Autowired private DefaultMessageSender defaultMessageSender; + @Autowired + private RtsMapFunctionService rtsMapFunctionService; @Override public String createSimulation(long mapId, SimulationWorkParamVO workParamVO, @NonNull LoginUserInfoVO loginUserInfoVO) { @@ -68,6 +72,14 @@ public class SimulationServiceImpl implements SimulationService { return simulation.getId(); } + @Override + public String createSimulation(long mapFunctionId, LoginUserInfoVO loginInfo) { + RtsMapFunctionVO rtsMapFunctionVO = rtsMapFunctionService.get(mapFunctionId); + Long mapId = rtsMapFunctionVO.getMapId(); + SimulationWorkParamVO workParamVO = rtsMapFunctionVO.getParamVO(); + return createSimulation(mapId, workParamVO, loginInfo); + } + @Override public void addItems(@NonNull String simulationId, Map functionInfoMap, LoginUserInfoVO loginInfo) { if (!CollectionUtils.isEmpty(functionInfoMap)) {