增加南工院沙盘服务

This commit is contained in:
joylink_zhangsai 2023-08-14 13:11:05 +08:00
parent 813d13d768
commit b4bb689dc5
18 changed files with 1805 additions and 627 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

@ -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

@ -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

@ -67,6 +67,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 +80,9 @@ public class DeviceServiceImpl implements DeviceService {
@Autowired
private IMapService iMapService;
@Autowired
private ProjectService projectService;
// 修改项目编码 20221009
@Override
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
@ -519,6 +523,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 +1103,106 @@ 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);
SrSignalConfigVO configVO = new SrSignalConfigVO(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);
ThailandSwitchConfigVO configVO = new ThailandSwitchConfigVO(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);
ThailandSectionConfigVO configVO = new ThailandSectionConfigVO(mapSectionNewVO.getCode(),
mapSectionNewVO.getSrCode());
section.setConfig(JsonUtils.writeValueAsString(configVO));
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);
ThailandTrainConfigVO configVO = new ThailandTrainConfigVO(mapTrainVO.getGroupNumber(),
String.valueOf(Integer.parseInt(mapTrainVO.getGroupNumber())));
train.setConfig(JsonUtils.writeValueAsString(configVO));
list.add(train);
}
return list;
}
}

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

@ -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);
}
}