Merge branch 'test'

This commit is contained in:
joylink_zhangsai 2023-09-27 18:09:23 +08:00
commit 9259fd123b
36 changed files with 3360 additions and 1871 deletions

View File

@ -4,5 +4,6 @@ public interface ProjectCode {
String THAILAND_SANDBOX = "THAILAND_SANDBOX";
String SR_SANDBOX = "SR_SANDBOX";
String NGY_SAND_TABLE = "NGY_SAND_TABLE";
}

View File

@ -1,9 +1,8 @@
package club.joylink.rtss.constants;
import lombok.Getter;
import java.util.Arrays;
import java.util.List;
import lombok.Getter;
/**
* 项目设备类型
@ -11,80 +10,137 @@ import java.util.List;
@Getter
public enum ProjectDeviceType {
/* -----------plc device start---------- */
/** 区段 */
SECTION,
/** 道岔 */
SWITCH,
/** 信号机 */
SIGNAL,
/** 屏蔽门控制柜 */
PSC,
/** 屏蔽门 */
PSD,
/** 端头控制盒(屏蔽门控制盒) */
PSL,
/** IBP盘 */
IBP,
/** PLC网关 */
PLC_GATEWAY,
/** 单元控制器 */
DCU,
/** UDP下位机 */
UDP_LOW,
/** UDP客户端 */
UDP_CLIENT,
/** 列车 */
TRAIN,
/* -----------plc device end---------- */
/* -----------plc device start---------- */
/**
* 区段
*/
SECTION,
/**
* 道岔
*/
SWITCH,
/**
* 信号机
*/
SIGNAL,
/**
* 屏蔽门控制柜
*/
PSC,
/**
* 屏蔽门
*/
PSD,
/**
* 端头控制盒屏蔽门控制盒
*/
PSL,
/**
* IBP盘
*/
IBP,
/**
* PLC网关
*/
PLC_GATEWAY,
/**
* 单元控制器
*/
DCU,
/**
* UDP下位机
*/
UDP_LOW,
/**
* UDP客户端
*/
UDP_CLIENT,
/**
* 列车
*/
TRAIN,
/* -----------plc device end---------- */
/* -----------client device start---------- */
/** 教员机instructor machine */
IM,
/** 调度工作站control workstation */
CW,
/** 现地工作站local workstation */
LW,
/** 联锁工作站interlock workstation */
ILW,
/** 虚拟综合后备盘(Integrated Back-Up Panel) */
VR_IBP,
/** 大屏工作站large screen workstation */
LSW,
/** 列车驾驶终端 */
DRIVE,
/** 虚拟站台屏蔽门终端 */
VR_PSD,
/** 现地综合监控 */
ISCS_LW,
/** 中心综合监控 */
ISCS_CW,
/** 车辆段终端 */
DEPOT,
/** 虚拟CCTV */
CCTV,
/** 虚拟电子沙盘 */
SANDBOX,
/** 派班工作站 */
SCHEDULING,
/* -----------client device start---------- */
/**
* 教员机instructor machine
*/
IM,
/**
* 调度工作站control workstation
*/
CW,
/**
* 现地工作站local workstation
*/
LW,
/**
* 联锁工作站interlock workstation
*/
ILW,
/**
* 虚拟综合后备盘(Integrated Back-Up Panel)
*/
VR_IBP,
/**
* 大屏工作站large screen workstation
*/
LSW,
/**
* 列车驾驶终端
*/
DRIVE,
/**
* 虚拟站台屏蔽门终端
*/
VR_PSD,
/**
* 现地综合监控
*/
ISCS_LW,
/**
* 中心综合监控
*/
ISCS_CW,
/**
* 车辆段终端
*/
DEPOT,
/**
* 虚拟CCTV
*/
CCTV,
/**
* 虚拟电子沙盘
*/
SANDBOX,
/**
* 派班工作站
*/
SCHEDULING,
PIS_STAND,
PIS_TRAIN,
/* -----------client device end---------- */
;
PIS_STAND,
PIS_TRAIN,
/* -----------client device end---------- */
/* -----------Other start---------- */
/**
* 沙盘运行计划
*/
SAND_TABLE_RUN_PLAN;
public static List<ProjectDeviceType> PlcDeviceList() {
return Arrays.asList(PLC_GATEWAY,
PSC,
PSD,
PSL,
IBP,
SECTION,
SWITCH,
SIGNAL,
DCU,
UDP_LOW,
UDP_CLIENT,
TRAIN);
}
public static List<ProjectDeviceType> PlcDeviceList() {
return Arrays.asList(PLC_GATEWAY,
PSC,
PSD,
PSL,
IBP,
SECTION,
SWITCH,
SIGNAL,
DCU,
UDP_LOW,
UDP_CLIENT,
TRAIN,
SAND_TABLE_RUN_PLAN);
}
}

View File

@ -2,11 +2,14 @@ package club.joylink.rtss.controller;
import club.joylink.rtss.services.draftData.DraftMapDataHandleService;
import club.joylink.rtss.services.publishData.PublishMapDataHandler;
import java.util.LinkedHashMap;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import java.util.LinkedHashMap;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
/**
* 地图数据处理
@ -16,31 +19,40 @@ import java.util.LinkedHashMap;
@RequestMapping("/api/mapData/handle")
public class MapDataHandleController {
@Autowired
private DraftMapDataHandleService draftMapDataHandleService;
@Autowired
private PublishMapDataHandler publishMapDataHandler;
@Autowired
private DraftMapDataHandleService draftMapDataHandleService;
@Autowired
private PublishMapDataHandler publishMapDataHandler;
@PutMapping("")
public void dataHandle() {
this.publishMapDataHandler.dataHandle();
}
@PutMapping("")
public void dataHandle() {
this.publishMapDataHandler.dataHandle();
}
@PutMapping("/xian3")
public void overlapSetHandle() {
this.publishMapDataHandler.xian3Handle();
}
@PutMapping("/xian3")
public void overlapSetHandle() {
this.publishMapDataHandler.xian3Handle();
}
@PutMapping("/signalSd")
public void signalShowDirection() {
this.publishMapDataHandler.signalShowDirection();
}
@PutMapping("/signalSd")
public void signalShowDirection() {
this.publishMapDataHandler.signalShowDirection();
}
/**
* 批量修改线路数据和ISCS的车站名
*/
@PutMapping("/{mapId}/stationName/mapAndIscs")
public void changeStationName(@PathVariable long mapId, @RequestBody LinkedHashMap<String, String> nameMap) {
this.publishMapDataHandler.changeStationName(mapId, nameMap);
}
/**
* 批量修改线路数据和ISCS的车站名
*/
@PutMapping("/{mapId}/stationName/mapAndIscs")
public void changeStationName(@PathVariable long mapId,
@RequestBody LinkedHashMap<String, String> nameMap) {
this.publishMapDataHandler.changeStationName(mapId, nameMap);
}
/**
* 批量修改线路区段长度
*/
@PutMapping("/{mapId}/{multiple}/sectionLen")
public void updateSectionLen(@PathVariable long mapId, @PathVariable int multiple) {
publishMapDataHandler.updateSectionLen(mapId, multiple);
}
}

View File

