|
@@ -299,111 +299,108 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(cameraDetail == null){
|
|
|
throw new BusinessException(ResultCode.CAMERA_SN_NOT_EXIST);
|
|
|
}
|
|
|
- ScenePro scenePro = this.getByNum(param.getNum());
|
|
|
- ScenePlus scenePlus = scenePlusService.getByNum(param.getNum());
|
|
|
- if((scenePro == null || scenePro.getCameraId() == null ) && (scenePlus== null || scenePlus.getCameraId() == null)){
|
|
|
- throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
- }
|
|
|
- Integer status = scenePro == null ? scenePlus.getSceneStatus() : scenePro.getStatus();
|
|
|
- if(status == 0){
|
|
|
- throw new BusinessException(SceneConstant.FAILURE_CODE_5037, SceneConstant.FAILURE_MSG_5037);
|
|
|
- }
|
|
|
+ if(StringUtils.isNotBlank(param.getNum())){
|
|
|
+ param.getNumList().add(param.getNum());
|
|
|
+ }
|
|
|
+ for (String num : param.getNumList()) {
|
|
|
+ ScenePro scenePro = this.getByNum(num);
|
|
|
+ ScenePlus scenePlus = scenePlusService.getByNum(num);
|
|
|
+ if((scenePro == null || scenePro.getCameraId() == null ) && (scenePlus== null || scenePlus.getCameraId() == null)){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
|
|
|
+ }
|
|
|
+ Integer status = scenePro == null ? scenePlus.getSceneStatus() : scenePro.getStatus();
|
|
|
+ if(status == 0){
|
|
|
+ throw new BusinessException(SceneConstant.FAILURE_CODE_5037, SceneConstant.FAILURE_MSG_5037);
|
|
|
+ }
|
|
|
|
|
|
- Long sceneCameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
|
|
|
- Long space = scenePro == null ? 0 :scenePro.getSpace();
|
|
|
- String dataSource = scenePro == null ? null :scenePro.getDataSource();
|
|
|
- if(scenePlus !=null){
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
- space = scenePlusExt.getSpace();
|
|
|
- dataSource = scenePlusExt.getDataSource();
|
|
|
- }
|
|
|
- space = space == null ? 0 :space;
|
|
|
- cameraDetailService.initSpace(cameraDetail.getCameraId());
|
|
|
- Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail, space);
|
|
|
- //深时场景无限容量
|
|
|
- if( !checkSpace){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_SPACE_ERROR);
|
|
|
- }
|
|
|
+ Long sceneCameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
|
|
|
+ Long space = scenePro == null ? 0 :scenePro.getSpace();
|
|
|
+ String dataSource = scenePro == null ? null :scenePro.getDataSource();
|
|
|
+ if(scenePlus !=null){
|
|
|
+ ScenePlusExt scenePlusExt = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ space = scenePlusExt.getSpace();
|
|
|
+ dataSource = scenePlusExt.getDataSource();
|
|
|
+ }
|
|
|
+ space = space == null ? 0 :space;
|
|
|
+ cameraDetailService.initSpace(cameraDetail.getCameraId());
|
|
|
+ Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail, space);
|
|
|
+ //深时场景无限容量
|
|
|
+ if( !checkSpace){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_SPACE_ERROR);
|
|
|
+ }
|
|
|
|
|
|
- Camera oldCamera = cameraService.getById(sceneCameraId);
|
|
|
- if(oldCamera == null){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
- }
|
|
|
- CameraDetail oldCameraDetail = cameraDetailService.getByCameraId(oldCamera.getId());
|
|
|
- if(oldCameraDetail == null){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
- }
|
|
|
- if(oldCameraDetail.getCameraId().equals(cameraDetail.getCameraId())){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_NOT_MOVE);
|
|
|
- }
|
|
|
- if(!oldCameraDetail.getType().equals(cameraDetail.getType())){
|
|
|
- throw new BusinessException(ResultCode.CAMERA_TYPE_NOT_ERROR);
|
|
|
- }
|
|
|
-// String home = dataSource.replace("/mnt/data", "home")+"/data.fdage";
|
|
|
-// if(!fYunFileServiceInterface.fileExist(home)){
|
|
|
-// throw new BusinessException(ResultCode.MOVE_ERROR);
|
|
|
-// }
|
|
|
+ Camera oldCamera = cameraService.getById(sceneCameraId);
|
|
|
+ if(oldCamera == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
+ }
|
|
|
+ CameraDetail oldCameraDetail = cameraDetailService.getByCameraId(oldCamera.getId());
|
|
|
+ if(oldCameraDetail == null){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_EXIST);
|
|
|
+ }
|
|
|
+ if(oldCameraDetail.getCameraId().equals(cameraDetail.getCameraId())){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_NOT_MOVE);
|
|
|
+ }
|
|
|
+ if(!oldCameraDetail.getType().equals(cameraDetail.getType())){
|
|
|
+ throw new BusinessException(ResultCode.CAMERA_TYPE_NOT_ERROR);
|
|
|
+ }
|
|
|
|
|
|
-// HashMap<String, SceneCopyLog> byNewNumList = copyLogService.getByNewNumList(Arrays.asList(param.getNum()));
|
|
|
-// if(byNewNumList.size() >0){
|
|
|
-// throw new BusinessException(ResultCode.MOVE_ERROR_COPY);
|
|
|
-// }
|
|
|
+ Long oldUseSpace = oldCameraDetail.getUsedSpace() - space < 0 ? 0 : oldCameraDetail.getUsedSpace() - space;
|
|
|
+ if("GB".equals(oldCameraDetail.getUnit())){
|
|
|
+ oldUseSpace = 1L;
|
|
|
+ }
|
|
|
+ Long subSpace = oldCameraDetail.getTotalSpace() - oldUseSpace;
|
|
|
|
|
|
- Long oldUseSpace = oldCameraDetail.getUsedSpace() - space < 0 ? 0 : oldCameraDetail.getUsedSpace() - space;
|
|
|
- if("GB".equals(oldCameraDetail.getUnit())){
|
|
|
- oldUseSpace = 1L;
|
|
|
- }
|
|
|
- Long subSpace = oldCameraDetail.getTotalSpace() - oldUseSpace;
|
|
|
+ if(scenePro!=null){
|
|
|
+ LambdaUpdateWrapper<ScenePro> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(ScenePro::getId,scenePro.getId());
|
|
|
+ wrapper.set(ScenePro::getCameraId,camera.getId());
|
|
|
+ wrapper.set(ScenePro::getUserId,cameraDetail.getUserId());
|
|
|
+ // wrapper.set(ScenePro::getStatus,0);
|
|
|
+ // this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),0,"status");
|
|
|
+ this.update(wrapper);
|
|
|
+ //场景迁移到另外的相机清除本身在的文件夹
|
|
|
+ folderSceneService.delBySceneId(scenePro.getId());
|
|
|
+ }
|
|
|
+ if(scenePlus!=null){
|
|
|
+ LambdaUpdateWrapper<ScenePlus> wrapper = new LambdaUpdateWrapper<>();
|
|
|
+ wrapper.eq(ScenePlus::getId,scenePlus.getId());
|
|
|
+ wrapper.set(ScenePlus::getCameraId,camera.getId());
|
|
|
+ wrapper.set(ScenePlus::getUserId,cameraDetail.getUserId());
|
|
|
+ //wrapper.set(ScenePlus::getSceneStatus,0);
|
|
|
+ //this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),0,"status");
|
|
|
+ scenePlusService.update(wrapper);
|
|
|
+ folderSceneService.delBySceneId(scenePlus.getId());
|
|
|
+ }
|
|
|
+ //协作相机
|
|
|
+ sceneResourceCameraService.setCooperationUser(cameraDetail,num);
|
|
|
|
|
|
- if(scenePro!=null){
|
|
|
- LambdaUpdateWrapper<ScenePro> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.eq(ScenePro::getId,scenePro.getId());
|
|
|
- wrapper.set(ScenePro::getCameraId,camera.getId());
|
|
|
- wrapper.set(ScenePro::getUserId,cameraDetail.getUserId());
|
|
|
- // wrapper.set(ScenePro::getStatus,0);
|
|
|
- // this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),0,"status");
|
|
|
- this.update(wrapper);
|
|
|
- //场景迁移到另外的相机清除本身在的文件夹
|
|
|
- folderSceneService.delBySceneId(scenePro.getId());
|
|
|
- }
|
|
|
- if(scenePlus!=null){
|
|
|
- LambdaUpdateWrapper<ScenePlus> wrapper = new LambdaUpdateWrapper<>();
|
|
|
- wrapper.eq(ScenePlus::getId,scenePlus.getId());
|
|
|
- wrapper.set(ScenePlus::getCameraId,camera.getId());
|
|
|
- wrapper.set(ScenePlus::getUserId,cameraDetail.getUserId());
|
|
|
- //wrapper.set(ScenePlus::getSceneStatus,0);
|
|
|
- //this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),0,"status");
|
|
|
- scenePlusService.update(wrapper);
|
|
|
- folderSceneService.delBySceneId(scenePlus.getId());
|
|
|
- }
|
|
|
- //协作相机
|
|
|
- sceneResourceCameraService.setCooperationUser(cameraDetail,param.getNum());
|
|
|
+ //String newDataSource = updateFdageNewDataSource(scenePro, scenePlus, oldCamera.getSnCode(), param.getSnCode(), dataSource);
|
|
|
|
|
|
- //String newDataSource = updateFdageNewDataSource(scenePro, scenePlus, oldCamera.getSnCode(), param.getSnCode(), dataSource);
|
|
|
+ if(cameraDetail.getType() == 10 || cameraDetail.getType() == 11){ //深时场景
|
|
|
+ //迁移深时 dataSource
|
|
|
+ //FileUtil.move(new File(dataSource +"_laserData"),new File(newDataSource+"_laserData"),true);
|
|
|
+ laserService.move(num,oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),dataSource);
|
|
|
+ }
|
|
|
+ cameraDetailService.initSpace(oldCameraDetail);
|
|
|
+ cameraDetailService.initSpace(cameraDetail);
|
|
|
|
|
|
- if(cameraDetail.getType() == 10 || cameraDetail.getType() == 11){ //深时场景
|
|
|
- //迁移深时 dataSource
|
|
|
- //FileUtil.move(new File(dataSource +"_laserData"),new File(newDataSource+"_laserData"),true);
|
|
|
- laserService.move(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),dataSource);
|
|
|
- }
|
|
|
- cameraDetailService.initSpace(oldCameraDetail);
|
|
|
- cameraDetailService.initSpace(cameraDetail);
|
|
|
+ if(!"aws".equals(CacheUtil.uploadType) && oldCameraDetail.getType() != 11 && oldCameraDetail.getType() != 10 && subSpace >0){ //有剩余容量解封容量内场景
|
|
|
+ this.lockOrUnLockBySpace(oldCameraDetail.getCameraId());
|
|
|
+ }
|
|
|
+ if(!"aws".equals(CacheUtil.uploadType) && cameraDetail.getType() != 11 && cameraDetail.getType() != 10){ //有剩余容量解封容量内场景
|
|
|
+ this.lockOrUnLockBySpace(cameraDetail.getCameraId());
|
|
|
+ }
|
|
|
|
|
|
- if(!"aws".equals(CacheUtil.uploadType) && oldCameraDetail.getType() != 11 && oldCameraDetail.getType() != 10 && subSpace >0){ //有剩余容量解封容量内场景
|
|
|
- this.lockOrUnLockBySpace(oldCameraDetail.getCameraId());
|
|
|
- }
|
|
|
- if(!"aws".equals(CacheUtil.uploadType) && cameraDetail.getType() != 11 && cameraDetail.getType() != 10){ //有剩余容量解封容量内场景
|
|
|
- this.lockOrUnLockBySpace(cameraDetail.getCameraId());
|
|
|
+ if("aws".equals(CacheUtil.uploadType) && subSpace >0){ //有剩余容量解封容量内场景
|
|
|
+ this.lockOrUnLockBySpace(oldCameraDetail.getCameraId());
|
|
|
+ }
|
|
|
+ if("aws".equals(CacheUtil.uploadType)){ //有剩余容量解封容量内场景
|
|
|
+ this.lockOrUnLockBySpace(cameraDetail.getCameraId());
|
|
|
+ }
|
|
|
+ sceneMoveLogService.saveLog(scenePro,scenePlus,camera.getSnCode(),oldCamera.getSnCode(),dataSource,dataSource, null);
|
|
|
+ laserService.moveWenBao(num,oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),dataSource);
|
|
|
}
|
|
|
|
|
|
- if("aws".equals(CacheUtil.uploadType) && subSpace >0){ //有剩余容量解封容量内场景
|
|
|
- this.lockOrUnLockBySpace(oldCameraDetail.getCameraId());
|
|
|
- }
|
|
|
- if("aws".equals(CacheUtil.uploadType)){ //有剩余容量解封容量内场景
|
|
|
- this.lockOrUnLockBySpace(cameraDetail.getCameraId());
|
|
|
- }
|
|
|
- sceneMoveLogService.saveLog(scenePro,scenePlus,camera.getSnCode(),oldCamera.getSnCode(),dataSource,dataSource, null);
|
|
|
- laserService.moveWenBao(param.getNum(),oldCamera.getSnCode(),camera.getSnCode(),cameraDetail.getUserId(),dataSource);
|
|
|
|
|
|
}
|
|
|
|