diff --git a/src/main/java/club/joylink/rtss/controller/MinioController.java b/src/main/java/club/joylink/rtss/controller/MinioController.java index ab2e16325..dd0268bc8 100644 --- a/src/main/java/club/joylink/rtss/controller/MinioController.java +++ b/src/main/java/club/joylink/rtss/controller/MinioController.java @@ -18,6 +18,11 @@ public class MinioController { @Autowired private MinioService minioService; + @GetMapping("/checkIsExist") + public boolean checkFileIsExist(String directory, String fileName) { + return minioService.checkFileIsExist(directory, fileName); + } + @GetMapping("/preSignedUrl") public String getPreSignedObjectUrl(String directory, String fileName, Method method) { return minioService.preSignedObjectUrl(directory, fileName, method); 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 394da50e0..5a56bfcdb 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -506,6 +506,14 @@ public class SimulationV1Controller { simulationService.removeFunctions(simulationId, functions, loginInfo); } + /** + * 按计划行车(新) + */ + @PutMapping("/new/{simulationId}/runAsPlan") + public void runAsPlanNew(@PathVariable String simulationId, @RequestBody @Validated RunAsPlanParam param) { + simulationService.runAsPlan(simulationId, param); + } + /** * 重置仿真(新) */ diff --git a/src/main/java/club/joylink/rtss/services/MinioService.java b/src/main/java/club/joylink/rtss/services/MinioService.java index 1141921a9..3ea474871 100644 --- a/src/main/java/club/joylink/rtss/services/MinioService.java +++ b/src/main/java/club/joylink/rtss/services/MinioService.java @@ -35,5 +35,13 @@ public interface MinioService { */ void update(MinioFileInfo fileInfo); + /** + * 获取带有验证信息的下载路径 + */ String downloadObjectUrl(String directory, String fileName); + + /** + * 检查文件是否存在 + */ + boolean checkFileIsExist(String directory, String fileName); } diff --git a/src/main/java/club/joylink/rtss/services/MinioServiceImpl.java b/src/main/java/club/joylink/rtss/services/MinioServiceImpl.java index 1f7e9a780..2ce7e4b54 100644 --- a/src/main/java/club/joylink/rtss/services/MinioServiceImpl.java +++ b/src/main/java/club/joylink/rtss/services/MinioServiceImpl.java @@ -86,4 +86,9 @@ public class MinioServiceImpl implements MinioService { MinioClientUtil minioClientUtil = createMinioClientUtil(directory); return minioClientUtil.getDownLoadPath(fileName); } + + @Override + public boolean checkFileIsExist(String directory, String fileName) { + return createMinioClientUtil(directory).checkFileIsExist(fileName); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java index c3c563980..799046b71 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/Simulation.java @@ -681,6 +681,13 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation member1.isSame(device)).collect(Collectors.toList()); } + public List getSimulationMembersByDeviceCode(String deviceCode) { + MapElement device = repository.getByCode(deviceCode); + List list = getSimulationMembersByDevice(device); + BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(list, "[code:%s]无对应的仿真成员"); + return list; + } + public SimulationMember querySimulationMember(MapElement device, SimulationMember.Type memberType) { return getSimulationMembers().stream() .filter(member -> Objects.equals(member.getDevice(), device)) 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 4c15ff9b2..cd3cb576b 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationService.java @@ -2,6 +2,7 @@ package club.joylink.rtss.simulation.cbtc; import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; import club.joylink.rtss.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import lombok.NonNull; import java.util.List; @@ -23,6 +24,11 @@ public interface SimulationService { */ void removeFunctions(String simulationId, List functions, LoginUserInfoVO loginInfo); + /** + * 按计划行车 + */ + void runAsPlan(String simulationId, RunAsPlanParam param); + /** * 重置仿真 */ 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 f14fd06e6..fe913987c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/SimulationServiceImpl.java @@ -3,12 +3,12 @@ package club.joylink.rtss.simulation.cbtc; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.SimulationManager; import club.joylink.rtss.simulation.cbtc.event.SimulationCreateSuccessEvent; -import club.joylink.rtss.simulation.cbtc.init.SimulationInitService; -import club.joylink.rtss.simulation.cbtc.init.SimulationInitServiceManager; 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.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import lombok.NonNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.ApplicationContext; @@ -24,7 +24,7 @@ public class SimulationServiceImpl implements SimulationService { @Autowired private SimulationManager simulationManager; @Autowired - private SimulationInitServiceManager simulationInitServiceManager; + private SimulationWorkServiceManager simulationWorkServiceManager; @Autowired private GroupSimulationService groupSimulationService; @Autowired @@ -34,13 +34,7 @@ public class SimulationServiceImpl implements SimulationService { @Override public String createSimulation(@NonNull LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) { - System.out.println(JsonUtils.writeValueAsString(workParamVO)); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO, "仿真创建参数不能为空"); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getMapId(), "仿真线路id不能为空"); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getType(), "仿真类型不能为空"); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.findUsage(), "仿真用途不能为空"); - - SimulationInitService initService = simulationInitServiceManager.getInitService(workParamVO.getType()); + SimulationWorkService initService = simulationWorkServiceManager.getInitService(workParamVO.getType()); Simulation simulation = initService.create(loginUserInfoVO, workParamVO); // 删除旧仿真,保存新仿真 @@ -59,6 +53,7 @@ public class SimulationServiceImpl implements SimulationService { if (!CollectionUtils.isEmpty(workParamVO.getFunctionMap())) { initService.addFunctions(simulation, workParamVO.getFunctionMap(), loginUserInfoVO); } + applicationContext.publishEvent(new SimulationCreateSuccessEvent(this, simulation)); // 仿真开始运行 simulationManager.start(simulation.getId()); @@ -74,7 +69,7 @@ public class SimulationServiceImpl implements SimulationService { private void addFunctions(@NonNull Simulation simulation, Map> functionMap, LoginUserInfoVO loginInfo) { if (!CollectionUtils.isEmpty(functionMap)) { Simulation.Type simulationType = simulation.getType(); - SimulationInitService initService = simulationInitServiceManager.getInitService(simulationType); + SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulationType); if (StringUtils.hasText(simulation.getCreatorId())) { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(), "非仿真创建者不能使用该功能"); @@ -89,17 +84,24 @@ public class SimulationServiceImpl implements SimulationService { removeFunctions(simulation, functions, loginInfo); } + @Override + public void runAsPlan(String simulationId, RunAsPlanParam param) { + Simulation simulation = simulationManager.getById(simulationId, Simulation.class); + SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulation.getType()); + initService.runAsPlan(simulation, param); + } + @Override public void reset(String simulationId) { Simulation simulation = simulationManager.getById(simulationId, Simulation.class); - SimulationInitService initService = simulationInitServiceManager.getInitService(simulation.getType()); + SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulation.getType()); initService.reset(simulation); } private void removeFunctions(@NonNull Simulation simulation, List functions, LoginUserInfoVO loginInfo) { if (!CollectionUtils.isEmpty(functions)) { Simulation.Type simulationType = simulation.getType(); - SimulationInitService initService = simulationInitServiceManager.getInitService(simulationType); + SimulationWorkService initService = simulationWorkServiceManager.getInitService(simulationType); if (StringUtils.hasText(simulation.getCreatorId())) { BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertEquals(loginInfo.getAccountVO().getIdStr(), simulation.getCreatorId(), "非仿真创建者不能使用该功能"); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/init/SimulationInitService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/init/SimulationInitService.java deleted file mode 100644 index a186c8dc9..000000000 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/init/SimulationInitService.java +++ /dev/null @@ -1,28 +0,0 @@ -package club.joylink.rtss.simulation.cbtc.init; - -import club.joylink.rtss.simulation.cbtc.Simulation; -import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; -import club.joylink.rtss.vo.LoginUserInfoVO; - -import java.util.Collection; -import java.util.Map; - -public interface SimulationInitService { - Simulation.Type getType(); - - Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO createParamVO); - - void loadData(Simulation simulation); - - void addJobs(Simulation simulation); - - void addMessagePublisher(Simulation simulation); - - void init(Simulation simulation); - - void reset(Simulation simulation); - - void addFunctions(Simulation simulation, Map> functionMap, LoginUserInfoVO loginInfo); - - void removeFunctions(Simulation simulation, Collection functions); -} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java index d01fb9986..c08ef220c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/member/MemberManager.java @@ -76,7 +76,7 @@ public class MemberManager { public void init(Simulation simulation) { /* -----------默认创建一个行调,一个通号;车站和司机按设备创建----------- */ // 调度 - if (!simulation.getRepository().getConfig().isRailway()){ + if (!simulation.getRepository().getConfig().isRailway()) { this.addRole(simulation, SimulationMember.Type.DISPATCHER); } // 通号 @@ -105,9 +105,9 @@ public class MemberManager { if (simulation.getRepository().getConfig().isRailway()) { // 调度台--调度关联 List disStationList = simulation.getRepository().getDisStationList(); - if(null!=disStationList){ - for(DisStation disStation : disStationList){ - this.addRole(simulation,SimulationMember.Type.DISPATCHER,disStation.getName()+"调度",disStation); + if (null != disStationList) { + for (DisStation disStation : disStationList) { + this.addRole(simulation, SimulationMember.Type.DISPATCHER, disStation.getName() + "调度", disStation); } } } @@ -305,4 +305,56 @@ public class MemberManager { this.cancelPlay(simulation, userId); } } + + public void addRailMembers(Simulation simulation) { + // 调度 + if (!simulation.getRepository().getConfig().isRailway()) { + this.addRole(simulation, SimulationMember.Type.DISPATCHER); + } + // 通号 + this.addRole(simulation, SimulationMember.Type.MAINTAINER); + // 行值 + List stationList = simulation.getRepository().getSortedStationList(); + for (Station station : stationList) { +// if (station.isNormal()) { +// this.addRole(simulation, SimulationMember.Type.STATION_SUPERVISOR, null, station); +// } else if (station.isDepot()) { +// // 车辆段调度 +// this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER, station.getName() + "调度", station); +// } + Arrays.asList( + SimulationMember.Type.STATION_SUPERVISOR, + SimulationMember.Type.STATION_ASSISTANT, SimulationMember.Type.STATION_MASTER, + SimulationMember.Type.STATION_SIGNALER, SimulationMember.Type.STATION_PASSENGER, + SimulationMember.Type.STATION_SWITCH_MAN, SimulationMember.Type.STATION_FACILITATOR, + SimulationMember.Type.STATION_WORKER, SimulationMember.Type.DEVICE_MANAGER + ).forEach(type -> this.addRole(simulation, type, null, station)); + } + // 调度台--调度关联 + List disStationList = simulation.getRepository().getDisStationList(); + if (null != disStationList) { + for (DisStation disStation : disStationList) { + this.addRole(simulation, SimulationMember.Type.DISPATCHER, disStation.getName() + "调度", disStation); + } + } + // 司机 + List vrTrainList = simulation.getRepository().getAllVrTrain(); + for (VirtualRealityTrain vrTrain : vrTrainList) { + this.addRole(simulation, SimulationMember.Type.DRIVER, null, vrTrain); + } +// // 工电调度 +// this.addRole(simulation, SimulationMember.Type.ELECTRIC_DISPATCHER); +// // 车辆段调度 +// this.addRole(simulation, SimulationMember.Type.DEPOT_DISPATCHER); +// // 车辆段信号楼 +// this.addRole(simulation, SimulationMember.Type.DEPOT_SIGNAL_BUILDING); +// // 停车场信号楼 +// this.addRole(simulation, SimulationMember.Type.PARKING_LOT_SIGNAL_BUILDING); + // 上级部门 + this.addRole(simulation, SimulationMember.Type.PARENT_DEPARTMENT); +// // 派班员 +// this.addRole(simulation, SimulationMember.Type.SCHEDULING); +// // 车务段段长 +// this.addRole(simulation, SimulationMember.Type.TRAIN_MASTER); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowListener.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowListener.java index 58478645f..317e4230c 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowListener.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowListener.java @@ -20,14 +20,14 @@ public class PassengerFlowListener { @Async("nsExecutor") @EventListener public void handle(SimulationRunAsPlanEvent event) { - if (passengerFlowSimulateService.initPassengerFlow(event)) { + if (passengerFlowSimulateService.initPassengerFlow(event.getSimulation())) { largePassengerFlowStrategyService.addJobs(event.getSimulation()); } } @EventListener public void handle(SimulationResetEvent event) { - passengerFlowSimulateService.simulationReset(event); + passengerFlowSimulateService.simulationReset(event.getSimulation()); largePassengerFlowStrategyService.removeJobs(event.getSimulation()); } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java index 8c943dd06..6bed431a0 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/passenger/PassengerFlowSimulateService.java @@ -14,8 +14,6 @@ import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo; import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain; import club.joylink.rtss.simulation.cbtc.event.PassengerUserConnectEvent; import club.joylink.rtss.simulation.cbtc.event.SimulationDestroyEvent; -import club.joylink.rtss.simulation.cbtc.event.SimulationResetEvent; -import club.joylink.rtss.simulation.cbtc.event.SimulationRunAsPlanEvent; import club.joylink.rtss.simulation.cbtc.passenger.data.*; import club.joylink.rtss.simulation.cbtc.passenger.strategy.Config; import club.joylink.rtss.util.JsonUtils; @@ -86,8 +84,7 @@ public class PassengerFlowSimulateService { group2mapPassengerFlowID.remove(simulation.getId()); } - public void simulationReset(SimulationResetEvent event) { - Simulation simulation = event.getSimulation(); + public void simulationReset(Simulation simulation) { log.info(String.format("仿真[%s]初始化,清理客流仿真数据", simulation.getId())); passengerFlowSimulationDataMap.remove(simulation.getId()); passengerFlowViewMap.remove(simulation.getId()); @@ -98,8 +95,7 @@ public class PassengerFlowSimulateService { /** * @return 客流初始化成功 */ - public boolean initPassengerFlow(SimulationRunAsPlanEvent event) { - Simulation simulation = event.getSimulation(); + public boolean initPassengerFlow(Simulation simulation) { MapVO map = simulation.getBuildParams().getMap(); Long mapId = map.getId(); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/vo/SingleClientParamVO.java b/src/main/java/club/joylink/rtss/simulation/cbtc/vo/SingleClientParamVO.java new file mode 100644 index 000000000..a137e801e --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/vo/SingleClientParamVO.java @@ -0,0 +1,15 @@ +package club.joylink.rtss.simulation.cbtc.vo; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import lombok.Getter; +import lombok.NoArgsConstructor; +import lombok.Setter; + +@Getter +@Setter +@NoArgsConstructor +public class SingleClientParamVO { + private Simulation.Client client; + + private String deviceCode; +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/work/EmergencySimulationWorkServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/EmergencySimulationWorkServiceImpl.java new file mode 100644 index 000000000..7feb20949 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/EmergencySimulationWorkServiceImpl.java @@ -0,0 +1,65 @@ +package club.joylink.rtss.simulation.cbtc.work; + +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; +import club.joylink.rtss.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; +import lombok.extern.slf4j.Slf4j; +import org.springframework.stereotype.Service; + +import java.util.Collection; +import java.util.Map; + +@Slf4j +@Service +public class EmergencySimulationWorkServiceImpl implements SimulationWorkService { + @Override + public Simulation.Type getType() { + return Simulation.Type.EMERGENCY; + } + + @Override + public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) { + return null; + } + + @Override + public void loadData(Simulation simulation) { + + } + + @Override + public void addJobs(Simulation simulation) { + + } + + @Override + public void addMessagePublisher(Simulation simulation) { + + } + + @Override + public void init(Simulation simulation) { + + } + + @Override + public void runAsPlan(Simulation simulation, RunAsPlanParam param) { + + } + + @Override + public void reset(Simulation simulation) { + + } + + @Override + public void addFunctions(Simulation simulation, Map> functionMap, LoginUserInfoVO loginInfo) { + + } + + @Override + public void removeFunctions(Simulation simulation, Collection functions) { + + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/init/MetroSimulationInitServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java similarity index 83% rename from src/main/java/club/joylink/rtss/simulation/cbtc/init/MetroSimulationInitServiceImpl.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java index 8a380f7eb..1bc4c5349 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/init/MetroSimulationInitServiceImpl.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/MetroSimulationWorkServiceImpl.java @@ -1,10 +1,11 @@ -package club.joylink.rtss.simulation.cbtc.init; +package club.joylink.rtss.simulation.cbtc.work; import club.joylink.rtss.entity.Ibp; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.services.*; import club.joylink.rtss.services.iscs.IscsDeviceService; import club.joylink.rtss.services.iscs.IscsSystemResourcesService; +import club.joylink.rtss.services.project.DeviceService; import club.joylink.rtss.services.psl.IVirtualRealityPslService; import club.joylink.rtss.services.publishData.IbpService; import club.joylink.rtss.services.runplan.IRunPlanParktimeService; @@ -31,6 +32,8 @@ import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.member.SimulationUser; import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop; import club.joylink.rtss.simulation.cbtc.onboard.TrainTargetUpdateService; +import club.joylink.rtss.simulation.cbtc.passenger.PassengerFlowSimulateService; +import club.joylink.rtss.simulation.cbtc.passenger.strategy.LargePassengerFlowStrategyService; import club.joylink.rtss.simulation.cbtc.pis.PisLogicLoop; import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService; import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; @@ -49,12 +52,13 @@ import club.joylink.rtss.vo.client.runplan.RunPlanVO; import club.joylink.rtss.vo.client.runplan.user.RunPlanParkingTimeVO; import club.joylink.rtss.vo.client.runplan.user.RunPlanRunlevelVO; import club.joylink.rtss.vo.client.schedulingNew.SchedulingPlanNewVO; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; import club.joylink.rtss.vo.map.MapVO; -import lombok.NonNull; import lombok.extern.slf4j.Slf4j; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; import java.time.LocalDate; import java.time.LocalDateTime; @@ -65,7 +69,7 @@ import java.util.Objects; @Slf4j @Service -public class MetroSimulationInitServiceImpl implements SimulationInitService { +public class MetroSimulationWorkServiceImpl implements SimulationWorkService { @Autowired private IMapService iMapService; @Autowired @@ -128,6 +132,14 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { private SimulationLifeCycleService simulationLifeCycleService; @Autowired private ITrainingV1Service iTrainingV1Service; + @Autowired + private PassengerFlowSimulateService passengerFlowSimulateService; + @Autowired + private GroupSimulationService groupSimulationService; + @Autowired + private LargePassengerFlowStrategyService largePassengerFlowStrategyService; + @Autowired + private DeviceService deviceService; @Override public Simulation.Type getType() { @@ -135,10 +147,10 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { } @Override - public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO createParamVO) { - checkParam(createParamVO); - SimulationBuildParams params = prepareSimulationParams(loginUserInfoVO, createParamVO); - String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), createParamVO.getMapId()); + public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) { + checkParam(workParamVO); + SimulationBuildParams params = prepareSimulationParams(loginUserInfoVO, workParamVO); + String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), workParamVO.getMapId()); Simulation simulation = new Simulation(group); simulation.setBuildParams(params); return simulation; @@ -204,9 +216,61 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { playSimulationMember(simulation); } + @Override + public void runAsPlan(Simulation simulation, RunAsPlanParam param) { + SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO(); + Map> functionMap = workParamVO.getFunctionMap(); + if (CollectionUtils.isEmpty(functionMap)) { + groupSimulationService.runAsPlan(simulation.getId(), param); + } else { + for (Map.Entry> entry : functionMap.entrySet()) { + Simulation.Function function = entry.getKey(); + Map funcParam = entry.getValue(); + switch (function) { + case LPF: + boolean initSuccess = passengerFlowSimulateService.initPassengerFlow(simulation); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertTrue(initSuccess, "大客流初始化失败"); + largePassengerFlowStrategyService.addJobs(simulation); + break; + case TRAINING_ROOM: + break; + case TRAINING_DESIGN: + break; + case TRAINING: + break; + case EXAM: + break; + } + } + } + } + @Override public void reset(Simulation simulation) { simulationLifeCycleService.reset(simulation); + + SimulationWorkParamVO workParamVO = simulation.getBuildParams().getWorkParamVO(); + Map> functionMap = workParamVO.getFunctionMap(); + if (!CollectionUtils.isEmpty(functionMap)) { + for (Map.Entry> entry : functionMap.entrySet()) { + Simulation.Function function = entry.getKey(); + Map funcParam = entry.getValue(); + switch (function) { + case LPF: + passengerFlowSimulateService.simulationReset(simulation); + largePassengerFlowStrategyService.removeJobs(simulation); + break; + case TRAINING_ROOM: + break; + case TRAINING_DESIGN: + break; + case TRAINING: + break; + case EXAM: + break; + } + } + } } @Override @@ -267,13 +331,13 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { switch (usageInfo.getUsage()) { case SINGLE_MEMBER: BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertMapNotEmpty(usageInfo.getParam(), "单角色仿真必须指定角色"); - simulationMember = selectSimulationMemberFromParam(simulation, usageInfo); + simulationMember = selectSimulationMemberByMemberInfo(simulation, usageInfo); break; case SINGLE_CLIENT: throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("待实现"); case JOINT: if (!CollectionUtils.isEmpty(usageInfo.getParam())) { - simulationMember = selectSimulationMemberFromParam(simulation, usageInfo); + simulationMember = selectSimulationMemberByMemberInfo(simulation, usageInfo); } else { simulationMember = simulation.getMemberListByType(SimulationMember.Type.DISPATCHER).get(0); } @@ -287,32 +351,21 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { } } - private SimulationMember selectSimulationMemberFromParam(Simulation simulation, SimulationWorkParamVO.UsageInfo usageInfo) { + private SimulationMember selectSimulationMemberByMemberInfo(Simulation simulation, SimulationWorkParamVO.UsageInfo usageInfo) { SingleMemberParamVO singleMemberParamVO = JsonUtils.read(JsonUtils.writeValueAsString(usageInfo.getParam()), SingleMemberParamVO.class); SimulationMember.Type memberType = singleMemberParamVO.getMemberType(); String deviceCode = singleMemberParamVO.getDeviceCode(); SimulationMember simulationMember = null; - if (memberType != null && deviceCode != null) { + if (memberType != null && StringUtils.hasText(deviceCode)) { simulationMember = simulation.getSimulationMember(memberType, deviceCode); } else if (memberType != null) { simulationMember = simulation.getMemberListByType(memberType).get(0); - } else if (deviceCode != null) { - simulationMember = simulation.getSimulationMember(memberType, deviceCode); + } else if (StringUtils.hasText(deviceCode)) { + simulationMember = simulation.getSimulationMembersByDeviceCode(deviceCode).get(0); } return simulationMember; } - /** - * 检查仿真创建参数 - */ - private void checkParam(@NonNull SimulationWorkParamVO createParamVO) { - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(createParamVO.getMapId()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(createParamVO.getType()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(createParamVO.findUsage()); - BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(!CollectionUtils.isEmpty(createParamVO.getFunctionMap()) - && createParamVO.getFunctionMap().size() > 1, "功能数量超限"); - } - private void loadMapData(Simulation simulation) { SimulationBuildParams buildParams = simulation.getBuildParams(); simulation.setBuildParams(buildParams); @@ -342,24 +395,19 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap()); simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.getSectionArriveNearMap()); simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap()); -// simulation.getRepository().setRouteUnitMap(mapDataBuildResult.getRouteUnitMap()); simulation.getRepository().setRoutePathMap(mapDataBuildResult.getRoutePathMap()); simulation.getRepository().setDestinationMap(mapDataBuildResult.getDestinationMap()); simulation.getRepository().setRoutingList(mapDataBuildResult.getRoutingList()); -// simulation.getRepository().setRunLevelList(mapDataBuildResult.getRunLevelList()); simulation.getRepository().getCatenaryMap().putAll(mapDataBuildResult.getCatenaryMap()); simulation.getRepository().getSectionRespondersMap().putAll(mapDataBuildResult.getSectionRespondersMap()); simulation.getRepository().setParkingTracksMap(mapDataBuildResult.getParkingTracksMap()); -// simulation.getRepository().setParkTimeMap(mapDataBuildResult.getParkTimeMap()); UserConfigDataBuilder.buildRunLevel(simulation.getRepository(), buildParams.getUserRunLevelList(), buildParams.getMap(), mapDataBuildResult.getErrMsgList()); UserConfigDataBuilder.buildParkTime(simulation.getRepository(), buildParams.getUserParkTimeList(), buildParams.getMap(), mapDataBuildResult.getErrMsgList()); if (!CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) { // 存在数据异常 mapDataBuildResult.getErrMsgList().forEach(errMsg -> log.warn(String.format("地图数据异常:%s", errMsg))); - if (!buildParams.getMap().getConfigVO().isRailway()) { - simulation.setMapDataError(true); - } + simulation.setMapDataError(true); simulation.addDataErrMsgs(mapDataBuildResult.getErrMsgList()); } // 加载ISCS资源 @@ -370,15 +418,11 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { SimulationBuilder.checkAndLoadSchedulingPlan(simulation, buildParams.getSchedulingPlan()); // 加载车辆段route path SimulationBuilder.loadDepotInOutRoutePath(simulation); - // CTC行车日志数据结构构建 - if (simulation.getRepository().getConfig().isRailway()) { - SimulationBuilder.buildCtcStationRunPlanLog(simulation); - } } - private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO createParamVO) { + private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) { // 获取地图数据 - Long mapId = createParamVO.getMapId(); + Long mapId = workParamVO.getMapId(); MapVO mapVO = iMapService.getMapDetail(mapId); List runLevelList = this.prepareRunLevelData(loginUserInfoVO, mapId); List parkTimeList = this.prepareParkTimeData(loginUserInfoVO, mapId); @@ -388,7 +432,7 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); // 都有的属性构造 builder.loginUserInfo(loginUserInfoVO) - .workParamVO(createParamVO) + .workParamVO(workParamVO) .createTime(LocalDateTime.now()) .map(mapVO) .userRunLevelList(runLevelList) @@ -396,7 +440,7 @@ public class MetroSimulationInitServiceImpl implements SimulationInitService { .operationDefinitionList(operationDefinitionList); //运行图选择性构造 LocalDate runPlanDate = SimulationConstants.getRunPlanDate(); - RunPlanVO runPlanVO = findRunPlan(createParamVO, loginUserInfoVO.getAccountVO().getId(), mapId); + RunPlanVO runPlanVO = findRunPlan(workParamVO, loginUserInfoVO.getAccountVO().getId(), mapId); if (Objects.nonNull(runPlanVO)) { runPlanVO.setRunDate(runPlanDate); builder.runPlan(runPlanVO); diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/work/RailwaySimulationWorkServiceImpl.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/RailwaySimulationWorkServiceImpl.java new file mode 100644 index 000000000..6a3ab39e1 --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/RailwaySimulationWorkServiceImpl.java @@ -0,0 +1,254 @@ +package club.joylink.rtss.simulation.cbtc.work; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.services.ICommandService; +import club.joylink.rtss.services.IMapService; +import club.joylink.rtss.simulation.cbtc.ATS.ATSLogicLoop; +import club.joylink.rtss.simulation.cbtc.ATS.ATSMessageCollectAndDispatcher; +import club.joylink.rtss.simulation.cbtc.CI.CiLogic; +import club.joylink.rtss.simulation.cbtc.CTC.CTCLogicLoop; +import club.joylink.rtss.simulation.cbtc.DeviceStatusService; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.SimulationIdGenerator; +import club.joylink.rtss.simulation.cbtc.SimulationLifeCycleService; +import club.joylink.rtss.simulation.cbtc.build.SimulationBuildParams; +import club.joylink.rtss.simulation.cbtc.build.SimulationBuilder; +import club.joylink.rtss.simulation.cbtc.communication.Joylink3DMessageService; +import club.joylink.rtss.simulation.cbtc.device.virtual.VRDeviceLogicLoop; +import club.joylink.rtss.simulation.cbtc.device.virtual.VRTrainRunningService; +import club.joylink.rtss.simulation.cbtc.fault.FaultGenerator; +import club.joylink.rtss.simulation.cbtc.member.MemberManager; +import club.joylink.rtss.simulation.cbtc.member.SimulationMember; +import club.joylink.rtss.simulation.cbtc.member.SimulationUser; +import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPLogicLoop; +import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService; +import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; +import club.joylink.rtss.simulation.cbtc.vo.SingleMemberParamVO; +import club.joylink.rtss.util.JsonUtils; +import club.joylink.rtss.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.client.CommandDefinitionVO; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; +import club.joylink.rtss.vo.map.MapVO; +import lombok.extern.slf4j.Slf4j; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; +import org.springframework.util.CollectionUtils; +import org.springframework.util.StringUtils; + +import java.time.LocalDateTime; +import java.util.Collection; +import java.util.List; +import java.util.Map; +import java.util.Objects; + +@Slf4j +@Service +public class RailwaySimulationWorkServiceImpl implements SimulationWorkService { + @Autowired + private IMapService iMapService; + @Autowired + private ICommandService iCommandService; + @Autowired + private MemberManager memberManager; + @Autowired + private ATSLogicLoop atsLogicLoop; + @Autowired + private CTCLogicLoop ctcLogicLoop; + @Autowired + private ATPLogicLoop atpLogicLoop; + @Autowired + private SimulationRobotService simulationRobotService; + @Autowired + private VRTrainRunningService vrTrainRunningService; + @Autowired + private CiLogic ciLogic; + @Autowired + private VRDeviceLogicLoop vrDeviceLogicLoop; + @Autowired + private ATSMessageCollectAndDispatcher atsMessageCollectAndDispatcher; + @Autowired + private Joylink3DMessageService joylink3DMessageService; + @Autowired + private FaultGenerator faultGenerator; + @Autowired + private DeviceStatusService deviceStatusService; + @Autowired + private SimulationLifeCycleService simulationLifeCycleService; + + @Override + public Simulation.Type getType() { + return Simulation.Type.RAILWAY; + } + + @Override + public Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) { + checkParam(workParamVO); + SimulationBuildParams params = prepareSimulationParams(loginUserInfoVO, workParamVO); + String group = SimulationIdGenerator.generateGroup(loginUserInfoVO.getAccountVO().getId(), workParamVO.getMapId()); + Simulation simulation = new Simulation(group); + simulation.setBuildParams(params); + return simulation; + } + + @Override + public void loadData(Simulation simulation) { + SimulationBuildParams params = simulation.getBuildParams(); + // 加载地图数据 + loadMapData(simulation); +// // 车辆段 +// depotService.loadDepotTrain(simulation); + // 添加仿真用户 + SimulationUser simulationUser = new SimulationUser(simulation, params.getLoginUserInfo()); + simulation.addSimulationUser(simulationUser); + // 添加仿真成员 + memberManager.addRailMembers(simulation); + } + + @Override + public void addJobs(Simulation simulation) { + ctcLogicLoop.addJobs(simulation); + atpLogicLoop.addJobs(simulation); + atsLogicLoop.addJobs(simulation); + simulationRobotService.addJobs(simulation); + vrTrainRunningService.addJobs(simulation); + ciLogic.addJobs(simulation); + vrDeviceLogicLoop.addJobs(simulation); + atsMessageCollectAndDispatcher.addJobs(simulation); + joylink3DMessageService.addJobs(simulation); + faultGenerator.addJobs(simulation); + } + + @Override + public void addMessagePublisher(Simulation simulation) { + + } + + @Override + public void init(Simulation simulation) { + // 初始化设备状态 + deviceStatusService.init(simulation); + // 根据使用方式,设置用户扮演角色 + playSimulationMember(simulation); + } + + @Override + public void runAsPlan(Simulation simulation, RunAsPlanParam param) { + + } + + @Override + public void reset(Simulation simulation) { + simulationLifeCycleService.reset(simulation); + } + + @Override + public void addFunctions(Simulation simulation, Map> functionMap, LoginUserInfoVO loginInfo) { + + } + + @Override + public void removeFunctions(Simulation simulation, Collection functions) { + + } + + private SimulationBuildParams prepareSimulationParams(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO) { + // 获取地图数据 + Long mapId = workParamVO.getMapId(); + MapVO mapVO = iMapService.getMapDetail(mapId); + // 获取操作定义数据 + List operationDefinitionList = iCommandService + .queryDefinitionsByLineCode(mapVO.getLineCode()); + SimulationBuildParams.SimulationBuildParamsBuilder builder = SimulationBuildParams.builder(); + // 都有的属性构造 + builder.loginUserInfo(loginUserInfoVO) + .workParamVO(workParamVO) + .createTime(LocalDateTime.now()) + .map(mapVO) + .operationDefinitionList(operationDefinitionList); + return builder.build(); + } + + private void loadMapData(Simulation simulation) { + SimulationBuildParams buildParams = simulation.getBuildParams(); + simulation.setBuildParams(buildParams); + if (Objects.nonNull(buildParams.getLoginUserInfo())) { + simulation.setCreatorId(buildParams.getLoginUserInfo().getAccountVO().getIdStr()); + simulation.setProject(buildParams.getLoginUserInfo().getProject()); + simulation.setProjectVO(buildParams.getLoginUserInfo().getProjectInfo()); + } + // 线路配置参数 + simulation.getRepository().setConfig(SimulationBuilder.buildConfig(buildParams.getMap().getConfigVO(), + buildParams.getMap().getGraphDataNew().getMapFunctionConfig())); + simulation.getRepository().getConfig() + .setRouteLikeHa1(buildParams.getMap().getGraphDataNew().getGenerateConfig().isLikeHa1()); + simulation.getRepository().getConfig() + .setOverlapSettingByTrigger(buildParams.getMap().getGraphDataNew().getGenerateConfig().isOverlapSettingByTrigger()); + simulation.getRepository().getConfig() + .setSharingECStations(buildParams.getMap().getGraphDataNew().getGenerateConfig().getSharingECStations()); + simulation.getRepository().getConfig() + .setHandleDepot(buildParams.getMap().getGraphDataNew().getGenerateConfig().isHandleDepot()); + // 地图数据构建 + SimulationBuilder.SimulationDeviceBuildResult mapDataBuildResult = SimulationBuilder.checkAndBuildMapData(buildParams.getMap()); + + simulation.getRepository().setDeviceMap(mapDataBuildResult.getDeviceMap()); + simulation.getRepository().setSectionArriveNearMap(mapDataBuildResult.getSectionArriveNearMap()); + simulation.getRepository().setVrDeviceMap(mapDataBuildResult.getVrDeviceMap()); + simulation.getRepository().setRoutePathMap(mapDataBuildResult.getRoutePathMap()); + simulation.getRepository().setDestinationMap(mapDataBuildResult.getDestinationMap()); + simulation.getRepository().getSectionRespondersMap().putAll(mapDataBuildResult.getSectionRespondersMap()); + if (!CollectionUtils.isEmpty(mapDataBuildResult.getErrMsgList())) { // 存在数据异常 + mapDataBuildResult.getErrMsgList().forEach(errMsg -> log.warn(String.format("地图数据异常:%s", errMsg))); +// simulation.setMapDataError(true); //目前大铁线路缺少数据导致检验不通过;后续修改之后取消注释 + simulation.addDataErrMsgs(mapDataBuildResult.getErrMsgList()); + } + SimulationBuilder.loadDepotInOutRoutePath(simulation); + // CTC行车日志数据结构构建 + if (simulation.getRepository().getConfig().isRailway()) { + SimulationBuilder.buildCtcStationRunPlanLog(simulation); + } + } + + private void playSimulationMember(Simulation simulation) { + Long creatorId = simulation.getBuildParams().getLoginUserInfo().getAccountVO().getId(); + SimulationWorkParamVO createParamVO = simulation.getBuildParams().getWorkParamVO(); + SimulationWorkParamVO.UsageInfo usageInfo = createParamVO.getUsageInfo(); + SimulationMember simulationMember = null; + if (usageInfo != null) { + switch (usageInfo.getUsage()) { + case SINGLE_MEMBER: + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertMapNotEmpty(usageInfo.getParam(), "单角色仿真必须指定角色"); + simulationMember = selectSimulationMemberFromParam(simulation, usageInfo); + break; + case SINGLE_CLIENT: + throw BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.exception("待实现"); + case JOINT: + if (!CollectionUtils.isEmpty(usageInfo.getParam())) { + simulationMember = selectSimulationMemberFromParam(simulation, usageInfo); + } else { + simulationMember = simulation.getMemberListByType(SimulationMember.Type.DISPATCHER).get(0); + } + break; + default: + throw new IllegalStateException("Unexpected value: " + usageInfo.getUsage()); + } + } + if (simulationMember != null) { + memberManager.playRole(simulation, creatorId, simulationMember.getId()); + } + } + + private SimulationMember selectSimulationMemberFromParam(Simulation simulation, SimulationWorkParamVO.UsageInfo usageInfo) { + SingleMemberParamVO singleMemberParamVO = JsonUtils.read(JsonUtils.writeValueAsString(usageInfo.getParam()), SingleMemberParamVO.class); + SimulationMember.Type memberType = singleMemberParamVO.getMemberType(); + String deviceCode = singleMemberParamVO.getDeviceCode(); + SimulationMember simulationMember = null; + if (memberType != null && StringUtils.hasText(deviceCode)) { + simulationMember = simulation.getSimulationMember(memberType, deviceCode); + } else if (memberType != null) { + simulationMember = simulation.getMemberListByType(memberType).get(0); + } else if (StringUtils.hasText(deviceCode)) { + simulationMember = simulation.getSimulationMembersByDeviceCode(deviceCode).get(0); + } + return simulationMember; + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkService.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkService.java new file mode 100644 index 000000000..0eb349eaa --- /dev/null +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkService.java @@ -0,0 +1,46 @@ +package club.joylink.rtss.simulation.cbtc.work; + +import club.joylink.rtss.exception.BusinessExceptionAssertEnum; +import club.joylink.rtss.simulation.cbtc.Simulation; +import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO; +import club.joylink.rtss.vo.LoginUserInfoVO; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; +import lombok.NonNull; +import org.springframework.util.CollectionUtils; + +import java.util.Collection; +import java.util.Map; + +public interface SimulationWorkService { + Simulation.Type getType(); + + Simulation create(LoginUserInfoVO loginUserInfoVO, SimulationWorkParamVO workParamVO); + + void loadData(Simulation simulation); + + void addJobs(Simulation simulation); + + void addMessagePublisher(Simulation simulation); + + void init(Simulation simulation); + + void runAsPlan(Simulation simulation, RunAsPlanParam param); + + void reset(Simulation simulation); + + void addFunctions(Simulation simulation, Map> functionMap, LoginUserInfoVO loginInfo); + + void removeFunctions(Simulation simulation, Collection functions); + + /** + * 检查仿真参数 + */ + default void checkParam(@NonNull SimulationWorkParamVO workParamVO) { + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO, "仿真工作参数不能为空"); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getMapId(), "仿真线路id不能为空"); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.getType(), "仿真类型不能为空"); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(workParamVO.findUsage(), "仿真用途不能为空"); + BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotTrue(!CollectionUtils.isEmpty(workParamVO.getFunctionMap()) + && workParamVO.getFunctionMap().size() > 1, "功能数量超限"); + } +} diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/init/SimulationInitServiceManager.java b/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java similarity index 64% rename from src/main/java/club/joylink/rtss/simulation/cbtc/init/SimulationInitServiceManager.java rename to src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java index 1d9f9968e..1bb46dbbb 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/init/SimulationInitServiceManager.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/work/SimulationWorkServiceManager.java @@ -1,4 +1,4 @@ -package club.joylink.rtss.simulation.cbtc.init; +package club.joylink.rtss.simulation.cbtc.work; import club.joylink.rtss.exception.BusinessExceptionAssertEnum; import club.joylink.rtss.simulation.cbtc.Simulation; @@ -13,17 +13,17 @@ import java.util.function.Function; import java.util.stream.Collectors; @Component -public class SimulationInitServiceManager implements ApplicationContextAware { - private Map map; +public class SimulationWorkServiceManager implements ApplicationContextAware { + private Map map; @Override public void setApplicationContext(ApplicationContext applicationContext) throws BeansException { - Map services = applicationContext.getBeansOfType(SimulationInitService.class); - map = services.values().stream().collect(Collectors.toMap(SimulationInitService::getType, Function.identity())); + Map services = applicationContext.getBeansOfType(SimulationWorkService.class); + map = services.values().stream().collect(Collectors.toMap(SimulationWorkService::getType, Function.identity())); } - public SimulationInitService getInitService(@NonNull Simulation.Type simulationType) { - SimulationInitService initService = map.get(simulationType); + public SimulationWorkService getInitService(@NonNull Simulation.Type simulationType) { + SimulationWorkService initService = map.get(simulationType); BusinessExceptionAssertEnum.SYSTEM_EXCEPTION.assertNotNull(initService, String.format("[%s]仿真未配置初始化服务", simulationType)); return initService; } diff --git a/src/main/resources/application.yml b/src/main/resources/application.yml index 9f4bdc007..3cba27f8c 100644 --- a/src/main/resources/application.yml +++ b/src/main/resources/application.yml @@ -1,222 +1,222 @@ -server: - port: 9000 - -modbus-tcp: - port: 19000 - -udp: - serverPort: 20002 - clientPort: 20001 - -spring: - profiles: - active: dev - application: - name: joylink-rtss - jackson: - date-format: yyyy-MM-dd HH:mm:ss - time-zone: GMT+8 - default-property-inclusion: non_null - # 后续转为MINIO后删除 - servlet: - multipart: - max-file-size: 10MB - # JavaMailSender 邮件发送的配置 - mail: - host: smtp.exmail.qq.com - port: 465 - username: serviceemai@joylink.club - password: Jiulian0503 - properties: - mail: - smtp: - auth: true - starttls: - enable: true - required: true - socketFactory: - port: 465 - class: javax.net.ssl.SSLSocketFactory - fallback: false - # 数据库连接配置 - datasource: - driverClassName: com.mysql.cj.jdbc.Driver - hikari: - minimum-idle: 5 # 连接池维护的最小空闲连接数 - maximum-pool-size: 10 #配置最大连接池大小 - auto-commit: true #配置从池返回的连接的默认自动提交行为 - idle-timeout: 30000 # 允许连接在连接池中空闲的最长时间,单位ms - pool-name: HikariPool - max-lifetime: 1800000 # 池中连接关闭后的最长生命周期,单位ms - connection-timeout: 30000 # 等待连接的超时时间,单位ms - -# mybatis 设置 -mybatis: - mapper-locations: classpath:mybatis/mapper/*.xml - configuration: - map-underscore-to-camel-case: true -pagehelper: - helper-dialect: mysql - reasonable: true - support-methods-arguments: true - params: count=countSql - -# 微信配置 -wechat: - domain-uri: https://api.weixin.qq.com - wm-base-url: https://joylink.club/oss/joylink/%s?state=%s - sp-app-id: wxe9150dbbcbf9440b - sp-app-secret: 4b5d453e5ec246a3f1b72360c59e4fab - sp-app2-id: wxecb0321367be529c - sp-app2-secret: 3c31cb41588f27a78160092249123766 - sp-app3-id: wxe6140d5985333338 - sp-app3-secret: 6b7359860c22e3607467df421cd24eef - -# 腾讯云 -tencent-cloud: - app-id: 1400093601 - app-key: 4a724df65b2bb7e4dc9b4302693f2485 - domain-uri: https://yun.tim.qq.com/v5/tlssmssvr - allow-send: true - -# 环境连接配置 start ---- -spring: - profiles: dev - datasource: - url: jdbc:mysql://192.168.3.233:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true - username: root - password: joylink0503 - -tencent-cloud: - allow-send: false - -logging: - file: - path: /logs/joylink/rtss - max-size: 100MB - level: - club.joylink.rtss: DEBUG - -minio: - endpoint: http://192.168.3.233 - accessKey: jladmin - secretKey: Joylink@0503 - bucket: oss-rtss - replaceHttps: true - -common: - env: dev - license-secret-key: joylink - ---- -spring: - profiles: local-test - datasource: - url: jdbc:mysql://192.168.53.22:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai - username: root - password: joylink0503 - -tencent-cloud: - allow-send: false - -logging: - file: - path: /usr/local/joylink/logs/rtss - level: - club.joylink.rtss: INFO - -minio: - endpoint: http://192.168.3.233 - accessKey: jladmin - secretKey: Joylink@0503 - bucket: oss-rtss - replaceHttps: true - -common: - env: test - - ---- -spring: - profiles: local - datasource: - url: jdbc:mysql://192.168.0.254:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true - username: root - password: localdb - -tencent-cloud: - allow-send: false - -logging: - file: - path: /usr/local/joylink/logs/rtss - level: - club.joylink.rtss: INFO - -minio: - endpoint: http://192.168.3.233 - accessKey: jladmin - secretKey: Joylink@0503 - bucket: oss-rtss - replaceHttps: true - - -common: - env: local - license-secret-key: joylink - ---- -spring: - profiles: test - datasource: - url: jdbc:mysql://172.16.0.128:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai - username: root - password: Joylink@0503 - -tencent-cloud: - allow-send: false - -logging: - file: - path: /usr/local/joylink/logs/rtss - level: - club.joylink.rtss: INFO - -minio: - endpoint: https://joylink.club - accessKey: jladmin - secretKey: Joylink@0503 - bucket: oss-rtss - replaceHttps: false - -common: - env: test - ---- -spring: - profiles: prd - datasource: - url: jdbc:mysql://192.168.0.169:3306/joylink?useSSL=false&serverTimezone=Asia/Shanghai - username: root - password: joylink@0503 - -file: - path: https://joylink.club/jlfile/api/upload/joylink/avatar - -logging: - file: - path: /usr/local/joylink/logs/rtss - level: - club.joylink.rtss: INFO - -minio: - endpoint: https://joylink.club - accessKey: jladmin - secretKey: Joylink@0503 - bucket: oss-rtss - replaceHttps: false - -common: - env: prd -# 环境连接配置 end +server: + port: 9000 + +modbus-tcp: + port: 19000 + +udp: + serverPort: 20002 + clientPort: 20001 + +spring: + profiles: + active: dev + application: + name: joylink-rtss + jackson: + date-format: yyyy-MM-dd HH:mm:ss + time-zone: GMT+8 + default-property-inclusion: non_null + # 后续转为MINIO后删除 + servlet: + multipart: + max-file-size: 10MB + # JavaMailSender 邮件发送的配置 + mail: + host: smtp.exmail.qq.com + port: 465 + username: serviceemai@joylink.club + password: Jiulian0503 + properties: + mail: + smtp: + auth: true + starttls: + enable: true + required: true + socketFactory: + port: 465 + class: javax.net.ssl.SSLSocketFactory + fallback: false + # 数据库连接配置 + datasource: + driverClassName: com.mysql.cj.jdbc.Driver + hikari: + minimum-idle: 5 # 连接池维护的最小空闲连接数 + maximum-pool-size: 10 #配置最大连接池大小 + auto-commit: true #配置从池返回的连接的默认自动提交行为 + idle-timeout: 30000 # 允许连接在连接池中空闲的最长时间,单位ms + pool-name: HikariPool + max-lifetime: 1800000 # 池中连接关闭后的最长生命周期,单位ms + connection-timeout: 30000 # 等待连接的超时时间,单位ms + +# mybatis 设置 +mybatis: + mapper-locations: classpath:mybatis/mapper/*.xml + configuration: + map-underscore-to-camel-case: true +pagehelper: + helper-dialect: mysql + reasonable: true + support-methods-arguments: true + params: count=countSql + +# 微信配置 +wechat: + domain-uri: https://api.weixin.qq.com + wm-base-url: https://joylink.club/oss/joylink/%s?state=%s + sp-app-id: wxe9150dbbcbf9440b + sp-app-secret: 4b5d453e5ec246a3f1b72360c59e4fab + sp-app2-id: wxecb0321367be529c + sp-app2-secret: 3c31cb41588f27a78160092249123766 + sp-app3-id: wxe6140d5985333338 + sp-app3-secret: 6b7359860c22e3607467df421cd24eef + +# 腾讯云 +tencent-cloud: + app-id: 1400093601 + app-key: 4a724df65b2bb7e4dc9b4302693f2485 + domain-uri: https://yun.tim.qq.com/v5/tlssmssvr + allow-send: true + +# 环境连接配置 start +--- +spring: + profiles: dev + datasource: + url: jdbc:mysql://192.168.3.233:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true + username: root + password: joylink0503 + +tencent-cloud: + allow-send: false + +logging: + file: + path: /logs/joylink/rtss + max-size: 100MB + level: + club.joylink.rtss: DEBUG + +minio: + endpoint: http://192.168.3.233 + accessKey: jladmin + secretKey: Joylink@0503 + bucket: oss-rtss + replaceHttps: true + +common: + env: dev + license-secret-key: joylink + +--- +spring: + profiles: local-test + datasource: + url: jdbc:mysql://192.168.53.22:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: joylink0503 + +tencent-cloud: + allow-send: false + +logging: + file: + path: /usr/local/joylink/logs/rtss + level: + club.joylink.rtss: INFO + +minio: + endpoint: http://192.168.3.233 + accessKey: jladmin + secretKey: Joylink@0503 + bucket: oss-rtss + replaceHttps: true + +common: + env: test + + +--- +spring: + profiles: local + datasource: + url: jdbc:mysql://192.168.0.254:3306/joylink?useSSL=false&characterEncoding=utf-8&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true + username: root + password: localdb + +tencent-cloud: + allow-send: false + +logging: + file: + path: /usr/local/joylink/logs/rtss + level: + club.joylink.rtss: INFO + +minio: + endpoint: http://192.168.3.233 + accessKey: jladmin + secretKey: Joylink@0503 + bucket: oss-rtss + replaceHttps: true + + +common: + env: local + license-secret-key: joylink + +--- +spring: + profiles: test + datasource: + url: jdbc:mysql://172.16.0.128:3306/joylink?useUnicode=true&characterEncoding=utf-8&useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: Joylink@0503 + +tencent-cloud: + allow-send: false + +logging: + file: + path: /usr/local/joylink/logs/rtss + level: + club.joylink.rtss: INFO + +minio: + endpoint: https://joylink.club + accessKey: jladmin + secretKey: Joylink@0503 + bucket: oss-rtss + replaceHttps: false + +common: + env: test + +--- +spring: + profiles: prd + datasource: + url: jdbc:mysql://192.168.0.169:3306/joylink?useSSL=false&serverTimezone=Asia/Shanghai + username: root + password: joylink@0503 + +file: + path: https://joylink.club/jlfile/api/upload/joylink/avatar + +logging: + file: + path: /usr/local/joylink/logs/rtss + level: + club.joylink.rtss: INFO + +minio: + endpoint: https://joylink.club + accessKey: jladmin + secretKey: Joylink@0503 + bucket: oss-rtss + replaceHttps: false + +common: + env: prd +# 环境连接配置 end