@ -41,247 +41,273 @@ import org.springframework.web.bind.annotation.RestController;
@RequestMapping(path = "/api/device")
public class DeviceController {
@Autowired
private DeviceService deviceService;
@Autowired
private DeviceService deviceService;
/**
* 分页查询项目设备
*/
@GetMapping("/paging")
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
return this.deviceService.pagingQuery(queryVO);
}
/**
* 分页查询项目设备
*/
@GetMapping("/paging")
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
return this.deviceService.pagingQuery(queryVO);
}
/**
* 项目设备编号是否已经存在
*/
@GetMapping("/exist/{code}")
public boolean isDeviceCodeExist(@PathVariable String code, String projectCode) {
String project = Project.isDefault(projectCode) ? Project.DEFAULT_PROJECT_CODE : projectCode;
return this.deviceService.isDeviceCodeExist(project, code);
}
/**
* 项目设备编号是否已经存在
*/
@GetMapping("/exist/{code}")
public boolean isDeviceCodeExist(@PathVariable String code, String projectCode) {
String project = Project.isDefault(projectCode) ? Project.DEFAULT_PROJECT_CODE : projectCode;
return this.deviceService.isDeviceCodeExist(project, code);
}
/**
* 新建项目设备
*/
@PostMapping("")
public String create(@RequestBody @Validated ProjectDeviceVO deviceVO,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO userLoginInfo) {
return this.deviceService.create(deviceVO, userLoginInfo);
}
/**
* 新建项目设备
*/
@PostMapping("")
public String create(@RequestBody @Validated ProjectDeviceVO deviceVO,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO userLoginInfo) {
return this.deviceService.create(deviceVO, userLoginInfo);
}
/**
* 获取设备详情包含配置信息
*/
@GetMapping("/{id}")
public ProjectDeviceVO getDeviceDetailInfoById(@PathVariable Long id) {
return this.deviceService.getDeviceDetailInfoById(id);
}
/**
* 获取设备详情包含配置信息
*/
@GetMapping("/{id}")
public ProjectDeviceVO getDeviceDetailInfoById(@PathVariable Long id) {
return this.deviceService.getDeviceDetailInfoById(id);
}
/**
* 添加/修改道岔设备网关映射配置
*/
@PutMapping("/{id}/config/plcgateway")
public void updatePlcGatewayConfig(@PathVariable Long id, @RequestBody @Validated PlcGatewayConfigVO configVO) {
this.deviceService.updatePlcGatewayConfig(id, configVO);
}
/**
* 添加/修改道岔设备网关映射配置
*/
@PutMapping("/{id}/config/plcgateway")
public void updatePlcGatewayConfig(@PathVariable Long id,
@RequestBody @Validated PlcGatewayConfigVO configVO) {
this.deviceService.updatePlcGatewayConfig(id, configVO);
}
/**
* 添加/修改道岔设备网关映射配置
*/
@PutMapping("/{id}/config/switch")
public void updateSwitchConfig(@PathVariable Long id, @RequestBody @Validated SwitchConfigVO configVO) {
this.deviceService.updateSwitchConfig(id, configVO);
}
/**
* 添加/修改道岔设备网关映射配置
*/
@PutMapping("/{id}/config/switch")
public void updateSwitchConfig(@PathVariable Long id,
@RequestBody @Validated SwitchConfigVO configVO) {
this.deviceService.updateSwitchConfig(id, configVO);
}
/**
* 添加/修改信号机设备网关映射配置
*/
@PutMapping("/{id}/config/signal")
public void updateSignalConfig(@PathVariable Long id, @RequestBody @Validated SignalConfigVO configVO) {
this.deviceService.updateSignalConfig(id, configVO);
}
/**
* 添加/修改信号机设备网关映射配置
*/
@PutMapping("/{id}/config/signal")
public void updateSignalConfig(@PathVariable Long id,
@RequestBody @Validated SignalConfigVO configVO) {
this.deviceService.updateSignalConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psc")
public void updatePscConfig(@PathVariable Long id, @RequestBody @Validated PscConfigVO configVO) {
this.deviceService.updatePscConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psc")
public void updatePscConfig(@PathVariable Long id, @RequestBody @Validated PscConfigVO configVO) {
this.deviceService.updatePscConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psd")
public void updatePsdConfig(@PathVariable Long id, @RequestBody @Validated PsdConfigVO configVO) {
this.deviceService.updatePsdConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psd")
public void updatePsdConfig(@PathVariable Long id, @RequestBody @Validated PsdConfigVO configVO) {
this.deviceService.updatePsdConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psl")
public void updatePslConfig(@PathVariable Long id, @RequestBody @Validated PslConfigVO configVO) {
this.deviceService.updatePslConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psl")
public void updatePslConfig(@PathVariable Long id, @RequestBody @Validated PslConfigVO configVO) {
this.deviceService.updatePslConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/ibp")
public void updateIbpConfig(@PathVariable Long id, @RequestBody @Validated IbpConfigVO configVO) {
this.deviceService.updateIbpConfig(id, configVO);
}
/**
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/ibp")
public void updateIbpConfig(@PathVariable Long id, @RequestBody @Validated IbpConfigVO configVO) {
this.deviceService.updateIbpConfig(id, configVO);
}
/**
* 添加/修改虚拟IBP盘配置
*/
@PutMapping("/{id}/config/vribp")
public void updateVrIbpConfig(@PathVariable Long id, @RequestBody @Validated VrIbpConfigVO configVO) {
this.deviceService.updateVrIbpConfig(id, configVO);
}
/**
* 添加/修改虚拟IBP盘配置
*/
@PutMapping("/{id}/config/vribp")
public void updateVrIbpConfig(@PathVariable Long id,
@RequestBody @Validated VrIbpConfigVO configVO) {
this.deviceService.updateVrIbpConfig(id, configVO);
}
/**
* 添加/修改现地工作站配置
*/
@PutMapping("/{id}/config/lw")
public void updateLwConfig(@PathVariable Long id, @RequestBody @Validated LwConfigVO configVO) {
this.deviceService.updateLwConfig(id, configVO);
}
/**
* 添加/修改现地工作站配置
*/
@PutMapping("/{id}/config/lw")
public void updateLwConfig(@PathVariable Long id, @RequestBody @Validated LwConfigVO configVO) {
this.deviceService.updateLwConfig(id, configVO);
}
/**
* 添加/修改大屏工作站配置
*/
@PutMapping("/{id}/config/lsw")
public void updateLswConfig(@PathVariable Long id, @RequestBody @Validated LswConfigVO configVO) {
this.deviceService.updateLswConfig(id, configVO);
}
/**
* 添加/修改大屏工作站配置
*/
@PutMapping("/{id}/config/lsw")
public void updateLswConfig(@PathVariable Long id, @RequestBody @Validated LswConfigVO configVO) {
this.deviceService.updateLswConfig(id, configVO);
}
/**
* 添加/修改CCTV工作站配置
*/
@PutMapping("/{id}/config/cctv")
public void updateCctvConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateCctvConfig(id, configVO);
}
/**
* 添加/修改CCTV工作站配置
*/
@PutMapping("/{id}/config/cctv")
public void updateCctvConfig(@PathVariable Long id,
@RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateCctvConfig(id, configVO);
}
/**
* 添加/修改电子沙盘工作站配置
*/
@PutMapping("/{id}/config/sandbox")
public void updateSandboxConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateSandboxConfig(id, configVO);
}
/**
* 添加/修改电子沙盘工作站配置
*/
@PutMapping("/{id}/config/sandbox")
public void updateSandboxConfig(@PathVariable Long id,
@RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateSandboxConfig(id, configVO);
}
/**
* 添加/修改虚拟屏蔽门工作站配置
*/
@PutMapping("/{id}/config/vrpsd")
public void updateVrpsdConfig(@PathVariable Long id, @RequestBody @Validated VrpsdConfigVO configVO) {
this.deviceService.updateVrpsdConfig(id, configVO);
}
/**
* 添加/修改虚拟屏蔽门工作站配置
*/
@PutMapping("/{id}/config/vrpsd")
public void updateVrpsdConfig(@PathVariable Long id,
@RequestBody @Validated VrpsdConfigVO configVO) {
this.deviceService.updateVrpsdConfig(id, configVO);
}
/**
* 添加/修改现地综合监控工作站配置
*/
@PutMapping("/{id}/config/iscslw")
public void updateIscsLwConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateIscsLwConfig(id, configVO);
}
/**
* 添加/修改现地综合监控工作站配置
*/
@PutMapping("/{id}/config/iscslw")
public void updateIscsLwConfig(@PathVariable Long id,
@RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateIscsLwConfig(id, configVO);
}
/**
* 添加/修改中心综合监控工作站配置
*/
@PutMapping("/{id}/config/iscscw")
public void updateIscsCwConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateIscsCwConfig(id, configVO);
}
/**
* 添加/修改中心综合监控工作站配置
*/
@PutMapping("/{id}/config/iscscw")
public void updateIscsCwConfig(@PathVariable Long id,
@RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateIscsCwConfig(id, configVO);
}
/**
* 添加/修改联锁工作站配置
*/
@PutMapping("/{id}/config/ilw")
public void updateIlwConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateIlwConfig(id, configVO);
}
/**
* 添加/修改联锁工作站配置
*/
@PutMapping("/{id}/config/ilw")
public void updateIlwConfig(@PathVariable Long id,
@RequestBody @Validated RelationLoginConfigVO configVO) {
this.deviceService.updateIlwConfig(id, configVO);
}
/**
* 修改配置以json的形式
*/
@PutMapping("/config/updateConfig")
public void updateConfig(@RequestBody ProjectDeviceVO projectDeviceVO) {
this.deviceService.updateConfig(projectDeviceVO);
}
/**
* 修改配置以json的形式
*/
@PutMapping("/config/updateConfig")
public void updateConfig(@RequestBody ProjectDeviceVO projectDeviceVO) {
this.deviceService.updateConfig(projectDeviceVO);
}
/**
* 删除设备
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) {
this.deviceService.delete(id);
}
/**
* 删除设备
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) {
this.deviceService.delete(id);
}
/**
* 查询某个类型的所有设备
*/
@GetMapping("/{project}/{type}/all")
public List<ProjectDeviceVO> queryByType(@PathVariable String project, @PathVariable ProjectDeviceType type) {
return this.deviceService.queryByType(type, project);
}
/**
* 查询某个类型的所有设备
*/
@GetMapping("/{project}/{type}/all")
public List<ProjectDeviceVO> queryByType(@PathVariable String project,
@PathVariable ProjectDeviceType type) {
return this.deviceService.queryByType(type, project);
}
//
//
// @ApiOperation(value = "查询项目下的所有设备")
// @GetMapping("/project")
// public List<ProjectDeviceVO> queryByProjectCode(String projectCode, String group) {
// return this.iProjectDeviceService.queryByProjectCode(projectCode, group);
// }
@PostMapping("/xty/addOrUpdate")
public void addOrUpdateXtyDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateXtyDeviceConfig(accountVO);
}
@PostMapping("/xty/addOrUpdate")
public void addOrUpdateXtyDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateXtyDeviceConfig(accountVO);
}
@PostMapping("/gzb/addOrUpdate")
public void addOrUpdateGzbDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateGzbDeviceConfig(accountVO);
}
@PostMapping("/gzb/addOrUpdate")
public void addOrUpdateGzbDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateGzbDeviceConfig(accountVO);
}
@PostMapping("/sdy/addOrUpdate")
public void addOrUpdateSdyDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateSdyDeviceConfig(accountVO);
}
@PostMapping("/sdy/addOrUpdate")
public void addOrUpdateSdyDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateSdyDeviceConfig(accountVO);
}
@PostMapping("/zjd/addOrUpdate")
public void addOrUpdateZjdDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateRichorDeviceConfig(accountVO);
}
@PostMapping("/zjd/addOrUpdate")
public void addOrUpdateZjdDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateRichorDeviceConfig(accountVO);
}
@PostMapping("/sr/addOrUpdate/{mapId}")
public void addOrUpdateSrDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateSrDeviceConfig(accountVO, mapId);
}
@PostMapping("/sr/addOrUpdate/{mapId}")
public void addOrUpdateSrDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateSrDeviceConfig(accountVO, mapId);
}
@PostMapping("/hhcj/addOrUpdate")
public void addOrUpdateHhcjDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateHhcjDeviceConfig(accountVO);
}
@PostMapping("/hhcj/addOrUpdate")
public void addOrUpdateHhcjDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateHhcjDeviceConfig(accountVO);
}
@PostMapping("/say/addOrUpdate")
public void addOrUpdateSayDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateSayDeviceConfig(accountVO);
}
@PostMapping("/say/addOrUpdate")
public void addOrUpdateSayDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
this.deviceService.addOrUpdateSayDeviceConfig(accountVO);
}
@PostMapping("/thailand/addOrUpdate/{mapId}")
public void addOrUpdateThailandDeviceConfig(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateThailandDeviceConfig(accountVO, mapId);
}
@PostMapping("/thailand/addOrUpdate/{mapId}")
public void addOrUpdateThailandDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateThailandDeviceConfig(accountVO, mapId);
}
@PostMapping("/ngy/addOrUpdate/{mapId}")
public void addOrUpdateNgyDeviceConfig(
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO, @PathVariable Long mapId) {
this.deviceService.addOrUpdateNgyDeviceConfig(accountVO, mapId);
}
}

View File

@ -76,7 +76,7 @@ public class SimulationV1Controller {
@GetMapping("")
public String simulation(Long mapId, String prdType,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO loginUserInfoVO) {
LoginUserInfoVO loginUserInfoVO) {
String simulation = this.groupSimulationService.simulation(mapId, prdType, loginUserInfoVO);
return simulation;
}
@ -87,7 +87,7 @@ public class SimulationV1Controller {
@GetMapping(path = "/training/{trainingId}")
public String trainingSimulation(@PathVariable Long trainingId,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO loginUserInfoVO) {
LoginUserInfoVO loginUserInfoVO) {
return this.groupSimulationService.trainingSimulation(trainingId, loginUserInfoVO);
}
@ -97,7 +97,7 @@ public class SimulationV1Controller {
@GetMapping(path = "/exam/{examId}")
public String examSimulate(@PathVariable Long examId,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO loginUserInfoVO) {
LoginUserInfoVO loginUserInfoVO) {
return this.groupSimulationService.examSimulation(examId, loginUserInfoVO);
}
@ -123,7 +123,7 @@ public class SimulationV1Controller {
@GetMapping("/{group}/simulationUser")
public SimulationUserVO getSimulationUserInfo(@PathVariable String group,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_USER_KEY)
AccountVO accountVO) {
AccountVO accountVO) {
return this.groupSimulationService.getSimulationUserInfo(group, accountVO);
}
@ -543,7 +543,7 @@ public class SimulationV1Controller {
*/
@GetMapping("/paged/supervise")
public PageVO<SimulationInfoVO> pagedSuperviseSimulation(@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY) LoginUserInfoVO loginUserInfoVO,
SimulationInfoQueryVO queryVO) {
SimulationInfoQueryVO queryVO) {
return simulationService.pagedSimulationByOrg(loginUserInfoVO.getTopOrgId(), queryVO);
}
@ -612,4 +612,9 @@ public class SimulationV1Controller {
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);
}
}

View File

@ -21,213 +21,218 @@ import club.joylink.rtss.vo.client.project.VrpsdConfigVO;
import java.util.List;
public interface DeviceService {
/**
* 分页查询项目设备
*
* @param queryVO
* @param userLoginInfo
* @return
*/
PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO);
/**
* 项目设备编码是否存在
*
* @param project
* @param code
* @return
*/
boolean isDeviceCodeExist(String project, String code);
/**
* 分页查询项目设备
*
* @param queryVO
* @return
*/
PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO);
/**
* 新增设备
*
* @param deviceVO
* @param userLoginInfo
* @return
*/
String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo);
/**
* 项目设备编码是否存在
*
* @param project
* @param code
* @return
*/
boolean isDeviceCodeExist(String project, String code);
/**
* 获取设备基础信息
*
* @param id
* @return
*/
ProjectDeviceVO getDeviceBaseInfoById(Long id);
/**
* 新增设备
*
* @param deviceVO
* @param userLoginInfo
* @return
*/
String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo);
void updatePlcGatewayConfig(Long id, PlcGatewayConfigVO configVO);
/**
* 获取设备基础信息
*
* @param id
* @return
*/
ProjectDeviceVO getDeviceBaseInfoById(Long id);
/**
* 更新道岔配置
*
* @param id
* @param configVO
*/
void updateSwitchConfig(Long id, SwitchConfigVO configVO);
void updatePlcGatewayConfig(Long id, PlcGatewayConfigVO configVO);
/**
* 更新信号机配置
*
* @param id
* @param configVO
*/
void updateSignalConfig(Long id, SignalConfigVO configVO);
/**
* 更新道岔配置
*
* @param id
* @param configVO
*/
void updateSwitchConfig(Long id, SwitchConfigVO configVO);
/**
* 更新屏蔽门控制柜配置
*
* @param id
* @param configVO
*/
void updatePscConfig(Long id, PscConfigVO configVO);
/**
* 更新信号机配置
*
* @param id
* @param configVO
*/
void updateSignalConfig(Long id, SignalConfigVO configVO);
/**
* 更新屏蔽门配置
*
* @param id
* @param configVO
*/
void updatePsdConfig(Long id, PsdConfigVO configVO);
/**
* 更新屏蔽门控制柜配置
*
* @param id
* @param configVO
*/
void updatePscConfig(Long id, PscConfigVO configVO);
/**
* 更新屏蔽门控制盒配置
*
* @param id
* @param configVO
*/
void updatePslConfig(Long id, PslConfigVO configVO);
/**
* 更新屏蔽门配置
*
* @param id
* @param configVO
*/
void updatePsdConfig(Long id, PsdConfigVO configVO);
/**
* 更新IBP盘配置
*
* @param id
* @param configVO
*/
void updateIbpConfig(Long id, IbpConfigVO configVO);
/**
* 更新屏蔽门控制盒配置
*
* @param id
* @param configVO
*/
void updatePslConfig(Long id, PslConfigVO configVO);
/**
* 更新虚拟IBP盘配置
*
* @param id
* @param configVO
*/
void updateVrIbpConfig(Long id, VrIbpConfigVO configVO);
/**
* 更新IBP盘配置
*
* @param id
* @param configVO
*/
void updateIbpConfig(Long id, IbpConfigVO configVO);
/**
* 更新现地工作站配置
*
* @param id
* @param configVO
*/
void updateLwConfig(Long id, LwConfigVO configVO);
/**
* 更新虚拟IBP盘配置
*
* @param id
* @param configVO
*/
void updateVrIbpConfig(Long id, VrIbpConfigVO configVO);
/**
* 更新大屏工作站配置
*
* @param id
* @param configVO
*/
void updateLswConfig(Long id, LswConfigVO configVO);
/**
* 更新现地工作站配置
*
* @param id
* @param configVO
*/
void updateLwConfig(Long id, LwConfigVO configVO);
/**
* 更新CCTV工作站配置
*
* @param id
* @param configVO
*/
void updateCctvConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新大屏工作站配置
*
* @param id
* @param configVO
*/
void updateLswConfig(Long id, LswConfigVO configVO);
/**
* 更新电子沙盘工作站配置
*
* @param id
* @param configVO
*/
void updateSandboxConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新CCTV工作站配置
*
* @param id
* @param configVO
*/
void updateCctvConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新现地ISCS工作站配置
*
* @param id
* @param configVO
*/
void updateIscsLwConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新电子沙盘工作站配置
*
* @param id
* @param configVO
*/
void updateSandboxConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新中心ISCS工作站配置
*
* @param id
* @param configVO
*/
void updateIscsCwConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新现地ISCS工作站配置
*
* @param id
* @param configVO
*/
void updateIscsLwConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新虚拟屏蔽门客户端配置
*
* @param id
* @param configVO
*/
void updateVrpsdConfig(Long id, VrpsdConfigVO configVO);
/**
* 更新中心ISCS工作站配置
*
* @param id
* @param configVO
*/
void updateIscsCwConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新联锁工作站客户端配置
*
* @param id
* @param configVO
*/
void updateIlwConfig(Long id, RelationLoginConfigVO configVO);
/**
* 更新虚拟屏蔽门客户端配置
*
* @param id
* @param configVO
*/
void updateVrpsdConfig(Long id, VrpsdConfigVO configVO);
/**
* 更新以json直接更新
*/
void updateConfig(ProjectDeviceVO projectDeviceVO);
/**
* 更新联锁工作站客户端配置
*
* @param id
* @param configVO
*/
void updateIlwConfig(Long id, RelationLoginConfigVO configVO);
/**
* 删除设备
*
* @param id
*/
void delete(Long id);
/**
* 更新以json直接更新
*/
void updateConfig(ProjectDeviceVO projectDeviceVO);
/**
* 查询某分类下的所有设备
*
* @param type
* @param project
* @return
*/
List<ProjectDeviceVO> queryByType(ProjectDeviceType type, String project);
/**
* 删除设备
*
* @param id
*/
void delete(Long id);
ProjectDeviceVO getDeviceDetailInfoById(Long id);
/**
* 查询某分类下的所有设备
*
* @param type
* @param project
* @return
*/
List<ProjectDeviceVO> queryByType(ProjectDeviceType type, String project);
/**
* TODO 20220922用于替换上方方法占位
*/
ProjectDeviceVO getDeviceDetailInfoOf(String projectCode, String deviceCode);
ProjectDeviceVO getDeviceDetailInfoById(Long id);
/**
* 查询指定分类下的所有设备
*
* @param typeList
* @param project
* @return
*/
List<ProjectDeviceVO> queryDetailByTypes(List<ProjectDeviceType> typeList, String project);
/**
* 用于替换上方方法占位
*/
ProjectDeviceVO getDeviceDetailInfoOf(String projectCode, String deviceCode);
void addOrUpdateXtyDeviceConfig(AccountVO accountVO);
/**
* 查询指定分类下的所有设备
*
* @param typeList
* @param project
* @return
*/
List<ProjectDeviceVO> queryDetailByTypes(List<ProjectDeviceType> typeList, String project);
void addOrUpdateGzbDeviceConfig(AccountVO accountVO);
void addOrUpdateXtyDeviceConfig(AccountVO accountVO);
void addOrUpdateSdyDeviceConfig(AccountVO accountVO);
void addOrUpdateGzbDeviceConfig(AccountVO accountVO);
void addOrUpdateRichorDeviceConfig(AccountVO accountVO);
void addOrUpdateSdyDeviceConfig(AccountVO accountVO);
void addOrUpdateSrDeviceConfig(AccountVO accountVO, Long mapId);
void addOrUpdateRichorDeviceConfig(AccountVO accountVO);
void addOrUpdateHhcjDeviceConfig(AccountVO accountVO);
void addOrUpdateSrDeviceConfig(AccountVO accountVO, Long mapId);
void addOrUpdateSayDeviceConfig(AccountVO accountVO);
void addOrUpdateHhcjDeviceConfig(AccountVO accountVO);
void addOrUpdateThailandDeviceConfig(AccountVO accountVO, Long mapId);
void addOrUpdateSayDeviceConfig(AccountVO accountVO);
void addOrUpdateThailandDeviceConfig(AccountVO accountVO, Long mapId);
/**
* 所有沙盘项目通用接口
*/
void addOrUpdateNgyDeviceConfig(AccountVO accountVO, Long mapId);
}

