Merge branch 'test-training2' of https://git.code.tencent.com/lian-cbtc/rtss-server into test-training2-xzb1

This commit is contained in:
xzb 2022-10-09 18:03:48 +08:00
commit ceadaccb3b
4 changed files with 44 additions and 50 deletions

View File

@ -2,6 +2,7 @@ package club.joylink.rtss.controller.project;
import club.joylink.rtss.constants.ProjectDeviceType;
import club.joylink.rtss.controller.advice.AuthenticateInterceptor;
import club.joylink.rtss.entity.project.Project;
import club.joylink.rtss.services.project.DeviceService;
import club.joylink.rtss.vo.AccountVO;
import club.joylink.rtss.vo.LoginUserInfoVO;
@ -14,7 +15,7 @@ import org.springframework.web.bind.annotation.*;
import java.util.List;
/**
*项目设备管理接口()
* 项目设备管理接口()
*/
@RestController
@RequestMapping(path = "/api/device")
@ -24,27 +25,24 @@ public class DeviceController {
private DeviceService deviceService;
/**
*分页查询项目设备
* 分页查询项目设备
*/
@GetMapping("/paging")
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO userLoginInfo) {
return this.deviceService.pagingQuery(queryVO, userLoginInfo);
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
return this.deviceService.pagingQuery(queryVO);
}
/**
*项目设备编号是否已经存在
* 项目设备编号是否已经存在
*/
@GetMapping("/exist/{code}")
public boolean isDeviceCodeExist(@PathVariable String code,
@RequestAttribute(name = AuthenticateInterceptor.LOGIN_INFO_KEY)
LoginUserInfoVO userLoginInfo) {
return this.deviceService.isDeviceCodeExist(userLoginInfo.getProject(), 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,
@ -54,7 +52,7 @@ public class DeviceController {
}
/**
*获取设备详情包含配置信息
* 获取设备详情包含配置信息
*/
@GetMapping("/{id}")
public ProjectDeviceVO getDeviceDetailInfoById(@PathVariable Long id) {
@ -62,7 +60,7 @@ public class DeviceController {
}
/**
*添加/修改道岔设备网关映射配置
* 添加/修改道岔设备网关映射配置
*/
@PutMapping("/{id}/config/plcgateway")
public void updatePlcGatewayConfig(@PathVariable Long id, @RequestBody @Validated PlcGatewayConfigVO configVO) {
@ -70,7 +68,7 @@ public class DeviceController {
}
/**
*添加/修改道岔设备网关映射配置
* 添加/修改道岔设备网关映射配置
*/
@PutMapping("/{id}/config/switch")
public void updateSwitchConfig(@PathVariable Long id, @RequestBody @Validated SwitchConfigVO configVO) {
@ -78,7 +76,7 @@ public class DeviceController {
}
/**
*添加/修改信号机设备网关映射配置
* 添加/修改信号机设备网关映射配置
*/
@PutMapping("/{id}/config/signal")
public void updateSignalConfig(@PathVariable Long id, @RequestBody @Validated SignalConfigVO configVO) {
@ -86,7 +84,7 @@ public class DeviceController {
}
/**
*添加/修改屏蔽门设备网关映射配置
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psc")
public void updatePscConfig(@PathVariable Long id, @RequestBody @Validated PscConfigVO configVO) {
@ -94,7 +92,7 @@ public class DeviceController {
}
/**
*添加/修改屏蔽门设备网关映射配置
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psd")
public void updatePsdConfig(@PathVariable Long id, @RequestBody @Validated PsdConfigVO configVO) {
@ -102,7 +100,7 @@ public class DeviceController {
}
/**
*添加/修改屏蔽门设备网关映射配置
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/psl")
public void updatePslConfig(@PathVariable Long id, @RequestBody @Validated PslConfigVO configVO) {
@ -110,7 +108,7 @@ public class DeviceController {
}
/**
*添加/修改屏蔽门设备网关映射配置
* 添加/修改屏蔽门设备网关映射配置
*/
@PutMapping("/{id}/config/ibp")
public void updateIbpConfig(@PathVariable Long id, @RequestBody @Validated IbpConfigVO configVO) {
@ -118,7 +116,7 @@ public class DeviceController {
}
/**
*添加/修改虚拟IBP盘配置
* 添加/修改虚拟IBP盘配置
*/
@PutMapping("/{id}/config/vribp")
public void updateVrIbpConfig(@PathVariable Long id, @RequestBody @Validated VrIbpConfigVO configVO) {
@ -126,7 +124,7 @@ public class DeviceController {
}
/**
*添加/修改现地工作站配置
* 添加/修改现地工作站配置
*/
@PutMapping("/{id}/config/lw")
public void updateLwConfig(@PathVariable Long id, @RequestBody @Validated LwConfigVO configVO) {
@ -134,7 +132,7 @@ public class DeviceController {
}
/**
*添加/修改大屏工作站配置
* 添加/修改大屏工作站配置
*/
@PutMapping("/{id}/config/lsw")
public void updateLswConfig(@PathVariable Long id, @RequestBody @Validated LswConfigVO configVO) {
@ -142,7 +140,7 @@ public class DeviceController {
}
/**
*添加/修改CCTV工作站配置
* 添加/修改CCTV工作站配置
*/
@PutMapping("/{id}/config/cctv")
public void updateCctvConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
@ -150,7 +148,7 @@ public class DeviceController {
}
/**
*添加/修改电子沙盘工作站配置
* 添加/修改电子沙盘工作站配置
*/
@PutMapping("/{id}/config/sandbox")
public void updateSandboxConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
@ -158,7 +156,7 @@ public class DeviceController {
}
/**
*添加/修改虚拟屏蔽门工作站配置
* 添加/修改虚拟屏蔽门工作站配置
*/
@PutMapping("/{id}/config/vrpsd")
public void updateVrpsdConfig(@PathVariable Long id, @RequestBody @Validated VrpsdConfigVO configVO) {
@ -166,7 +164,7 @@ public class DeviceController {
}
/**
*添加/修改现地综合监控工作站配置
* 添加/修改现地综合监控工作站配置
*/
@PutMapping("/{id}/config/iscslw")
public void updateIscsLwConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
@ -174,7 +172,7 @@ public class DeviceController {
}
/**
*添加/修改中心综合监控工作站配置
* 添加/修改中心综合监控工作站配置
*/
@PutMapping("/{id}/config/iscscw")
public void updateIscsCwConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
@ -182,7 +180,7 @@ public class DeviceController {
}
/**
*添加/修改联锁工作站配置
* 添加/修改联锁工作站配置
*/
@PutMapping("/{id}/config/ilw")
public void updateIlwConfig(@PathVariable Long id, @RequestBody @Validated RelationLoginConfigVO configVO) {
@ -198,7 +196,7 @@ public class DeviceController {
}
/**
*删除设备
* 删除设备
*/
@DeleteMapping("/{id}")
public void delete(@PathVariable Long id) {
@ -206,7 +204,7 @@ public class DeviceController {
}
/**
*查询某个类型的所有设备
* 查询某个类型的所有设备
*/
@GetMapping("/{type}/all")
public List<ProjectDeviceVO> queryByType(@PathVariable ProjectDeviceType type,

View File

@ -16,7 +16,7 @@ public interface DeviceService {
* @param userLoginInfo
* @return
*/
PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO, LoginUserInfoVO userLoginInfo);
PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO);
/**
* 项目设备编码是否存在

View File

@ -55,13 +55,13 @@ public class DeviceServiceImpl implements DeviceService {
@Autowired
private IMapService iMapService;
// 修改项目编码 20221009
@Override
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO,
LoginUserInfoVO userLoginInfo) {
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
ProjectDeviceExample example = new ProjectDeviceExample();
ProjectDeviceExample.Criteria criteria = example.createCriteria();
if (!Objects.equals(userLoginInfo.getProject(), Project.DEFAULT_PROJECT_CODE)) {
criteria.andProjectCodeEqualTo(userLoginInfo.getProject());
if (StringUtils.hasText(queryVO.getProjectCode())) {
criteria.andProjectCodeEqualTo(queryVO.getProjectCode());
}
if (StringUtils.hasText(queryVO.getCode())) {
criteria.andCodeLike(String.format("%%%s%%", queryVO.getCode()));
@ -77,8 +77,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public boolean isDeviceCodeExist(String project, String code) {
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotEquals(project, Project.DEFAULT_PROJECT_CODE,
String.format("项目[%s]没有权限", project));
ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria().andProjectCodeEqualTo(project).andCodeEqualTo(code);
if (this.projectDeviceDAO.countByExample(example) > 0) {
@ -90,9 +88,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override
public String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo) {
ProjectDevice projectDevice = deviceVO.buildDB();
BusinessExceptionAssertEnum.OPERATION_NOT_SUPPORTED.assertNotEquals(userLoginInfo.getProject(),
Project.DEFAULT_PROJECT_CODE, String.format("项目[%s]无权添加设备", userLoginInfo.getProject()));
projectDevice.setProjectCode(userLoginInfo.getProject());
projectDevice.setCreator(userLoginInfo.getAccountVO().getId());
projectDevice.setCreateTime(LocalDateTime.now());
this.projectDeviceDAO.insert(projectDevice);

View File

@ -284,6 +284,7 @@ public class ProjectDeviceVO {
@JsonIgnore
public ProjectDevice buildDB() {
ProjectDevice device = new ProjectDevice();
device.setProjectCode(this.getProject());
device.setCode(this.getCode());
device.setType(this.getType().name());
return device;