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

View File

@ -16,7 +16,7 @@ public interface DeviceService {
* @param userLoginInfo * @param userLoginInfo
* @return * @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 @Autowired
private IMapService iMapService; private IMapService iMapService;
// 修改项目编码 20221009
@Override @Override
public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO, public PageVO<ProjectDeviceVO> pagingQuery(ProjectDevicePageQueryVO queryVO) {
LoginUserInfoVO userLoginInfo) {
ProjectDeviceExample example = new ProjectDeviceExample(); ProjectDeviceExample example = new ProjectDeviceExample();
ProjectDeviceExample.Criteria criteria = example.createCriteria(); ProjectDeviceExample.Criteria criteria = example.createCriteria();
if (!Objects.equals(userLoginInfo.getProject(), Project.DEFAULT_PROJECT_CODE)) { if (StringUtils.hasText(queryVO.getProjectCode())) {
criteria.andProjectCodeEqualTo(userLoginInfo.getProject()); criteria.andProjectCodeEqualTo(queryVO.getProjectCode());
} }
if (StringUtils.hasText(queryVO.getCode())) { if (StringUtils.hasText(queryVO.getCode())) {
criteria.andCodeLike(String.format("%%%s%%", queryVO.getCode())); criteria.andCodeLike(String.format("%%%s%%", queryVO.getCode()));
@ -77,8 +77,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override @Override
public boolean isDeviceCodeExist(String project, String code) { 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(); ProjectDeviceExample example = new ProjectDeviceExample();
example.createCriteria().andProjectCodeEqualTo(project).andCodeEqualTo(code); example.createCriteria().andProjectCodeEqualTo(project).andCodeEqualTo(code);
if (this.projectDeviceDAO.countByExample(example) > 0) { if (this.projectDeviceDAO.countByExample(example) > 0) {
@ -90,9 +88,6 @@ public class DeviceServiceImpl implements DeviceService {
@Override @Override
public String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo) { public String create(ProjectDeviceVO deviceVO, LoginUserInfoVO userLoginInfo) {
ProjectDevice projectDevice = deviceVO.buildDB(); 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.setCreator(userLoginInfo.getAccountVO().getId());
projectDevice.setCreateTime(LocalDateTime.now()); projectDevice.setCreateTime(LocalDateTime.now());
this.projectDeviceDAO.insert(projectDevice); this.projectDeviceDAO.insert(projectDevice);

View File

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