View File

@ -8,6 +8,10 @@ import club.joylink.rtss.entity.ProjectDevice;
import club.joylink.rtss.entity.ProjectDeviceExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSectionConfigVO;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSignalConfigVO;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSwitchConfigVO;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableTrainConfigVO;
import club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.service.ThailandSignalServiceImpl;
import club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.service.ThailandSwitchServiceImpl;
import club.joylink.rtss.util.JsonUtils;
@ -67,6 +71,7 @@ import java.util.Objects;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
@ -79,6 +84,9 @@ public class DeviceServiceImpl implements DeviceService {
@Autowired
private IMapService iMapService;
@Autowired
private ProjectService projectService;
// 修改项目编码 20221009
@Override
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
@ -519,6 +527,24 @@ public class DeviceServiceImpl implements DeviceService {
}
}
@Transactional
@Override
public void addOrUpdateNgyDeviceConfig(AccountVO accountVO, Long mapId) {
// 删除旧配置
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria()
.andProjectCodeEqualTo(ProjectCode.NGY_SAND_TABLE)
.andTypeIn(ProjectDeviceType.PlcDeviceList().stream().map(Enum::name)
.collect(Collectors.toList()));
this.projectDeviceDAO.deleteByExample(example);
// 保存新配置
List<ProjectDevice> list = this.buildNgyProjectDevices(accountVO, mapId,
ProjectCode.NGY_SAND_TABLE);
for (ProjectDevice projectDevice : list) {
this.projectDeviceDAO.insert(projectDevice);
}
}
private List<ProjectDevice> buildSayProjectDevices(AccountVO accountVO) {
LocalDateTime now = LocalDateTime.now();
List<ProjectDevice> list = new ArrayList<>();
@ -1081,4 +1107,146 @@ public class DeviceServiceImpl implements DeviceService {
configVO.setHeadDelayTime(headDelayTime);
configVO.setTailDelayTime(tailDelayTime);
}
private List<ProjectDevice> buildNgyProjectDevices(AccountVO accountVO, long mapId,
String projectCode) {
LocalDateTime now = LocalDateTime.now();
List<ProjectDevice> list = new ArrayList<>();
//道岔和列车数据发送端口
ProjectDevice switchTrainUdpLow = new ProjectDevice();
switchTrainUdpLow.setProjectCode(projectCode);
switchTrainUdpLow.setCode("udp-sender-1");
switchTrainUdpLow.setType(ProjectDeviceType.UDP_LOW.name());
switchTrainUdpLow.setCreator(accountVO.getId());
switchTrainUdpLow.setCreateTime(now);
switchTrainUdpLow.setConfig(
new UDPLowConfigVO(ThailandSwitchServiceImpl.NAME, "192.168.0.10", 44449).toJson());
list.add(switchTrainUdpLow);
//信号机数据发送端口
ProjectDevice signalUdpLow = new ProjectDevice();
signalUdpLow.setProjectCode(projectCode);
signalUdpLow.setCode("udp-sender-2");
signalUdpLow.setType(ProjectDeviceType.UDP_LOW.name());
signalUdpLow.setCreator(accountVO.getId());
signalUdpLow.setCreateTime(now);
signalUdpLow.setConfig(
new UDPLowConfigVO(ThailandSignalServiceImpl.NAME, "192.168.0.10", 44445).toJson());
list.add(signalUdpLow);
//UDP数据接收
ProjectDevice udpClient = new ProjectDevice();
udpClient.setProjectCode(projectCode);
udpClient.setCode("udp-receiver");
udpClient.setType(ProjectDeviceType.UDP_CLIENT.name());
udpClient.setCreator(accountVO.getId());
udpClient.setCreateTime(now);
UDPClientConfigVO udpClientConfigVO = new UDPClientConfigVO("192.168.0.10", 44449);
udpClient.setConfig(JsonUtils.writeValueAsString(udpClientConfigVO));
list.add(udpClient);
/*-------------------- 地图设备 --------------------*/
MapVO map = iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = map.getGraphDataNew();
//信号机
for (MapSignalNewVO mapSignalNewVO : graphDataNew.getSignalList()) {
if (StringUtils.hasText(mapSignalNewVO.getSrCode())) {
ProjectDevice signal = new ProjectDevice();
signal.setProjectCode(projectCode);
signal.setCode(
String.join("-", "signal", mapSignalNewVO.getCode(), mapSignalNewVO.getName()));
signal.setType(ProjectDeviceType.SIGNAL.name());
signal.setCreator(accountVO.getId());
signal.setCreateTime(now);
SandTableSignalConfigVO configVO = new SandTableSignalConfigVO(mapSignalNewVO.getCode(),
mapSignalNewVO.getSrCode());
signal.setConfig(JsonUtils.writeValueAsString(configVO));
list.add(signal);
}
}
//道岔
for (MapSwitchVO mapSwitchVO : graphDataNew.getSwitchList()) {
if (StringUtils.hasText(mapSwitchVO.getSrCode())) {
ProjectDevice aSwitch = new ProjectDevice();
aSwitch.setProjectCode(projectCode);
aSwitch.setCode(String.join("-", "switch", mapSwitchVO.getCode(), mapSwitchVO.getName()));
aSwitch.setType(ProjectDeviceType.SWITCH.name());
aSwitch.setCreator(accountVO.getId());
aSwitch.setCreateTime(now);
SandTableSwitchConfigVO configVO = new SandTableSwitchConfigVO(mapSwitchVO.getCode(),
mapSwitchVO.getSrCode());
aSwitch.setConfig(JsonUtils.writeValueAsString(configVO));
list.add(aSwitch);
}
}
//区段
for (MapSectionNewVO mapSectionNewVO : graphDataNew.getSectionList()) {
if (StringUtils.hasText(mapSectionNewVO.getSrCode())) {
ProjectDevice section = new ProjectDevice();
section.setProjectCode(projectCode);
section.setCode(
String.join("-", "section", mapSectionNewVO.getCode(), mapSectionNewVO.getName()));
section.setType(ProjectDeviceType.SECTION.name());
section.setCreator(accountVO.getId());
section.setCreateTime(now);
SandTableSectionConfigVO configVO = new SandTableSectionConfigVO(mapSectionNewVO.getCode(),
mapSectionNewVO.getSrCode());
section.setConfig(JsonUtils.writeValueAsString(configVO));
ngyFillTime(configVO, mapSectionNewVO);
list.add(section);
}
}
//列车
List<MapTrainVO> trainList = graphDataNew.getTrainList();
for (MapTrainVO mapTrainVO : trainList) {
ProjectDevice train = new ProjectDevice();
train.setProjectCode(projectCode);
train.setCode("train-" + mapTrainVO.getGroupNumber());
train.setType(ProjectDeviceType.TRAIN.name());
train.setCreator(accountVO.getId());
train.setCreateTime(now);
SandTableTrainConfigVO configVO = new SandTableTrainConfigVO(mapTrainVO.getGroupNumber(),
String.valueOf(Integer.parseInt(mapTrainVO.getGroupNumber())));
train.setConfig(JsonUtils.writeValueAsString(configVO));
list.add(train);
}
return list;
}
private void ngyFillTime(SandTableSectionConfigVO configVO, MapSectionNewVO section) {
Float headDelayTime = null;
Float tailDelayTime = null;
if (section.isStandTrack() || section.isReentryTrack() || section.isTransferTrack()) {
if (section.isStandTrack()) {
tailDelayTime = 1f;
} else {
tailDelayTime = 0f;
}
} else {
headDelayTime = 2f;
}
switch (section.getCode()) {
case "T68": // 43G
tailDelayTime = 1.4f;
break;
case "T62": //37G
tailDelayTime = 0.8f;
break;
case "T35": //9G
tailDelayTime = 1.3f;
break;
case "T33": //5G
tailDelayTime = 0.9f;
break;
case "T5": //8G
tailDelayTime = 0.8f;
break;
case "T7": //12G
tailDelayTime = 0.6f;
break;
case "T45": //24G
tailDelayTime = 0.8f;
break;
}
configVO.setHeadDelayTime(headDelayTime);
configVO.setTailDelayTime(tailDelayTime);
}
}

View File

