|
@@ -236,7 +236,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(incrementType.getCameraCapacity() == -1){
|
|
|
totalSpace = -1L;
|
|
|
}else {
|
|
|
- totalSpace = incrementType.getCameraCapacity() * 1024 * 1024L;
|
|
|
+ totalSpace = incrementType.getCameraCapacity() * 1024* 1024 * 1024L;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -267,20 +267,26 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
List<ScenePro> list = this.list(wrapper);
|
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
|
|
|
|
- Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - totalSpace);
|
|
|
- if(totalSpace == -1){
|
|
|
- beyondSpace = Long.MAX_VALUE;
|
|
|
+ List<Long> lockedIds = new ArrayList<>();
|
|
|
+
|
|
|
+ if(totalSpace == -1 && payStatus == 1){
|
|
|
+ List<Long> collect = list.stream().map(ScenePro::getId).collect(Collectors.toList());
|
|
|
+ List<Long> collect2 = plusList.stream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
+ lockedIds.addAll(collect);
|
|
|
+ lockedIds.addAll(collect2);
|
|
|
+ lockOrUnLockScenes(lockedIds,payStatus); // 无限容量 全部解封
|
|
|
+ return;
|
|
|
}
|
|
|
|
|
|
+ Long beyondSpace = 0L;
|
|
|
Long accumulateSpace = 0L;
|
|
|
- List<Long> lockedIds = new ArrayList<>();
|
|
|
if(payStatus == 1){
|
|
|
- Long doSpace = getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
|
|
|
- beyondSpace -= doSpace;
|
|
|
+ beyondSpace = totalSpace - cameraDetail.getTotalSpace();
|
|
|
+ getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
|
|
|
getSceneLockedIds(lockedIds,list,beyondSpace,accumulateSpace);
|
|
|
}else {
|
|
|
- Long doSpace = getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
|
|
|
- beyondSpace -= doSpace;
|
|
|
+ beyondSpace = cameraDetail.getUsedSpace() - totalSpace;
|
|
|
+ getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
|
|
|
getScenePlusLockedIds(lockedIds,plusList,beyondSpace,accumulateSpace);
|
|
|
}
|
|
|
|
|
@@ -289,19 +295,18 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
|
|
|
- private Long getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long beyondSpace,Long accumulateSpace){
|
|
|
+ private void getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long beyondSpace,Long accumulateSpace){
|
|
|
if (list != null && list.size() > 0){
|
|
|
for (ScenePro scenePro : list){
|
|
|
accumulateSpace += scenePro.getSpace();
|
|
|
if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
- return accumulateSpace - scenePro.getSpace();
|
|
|
+ break;
|
|
|
}
|
|
|
lockedIds.add(scenePro.getId());
|
|
|
}
|
|
|
}
|
|
|
- return accumulateSpace;
|
|
|
}
|
|
|
- private Long getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long beyondSpace, Long accumulateSpace){
|
|
|
+ private void getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long beyondSpace, Long accumulateSpace){
|
|
|
if (list != null && list.size() > 0){
|
|
|
List<Long> plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
|
HashMap<Long, ScenePlusExt> byPlusIds = scenePlusExtService.getByPlusIds(plusIds);
|
|
@@ -309,12 +314,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
|
|
|
accumulateSpace += scenePlusExt.getSpace();
|
|
|
if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
- return accumulateSpace - scenePlusExt.getSpace();
|
|
|
+ break;
|
|
|
}
|
|
|
lockedIds.add(scenePlus.getId());
|
|
|
}
|
|
|
}
|
|
|
- return accumulateSpace;
|
|
|
}
|
|
|
|
|
|
|
|
@@ -361,7 +365,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
/**
|
|
|
* 从oss中获取文件,并重写,上传替换
|
|
|
*/
|
|
|
- private void updateOssStatus(String path,Integer payStatus) {
|
|
|
+ @Override
|
|
|
+ public void updateOssStatus(String path,Integer payStatus) {
|
|
|
try {
|
|
|
if(!fYunFileService.fileExist(path)){
|
|
|
return;
|
|
@@ -657,6 +662,27 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(detailEntity == null){
|
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
|
}
|
|
|
+ UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
+ if(userIncrement == null){
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
|
|
|
+ }
|
|
|
+ IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
+ if(incrementType == null){
|
|
|
+ throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
|
|
|
+ }
|
|
|
+ if(incrementType.getCameraCapacity() != -1){
|
|
|
+ Long usedSpace = detailEntity.getUsedSpace();
|
|
|
+ if( scenePro != null && scenePro.getSpace() + usedSpace > incrementType.getCameraCapacity() * 1024 * 1024 * 1024L){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
|
|
|
+ }
|
|
|
+ if( scenePlus != null ){
|
|
|
+ ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ if(ext.getSpace() + usedSpace > incrementType.getCameraCapacity() * 1024 * 1024 * 1024L){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
String title = scenePro == null ? scenePlus.getTitle() : scenePro.getSceneName();
|
|
|
String newTitle = title.concat("(copy)");
|
|
@@ -785,6 +811,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
FileUtils.copyDirectiory(ConstantFilePath.SCENE_PATH +"video/video" + oldNum,ConstantFilePath.SCENE_PATH +"video/video" + newNum);
|
|
|
oldScene.setStatus(-2);
|
|
|
this.updateById(oldScene);
|
|
|
+
|
|
|
+ cameraDetail.setUsedSpace(cameraDetail.getUsedSpace() + oldScene.getSpace());
|
|
|
+ cameraDetailService.updateById(cameraDetail);
|
|
|
+ if(oldScene.getPayStatus() == -2){
|
|
|
+ this.updateOssStatus(String.format(OssPath.v3_statusPath,oldScene.getNum()),-2);
|
|
|
+ }
|
|
|
log.info("复制场景结束-{}", new Date());
|
|
|
if(oldScene.getSceneSource() == 4){ //深时复制
|
|
|
String laserPath = laserService.copyDataSource(preDataSource,oldScene.getDataSource());
|