|
@@ -43,29 +43,24 @@ public class RtkInfoController {
|
|
|
|
|
|
@PostMapping("/saveOrEdit")
|
|
|
public ResultData saveOrEdit(@RequestBody RtkInfo rtkInfo){
|
|
|
- if(rtkInfo.getRtkType() == null || StringUtils.isBlank(rtkInfo.getCameraSnCode()) || StringUtils.isBlank(rtkInfo.getRtkSnCode())){
|
|
|
- throw new BusinessException(ResultCode.MISSING_REQUIRED_PARAMETERS);
|
|
|
+ if(StringUtils.isNotBlank(rtkInfo.getRtkSnCode())){
|
|
|
+ RtkInfo dbRtkInfo = rtkInfoService.getByRtkSnCode(rtkInfo.getRtkSnCode());
|
|
|
+ if(rtkInfo.getId() == null){
|
|
|
+ if(dbRtkInfo != null){
|
|
|
+ throw new BusinessException(ResultCode.RTK_SN_EXIST);
|
|
|
+ }
|
|
|
+ }else {
|
|
|
+ if( dbRtkInfo != null && !Objects.equals(dbRtkInfo.getId(), rtkInfo.getId()) ){
|
|
|
+ throw new BusinessException(ResultCode.RTK_SN_EXIST);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
- RtkInfo dbRtkInfo = rtkInfoService.getByRtkSnCode(rtkInfo.getRtkSnCode());
|
|
|
- RtkInfo dbRtkInfo2 = rtkInfoService.getByCameraSnCode(rtkInfo.getCameraSnCode());
|
|
|
if(rtkInfo.getId() == null){
|
|
|
rtkInfo.setCreateUserId(Long.valueOf((String)StpUtil.getLoginId()));
|
|
|
- if(dbRtkInfo != null){
|
|
|
- throw new BusinessException(ResultCode.RTK_SN_EXIST);
|
|
|
- }
|
|
|
- if(dbRtkInfo2 != null){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_SN_EXIST);
|
|
|
- }
|
|
|
}else {
|
|
|
rtkInfo.setUpdateUserId(Long.valueOf((String)StpUtil.getLoginId()));
|
|
|
- if( dbRtkInfo != null && !Objects.equals(dbRtkInfo.getId(), rtkInfo.getId()) ){
|
|
|
- throw new BusinessException(ResultCode.RTK_SN_EXIST);
|
|
|
- }
|
|
|
- if( dbRtkInfo2 != null && !Objects.equals(dbRtkInfo2.getId(), rtkInfo.getId()) ){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_SN_EXIST);
|
|
|
- }
|
|
|
}
|
|
|
- if(rtkInfo.getRtkType() == 0){
|
|
|
+ if(rtkInfo.getRtkType() != null && rtkInfo.getRtkType() == 0){
|
|
|
rtkInfo.setIpAddr(null);
|
|
|
rtkInfo.setMountPoint(null);
|
|
|
rtkInfo.setPort(null);
|
|
@@ -73,9 +68,11 @@ public class RtkInfoController {
|
|
|
rtkInfo.setPassword(null);
|
|
|
rtkInfo.setOperator(null);
|
|
|
}
|
|
|
- Camera camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
|
|
|
- if(camera == null){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
+ if(StringUtils.isNotBlank(rtkInfo.getCameraSnCode())){
|
|
|
+ Camera camera = cameraService.getBySnCode(rtkInfo.getCameraSnCode());
|
|
|
+ if(camera == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
+ }
|
|
|
}
|
|
|
rtkInfoService.saveOrEdit(rtkInfo);
|
|
|
return ResultData.ok();
|