@ -5,7 +5,12 @@ import club.joylink.rtss.constants.MapStatus;
import club.joylink.rtss.dao.IscsDAO;
import club.joylink.rtss.dao.MapDataDAO;
import club.joylink.rtss.dao.MapInfoDAO;
import club.joylink.rtss.entity.*;
import club.joylink.rtss.entity.Iscs;
import club.joylink.rtss.entity.IscsExample;
import club.joylink.rtss.entity.MapDataExample;
import club.joylink.rtss.entity.MapDataWithBLOBs;
import club.joylink.rtss.entity.MapInfo;
import club.joylink.rtss.entity.MapInfoExample;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.services.IMapService;
import club.joylink.rtss.services.cache.ICacheService;
@ -18,250 +23,267 @@ import club.joylink.rtss.vo.map.MapCheckConfig;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.MapLogicDataNewVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.map.graph.MapSectionNewVO;
import club.joylink.rtss.vo.map.graph.MapSignalNewVO;
import club.joylink.rtss.vo.map.logic.MapRouteNewVO;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.util.CollectionUtils;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
@Service
public class PublishMapDataHandler {
@Autowired
private IMapService iMapService;
@Autowired
private MapInfoDAO mapInfoDAO;
@Autowired
private MapDataDAO mapDataDAO;
@Autowired
private IscsDAO iscsDAO;
@Autowired
private ICacheService iCacheService;
public List<MapInfo> queryMapInfos() {
MapInfoExample example = new MapInfoExample();
example.createCriteria().andStatusNotEqualTo(MapStatus.Delete.getCode());
List<MapInfo> mapInfos = this.mapInfoDAO.selectByExample(example);
return mapInfos;
}
@Autowired
private IMapService iMapService;
@Autowired
private MapInfoDAO mapInfoDAO;
@Autowired
private MapDataDAO mapDataDAO;
@Autowired
private IscsDAO iscsDAO;
@Autowired
private ICacheService iCacheService;
public void dataHandle() {
List<MapInfo> mapInfos = this.queryMapInfos();
for (MapInfo mapInfo : mapInfos) {
this.handle(mapInfo);
}
}
public List<MapInfo> queryMapInfos() {
MapInfoExample example = new MapInfoExample();
example.createCriteria().andStatusNotEqualTo(MapStatus.Delete.getCode());
List<MapInfo> mapInfos = this.mapInfoDAO.selectByExample(example);
return mapInfos;
}
@Transactional
public void handle(MapInfo mapInfo) {
Long mapId = mapInfo.getId();
MapVO detail = this.iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = detail.getGraphDataNew();
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
for (MapSignalNewVO signal : signalList) {
Signal.SignalType type = signal.getType();
switch (type) {
case PROTECTION:
case PASSING:
signal.setSignalModel(SignalModel.RGY.name());
break;
case BLOCKING:
signal.setSignalModel(SignalModel.R.name());
break;
case SHUNTING:
signal.setSignalModel(SignalModel.BW.name());
break;
case ARRIVAL:
signal.setSignalModel(SignalModel.YGRYW.name());
break;
case EXIT:
signal.setSignalModel(SignalModel.YGRGW.name());
break;
}
}
MapLogicDataNewVO logicDataNew = detail.getLogicDataNew();
List<MapRouteNewVO> routeList = logicDataNew.getRouteList();
for (MapRouteNewVO route : routeList) {
if (route.isGreenOpen()) {
route.setAspect(SignalAspect.G);
} else {
route.setAspect(SignalAspect.Y);
}
}
//地图数据
MapDataWithBLOBs mapData = new MapDataWithBLOBs();
mapData.setMapId(mapId);
mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew));
mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew()));
if (detail.getCheckConfig() != null) {
mapData.setCheckConfig(detail.getCheckConfig().toJson());
} else {
mapData.setCheckConfig(new MapCheckConfig().toJson());
}
mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId)));
mapData.setNote("处理进路信号显示");
mapData.setTime(LocalDateTime.now());
mapData.setUserId(1L);
mapDataDAO.insert(mapData);
// 更新地图当前使用的地图数据版本
MapInfo map = new MapInfo();
map.setId(mapId);
map.setVersion(mapData.getVersion());
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
public void dataHandle() {
List<MapInfo> mapInfos = this.queryMapInfos();
for (MapInfo mapInfo : mapInfos) {
this.handle(mapInfo);
}
}
public void xian3Handle() {
MapInfoExample example = new MapInfoExample();
example.createCriteria()
.andLineCodeEqualTo("11")
.andStatusNotEqualTo(MapStatus.Delete.getCode());
List<MapInfo> mapInfos = this.mapInfoDAO.selectByExample(example);
for (MapInfo mapInfo : mapInfos) {
handleSignal(mapInfo);
}
@Transactional
public void handle(MapInfo mapInfo) {
Long mapId = mapInfo.getId();
MapVO detail = this.iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = detail.getGraphDataNew();
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
for (MapSignalNewVO signal : signalList) {
Signal.SignalType type = signal.getType();
switch (type) {
case PROTECTION:
case PASSING:
signal.setSignalModel(SignalModel.RGY.name());
break;
case BLOCKING:
signal.setSignalModel(SignalModel.R.name());
break;
case SHUNTING:
signal.setSignalModel(SignalModel.BW.name());
break;
case ARRIVAL:
signal.setSignalModel(SignalModel.YGRYW.name());
break;
case EXIT:
signal.setSignalModel(SignalModel.YGRGW.name());
break;
}
}
MapLogicDataNewVO logicDataNew = detail.getLogicDataNew();
List<MapRouteNewVO> routeList = logicDataNew.getRouteList();
for (MapRouteNewVO route : routeList) {
if (route.isGreenOpen()) {
route.setAspect(SignalAspect.G);
} else {
route.setAspect(SignalAspect.Y);
}
}
//地图数据
MapDataWithBLOBs mapData = new MapDataWithBLOBs();
mapData.setMapId(mapId);
mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew));
mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew()));
if (detail.getCheckConfig() != null) {
mapData.setCheckConfig(detail.getCheckConfig().toJson());
} else {
mapData.setCheckConfig(new MapCheckConfig().toJson());
}
mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId)));
mapData.setNote("处理进路信号显示");
mapData.setTime(LocalDateTime.now());
mapData.setUserId(1L);
mapDataDAO.insert(mapData);
// 更新地图当前使用的地图数据版本
MapInfo map = new MapInfo();
map.setId(mapId);
map.setVersion(mapData.getVersion());
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
}
private void handleSignal(MapInfo mapInfo) {
Long mapId = mapInfo.getId();
MapVO detail = this.iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = detail.getGraphDataNew();
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
MapLogicDataNewVO logicDataNew = detail.getLogicDataNew();
List<MapRouteNewVO> routeList = logicDataNew.getRouteList();
Map<String, MapRouteNewVO> routeMap = new HashMap<>();
for (MapRouteNewVO mapRouteNewVO : routeList) {
if (mapRouteNewVO.getEndSignalCode() != null) {
if (!routeMap.containsKey(mapRouteNewVO.getEndSignalCode())) {
routeMap.put(mapRouteNewVO.getEndSignalCode(), mapRouteNewVO);
}
}
}
for (MapSignalNewVO signalVO : signalList) {
MapRouteNewVO route = routeMap.get(signalVO.getCode());
if (route != null) {
signalVO.setCtcSetOverlap(route.isSetOverlapInCtc());
}
}
//地图数据
MapDataWithBLOBs mapData = new MapDataWithBLOBs();
mapData.setMapId(mapId);
mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew));
mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew()));
if (detail.getCheckConfig() != null) {
mapData.setCheckConfig(detail.getCheckConfig().toJson());
} else {
mapData.setCheckConfig(new MapCheckConfig().toJson());
}
mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId)));
mapData.setNote("处理信号机CTC级别是否办理延续保护");
mapData.setTime(LocalDateTime.now());
mapData.setUserId(1L);
mapDataDAO.insert(mapData);
// 更新地图当前使用的地图数据版本
MapInfo map = new MapInfo();
map.setId(mapId);
map.setVersion(mapData.getVersion());
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
public void xian3Handle() {
MapInfoExample example = new MapInfoExample();
example.createCriteria()
.andLineCodeEqualTo("11")
.andStatusNotEqualTo(MapStatus.Delete.getCode());
List<MapInfo> mapInfos = this.mapInfoDAO.selectByExample(example);
for (MapInfo mapInfo : mapInfos) {
handleSignal(mapInfo);
}
}
public void signalShowDirection() {
MapInfoExample example = new MapInfoExample();
example.createCriteria()
.andStatusNotEqualTo(MapStatus.Delete.getCode());
List<MapInfo> mapInfos = this.mapInfoDAO.selectByExample(example);
for (MapInfo mapInfo : mapInfos) {
handleSignalShowDirection(mapInfo);
private void handleSignal(MapInfo mapInfo) {
Long mapId = mapInfo.getId();
MapVO detail = this.iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = detail.getGraphDataNew();
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
MapLogicDataNewVO logicDataNew = detail.getLogicDataNew();
List<MapRouteNewVO> routeList = logicDataNew.getRouteList();
Map<String, MapRouteNewVO> routeMap = new HashMap<>();
for (MapRouteNewVO mapRouteNewVO : routeList) {
if (mapRouteNewVO.getEndSignalCode() != null) {
if (!routeMap.containsKey(mapRouteNewVO.getEndSignalCode())) {
routeMap.put(mapRouteNewVO.getEndSignalCode(), mapRouteNewVO);
}
}
}
for (MapSignalNewVO signalVO : signalList) {
MapRouteNewVO route = routeMap.get(signalVO.getCode());
if (route != null) {
signalVO.setCtcSetOverlap(route.isSetOverlapInCtc());
}
}
//地图数据
MapDataWithBLOBs mapData = new MapDataWithBLOBs();
mapData.setMapId(mapId);
mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew));
mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew()));
if (detail.getCheckConfig() != null) {
mapData.setCheckConfig(detail.getCheckConfig().toJson());
} else {
mapData.setCheckConfig(new MapCheckConfig().toJson());
}
mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId)));
mapData.setNote("处理信号机CTC级别是否办理延续保护");
mapData.setTime(LocalDateTime.now());
mapData.setUserId(1L);
mapDataDAO.insert(mapData);
// 更新地图当前使用的地图数据版本
MapInfo map = new MapInfo();
map.setId(mapId);
map.setVersion(mapData.getVersion());
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
}
private void handleSignalShowDirection(MapInfo mapInfo) {
Long mapId = mapInfo.getId();
MapVO detail = this.iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = detail.getGraphDataNew();
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
for (MapSignalNewVO signalVO : signalList) {
signalVO.setShowRight(signalVO.isRight());
}
//地图数据
MapDataWithBLOBs mapData = new MapDataWithBLOBs();
mapData.setMapId(mapId);
mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew));
mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew()));
if (detail.getCheckConfig() != null) {
mapData.setCheckConfig(detail.getCheckConfig().toJson());
} else {
mapData.setCheckConfig(new MapCheckConfig().toJson());
}
mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId)));
mapData.setNote("处理信号机显示方向");
mapData.setTime(LocalDateTime.now());
mapData.setUserId(1L);
mapDataDAO.insert(mapData);
// 更新地图当前使用的地图数据版本
MapInfo map = new MapInfo();
map.setId(mapId);
map.setVersion(mapData.getVersion());
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
public void signalShowDirection() {
MapInfoExample example = new MapInfoExample();
example.createCriteria()
.andStatusNotEqualTo(MapStatus.Delete.getCode());
List<MapInfo> mapInfos = this.mapInfoDAO.selectByExample(example);
for (MapInfo mapInfo : mapInfos) {
handleSignalShowDirection(mapInfo);
}
}
public void changeStationName(long mapId, Map<String, String> nameMap) {
// 修改地图数据
MapDataWithBLOBs mapData = getMapDataEntity(mapId);
String graphData = mapData.getGraphData();
String logicData = mapData.getLogicData();
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
graphData = graphData.replace(k, v);
logicData = logicData.replace(k, v);
}
mapData.setGraphData(graphData);
mapData.setLogicData(logicData);
mapDataDAO.updateByPrimaryKeyWithBLOBs(mapData);
// 修改ISCS数据
IscsExample iscsExample = new IscsExample();
iscsExample.createCriteria().andMapIdEqualTo(mapId);
List<Iscs> iscsList = iscsDAO.selectByExampleWithBLOBs(iscsExample);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(iscsList);
for (Iscs iscs : iscsList) {
String iscsGraphData = iscs.getGraphData();
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
iscsGraphData = iscsGraphData.replace(k, v);
}
iscs.setGraphData(iscsGraphData);
iscsDAO.updateByPrimaryKeyWithBLOBs(iscs);
}
// 刷新缓存
iCacheService.remove(BusinessConsts.CachePrefix.Map + mapId);
iMapService.getMapDetail(mapId);
private void handleSignalShowDirection(MapInfo mapInfo) {
Long mapId = mapInfo.getId();
MapVO detail = this.iMapService.getMapDetail(mapId);
MapGraphDataNewVO graphDataNew = detail.getGraphDataNew();
List<MapSignalNewVO> signalList = graphDataNew.getSignalList();
for (MapSignalNewVO signalVO : signalList) {
signalVO.setShowRight(signalVO.isRight());
}
//地图数据
MapDataWithBLOBs mapData = new MapDataWithBLOBs();
mapData.setMapId(mapId);
mapData.setGraphData(JsonUtils.writeValueAsString(graphDataNew));
mapData.setLogicData(JsonUtils.writeValueAsString(detail.getLogicDataNew()));
if (detail.getCheckConfig() != null) {
mapData.setCheckConfig(detail.getCheckConfig().toJson());
} else {
mapData.setCheckConfig(new MapCheckConfig().toJson());
}
mapData.setVersion(VersionUtil.generateNext(this.iMapService.findMapVersion(mapId)));
mapData.setNote("处理信号机显示方向");
mapData.setTime(LocalDateTime.now());
mapData.setUserId(1L);
mapDataDAO.insert(mapData);
// 更新地图当前使用的地图数据版本
MapInfo map = new MapInfo();
map.setId(mapId);
map.setVersion(mapData.getVersion());
mapInfoDAO.updateByPrimaryKeySelective(map);
this.iMapService.removeCache(mapId);
}
private MapDataWithBLOBs getMapDataEntity(long mapId) {
MapInfo mapInfo = mapInfoDAO.selectByPrimaryKey(mapId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapInfo);
return getMapDataEntity(mapId, mapInfo.getVersion());
public void changeStationName(long mapId, Map<String, String> nameMap) {
// 修改地图数据
MapDataWithBLOBs mapData = getMapDataEntity(mapId);
String graphData = mapData.getGraphData();
String logicData = mapData.getLogicData();
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
graphData = graphData.replace(k, v);
logicData = logicData.replace(k, v);
}
mapData.setGraphData(graphData);
mapData.setLogicData(logicData);
mapDataDAO.updateByPrimaryKeyWithBLOBs(mapData);
// 修改ISCS数据
IscsExample iscsExample = new IscsExample();
iscsExample.createCriteria().andMapIdEqualTo(mapId);
List<Iscs> iscsList = iscsDAO.selectByExampleWithBLOBs(iscsExample);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertCollectionNotEmpty(iscsList);
for (Iscs iscs : iscsList) {
String iscsGraphData = iscs.getGraphData();
for (Map.Entry<String, String> entry : nameMap.entrySet()) {
String k = entry.getKey();
String v = entry.getValue();
iscsGraphData = iscsGraphData.replace(k, v);
}
iscs.setGraphData(iscsGraphData);
iscsDAO.updateByPrimaryKeyWithBLOBs(iscs);
}
// 刷新缓存
iCacheService.remove(BusinessConsts.CachePrefix.Map + mapId);
iMapService.getMapDetail(mapId);
}
private MapDataWithBLOBs findMapDataEntity(long mapId, String version) {
MapDataExample example = new MapDataExample();
example.createCriteria().andMapIdEqualTo(mapId).andVersionEqualTo(version);
List<MapDataWithBLOBs> list = mapDataDAO.selectByExampleWithBLOBs(example);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
private MapDataWithBLOBs getMapDataEntity(long mapId) {
MapInfo mapInfo = mapInfoDAO.selectByPrimaryKey(mapId);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(mapInfo);
return getMapDataEntity(mapId, mapInfo.getVersion());
}
private MapDataWithBLOBs getMapDataEntity(long mapId, String version) {
MapDataWithBLOBs entity = findMapDataEntity(mapId, version);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity);
return entity;
private MapDataWithBLOBs findMapDataEntity(long mapId, String version) {
MapDataExample example = new MapDataExample();
example.createCriteria().andMapIdEqualTo(mapId).andVersionEqualTo(version);
List<MapDataWithBLOBs> list = mapDataDAO.selectByExampleWithBLOBs(example);
return CollectionUtils.isEmpty(list) ? null : list.get(0);
}
private MapDataWithBLOBs getMapDataEntity(long mapId, String version) {
MapDataWithBLOBs entity = findMapDataEntity(mapId, version);
BusinessExceptionAssertEnum.DATA_NOT_EXIST.assertNotNull(entity);
return entity;
}
public void updateSectionLen(long mapId, int multiple) {
MapDataExample example = new MapDataExample();
example.setOrderByClause("id desc");
example.setLimit(1);
example.createCriteria().andMapIdEqualTo(mapId);
MapDataWithBLOBs map = mapDataDAO.selectByExampleWithBLOBs(example).get(0);
MapGraphDataNewVO data = JsonUtils.read(map.getGraphData(), MapGraphDataNewVO.class);
for (MapSectionNewVO section : data.getSectionList()) {
if (section.getLengthFact() != null && section.getLengthFact() != 0) {
section.setLengthFact(section.getLengthFact() * multiple);
}
}
map.setGraphData(JsonUtils.writeValueAsString(data));
mapDataDAO.updateByPrimaryKeyWithBLOBs(map);
}
}

