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 f43ac2e94..b46376e2f 100644 --- a/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java +++ b/src/main/java/club/joylink/rtss/controller/simulation/SimulationV1Controller.java @@ -15,6 +15,7 @@ import club.joylink.rtss.simulation.cbtc.command.CommandInitiateVO; import club.joylink.rtss.simulation.cbtc.communication.vo.fault.DeviceFaultInfo; import club.joylink.rtss.simulation.cbtc.data.status.IbpStatus; import club.joylink.rtss.simulation.cbtc.data.vo.SimulationVO; +import club.joylink.rtss.simulation.cbtc.member.MemberManager; import club.joylink.rtss.simulation.cbtc.member.SimulationMember; import club.joylink.rtss.simulation.cbtc.script.ScriptBO; import club.joylink.rtss.simulation.vo.SimulationInfoVO; @@ -30,22 +31,37 @@ import club.joylink.rtss.vo.client.operation.DriveParamVO; import club.joylink.rtss.vo.client.psl.PslStatus; import club.joylink.rtss.vo.client.runplan.PlanTripNumberVO; import club.joylink.rtss.vo.client.runplan.RunPlanEChartsDataVO; -import club.joylink.rtss.vo.client.simulationv1.*; +import club.joylink.rtss.vo.client.simulationv1.RunAsPlanParam; +import club.joylink.rtss.vo.client.simulationv1.SimulationInfoQueryVO; +import club.joylink.rtss.vo.client.simulationv1.SimulationLogPagedQueryVO; +import club.joylink.rtss.vo.client.simulationv1.SimulationMemberVO; +import club.joylink.rtss.vo.client.simulationv1.SimulationUserVO; import club.joylink.rtss.vo.map.MapVO; import club.joylink.rtss.vo.map.graph.MapStationNewVO; +import java.time.LocalDateTime; +import java.time.LocalTime; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; +import java.util.Set; +import java.util.stream.Collectors; +import java.util.stream.Stream; +import javax.validation.constraints.NotBlank; +import javax.validation.constraints.NotNull; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.format.annotation.DateTimeFormat; import org.springframework.util.StringUtils; import org.springframework.validation.annotation.Validated; -import org.springframework.web.bind.annotation.*; - -import javax.validation.constraints.NotBlank; -import javax.validation.constraints.NotNull; -import java.time.LocalDateTime; -import java.time.LocalTime; -import java.util.*; -import java.util.stream.Collectors; -import java.util.stream.Stream; +import org.springframework.web.bind.annotation.DeleteMapping; +import org.springframework.web.bind.annotation.GetMapping; +import org.springframework.web.bind.annotation.PathVariable; +import org.springframework.web.bind.annotation.PostMapping; +import org.springframework.web.bind.annotation.PutMapping; +import org.springframework.web.bind.annotation.RequestAttribute; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RestController; /** * 新仿真接口 @@ -54,312 +70,319 @@ import java.util.stream.Stream; @RequestMapping("/simulation") public class SimulationV1Controller { - @Autowired - private GroupSimulationService groupSimulationService; + @Autowired + private GroupSimulationService groupSimulationService; - @Autowired - private IVirtualRealityIbpService iVirtualRealityIBPService; + @Autowired + private IVirtualRealityIbpService iVirtualRealityIBPService; - @Autowired - private SimulationSupportService simulationSupportService; + @Autowired + private SimulationSupportService simulationSupportService; - @Autowired - private IVirtualRealityPslService iVirtualRealityPslService; - @Autowired - private SimulationService simulationService; - @Autowired - private SimulationManager simulationManager; + @Autowired + private IVirtualRealityPslService iVirtualRealityPslService; + @Autowired + private SimulationService simulationService; + @Autowired + private SimulationManager simulationManager; + @Autowired + private MemberManager memberManager; - /** - * 根据产品类型创建仿真 - */ - @GetMapping("") - public String simulation(Long mapId, String prdType, - @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) - LoginUserInfoVO loginUserInfoVO) { - String simulation = this.groupSimulationService.simulation(mapId, prdType, loginUserInfoVO); - return simulation; + /** + * 根据产品类型创建仿真 + */ + @GetMapping("") + public String simulation(Long mapId, String prdType, + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) + LoginUserInfoVO loginUserInfoVO) { + String simulation = this.groupSimulationService.simulation(mapId, prdType, loginUserInfoVO); + return simulation; + } + + /** + * 创建实训仿真 + */ + @GetMapping(path = "/training/{trainingId}") + public String trainingSimulation(@PathVariable Long trainingId, + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) + LoginUserInfoVO loginUserInfoVO) { + return this.groupSimulationService.trainingSimulation(trainingId, loginUserInfoVO); + } + + /** + * 创建考试仿真 + */ + @GetMapping(path = "/exam/{examId}") + public String examSimulate(@PathVariable Long examId, + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) + LoginUserInfoVO loginUserInfoVO) { + return this.groupSimulationService.examSimulation(examId, loginUserInfoVO); + } + + /** + * 获取客户端已经进入仿真的用户仿真所在group + */ + @GetMapping(path = "/running") + public List getRunningSimulationBySubscribeUser(@RequestAttribute AccountVO user) { + return this.groupSimulationService.getUserRunningSimulationGroups(user); + } + + /** + * 根据仿真group获取仿真基础信息 + */ + @GetMapping("/{group}") + public SimulationVO getSimulationBasicInfo(@PathVariable String group) { + return this.groupSimulationService.getSimulationBasicInfo(group); + } + + /** + * 获取用户在仿真中的用户信息 + */ + @GetMapping("/{group}/simulationUser") + public SimulationUserVO getSimulationUserInfo(@PathVariable String group, + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) + AccountVO accountVO) { + return this.groupSimulationService.getSimulationUserInfo(group, accountVO); + } + + /** + * 获取所有仿真用户 + */ + @GetMapping("/{group}/simulationUsers") + public List queryAllSimulationUsers(@PathVariable String group) { + return this.groupSimulationService.queryAllSimulationUsers(group); + } + + /** + * 根据仿真group获取仿真地图数据 + */ + @GetMapping("/{group}/mapData") + public MapVO getSimulationMapData(@PathVariable String group) { + return this.groupSimulationService.getSimulationMapData(group); + } + + /** + * 根据group获取排序的车站列表(包含车辆段/停车场) + */ + @GetMapping("/{group}/stationWithDepot") + public List getSortedStationListWithDepot(@PathVariable String group) { + return this.groupSimulationService.getSortedStationListWithDepot(group); + } + + /** + * 加载指定运行计划到仿真中 + */ + @PutMapping("/{group}/load/runPlan/{templateId}") + public void loadRunPlan(@PathVariable String group, @PathVariable Long templateId) { + this.groupSimulationService.loadRunPlan(group, templateId); + } + + /** + * 加载草稿运行图 + */ + @PutMapping("/{simulationId}/load/draftRunPlan/{draftRunPlanId}") + public void loadDraftRunPlan(@PathVariable String simulationId, + @PathVariable long draftRunPlanId) { + this.simulationService.loadDraftRunPlan(simulationId, draftRunPlanId); + } + + /** + * 根据仿真group获取仿真运行图 + */ + @GetMapping("/{group}/runPlan") + public RunPlanEChartsDataVO getSimulationRunPlan(@PathVariable String group) { + return this.groupSimulationService.getSimulationRunPlan(group); + } + + /** + * 获取仿真运行图车次号列表 + */ + @GetMapping("/{group}/tripNumbers") + public List getSimulationRunPlanTripNumbers(@PathVariable String group) { + return this.groupSimulationService.getSimulationRunPlanTripNumbers(group); + } + + /** + * 根据车次号获取服务号 + */ + @GetMapping("/{group}/serviceNumber") + public List getServiceNumberByTripNumber(@PathVariable String group, String tripNumber) { + return this.groupSimulationService.getServiceNumberByTripNumber(group, tripNumber); + } + + /** + * 根据车次号获取计划车次信息 + */ + @GetMapping("/{group}/planTripInfo") + public PlanTripNumberVO getPlanTripByTripNumber(@PathVariable String group, String tripNumber) { + return this.groupSimulationService.getPlanTripByTripNumber(group, tripNumber); + } + + /** + * 根据服务号和车次号获取计划车次信息 + */ + @GetMapping("/{group}/planTripInfoBySt") + public PlanTripNumberVO planTripInfoBySt(@PathVariable String group, String serviceNumber, + String tripNumber) { + return this.groupSimulationService.planTripInfoByServiceAndTripNumber(group, serviceNumber, + tripNumber); + } + + /** + * 仿真操作 + */ + @PostMapping("/{group}/operate/{type}") + public Object operate(@PathVariable @NotBlank String group, @PathVariable @NotNull String type, + @RequestBody(required = false) Map param, @RequestAttribute AccountVO user) { + if (null == param) { + param = new HashMap<>(); } + return this.groupSimulationService.operate(group, type, param, user); + } - /** - * 创建实训仿真 - */ - @GetMapping(path = "/training/{trainingId}") - public String trainingSimulation(@PathVariable Long trainingId, - @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) - LoginUserInfoVO loginUserInfoVO) { - return this.groupSimulationService.trainingSimulation(trainingId, loginUserInfoVO); - } + /** + * 仿真指令 + */ + @PostMapping("/{group}/command") + public void command(@PathVariable String group, + @RequestBody @Validated CommandInitiateVO initiateVO, @RequestAttribute AccountVO user) { + Simulation simulation = this.groupSimulationService.getSimulationByGroup(group); + SimulationMember member = simulation.getSimulationMemberByUserId(user.getId()); + this.groupSimulationService.command(simulation, initiateVO, member); + } - /** - * 创建考试仿真 - */ - @GetMapping(path = "/exam/{examId}") - public String examSimulate(@PathVariable Long examId, - @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) - LoginUserInfoVO loginUserInfoVO) { - return this.groupSimulationService.examSimulation(examId, loginUserInfoVO); - } + /** + * 根据计划时间获取此时间点可以加载的最大列车数量 + */ + @GetMapping("/{group}/loadTrainNumber") + public int getLoadTrainNumber(@PathVariable String group, + @DateTimeFormat(pattern = "HH:mm:ss") LocalTime time) { + BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(time, "时间不能为空"); + return this.groupSimulationService.getGivenTimeCouldLoadedTrainNumber(group, time); + } - /** - * 获取客户端已经进入仿真的用户仿真所在group - */ - @GetMapping(path = "/running") - public List getRunningSimulationBySubscribeUser(@RequestAttribute AccountVO user) { - return this.groupSimulationService.getUserRunningSimulationGroups(user); - } + /** + * 按计划行车 + */ + @PostMapping("/{group}/ranAsPlan") + public void runAsPlan(@PathVariable String group, @RequestBody @Validated RunAsPlanParam param) { + this.groupSimulationService.runAsPlan(group, param); + } - /** - * 根据仿真group获取仿真基础信息 - */ - @GetMapping("/{group}") - public SimulationVO getSimulationBasicInfo(@PathVariable String group) { - return this.groupSimulationService.getSimulationBasicInfo(group); - } + /** + * 修改仿真系统时间 + */ + @PutMapping("/{group}/modifySystemTime") + public void modifySystemTime(@PathVariable String group, @RequestBody RunAsPlanParam param) { + this.groupSimulationService.modifySystemTime(group, param.getTime()); + } - /** - * 获取用户在仿真中的用户信息 - */ - @GetMapping("/{group}/simulationUser") - public SimulationUserVO getSimulationUserInfo(@PathVariable String group, - @RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY) - AccountVO accountVO) { - return this.groupSimulationService.getSimulationUserInfo(group, accountVO); - } + /** + * 退出计划 + */ + @PostMapping("/{group}/planOver") + public void planOver(@PathVariable String group) { + this.groupSimulationService.planOver(group); + } - /** - * 获取所有仿真用户 - */ - @GetMapping("/{group}/simulationUsers") - public List queryAllSimulationUsers(@PathVariable String group) { - return this.groupSimulationService.queryAllSimulationUsers(group); - } + /** + * 退出仿真(主要是非房主用户退出综合演练用) + */ + @PutMapping("/{simulationId}/exit") + public void exitSimulation(@PathVariable String simulationId, @RequestAttribute AccountVO user) { + this.groupSimulationService.exitSimulation(simulationId, user); + } - /** - * 根据仿真group获取仿真地图数据 - */ - @GetMapping("/{group}/mapData") - public MapVO getSimulationMapData(@PathVariable String group) { - return this.groupSimulationService.getSimulationMapData(group); - } + /** + * 销毁仿真。 由系统管理员或老师在仿真监管功能中使用 + */ + @DeleteMapping("/{simulationId}/destroy") + public void destroySimulation(@PathVariable String simulationId) { + this.groupSimulationService.clearSimulation(simulationId); + } - /** - * 根据group获取排序的车站列表(包含车辆段/停车场) - */ - @GetMapping("/{group}/stationWithDepot") - public List getSortedStationListWithDepot(@PathVariable String group) { - return this.groupSimulationService.getSortedStationListWithDepot(group); - } + /** + * 加载剧本并扮演成员(已发布的剧本) + */ + @PutMapping(path = "/{group}/script/{scriptId}") + public void loadScriptAndPlayMember(@PathVariable String group, + @PathVariable Long scriptId, + String memberId, + ScriptBO.Mode mode, + @RequestAttribute AccountVO user) { + this.groupSimulationService.loadScriptAndPlayMember(group, scriptId, memberId, mode, user); + } - /** - * 加载指定运行计划到仿真中 - */ - @PutMapping("/{group}/load/runPlan/{templateId}") - public void loadRunPlan(@PathVariable String group, @PathVariable Long templateId) { - this.groupSimulationService.loadRunPlan(group, templateId); - } + /** + * 退出剧本 + */ + @PutMapping(path = "/{group}/exitScript") + public void exitScript(@PathVariable @NotBlank String group, @RequestAttribute AccountVO user) { + this.groupSimulationService.exitScript(group, user); + } - /** - * 加载草稿运行图 - */ - @PutMapping("/{simulationId}/load/draftRunPlan/{draftRunPlanId}") - public void loadDraftRunPlan(@PathVariable String simulationId, @PathVariable long draftRunPlanId) { - this.simulationService.loadDraftRunPlan(simulationId, draftRunPlanId); - } + /** + * 获取所有仿真成员列表 + */ + @GetMapping(path = "/{group}/members") + public List getSimulationMembers(@PathVariable @NotBlank String group) { + return this.groupSimulationService.getSimulationMembers(group); + } - /** - * 根据仿真group获取仿真运行图 - */ - @GetMapping("/{group}/runPlan") - public RunPlanEChartsDataVO getSimulationRunPlan(@PathVariable String group) { - return this.groupSimulationService.getSimulationRunPlan(group); - } + /** + * 获取仿真设备故障列表 + */ + @GetMapping(path = "/{group}/deviceFaultInfos") + public List getSimulationDeviceFaultInfoList( + @PathVariable @NotBlank String group) { + return this.groupSimulationService.getSimulationDeviceFaultInfoList(group); + } - /** - * 获取仿真运行图车次号列表 - */ - @GetMapping("/{group}/tripNumbers") - public List getSimulationRunPlanTripNumbers(@PathVariable String group) { - return this.groupSimulationService.getSimulationRunPlanTripNumbers(group); + /** + * 取消自动故障 + */ + @PutMapping(path = "/{group}/faultMode/{id}") + public void setFaultMode(@PathVariable @NotBlank String group, + @PathVariable(required = false) Integer id) { + if (Objects.isNull(id)) { + this.groupSimulationService.clearAllAutoFault(group); + return; } + this.groupSimulationService.cancelAutoFault(group, id); + } - /** - * 根据车次号获取服务号 - */ - @GetMapping("/{group}/serviceNumber") - public List getServiceNumberByTripNumber(@PathVariable String group, String tripNumber) { - return this.groupSimulationService.getServiceNumberByTripNumber(group, tripNumber); - } + /** + * 设置自动故障 + */ + @PostMapping(path = "/{group}/faultMode") + public Integer setFaultMode(@PathVariable @NotBlank String group, + @RequestBody FaultRuleVO ruleVO) { + return this.groupSimulationService.setFaultMode(group, ruleVO); + } - /** - * 根据车次号获取计划车次信息 - */ - @GetMapping("/{group}/planTripInfo") - public PlanTripNumberVO getPlanTripByTripNumber(@PathVariable String group, String tripNumber) { - return this.groupSimulationService.getPlanTripByTripNumber(group, tripNumber); - } + /** + * 查询已设置所有的自动触发故障 + */ + @GetMapping(path = "/{group}/faultMode/faultRule") + public Set getNotTriggerAutoFault(@PathVariable @NotBlank String group) { + return this.groupSimulationService.getTriggerAutoFaults(group); + } - /** - * 根据服务号和车次号获取计划车次信息 - */ - @GetMapping("/{group}/planTripInfoBySt") - public PlanTripNumberVO planTripInfoBySt(@PathVariable String group, String serviceNumber, String tripNumber) { - return this.groupSimulationService.planTripInfoByServiceAndTripNumber(group, serviceNumber, tripNumber); - } + /** + * 查询所有目的地码 + */ + @GetMapping("/{group}/destinationCode/list") + public List getAllDestinationCode(@PathVariable String group) { + return this.groupSimulationService.getAllDestinationCode(group); + } - /** - * 仿真操作 - */ - @PostMapping("/{group}/operate/{type}") - public Object operate(@PathVariable @NotBlank String group, @PathVariable @NotNull String type, - @RequestBody(required = false) Map param, @RequestAttribute AccountVO user) { - if (null == param) { - param = new HashMap<>(); - } - return this.groupSimulationService.operate(group, type, param, user); - } - - /** - * 仿真指令 - */ - @PostMapping("/{group}/command") - public void command(@PathVariable String group, @RequestBody @Validated CommandInitiateVO initiateVO, @RequestAttribute AccountVO user) { - Simulation simulation = this.groupSimulationService.getSimulationByGroup(group); - SimulationMember member = simulation.getSimulationMemberByUserId(user.getId()); - this.groupSimulationService.command(simulation, initiateVO, member); - } - - /** - * 根据计划时间获取此时间点可以加载的最大列车数量 - */ - @GetMapping("/{group}/loadTrainNumber") - public int getLoadTrainNumber(@PathVariable String group, - @DateTimeFormat(pattern = "HH:mm:ss") LocalTime time) { - BusinessExceptionAssertEnum.ARGUMENT_ILLEGAL.assertNotNull(time, "时间不能为空"); - return this.groupSimulationService.getGivenTimeCouldLoadedTrainNumber(group, time); - } - - /** - * 按计划行车 - */ - @PostMapping("/{group}/ranAsPlan") - public void runAsPlan(@PathVariable String group, @RequestBody @Validated RunAsPlanParam param) { - this.groupSimulationService.runAsPlan(group, param); - } - - /** - * 修改仿真系统时间 - */ - @PutMapping("/{group}/modifySystemTime") - public void modifySystemTime(@PathVariable String group, @RequestBody RunAsPlanParam param) { - this.groupSimulationService.modifySystemTime(group, param.getTime()); - } - - /** - * 退出计划 - */ - @PostMapping("/{group}/planOver") - public void planOver(@PathVariable String group) { - this.groupSimulationService.planOver(group); - } - - /** - * 退出仿真(主要是非房主用户退出综合演练用) - */ - @PutMapping("/{simulationId}/exit") - public void exitSimulation(@PathVariable String simulationId, @RequestAttribute AccountVO user) { - this.groupSimulationService.exitSimulation(simulationId, user); - } - - /** - * 销毁仿真。 - * 由系统管理员或老师在仿真监管功能中使用 - */ - @DeleteMapping("/{simulationId}/destroy") - public void destroySimulation(@PathVariable String simulationId) { - this.groupSimulationService.clearSimulation(simulationId); - } - - /** - * 加载剧本并扮演成员(已发布的剧本) - */ - @PutMapping(path = "/{group}/script/{scriptId}") - public void loadScriptAndPlayMember(@PathVariable String group, - @PathVariable Long scriptId, - String memberId, - ScriptBO.Mode mode, - @RequestAttribute AccountVO user) { - this.groupSimulationService.loadScriptAndPlayMember(group, scriptId, memberId, mode, user); - } - - /** - * 退出剧本 - */ - @PutMapping(path = "/{group}/exitScript") - public void exitScript(@PathVariable @NotBlank String group, @RequestAttribute AccountVO user) { - this.groupSimulationService.exitScript(group, user); - } - - /** - * 获取所有仿真成员列表 - */ - @GetMapping(path = "/{group}/members") - public List getSimulationMembers(@PathVariable @NotBlank String group) { - return this.groupSimulationService.getSimulationMembers(group); - } - - /** - * 获取仿真设备故障列表 - */ - @GetMapping(path = "/{group}/deviceFaultInfos") - public List getSimulationDeviceFaultInfoList( - @PathVariable @NotBlank String group) { - return this.groupSimulationService.getSimulationDeviceFaultInfoList(group); - } - - /** - * 取消自动故障 - */ - @PutMapping(path = "/{group}/faultMode/{id}") - public void setFaultMode(@PathVariable @NotBlank String group, @PathVariable(required = false) Integer id) { - if (Objects.isNull(id)) { - this.groupSimulationService.clearAllAutoFault(group); - return; - } - this.groupSimulationService.cancelAutoFault(group, id); - } - - /** - * 设置自动故障 - */ - @PostMapping(path = "/{group}/faultMode") - public Integer setFaultMode(@PathVariable @NotBlank String group, @RequestBody FaultRuleVO ruleVO) { - return this.groupSimulationService.setFaultMode(group, ruleVO); - } - - /** - * 查询已设置所有的自动触发故障 - */ - @GetMapping(path = "/{group}/faultMode/faultRule") - public Set getNotTriggerAutoFault(@PathVariable @NotBlank String group) { - return this.groupSimulationService.getTriggerAutoFaults(group); - } - - /** - * 查询所有目的地码 - */ - @GetMapping("/{group}/destinationCode/list") - public List getAllDestinationCode(@PathVariable String group) { - return this.groupSimulationService.getAllDestinationCode(group); - } - - /** - * 获取IBP盘状态 - */ - @GetMapping("/{group}/{stationCode}/ibp/status") - public IbpStatus getIbpStatus(@PathVariable String group, @PathVariable String stationCode) { - return iVirtualRealityIBPService.getIbpStatus(group, stationCode); - } + /** + * 获取IBP盘状态 + */ + @GetMapping("/{group}/{stationCode}/ibp/status") + public IbpStatus getIbpStatus(@PathVariable String group, @PathVariable String stationCode) { + return iVirtualRealityIBPService.getIbpStatus(group, stationCode); + } // /** // * 按下IBP盘按钮 @@ -377,83 +400,90 @@ public class SimulationV1Controller { // iVirtualRealityIBPService.releaseTheElement(group, stationCode, buttonCode); // } - /** - * 查询报警列表 - */ - @GetMapping(path = "/{group}/alarm") - public List listAlarm(@PathVariable String group, String level, - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime, - @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) { - return groupSimulationService.listAlarm(group, level, startTime, endTime); - } + /** + * 查询报警列表 + */ + @GetMapping(path = "/{group}/alarm") + public List listAlarm(@PathVariable String group, String level, + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime startTime, + @DateTimeFormat(pattern = "yyyy-MM-dd HH:mm:ss") LocalDateTime endTime) { + return groupSimulationService.listAlarm(group, level, startTime, endTime); + } - /** - * 仿真报警确认 - */ - @PutMapping(path = "/{group}/alarm/confirm") - public void AlarmConfirm(@PathVariable String group, @RequestBody List codes, @RequestAttribute AccountVO user) { - groupSimulationService.alarmConfirm(group, codes, user); - } + /** + * 仿真报警确认 + */ + @PutMapping(path = "/{group}/alarm/confirm") + public void AlarmConfirm(@PathVariable String group, @RequestBody List codes, + @RequestAttribute AccountVO user) { + groupSimulationService.alarmConfirm(group, codes, user); + } - /** - * 仿真客流数据切换 - */ - @PutMapping(path = "/{group}/passengerFlow/{passengerFlowId}") - public void AlarmConfirm(@PathVariable String group, @PathVariable Long passengerFlowId) { - groupSimulationService.changePassengerFlow(group, passengerFlowId); - } + /** + * 仿真客流数据切换 + */ + @PutMapping(path = "/{group}/passengerFlow/{passengerFlowId}") + public void AlarmConfirm(@PathVariable String group, @PathVariable Long passengerFlowId) { + groupSimulationService.changePassengerFlow(group, passengerFlowId); + } - /** - * 获取仿真日志 - */ - @GetMapping("/{group}/log") - public PageVO getLog(@PathVariable String group, SimulationLogPagedQueryVO queryVO) { - return groupSimulationService.getLog(group, queryVO); - } + /** + * 获取仿真日志 + */ + @GetMapping("/{group}/log") + public PageVO getLog(@PathVariable String group, + SimulationLogPagedQueryVO queryVO) { + return groupSimulationService.getLog(group, queryVO); + } - /** - * 获取机器人驾驶参数 - */ - @GetMapping("/{simulationId}/driveParam/{groupNumber}") - public DriveParamVO getDriveParam(@PathVariable String simulationId, @PathVariable String groupNumber) { - return groupSimulationService.getDriveParam(simulationId, groupNumber); - } + /** + * 获取机器人驾驶参数 + */ + @GetMapping("/{simulationId}/driveParam/{groupNumber}") + public DriveParamVO getDriveParam(@PathVariable String simulationId, + @PathVariable String groupNumber) { + return groupSimulationService.getDriveParam(simulationId, groupNumber); + } - /* ----------------------- 泰雷兹操作辅助接口 ----------------------- */ + /* ----------------------- 泰雷兹操作辅助接口 ----------------------- */ - /** - * 查询进路路径 - */ - @GetMapping("/{group}/querySectionPaths") - public List> querySectionPaths(@PathVariable String group, String groupNumber, String standCode, String signalCode) { - return simulationSupportService.queryRoutePaths(group, groupNumber, standCode, signalCode); - } + /** + * 查询进路路径 + */ + @GetMapping("/{group}/querySectionPaths") + public List> querySectionPaths(@PathVariable String group, String groupNumber, + String standCode, String signalCode) { + return simulationSupportService.queryRoutePaths(group, groupNumber, standCode, signalCode); + } - /** - * 查询列车或运行线经过的站台 - */ - @GetMapping("/{group}/queryStands/trainOrDestination") - public List queryStandsThatTrainGoingThrough(@PathVariable String group, String groupNumber, String destinationCode) { - return simulationSupportService.queryStandsThatTrainGoingThrough(group, groupNumber, destinationCode); - } + /** + * 查询列车或运行线经过的站台 + */ + @GetMapping("/{group}/queryStands/trainOrDestination") + public List queryStandsThatTrainGoingThrough(@PathVariable String group, + String groupNumber, String destinationCode) { + return simulationSupportService.queryStandsThatTrainGoingThrough(group, groupNumber, + destinationCode); + } - /** - * 查询为该列车已建立的进路 - */ - @GetMapping("/{group}/queryEstablishedRoutes/{groupNumber}") - public List queryEstablishedRoutes(@PathVariable String group, @PathVariable String groupNumber) { - return simulationSupportService.queryEstablishedRoutes(group, groupNumber); - } + /** + * 查询为该列车已建立的进路 + */ + @GetMapping("/{group}/queryEstablishedRoutes/{groupNumber}") + public List queryEstablishedRoutes(@PathVariable String group, + @PathVariable String groupNumber) { + return simulationSupportService.queryEstablishedRoutes(group, groupNumber); + } - /* ----------------------- PSL盘接口 ----------------------- */ + /* ----------------------- PSL盘接口 ----------------------- */ - /** - * 获取PSL盘状态 - */ - @GetMapping("/{group}/{standCode}/psl/status") - public PslStatus getPslStatus(@PathVariable String group, @PathVariable String standCode) { - return iVirtualRealityPslService.getStatus(group, standCode); - } + /** + * 获取PSL盘状态 + */ + @GetMapping("/{group}/{standCode}/psl/status") + public PslStatus getPslStatus(@PathVariable String group, @PathVariable String standCode) { + return iVirtualRealityPslService.getStatus(group, standCode); + } // /** // * 按下PSL盘按钮 @@ -463,29 +493,30 @@ public class SimulationV1Controller { // iVirtualRealityPslService.pressTheButton(group, standCode, button); // } - /* ----------------------- ISCS接口 ----------------------- */ + /* ----------------------- ISCS接口 ----------------------- */ - /** - * 条件查询仿真中的ISCS系统资源 - */ - @GetMapping("/{group}/iscs/systemResources") - public List getAllIscsSystemResources(@PathVariable String group, IscsSystemResourcesQueryVO queryVO) { - return groupSimulationService.getAllIscsSystemResources(group, queryVO); - } + /** + * 条件查询仿真中的ISCS系统资源 + */ + @GetMapping("/{group}/iscs/systemResources") + public List getAllIscsSystemResources(@PathVariable String group, + IscsSystemResourcesQueryVO queryVO) { + return groupSimulationService.getAllIscsSystemResources(group, queryVO); + } - /** - * 查询所有pa系统的定时播放任务 - */ - @GetMapping("/{group}/iscs/paTimedPlay") - public List getPaTimedPlay(@PathVariable String group, String stationCode) { - return groupSimulationService.getAllPaTimedPlayInfo(group, stationCode); - } + /** + * 查询所有pa系统的定时播放任务 + */ + @GetMapping("/{group}/iscs/paTimedPlay") + public List getPaTimedPlay(@PathVariable String group, String stationCode) { + return groupSimulationService.getAllPaTimedPlayInfo(group, stationCode); + } - /* ----------------------- 仿真新接口 ----------------------- */ + /* ----------------------- 仿真新接口 ----------------------- */ - /** - * 仿真创建接口(新) - */ + /** + * 仿真创建接口(新) + */ /*@Deprecated @PostMapping("/new/{mapId}") public String createSimulation(@PathVariable long mapId, @RequestBody @Validated SimulationWorkParamVO paramVO, @@ -494,127 +525,137 @@ public class SimulationV1Controller { return simulationService.createSimulation(mapId, null, paramVO, loginUserInfoVO); }*/ - /** - * 根据地图功能id创建仿真 - */ - @PostMapping("/new/mapFunction/{mapFunctionId}") - public String createSimulationByMapFunction(@PathVariable long mapFunctionId, @RequestAttribute LoginUserInfoVO loginInfo) { - return simulationService.createSimulation(mapFunctionId, loginInfo); - } + /** + * 根据地图功能id创建仿真 + */ + @PostMapping("/new/mapFunction/{mapFunctionId}") + public String createSimulationByMapFunction(@PathVariable long mapFunctionId, + @RequestAttribute LoginUserInfoVO loginInfo) { + return simulationService.createSimulation(mapFunctionId, loginInfo); + } - /** - * 按计划行车(新) - */ - @PostMapping("/new/{simulationId}/runAsPlan") - public void runAsPlanNew(@PathVariable String simulationId, @RequestBody @Validated RunAsPlanParam param) { - simulationService.runAsPlan(simulationId, param); - } + /** + * 按计划行车(新) + */ + @PostMapping("/new/{simulationId}/runAsPlan") + public void runAsPlanNew(@PathVariable String simulationId, + @RequestBody @Validated RunAsPlanParam param) { + simulationService.runAsPlan(simulationId, param); + } - /** - * 重置仿真(新) - */ - @PutMapping("/new/{simulationId}/reset") - public void reset(@PathVariable String simulationId) { - simulationService.reset(simulationId); - } + /** + * 重置仿真(新) + */ + @PutMapping("/new/{simulationId}/reset") + public void reset(@PathVariable String simulationId) { + simulationService.reset(simulationId); + Simulation simulation = simulationManager.getById(simulationId, Simulation.class); + // 写在这里为了不与加载实训时冲突,如果写入reset方法,实训加载会多次处理,会有问题 + memberManager.loadExtraMembers(simulation, null); + } - /** - * 根据地图和功能ID获取仿真GroupId - * - * @return 仿真GroupId - */ - @GetMapping("/new/map/{mapId}/function/{functionId}") - public String querySimulationByMapIdAndMapFunction(@PathVariable("mapId") long mapId - , @PathVariable("functionId") long mapFunctionId) { - return simulationService.querySimulationByMapIdAndMapFunction(mapId, mapFunctionId); - } + /** + * 根据地图和功能ID获取仿真GroupId + * + * @return 仿真GroupId + */ + @GetMapping("/new/map/{mapId}/function/{functionId}") + public String querySimulationByMapIdAndMapFunction(@PathVariable("mapId") long mapId + , @PathVariable("functionId") long mapFunctionId) { + return simulationService.querySimulationByMapIdAndMapFunction(mapId, mapFunctionId); + } - /** - * 按组织查询存在的仿真(监管仿真) - */ - @GetMapping("/supervise") - public List listSimulationByOrg(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, - SimulationInfoQueryVO queryVO) { - return simulationService.listSimulationByOrg(loginUserInfoVO.getTopOrgId(), queryVO); - } + /** + * 按组织查询存在的仿真(监管仿真) + */ + @GetMapping("/supervise") + public List listSimulationByOrg( + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, + SimulationInfoQueryVO queryVO) { + return simulationService.listSimulationByOrg(loginUserInfoVO.getTopOrgId(), queryVO); + } - /** - * 分页,按组织查询存在的仿真(监管仿真) - */ - @GetMapping("/paged/supervise") - public PageVO pagedSuperviseSimulation(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, - SimulationInfoQueryVO queryVO) { - return simulationService.pagedSimulationByOrg(loginUserInfoVO.getTopOrgId(), queryVO); - } + /** + * 分页,按组织查询存在的仿真(监管仿真) + */ + @GetMapping("/paged/supervise") + public PageVO pagedSuperviseSimulation( + @RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO, + SimulationInfoQueryVO queryVO) { + return simulationService.pagedSimulationByOrg(loginUserInfoVO.getTopOrgId(), queryVO); + } - /** - * 获取所有存在的仿真 - */ - @GetMapping("/list") - public List queryInfo(SimulationInfoQueryVO queryVO) { - List simulationList = this.simulationManager.getSimulationList(); - Stream stream = simulationList.stream(); - if (StringUtils.hasText(queryVO.getGroup())) { - stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup())); - } - if (StringUtils.hasText(queryVO.getUserName())) { - stream = stream.filter(simulation -> simulation.getSimulationUsers().stream().anyMatch(user -> user.getName().contains(queryVO.getUserName()))); - } - return stream.map(Simulation::convertToVO).collect(Collectors.toList()); + /** + * 获取所有存在的仿真 + */ + @GetMapping("/list") + public List queryInfo(SimulationInfoQueryVO queryVO) { + List simulationList = this.simulationManager.getSimulationList(); + Stream stream = simulationList.stream(); + if (StringUtils.hasText(queryVO.getGroup())) { + stream = stream.filter(simulation -> simulation.getId().contains(queryVO.getGroup())); } + if (StringUtils.hasText(queryVO.getUserName())) { + stream = stream.filter(simulation -> simulation.getSimulationUsers().stream() + .anyMatch(user -> user.getName().contains(queryVO.getUserName()))); + } + return stream.map(Simulation::convertToVO).collect(Collectors.toList()); + } - /** - * 暂停 - */ - @PutMapping("/{id}/pause") - public void pause(@PathVariable String id) { - this.simulationManager.pause(id); - } + /** + * 暂停 + */ + @PutMapping("/{id}/pause") + public void pause(@PathVariable String id) { + this.simulationManager.pause(id); + } - /** - * 开始 - */ - @PutMapping("/{id}/start") - public void start(@PathVariable String id) { - this.simulationManager.start(id); - } + /** + * 开始 + */ + @PutMapping("/{id}/start") + public void start(@PathVariable String id) { + this.simulationManager.start(id); + } - /** - * 调整倍速 - */ - @PutMapping("/{id}/updateSpeed/{speed}") - public void updateSpeed(@PathVariable String id, @PathVariable int speed) { - this.simulationManager.updateSpeed(id, speed); - } + /** + * 调整倍速 + */ + @PutMapping("/{id}/updateSpeed/{speed}") + public void updateSpeed(@PathVariable String id, @PathVariable int speed) { + this.simulationManager.updateSpeed(id, speed); + } - /** - * 获取仿真中所有仿真用户 - */ - @GetMapping("/{id}/users") - public List getSimulationUsers(@PathVariable String id) { - return this.simulationManager.getSimulationUsers(id).stream() - .map(club.joylink.rtss.simulation.SimulationUser::convertToVO) - .collect(Collectors.toList()); - } + /** + * 获取仿真中所有仿真用户 + */ + @GetMapping("/{id}/users") + public List getSimulationUsers( + @PathVariable String id) { + return this.simulationManager.getSimulationUsers(id).stream() + .map(club.joylink.rtss.simulation.SimulationUser::convertToVO) + .collect(Collectors.toList()); + } - /** - * 监控仿真 - */ - @PostMapping("/{simulationId}/monitor") - public void monitor(@PathVariable String simulationId, @RequestAttribute AccountVO user) { - simulationService.monitor(simulationId, user); - } + /** + * 监控仿真 + */ + @PostMapping("/{simulationId}/monitor") + public void monitor(@PathVariable String simulationId, @RequestAttribute AccountVO user) { + simulationService.monitor(simulationId, user); + } - /** - * 查询"我"已加入的仿真 - */ - @GetMapping("/joined/by/me") - public SimulationVO querySimulationJoinedByMe(@RequestAttribute LoginUserInfoVO loginInfo) { - return simulationService.querySimulationJoinedByUser(loginInfo.getAccountVO().getId()); - } + /** + * 查询"我"已加入的仿真 + */ + @GetMapping("/joined/by/me") + public SimulationVO querySimulationJoinedByMe(@RequestAttribute LoginUserInfoVO loginInfo) { + return simulationService.querySimulationJoinedByUser(loginInfo.getAccountVO().getId()); + } - @GetMapping("/{simulationId}/{memberId}/unreceivedMessages") - public void sendUnreceivedMessages(@PathVariable String simulationId, @PathVariable String memberId) { - simulationService.sendUnreceivedMessages(simulationId, memberId); - } + @GetMapping("/{simulationId}/{memberId}/unreceivedMessages") + public void sendUnreceivedMessages(@PathVariable String simulationId, + @PathVariable String memberId) { + simulationService.sendUnreceivedMessages(simulationId, memberId); + } } diff --git a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java index fc7c1c0fd..3c3720628 100644 --- a/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java +++ b/src/main/java/club/joylink/rtss/simulation/cbtc/data/SimulationDataRepository.java @@ -310,6 +310,9 @@ public class SimulationDataRepository { public MapElement getByCode(String code) { MapElement mapElement = this.deviceMap.get(code); + if (Objects.isNull(mapElement)) { + mapElement = this.vrDeviceMap.get(code); + } if (Objects.isNull(mapElement)) { throw new SimulationException(SimulationExceptionType.System_Fault, String.format("地图数据异常:不存在code为[%s]的数据", code)); 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 c226aae22..522368466 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 @@ -314,15 +314,18 @@ public class MemberManager { } // 删除在原始数据中不存在的成员 List members = simulation.getSimulationMembers(); + Map simMemberMap = new HashMap<>(members.size()); for (SimulationMember m : members) { - if (!originMemberMap.containsKey(m.getId())) { - simulation.removeSimulationMember(m.getId()); + simMemberMap.put(m.getId(), m); + if (originMemberMap.containsKey(m.getId())) { + continue; } + simulation.removeSimulationMember(m.getId()); } // 加入额外的成员 if (!CollectionUtils.isEmpty(memberPOS)) { for (SimulationMemberPO p : memberPOS) { - if (originMemberMap.containsKey(p.getId())) { + if (simMemberMap.containsKey(p.getId())) { continue; } MapElement mapElement = null;