View File

@ -248,15 +248,22 @@ public class ATSMessageCollectAndDispatcher {
* 仿真设备操作消息
*/
public void handlerOperateMessage(Simulation simulation, OperationMessage operationMessage) {
SocketMessageVO<OperationMessage> socketMessageVO =
SocketMessageFactory.build(WebSocketMessageType.Simulation_ApplyHandle, simulation.getId(), operationMessage);
Set<SimulationMember> humanMembers = operationMessage.getTargetMembers().stream().filter(m -> !m.isRobot()).collect(Collectors.toSet());
//当在场景实训设计中并且无真人成员时将数据暂存等待后续角色有人扮演时再发送
if (simulation.isInSceneTraining() && CollectionUtils.isEmpty(humanMembers)) {
for (SimulationMember targetMember : operationMessage.getTargetMembers()) {
targetMember.getUnreceivedMessages().offer(socketMessageVO);
}
return;
}
if (CollectionUtils.isEmpty(humanMembers)) {
//目标都是机器人选择一个机器人发送事件处理
applicationContext.publishEvent(new SimulationOperationMessageEvent(this, simulation, operationMessage));
return;
}
//目标成员有真人推送对应真人处理
SocketMessageVO<OperationMessage> socketMessageVO =
SocketMessageFactory.build(WebSocketMessageType.Simulation_ApplyHandle, simulation.getId(), operationMessage);
stompMessageService.sendToUser(humanMembers.stream().map(SimulationMember::getUserId).collect(Collectors.toSet()), socketMessageVO);
}

View File

@ -16,6 +16,7 @@ import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.vo.ControlModelApplyResult;
import club.joylink.rtss.vo.client.SocketMessageVO;
import club.joylink.rtss.vo.client.WebSocketMessageType;
import club.joylink.rtss.vo.client.factory.SocketMessageFactory;
@ -27,7 +28,6 @@ import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDateTime;
import java.time.LocalTime;
import java.util.*;
import java.util.stream.Collectors;
@ -110,7 +110,7 @@ public class AtsStationService {
*/
private void controlTransfer(Simulation simulation, SimulationMember fromMember, List<String> stationCodes, Station.ControlMode controlMode) {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "请求控的车站列表不能为空");
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "请求制权转换的车站列表不能为空");
}
for (String stationCode : stationCodes) {
Station station = simulation.getRepository().getByCode(stationCode, Station.class);
@ -126,12 +126,15 @@ public class AtsStationService {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "强制站控的车站不能为空");
}
List<ControlModelApplyResult> results = new ArrayList<>();
stationCodes.forEach(stationCode -> {
Station station = getStation(simulation, stationCode);
station.setControlMode(Station.ControlMode.Local);
results.add(new ControlModelApplyResult(stationCode, ControlModelApplyResult.Application.FORCE_LOCAL, true));
});
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, new OperationMessage(fromMember.getId(), new HashSet<>(Collections.singleton(fromMember)), Operation.Type.CM_Reply_Station_Control, null, true, stationCodes));
sendControlModelApplyResult(simulation, fromMember, results);
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, new OperationMessage(fromMember.getId(),
new HashSet<>(Collections.singleton(fromMember)), Operation.Type.CM_Reply_Station_Control, null, true, stationCodes));
}
@ -144,12 +147,15 @@ public class AtsStationService {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "紧急站控的车站不能为空");
}
List<ControlModelApplyResult> results = new ArrayList<>();
stationCodes.forEach(stationCode -> {
Station station = getStation(simulation, stationCode);
station.setControlMode(Station.ControlMode.Emergency);
results.add(new ControlModelApplyResult(stationCode, ControlModelApplyResult.Application.EMERGENCY_LOCAL, true));
});
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, new OperationMessage(fromMember.getId(), new HashSet<>(Collections.singleton(fromMember)), Operation.Type.CM_Reply_Station_Control, null, true, stationCodes));
sendControlModelApplyResult(simulation, fromMember, results);
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, new OperationMessage(fromMember.getId(),
new HashSet<>(Collections.singleton(fromMember)), Operation.Type.CM_Reply_Station_Control, null, true, stationCodes));
}
/**
@ -159,12 +165,15 @@ public class AtsStationService {
if (CollectionUtils.isEmpty(stationCodes)) {
throw new SimulationException(SimulationExceptionType.Operation_Handle_FAIL, "连锁控的车站不能为空");
}
List<ControlModelApplyResult> results = new ArrayList<>();
stationCodes.forEach(stationCode -> {
Station station = getStation(simulation, stationCode);
station.setControlMode(Station.ControlMode.Interlock);
results.add(new ControlModelApplyResult(stationCode, ControlModelApplyResult.Application.INTERLOCK, true));
});
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, new OperationMessage(fromMember.getId(), new HashSet<>(Collections.singleton(fromMember)), Operation.Type.CM_Reply_Interlock_Control, null, true, stationCodes));
sendControlModelApplyResult(simulation, fromMember, results);
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation, new OperationMessage(fromMember.getId(),
new HashSet<>(Collections.singleton(fromMember)), Operation.Type.CM_Reply_Interlock_Control, null, true, stationCodes));
}
/**
@ -189,25 +198,34 @@ public class AtsStationService {
throw new SimulationException(SimulationExceptionType.Invalid_Operation, "回复结果列表不能为空");
}
List<String> stationCodes = new ArrayList<>(replyVOList.size());
SimulationMember simulationMember = null;
SimulationMember applicant = null;
boolean replyResult = false;
List<ControlModelApplyResult> results = new ArrayList<>();
for (ControlTransferReplyVO reply : replyVOList) {
Station station = simulation.getRepository().getByCode(reply.getStationCode(), Station.class);
if (station.isControlTransferApplying()) {
if (Station.ControlMode.Center.equals(controlMode)) {
results.add(new ControlModelApplyResult(station.getCode(), ControlModelApplyResult.Application.CENTER, reply.isAgree()));
} else {
results.add(new ControlModelApplyResult(station.getCode(), ControlModelApplyResult.Application.LOCAL, reply.isAgree()));
}
if (reply.isAgree()) {
station.setControlMode(controlMode);
}
if (!Station.ControlMode.Center.equals(controlMode)) {
simulationMember = station.getApplicant();
applicant = station.getApplicant();
replyResult = reply.isAgree();
stationCodes.add(station.getCode());
}
station.cancelControlTransferApplication();
}
}
if (applicant != null) {
sendControlModelApplyResult(simulation, applicant, results);
}
if (!CollectionUtils.isEmpty(stationCodes)) {
atsMessageCollectAndDispatcher.handlerOperateMessage(simulation,
new OperationMessage(simulationMember.getId(), new HashSet<>(Collections.singleton(simulationMember)),
new OperationMessage(applicant.getId(), new HashSet<>(Collections.singleton(applicant)),
Operation.Type.CM_Reply_Station_Control, null, replyResult, stationCodes));
}
}
@ -574,7 +592,8 @@ public class AtsStationService {
/**
* 车站状态选择切换
* @param simulation 仿真实体
*
* @param simulation 仿真实体
* @param routeSetModeParams 转换参数
*/
public void switchRouteSetModel(Simulation simulation, List<RouteModelParam> routeSetModeParams) {
@ -601,9 +620,10 @@ public class AtsStationService {
/**
* 车站在分散自律时操作模式转换
*
* @param simulation 仿真
* @param fromMember 操作角色
* @param params 转换参数
* @param params 转换参数
*/
public void controlOperationModeSwitch(Simulation simulation, SimulationMember fromMember, List<OperationModeParam> params) {
List<String> logList = new ArrayList<>(params.size());
@ -644,8 +664,8 @@ public class AtsStationService {
/**
* 分散自律同意不同意转换模式操作
*
* @param simulation 仿真
* @param agreeStationCodes 同意车站编码
* @param simulation 仿真
* @param agreeStationCodes 同意车站编码
* @param noAgreeStationCodes 不同意车站编码
*/
public void handleOperationModelApply(Simulation simulation, List<String> agreeStationCodes, List<String> noAgreeStationCodes) {
@ -664,15 +684,16 @@ public class AtsStationService {
/**
* 发送申请转换操作模式申请
*
* @param simulation
*/
public void replyOperationMode(Simulation simulation) {
List<Station> stationList = simulation.getRepository().getStationList();
// 需要给用户发送的申请列表
Map<String, List<Map<String,Object>>> userMessageMap = new HashMap<>(stationList.size());
Map<String, List<Map<String, Object>>> userMessageMap = new HashMap<>(stationList.size());
stationList.stream().filter(station -> {
Station.OperationModeApplication modeApplication = station.getOperationModeApplication();
if (modeApplication== null) {
if (modeApplication == null) {
return false;
}
if (CollectionUtils.isEmpty(modeApplication.getApprovalMember())) {
@ -720,4 +741,18 @@ public class AtsStationService {
station.setOperationModeApplication(null);
}
}
/**
* 发送控制模式申请结果
*/
private void sendControlModelApplyResult(Simulation sim, SimulationMember applier, List<ControlModelApplyResult> results) {
SocketMessageVO<List<ControlModelApplyResult>> message = SocketMessageFactory.buildControlModelApplyResultMessage(sim.getId(), results);
if (!applier.isRobot()) {
stompMessageService.sendToUser(applier.getUserId(), message);
return;
}
if (sim.isInSceneTraining() && applier.isRobot()) {
applier.getUnreceivedMessages().offer(message);
}
}
}

View File

@ -40,6 +40,7 @@ import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.time.LocalDate;
import java.time.LocalDateTime;
@ -812,6 +813,11 @@ public class Simulation extends club.joylink.rtss.simulation.Simulation<Simulati
return mapFunctionVO == null ? null : mapFunctionVO.getId();
}
public boolean isInSceneTraining() {
return training2 != null && training2.isScene() && StringUtils.hasText(training2.getBgSceneJson())
&& !training2.isRunning();
}
public interface JobName {
String script = "Script";
String checkLpf = "checkLpf";

View File

@ -83,4 +83,6 @@ public interface SimulationService {
List<SimulationInfoVO> listSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO);
PageVO<SimulationInfoVO> pagedSimulationByOrg(Long topOrgId, SimulationInfoQueryVO queryVO);
void sendUnreceivedMessages(String simulationId, String memberId);
}

View File

@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.discriminate.VoiceDiscriminateRule;
import club.joylink.rtss.simulation.cbtc.event.SimulationCreateSuccessEvent;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.simulation.cbtc.work.SimulationWorkService;
@ -422,4 +423,17 @@ public class SimulationServiceImpl implements SimulationService {
List<SimulationInfoVO> collect = stream.skip(skipNum).limit(queryVO.getPageSize()).collect(Collectors.toList());
return new PageVO<>(queryVO.getPageNum(), queryVO.getPageSize(), list.size(), collect);
}
@Override
public void sendUnreceivedMessages(String simulationId, String memberId) {
Simulation simulation = simulationManager.getById(simulationId, Simulation.class);
SimulationMember member = simulation.getSimulationMemberById(memberId);
while (true) {
SocketMessageVO<?> message = member.getUnreceivedMessages().poll();
if (message == null) {
break;
}
stompMessageService.sendToUser(member.getUserId(), message);
}
}
}

View File

@ -7,7 +7,6 @@ import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.support.StationTurnBackStrategyOption;
import club.joylink.rtss.simulation.cbtc.data.vr.*;
import club.joylink.rtss.vo.map.MapCISwitchVO;
import club.joylink.rtss.vo.map.MapGraphDataNewVO;
import club.joylink.rtss.vo.map.MapVO;
import club.joylink.rtss.vo.map.RealLineConfigVO;
@ -1077,16 +1076,16 @@ public class MapDeviceBuilder {
if (Objects.equals(sectionVO.getType(), BusinessConsts.Section.SectionType.Type02)) { // 逻辑区段
Float startOffset = sectionVO.getLogicSectionStartOffset();
Float endOffset = sectionVO.getLogicSectionEndOffset();
section.setLen(sectionVO.getLengthFact());
if ((Objects.isNull(sectionVO.getLengthFact()) || sectionVO.getLengthFact() <= 0) &&
if ((Objects.isNull(sectionVO.getLengthFact()) || sectionVO.getLengthFact() <= 0) ||
(Objects.isNull(startOffset) || Objects.isNull(endOffset))) {
errMsgList.add(String.format("逻辑区段[%s(%s)]既没有设置实际长度且所在物理区段起始/终止偏移量也未设置",
errMsgList.add(String.format("逻辑区段[%s(%s)]没有设置实际长度或所在物理区段起始/终止偏移量未设置",
section.getName(), section.getCode()));
} else {
float max = Math.max(startOffset, endOffset);
float min = Math.min(startOffset, endOffset);
section.setMaxOffset(max);
section.setMinOffset(min);
section.setLen(sectionVO.getLengthFact());
}
}
// 所属设备集中站

View File

@ -316,7 +316,7 @@ public class Stand extends MayOutOfOrderDevice {
}
public String debugStr() {
return String.format("%s-%s-%s(%s)", this.station.getName(),
return String.format("%s-%s-%s(%s)", station == null ? null : station.getName(),
this.isRight() ? "右行" : "左行", this.getName(), this.getCode());
}

View File

@ -0,0 +1,32 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
@Getter
public class SandTableSectionConfig extends RealDeviceConfig {
private SandTableSectionConfigVO configVO;
/**
* 连续无占用次数
*/
@Setter
private int timesOfRelease;
public SandTableSectionConfig(ProjectDeviceVO projectDevice) {
super(projectDevice);
if (Objects.nonNull(projectDevice.getConfig())) {
this.configVO = JsonUtils.read(projectDevice.getConfig(), SandTableSectionConfigVO.class);
}
}
@Override
public String findDeviceCode() {
return configVO.findDeviceCode();
}
}

View File

@ -0,0 +1,39 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SandTableSectionConfigVO extends RealConfigVO {
private String vrCode;
private String sandboxCode;
/**
* 车头到达区段延迟停车时间/s
*/
private Float headDelayTime;
/**
* 车尾解除占用延迟停车时间/s
*/
private Float tailDelayTime;
public SandTableSectionConfigVO() {
super(null, null);
}
public SandTableSectionConfigVO(String vrCode, String sandboxCode) {
this();
this.vrCode = vrCode;
this.sandboxCode = sandboxCode;
}
@Override
public String findDeviceCode() {
return vrCode;
}
}

View File

@ -0,0 +1,30 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
@Getter
public class SandTableSignalConfig extends RealDeviceConfig {
private SandTableSignalConfigVO configVO;
@Setter
private SignalAspect aspect;
public SandTableSignalConfig(ProjectDeviceVO projectDevice) {
super(projectDevice);
if (Objects.nonNull(projectDevice.getConfig())) {
this.configVO = JsonUtils.read(projectDevice.getConfig(), SandTableSignalConfigVO.class);
}
}
@Override
public String findDeviceCode() {
return configVO.findDeviceCode();
}
}

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SandTableSignalConfigVO extends RealConfigVO {
private String vrCode;
private String sandboxCode;
public SandTableSignalConfigVO() {
super(null, null);
}
public SandTableSignalConfigVO(String vrCode, String sandboxCode) {
this();
this.vrCode = vrCode;
this.sandboxCode = sandboxCode;
}
@Override
public String findDeviceCode() {
return vrCode;
}
}

View File

@ -0,0 +1,30 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
@Getter
public class SandTableSwitchConfig extends RealDeviceConfig {
private SandTableSwitchConfigVO configVO;
@Setter
private SwitchIndication p;
public SandTableSwitchConfig(ProjectDeviceVO projectDevice) {
super(projectDevice);
if (Objects.nonNull(projectDevice.getConfig())) {
this.configVO = JsonUtils.read(projectDevice.getConfig(), SandTableSwitchConfigVO.class);
}
}
@Override
public String findDeviceCode() {
return configVO.findDeviceCode();
}
}

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SandTableSwitchConfigVO extends RealConfigVO {
private String vrCode;
private String sandboxCode;
public SandTableSwitchConfigVO() {
super(null, null);
}
public SandTableSwitchConfigVO(String vrCode, String sandboxCode) {
this();
this.vrCode = vrCode;
this.sandboxCode = sandboxCode;
}
@Override
public String findDeviceCode() {
return vrCode;
}
}

View File

@ -0,0 +1,57 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.client.project.ProjectDeviceVO;
import java.time.LocalDateTime;
import java.util.Objects;
import lombok.Getter;
import lombok.Setter;
@Getter
public class SandTableTrainConfig extends RealDeviceConfig {
private SandTableTrainConfigVO configVO;
@Setter
private Integer gear;
/**
* 列车需要在这个轨道停车
*/
private Section headSection;
/**
* 列车抵达停车点的时间
* <p>
* 当走到这个时间时需要将列车的车头位置更新至当前区段的停车点
* <p>
* 上述停车点指代一切可能需要停车的位置比如站台轨的停车点信号机2m前轨道尽头10m前
*/
@Setter
private LocalDateTime timeOfArriveStopPoint;
/**
* 人为驾驶的档位
*/
@Setter
private Integer manualGear;
public void updateHeadSection(Section headSection) {
this.headSection = headSection;
this.timeOfArriveStopPoint = null;
}
public SandTableTrainConfig(ProjectDeviceVO projectDevice) {
super(projectDevice);
if (Objects.nonNull(projectDevice.getConfig())) {
this.configVO = JsonUtils.read(projectDevice.getConfig(), SandTableTrainConfigVO.class);
}
}
@Override
public String findDeviceCode() {
return configVO.findDeviceCode();
}
}

View File

@ -0,0 +1,29 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.config;
import club.joylink.rtss.vo.client.project.RealConfigVO;
import lombok.Getter;
import lombok.Setter;
@Getter
@Setter
public class SandTableTrainConfigVO extends RealConfigVO {
private String vrCode;
private String sandboxCode;
public SandTableTrainConfigVO() {
super(null, null);
}
public SandTableTrainConfigVO(String vrCode, String sandboxCode) {
this();
this.vrCode = vrCode;
this.sandboxCode = sandboxCode;
}
@Override
public String findDeviceCode() {
return vrCode;
}
}

View File

@ -0,0 +1,83 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.ngy.service;
import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClientConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSectionConfig;
import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.HashMap;
import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class NgySectionServiceImpl implements UDPRealDeviceService {
private Map<VirtualRealityTrain, LocalDateTime> map = new HashMap<>();
@Override
public boolean isMatch(RealDeviceConfig realDevice) {
return (realDevice instanceof UDPClientConfig || realDevice instanceof SandTableSectionConfig)
&& ProjectCode.NGY_SAND_TABLE.equals(realDevice.getProject());
}
@Override
public void run(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
}
@Override
public void init(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
map.clear();
}
@Override
public void handle(Simulation simulation, ByteBuf msg) {
//检查数据
byte[] data = new byte[msg.readableBytes()];
if (data.length < 4) {
return;
}
msg.readBytes(data);
if (Byte.toUnsignedInt(data[1]) != 137) {
return;
}
//处理数据
Map<String, SandTableSectionConfig> configMap = simulation.queryAllRealDevice(
ProjectDeviceType.SECTION).stream()
.map(config -> (SandTableSectionConfig) config)
.collect(
Collectors.toMap(config -> config.getConfigVO().getSandboxCode(), Function.identity()));
for (int i = 3, dataLength = data.length; i < dataLength; i += 2) {
int code = Byte.toUnsignedInt(data[i - 1]);
String key = String.valueOf(code);
SandTableSectionConfig config = configMap.get(key);
if (config == null) {
continue;
}
VirtualRealitySectionAxleCounter axle = (VirtualRealitySectionAxleCounter) config.getMapElement();
if (axle != null) {
int n = Byte.toUnsignedInt(data[i]);
if (n == 170) {
config.setTimesOfRelease(0);
axle.setOccupy(true);
} else if (n == 85) {
// config.setTimesOfRelease(config.getTimesOfRelease() + 1);
// if (config.getTimesOfRelease() > 2) { //连续3次该计轴都是无占用状态才视为确实无占用
config.setTimesOfRelease(0);
axle.clear();
// }
}
}
}
}
}

View File

@ -0,0 +1,141 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.ngy.service;
import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SignalAspect;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClient;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSignalConfig;
import io.netty.buffer.ByteBuf;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class NgySignalServiceImpl implements UDPRealDeviceService {
public static final String NAME = "SIGNAL";
@Autowired
private UDPClient udpClient;
@Override
public boolean isMatch(UDPLowConfig udpLowConfig) {
return NAME.equals(udpLowConfig.getName());
}
@Override
public boolean isMatch(RealDeviceConfig realDevice) {
return realDevice instanceof SandTableSignalConfig &&
ProjectCode.NGY_SAND_TABLE.equals(realDevice.getProject());
}
@Override
public void run(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
SandTableSignalConfig config = (SandTableSignalConfig) realDevice;
//控制vr设备
VirtualRealitySignal vrSignal = (VirtualRealitySignal) realDevice.getMapElement();
SignalAspect aspect = vrSignal.getAspect();
SignalAspect command = vrSignal.getCommand();
if (Objects.equals(aspect, command)) {
return;
}
if (vrSignal.isTurning()) {
vrSignal.turning(SimulationConstants.VRD_LOOP_RATE);
}
//控制沙盘设备
aspect = vrSignal.getAspect();
if (aspect == null || udpLowConfig == null || Objects.equals(aspect, config.getAspect())) {
return;
}
byte[] data = buildData(aspect, config);
if (data == null) {
return;
}
udpClient.write(udpLowConfig.getAddr(), data);
}
@Override
public void init(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
}
@Override
public void handle(Simulation simulation, ByteBuf msg) {
}
private byte[] buildData(SignalAspect aspect, SandTableSignalConfig config) {
if (aspect == null) {
return null;
}
config.setAspect(aspect);
byte[] data = new byte[5];
data[1] = (byte) 203;
data[2] = (byte) Integer.parseInt(config.getConfigVO().getSandboxCode());
switch (aspect) {
case No:
case R:
case RF:
data[3] = (byte) 0;
break;
case G:
case GF:
data[3] = (byte) 1;
break;
case Y:
case YF:
data[3] = (byte) 2;
break;
case W:
case WF:
data[3] = (byte) 6;
break;
case B:
data[3] = (byte) 7;
break;
case GG:
data[3] = (byte) 5;
break;
case GY:
data[3] = (byte) 4;
break;
case YY:
data[3] = (byte) 3;
break;
case RY:
case RW:
return null;
default:
return null;
}
switch (aspect) {
case No:
case R:
case G:
case Y:
case W:
case B:
case RY:
case RW:
case GG:
case GY:
case YY:
data[4] = (byte) 0;
break;
case RF:
case YF:
case GF:
case WF:
data[4] = (byte) 1;
break;
default:
throw new IllegalStateException("Unexpected value: " + aspect);
}
return data;
}
}

View File

@ -0,0 +1,90 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.ngy.service;
import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SwitchIndication;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySwitch;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClient;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSwitchConfig;
import io.netty.buffer.ByteBuf;
import java.util.Objects;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Service
public class NgySwitchServiceImpl implements UDPRealDeviceService {
public static final String NAME = "SWITCH-TRAIN";
@Autowired
private UDPClient udpClient;
@Override
public boolean isMatch(UDPLowConfig udpLowConfig) {
return NAME.equals(udpLowConfig.getName());
}
@Override
public boolean isMatch(RealDeviceConfig realDevice) {
return realDevice instanceof SandTableSwitchConfig &&
ProjectCode.NGY_SAND_TABLE.equals(realDevice.getProject());
}
@Override
public void run(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
SandTableSwitchConfig config = (SandTableSwitchConfig) realDevice;
//控制vr设备
VirtualRealitySwitch vrSwitch = (VirtualRealitySwitch) realDevice.getMapElement();
if (vrSwitch.isTurning()) {
vrSwitch.turning(SimulationConstants.VRD_LOOP_RATE);
}
//控制沙盘设备
SwitchIndication p = vrSwitch.getP();
if (p == null || udpLowConfig == null || Objects.equals(p, config.getP())) {
return;
}
byte[] data = buildData(p, config);
if (data == null) {
return;
}
udpClient.write(udpLowConfig.getAddr(), data);
}
@Override
public void init(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
}
@Override
public void handle(Simulation simulation, ByteBuf msg) {
}
private byte[] buildData(SwitchIndication p, SandTableSwitchConfig config) {
if (p == null) {
return null;
}
config.setP(p);
byte[] data = new byte[4];
data[1] = (byte) 208;
data[2] = (byte) Integer.parseInt(config.getConfigVO().getSandboxCode());
switch (p) {
case N:
data[3] = (byte) 0;
break;
case R:
data[3] = (byte) 1;
break;
case NO:
case EX:
return null;
default:
throw new IllegalStateException("Unexpected value: " + p);
}
return data;
}
}

View File

@ -0,0 +1,399 @@
package club.joylink.rtss.simulation.cbtc.device.real.udp.ngy.service;
import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService;
import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPClient;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPLowConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.UDPRealDeviceService;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableSectionConfig;
import club.joylink.rtss.simulation.cbtc.device.real.udp.config.SandTableTrainConfig;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.robot.SimulationRobotService;
import club.joylink.rtss.vo.client.project.thailand.ThailandSectionConfigVO;
import io.netty.buffer.ByteBuf;
import java.time.LocalDateTime;
import java.util.Objects;
import java.util.Optional;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class NgyTrainServiceImpl implements UDPRealDeviceService {
public static final String NAME = NgySwitchServiceImpl.NAME;
@Autowired
private UDPClient udpClient;
@Autowired
private ATPService atpService;
@Autowired
private GroupSimulationService groupSimulationService;
@Autowired
private AtsTrainLoadService atsTrainLoadService;
@Autowired
private SimulationRobotService simulationRobotService;
@Autowired
private CiLogic ciLogic;
@Override
public boolean isMatch(UDPLowConfig udpLowConfig) {
return NAME.equals(udpLowConfig.getName());
}
@Override
public boolean isMatch(RealDeviceConfig realDevice) {
return realDevice instanceof SandTableTrainConfig &&
ProjectCode.NGY_SAND_TABLE.equals(realDevice.getProject());
}
@Override
public void run(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
SandTableTrainConfig config = (SandTableTrainConfig) realDevice;
//控制vr设备
VirtualRealityTrain train = (VirtualRealityTrain) config.getMapElement();
SimulationDataRepository repository = simulation.getRepository();
String groupNumber = train.getGroupNumber();
if (repository.isVrTrainOnline(groupNumber)) {
removeVrTrainIfNotSupervised(repository, groupNumber);
if (!train.isRobotStopControl() && config.getManualGear() != null) {
config.setManualGear(null);
config.setGear(null);
}
updateTrainPositionAndSpeed(simulation, train, config);
//减少关门后的延迟发车时间
if (train.getDelayTime() > 3000) {
train.setDelayTime(3000);
}
//控制沙盘设备
byte[] data = buildData(train, config);
udpClient.write(udpLowConfig.getAddr(), data);
} else {
addVrTrainIfSupervised(simulation, repository, groupNumber);
}
}
@Override
public void init(Simulation simulation, UDPLowConfig udpLowConfig, RealDeviceConfig realDevice) {
SandTableTrainConfig config = (SandTableTrainConfig) realDevice;
//控制vr设备
VirtualRealityTrain train = (VirtualRealityTrain) config.getMapElement();
//控制沙盘设备
byte[] data = buildData(train, config);
udpClient.write(udpLowConfig.getAddr(), data);
//清除状态
config.updateHeadSection(null);
}
@Override
public void handle(Simulation simulation, ByteBuf msg) {
}
/**
* 更新列车位置
* <p>
* 1.如果列车占压新的区段则先将列车车头位置更新至该区段的停车点之前保证列车可以继续运行 2.根据区段的配置信息决定列车何时将车头位置更新至停车点
* 3.根据上一步设置的停车时间判断执行更新车头位置至停车点逻辑触发列车停车逻辑
*/
private void updateTrainPositionAndSpeed(Simulation simulation, VirtualRealityTrain train,
SandTableTrainConfig config) {
//判断列车是否到达新区段
boolean right = train.isRight(); //车头方向
Section headSection = train.getHeadPosition().getSection(); //车头区段
Section previousSection = null; //车头方向的上一个区段
Section nextSection = headSection.getNextRunningSectionOf(right); //车头方向的下一个区段
SandTableSectionConfig sectionConfig = (SandTableSectionConfig) headSection.findAxle()
.getRealDevice(); //车头区段的配置
if (nextSection != null) {
boolean notSwitchTrack = !nextSection.isSwitchTrack();
boolean isSwitchRelSections =
nextSection.isSwitchTrack() && nextSection.getRelSwitch().getSectionsByPosition()
.contains(nextSection);
if (notSwitchTrack || isSwitchRelSections) {
VirtualRealitySectionAxleCounter nextAxle = nextSection.findAxle();
if (nextAxle.isOccupy()) {
train.setHeadPosition(
new SectionPosition(nextSection, right ? 0 : nextSection.getMaxOffset()));
config.setTimeOfArriveStopPoint(null);
sectionConfig = (SandTableSectionConfig) nextAxle.getRealDevice();
//更新变量
previousSection = headSection;
headSection = train.getHeadPosition().getSection();
nextSection = null;
}
}
}
//如果列车车头在进路首个区段进路开始解锁
//加此逻辑是因为有些进路首区段太短偶尔会出现前两个区段同时占压导致无法正常解锁
Route route = headSection.getRoute();
if (headSection.isLocked() && route != null) {
if (route.getFirstPhysicalSection().equals(headSection)) {
ciLogic.trainUnlockStart(simulation, route);
}
}
//根据区段的配置信息设置车头位置更新至停车点的时间
// fill(headSection, sectionConfig.getConfigVO());
LocalDateTime now = LocalDateTime.now();
if (config.getTimeOfArriveStopPoint() == null) {
int rate = 1000000000; //秒到纳秒的换算比例
Long delayOfNano = null; //延迟时间的纳秒表示
if (sectionConfig.getConfigVO().getHeadDelayTime() != null) { //车头占压延时停车
delayOfNano = (long) (sectionConfig.getConfigVO().getHeadDelayTime() * rate);
} else if (sectionConfig.getConfigVO().getTailDelayTime() != null) { //车尾出清延时停车
if (previousSection == null) {
previousSection = headSection.getNextRunningSectionOf(!right);
}
if (previousSection != null && !previousSection.isOccupied()) {
delayOfNano = (long) (sectionConfig.getConfigVO().getTailDelayTime() * rate);
}
} else { //未设置则认为车头占压即刻停车
delayOfNano = 0L;
}
if (delayOfNano != null) {
config.setTimeOfArriveStopPoint(now.plusNanos(delayOfNano));
}
}
//根据当前时间判断更新车头位置至停车点
LocalDateTime timeOfArriveStopPoint = config.getTimeOfArriveStopPoint();
Optional<SectionPosition> stopPositionOptional = simulationRobotService.calculateTargetPosition(
simulation, train);
SectionPosition stopPosition = stopPositionOptional.orElse(null);
if (timeOfArriveStopPoint != null && !now.isBefore(timeOfArriveStopPoint)) {
if (stopPosition != null && stopPosition.getSection().equals(headSection)) {
train.setHeadPosition(stopPosition);
} else {
float offset = right ? headSection.getMaxOffset() : 0;
train.setHeadPosition(new SectionPosition(headSection, offset));
}
}
//更新速度由于沙盘对延时要求很高机器人驾驶逻辑频率有点低所以选择不利用机器人驾驶的逻辑
if (config.getManualGear() != null) {
return;
}
if (train.isStop() && headSection.isStandTrack()) {
if (headSection.getStandList().stream().anyMatch(stand -> stand.getRemainTime() > 0)) {
//此处自行控制停站时间以确保用户的感知和设置的一样
return;
}
}
if (stopPosition != null) {
Float distance = CalculateService.calculateDistance(train.getHeadPosition(), stopPosition,
right, false);
if (distance == null || distance <= SimulationConstants.PARK_POINT_MAX_OFFSET) {
train.setSpeed(0);
return;
}
float highSpeed = 20 / 3.6f;
float lowSpeed = 10 / 3.6f;
if (headSection.isStandTrack()) {
train.setSpeed(lowSpeed);
return;
}
if (stopPosition.getSection().isStandTrack()) {
Section stopPreviousSection = stopPosition.getSection().getNextRunningSectionOf(!right);
if (stopPreviousSection != null && Objects.equals(stopPreviousSection.findAxle(),
headSection.findAxle())) { //当前车头在站台轨的前一个计轴区段
train.setSpeed(lowSpeed);
return;
}
}
train.setSpeed(highSpeed);
} else {
train.setSpeed(0);
}
}
/**
* 如果有监控添加一个vrTrain
*/
private void addVrTrainIfSupervised(Simulation simulation, SimulationDataRepository repository,
String groupNumber) {
TrainInfo trainInfo = repository.findSupervisedTrainByGroup(groupNumber);
if (trainInfo != null) {
Section section = repository.getByCode(trainInfo.getSection(), Section.class);
if (section.isSwitchAxleCounterSection()) {
section = section.getLogicList().get(0).getRelSwitch().getA();
}
atsTrainLoadService.loadSpareTrain(simulation, groupNumber, section.getCode(), false);
}
}
/**
* 移除vrTrain如果没有被监控
*/
private void removeVrTrainIfNotSupervised(SimulationDataRepository repository,
String groupNumber) {
TrainInfo trainInfo = repository.findSupervisedTrainByGroup(groupNumber);
if (trainInfo == null) {
repository.deleteOnlineTrain(groupNumber);
}
}
private byte[] buildData(VirtualRealityTrain train, SandTableTrainConfig config) {
int gear;
if (train.isStop()) {
gear = 0;
} else {
float speedKmPh = train.getSpeedKmPh();
if (train.isStop()) {
gear = 0;
} else {
gear = (int) Math.ceil(speedKmPh / 10);
gear = Math.max(1, gear);
}
if (train.isRight()) { //档位1-5是正向6-10是反向
gear += 5;
}
}
if (Objects.equals(config.getGear(), gear)) {
return null;
}
config.setGear(gear);
byte[] data = new byte[4];
data[1] = (byte) 1;
data[2] = (byte) Integer.parseInt(config.getConfigVO().getSandboxCode());
data[3] = (byte) gear;
return data;
}
/**
* 此方法用于调试调试完成后方法内的数据请保存到项目设备配置
*/
public void fill(Section section, ThailandSectionConfigVO configVO) {
Float headDelayTime = null;
Float tailDelayTime = null;
if (section.isStandTrack()) { //站台轨默认为车尾出清立即停车
headDelayTime = 5f;
}
switch (section.getCode()) {
case "T233": //X302G
headDelayTime = 7.3f;
break;
case "T232": //X303G
headDelayTime = 6.5f;
break;
case "T231": //X304G
headDelayTime = 5.5f;
break;
case "T178": //4站-3G
headDelayTime = 5.2f;
break;
case "T177": //4站-IG
headDelayTime = 5.4f;
break;
case "T175": //4站-IIG
headDelayTime = 6.6f;
break;
case "T174": //4站-4G
headDelayTime = 6.2f;
break;
case "T176": //4站-6G
headDelayTime = 5.9f;
break;
case "T179": //4站-5G
headDelayTime = 6.5f;
break;
case "T123": //3站-3G
headDelayTime = 5.2f;
break;
case "T122": //3站-IG
headDelayTime = 5.3f;
break;
case "T121": //3站-IIG
headDelayTime = 5.9f;
break;
case "T120": //3站-4G
headDelayTime = 5.5f;
break;
case "T78": //2站-IG
headDelayTime = 5.5f;
break;
case "T77": //2站-IIG
headDelayTime = 5.9f;
break;
case "T76": //2站-4G
headDelayTime = 5.7f;
break;
case "T22": //1站-1G
headDelayTime = 5.3f;
break;
case "T23": //1站-IIG
headDelayTime = 5.1f;
break;
case "T27": //1站-5G
headDelayTime = 4.9f;
break;
case "T26": //1站-3G
headDelayTime = 4.8f;
break;
case "T24": //1站-4G
headDelayTime = 5.1f;
break;
case "T25": //1站-6G
headDelayTime = 5.1f;
break;
case "T145": //QX04
headDelayTime = 1.9f;
break;
case "T146": //QS04
headDelayTime = 2.7f;
break;
case "T104": //QX03
tailDelayTime = 0f;
break;
case "T105": //QS03
tailDelayTime = 0f;
break;
case "T62": //QX02
tailDelayTime = 0f;
break;
case "T63": //QS02
tailDelayTime = 0f;
break;
}
configVO.setHeadDelayTime(headDelayTime);
configVO.setTailDelayTime(tailDelayTime);
}
public void controlTrain(String simulationId, String groupNumber, boolean right, int speed) {
Simulation simulation = groupSimulationService.getSimulationByGroup(simulationId);
VirtualRealityTrain train = simulation.getRepository().getOnlineTrainBy(groupNumber);
SandTableTrainConfig config = (SandTableTrainConfig) train.getRealDevice();
if (right != train.isRight()) { //调头
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED
.assertTrue(train.getSpeed() == 0, "换端需先停车");
atpService.turnDirectionImmediately(train);
}
train.setRobotTargetPosition(null); //终止机器人司机驾驶
//加减速
if (train.isEB()) {
return;
}
atpService.changeGear(train, VirtualRealityTrain.Handwheel.MANUAL);
int manualGear = speed / 10;
config.setManualGear(manualGear);
train.setSpeed(speed / 3.6f);
train.getRobotDriveParam().stopControl();
byte[] data = buildData(train, config);
UDPLowConfig udpLowConfig = (UDPLowConfig) simulation.queryOneRealDevice(
ProjectDeviceType.UDP_LOW);
udpClient.write(udpLowConfig.getAddr(), data);
}
}

View File

@ -2,7 +2,6 @@ package club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.service;
import club.joylink.rtss.constants.ProjectCode;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySectionAxleCounter;
import club.joylink.rtss.simulation.cbtc.device.real.modbustcp.device.RealDeviceConfig;
@ -15,18 +14,12 @@ import java.util.Map;
import java.util.function.Function;
import java.util.stream.Collectors;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
@Slf4j
@Service
public class ThailandSectionServiceImpl implements UDPRealDeviceService {
@Autowired
private MaService maService;
@Autowired
private ThailandTrainServiceImpl thailandTrainService;
@Override
public boolean isMatch(RealDeviceConfig realDevice) {
return realDevice instanceof UDPClientConfig && ProjectCode.THAILAND_SANDBOX
@ -75,11 +68,11 @@ public class ThailandSectionServiceImpl implements UDPRealDeviceService {
config.setTimesOfRelease(0);
axle.setOccupy(true);
} else if (n == 85) {
config.setTimesOfRelease(config.getTimesOfRelease() + 1);
if (config.getTimesOfRelease() > 2) { //连续3次该计轴都是无占用状态才视为确实无占用
config.setTimesOfRelease(0);
axle.clear();
}
// config.setTimesOfRelease(config.getTimesOfRelease() + 1);
// if (config.getTimesOfRelease() > 2) { //连续3次该计轴都是无占用状态才视为确实无占用
config.setTimesOfRelease(0);
axle.clear();
// }
}
}
}

View File

@ -3,11 +3,13 @@ package club.joylink.rtss.simulation.cbtc.device.real.udp.thailand.service;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.exception.BusinessExceptionAssertEnum;
import club.joylink.rtss.simulation.cbtc.ATS.service.AtsTrainLoadService;
import club.joylink.rtss.simulation.cbtc.CI.CiLogic;
import club.joylink.rtss.simulation.cbtc.GroupSimulationService;
import club.joylink.rtss.simulation.cbtc.Simulation;
import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.Route;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
@ -46,6 +48,8 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
private AtsTrainLoadService atsTrainLoadService;
@Autowired
private SimulationRobotService simulationRobotService;
@Autowired
private CiLogic ciLogic;
@Override
public boolean isMatch(UDPLowConfig udpLowConfig) {
@ -111,6 +115,14 @@ public class ThailandTrainServiceImpl implements UDPRealDeviceService {
nextSection = null;
}
}
//如果列车车头在进路首个区段进路开始解锁
//加此逻辑是因为有些进路首区段太短偶尔会出现前两个区段同时占压导致无法正常解锁
Route route = headSection.getRoute();
if (headSection.isLocked() && route != null) {
if (route.getFirstPhysicalSection().equals(headSection)) {
ciLogic.trainUnlockStart(simulation, route);
}
}
//根据区段的配置信息设置车头位置更新至停车点的时间
// fill(headSection, sectionConfig.getConfigVO());
LocalDateTime now = LocalDateTime.now();

View File

@ -12,6 +12,7 @@ import club.joylink.rtss.simulation.cbtc.event.SimulationMemberAddEvent;
import club.joylink.rtss.simulation.cbtc.event.SimulationUserPlayChangeEvent;
import club.joylink.rtss.simulation.cbtc.exception.SimulationException;
import club.joylink.rtss.simulation.cbtc.exception.SimulationExceptionType;
import club.joylink.rtss.websocket.StompMessageService;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.math.NumberUtils;
import org.springframework.beans.factory.annotation.Autowired;
@ -32,6 +33,8 @@ public class MemberManager {
@Autowired
private SimulationManager simulationManager;
@Autowired
private StompMessageService stompMessageService;
/**
* 初始化仿真成员

View File

@ -4,51 +4,20 @@ import club.joylink.rtss.simulation.cbtc.command.CommandBO;
import club.joylink.rtss.simulation.cbtc.data.map.MapElement;
import club.joylink.rtss.simulation.cbtc.data.map.MapNamedElement;
import club.joylink.rtss.simulation.vo.SimulationMemberVO;
import club.joylink.rtss.vo.client.SocketMessageVO;
import lombok.Getter;
import lombok.Setter;
import org.apache.commons.lang3.StringUtils;
import javax.validation.constraints.NotNull;
import java.util.Objects;
import java.util.concurrent.ConcurrentLinkedQueue;
/**
* 仿真成员
*/
@Getter
public class SimulationMember extends club.joylink.rtss.simulation.SimulationMember<SimulationMember.Type> {
// {
// //地铁角色
// Type[] metroTypes = {
// Type.DISPATCHER,
// Type.MAINTAINER,
// Type.STATION_SUPERVISOR,
// Type.DEPOT_DISPATCHER,
// Type.DRIVER,
// Type.ELECTRIC_DISPATCHER,
// Type.PARENT_DEPARTMENT,
// Type.SCHEDULING,
// Type.TRAIN_MASTER,
// Type.SIGNAL_BUILDING
// };
// //大铁角色
// Type[] railTypes = {
// Type.MAINTAINER,
// Type.DRIVER,
// Type.DISPATCHER,
// Type.MAINTAINER,
// Type.STATION_SUPERVISOR,
// Type.STATION_ASSISTANT,
// Type.STATION_MASTER,
// Type.STATION_SIGNALER,
// Type.STATION_PASSENGER,
// Type.STATION_SWITCH_MAN,
// Type.STATION_FACILITATOR,
// Type.STATION_WORKER,
// Type.DEVICE_MANAGER
// };
// }
private String id;
private Type type;
@ -77,6 +46,8 @@ public class SimulationMember extends club.joylink.rtss.simulation.SimulationMem
*/
private Integer departureDelay = 0;
private ConcurrentLinkedQueue<SocketMessageVO<?>> unreceivedMessages = new ConcurrentLinkedQueue<>();
public SimulationMember(String id, Type type, MapElement device) {
this(id, type, device, null);
}
@ -186,7 +157,7 @@ public class SimulationMember extends club.joylink.rtss.simulation.SimulationMem
/**
* 中心调度员
*/
DISPATCHER(Area.OCC, "值班主任"),
DISPATCHER(Area.OCC, "中心调度员"),
/**
* 电力调度
*/
@ -203,6 +174,14 @@ public class SimulationMember extends club.joylink.rtss.simulation.SimulationMem
* 车站值班员
*/
STATION_SUPERVISOR(Area.STATION, "车站值班员"),
/**
* 值班站长
*/
STATION_HEAD(Area.STATION, "值班站长"),
/**
* 站务员
*/
STATION_ATTENDANT(Area.STATION, "站务员"),
/**
* 司机
*/

View File

@ -1,7 +1,5 @@
package club.joylink.rtss.simulation.cbtc.robot;
import static club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed;
import club.joylink.rtss.services.psl.IVirtualRealityPslService;
import club.joylink.rtss.simulation.cbtc.ATP.ground.MaService;
import club.joylink.rtss.simulation.cbtc.ATS.operation.AtsOperationDispatcher;
@ -17,40 +15,27 @@ import club.joylink.rtss.simulation.cbtc.constant.SimulationConstants;
import club.joylink.rtss.simulation.cbtc.constant.SimulationModule;
import club.joylink.rtss.simulation.cbtc.data.CalculateService;
import club.joylink.rtss.simulation.cbtc.data.SimulationDataRepository;
import club.joylink.rtss.simulation.cbtc.data.map.PSD;
import club.joylink.rtss.simulation.cbtc.data.map.Section;
import club.joylink.rtss.simulation.cbtc.data.map.Signal;
import club.joylink.rtss.simulation.cbtc.data.map.Stand;
import club.joylink.rtss.simulation.cbtc.data.map.Station;
import club.joylink.rtss.simulation.cbtc.data.map.*;
import club.joylink.rtss.simulation.cbtc.data.support.SectionPosition;
import club.joylink.rtss.simulation.cbtc.data.vo.ControlTransferReplyVO;
import club.joylink.rtss.simulation.cbtc.data.vo.TrainInfo;
import club.joylink.rtss.simulation.cbtc.data.vr.StandParkedTrainActivity;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityPsl;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityScreenDoor;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealitySignal;
import club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain;
import club.joylink.rtss.simulation.cbtc.data.vr.*;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.SpeedCurve;
import club.joylink.rtss.simulation.cbtc.onboard.ATO.service.ATOService;
import club.joylink.rtss.simulation.cbtc.onboard.ATP.ATPService;
import club.joylink.rtss.simulation.cbtc.training2.Training2;
import club.joylink.rtss.vo.client.operation.DriveParamVO;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Objects;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Collectors;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import org.springframework.util.CollectionUtils;
import org.springframework.util.StringUtils;
import java.util.*;
import java.util.stream.Collectors;
import static club.joylink.rtss.simulation.cbtc.data.vr.VirtualRealityTrain.ConfirmationMessage.Confirm_Release_Speed;
/**
* 仿真机器人逻辑循环
*/
@ -442,9 +427,7 @@ public class SimulationRobotService {
return;
}
// 实训场景模式已设置背景处于编制状态的实训不做自动转换处理
Training2 training2 = simulation.getTraining2();
if (training2 != null && training2.isScene() && StringUtils.hasText(training2.getBgSceneJson())
&& !training2.isRunning()) {
if (simulation.isInSceneTraining()) {
return;
}
Map<SimulationMember, List<Station>> collect = simulation.getRepository().getStationList()

View File

@ -0,0 +1,35 @@
package club.joylink.rtss.simulation.cbtc.vo;
import lombok.AllArgsConstructor;
import lombok.Getter;
/**
* 控制模式转换申请结果
*/
@Getter
@AllArgsConstructor
public class ControlModelApplyResult {
private String stationCode;
private Application application;
private Result result;
public ControlModelApplyResult(String stationCode, Application application, boolean agree) {
this.stationCode = stationCode;
this.application = application;
this.result = agree ? Result.AGREE : Result.REJECT;
}
public enum Application {
LOCAL,
CENTER,
FORCE_LOCAL,
EMERGENCY_LOCAL,
INTERLOCK,
}
public enum Result {
AGREE,
REJECT,
TIMEOUT,
}
}

View File

@ -138,10 +138,6 @@ public enum WebSocketMessageType {
* 仿真-请求处理消息
*/
Simulation_ApplyHandle,
/**
* 仿真-控制权转换申请回复
*/
Simulation_ControlTransfer_Reply,
/**
* 仿真-结束消息
*/
@ -176,6 +172,11 @@ public enum WebSocketMessageType {
*/
Simulation_Conversation_Group,
/**
* 控制模式转换申请的结果
*/
Simulation_Control_Mode_Apply_Result,
//------------------ 仿真剧本 ------------------
/**
* 仿真-剧本已加载

View File

@ -22,6 +22,7 @@ import club.joylink.rtss.simulation.cbtc.data.vo.TrainIsAbout2ArriveVO;
import club.joylink.rtss.simulation.cbtc.member.SimulationMember;
import club.joylink.rtss.simulation.cbtc.member.SimulationUser;
import club.joylink.rtss.simulation.cbtc.message.SimulationSubscribeTopic;
import club.joylink.rtss.simulation.cbtc.vo.ControlModelApplyResult;
import club.joylink.rtss.simulation.cbtc.vo.SimulationWorkParamVO;
import club.joylink.rtss.util.JsonUtils;
import club.joylink.rtss.vo.LoginUserInfoVO;
@ -109,7 +110,8 @@ public class SocketMessageFactory {
case SIMULATION_RAIL_TICKET:
case Simulation_Alarm:
case Simulation_Operation_Mode_Apply:
case Simulation_Conversation_Group: {
case Simulation_Conversation_Group:
case Simulation_Control_Mode_Apply_Result:{
topicList.add(SimulationSubscribeTopic.Main.buildDestination(group));
break;
}
@ -502,4 +504,8 @@ public class SocketMessageFactory {
return build(WebSocketMessageType.SIMULATION_NCC_STATION_DIAGRAM,sId,stationDiagramList);
}
public static SocketMessageVO<List<ControlModelApplyResult>> buildControlModelApplyResultMessage(String sId, List<ControlModelApplyResult> results) {
return build(WebSocketMessageType.Simulation_Control_Mode_Apply_Result, sId, results);
}
}