|
@@ -82,6 +82,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
@Autowired
|
|
@Autowired
|
|
private IUserIncrementService userIncrementService;
|
|
private IUserIncrementService userIncrementService;
|
|
@Autowired
|
|
@Autowired
|
|
|
|
+ private IIncrementTypeService incrementTypeService;
|
|
|
|
+ @Autowired
|
|
private IScenePlusExtService scenePlusExtService;
|
|
private IScenePlusExtService scenePlusExtService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISceneEditInfoService sceneEditInfoService;
|
|
private ISceneEditInfoService sceneEditInfoService;
|
|
@@ -179,14 +181,27 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId, Integer payStatus) {
|
|
public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId, Integer payStatus) {
|
|
LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
|
|
LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
|
|
- Long count = 0L;
|
|
|
|
|
|
+ Long totalSpace = cameraDetail.getTotalSpace();
|
|
|
|
+ UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
|
+ if(userIncrement!=null){
|
|
|
|
+ IncrementType incrementType = incrementTypeService.getById(userIncrement.getId());
|
|
|
|
+ if(incrementType.getCameraCapacity() == -1){
|
|
|
|
+ totalSpace = -1L;
|
|
|
|
+ }else {
|
|
|
|
+ totalSpace = incrementType.getCameraCapacity() * 1024 * 1024L;
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
- count = userIncrementService.getValidCountByCameraId(cameraId);
|
|
|
|
wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
wrapper.eq(ScenePro::getPayStatus,-2);
|
|
wrapper.eq(ScenePro::getPayStatus,-2);
|
|
plusWr.eq(ScenePlus::getPayStatus,-2);
|
|
plusWr.eq(ScenePlus::getPayStatus,-2);
|
|
}else {
|
|
}else {
|
|
|
|
+ if (totalSpace >= cameraDetail.getUsedSpace()) {
|
|
|
|
+ // 总容量大于已使用容量,不予封存
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
wrapper.orderByDesc(ScenePro::getCreateTime);
|
|
wrapper.orderByDesc(ScenePro::getCreateTime);
|
|
plusWr.orderByDesc(ScenePlus::getCreateTime);
|
|
plusWr.orderByDesc(ScenePlus::getCreateTime);
|
|
wrapper.eq(ScenePro::getPayStatus,1);
|
|
wrapper.eq(ScenePro::getPayStatus,1);
|
|
@@ -201,15 +216,17 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
List<ScenePro> list = this.list(wrapper);
|
|
List<ScenePro> list = this.list(wrapper);
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
|
|
|
|
- Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - cameraDetail.getTotalSpace());
|
|
|
|
|
|
+ Long beyondSpace = Math.abs(cameraDetail.getUsedSpace() - totalSpace);
|
|
Long accumulateSpace = 0L;
|
|
Long accumulateSpace = 0L;
|
|
List<Long> lockedIds = new ArrayList<>();
|
|
List<Long> lockedIds = new ArrayList<>();
|
|
if(payStatus == 1){
|
|
if(payStatus == 1){
|
|
- getScenePlusLockedIds(lockedIds,plusList,count,beyondSpace,accumulateSpace);
|
|
|
|
- getSceneLockedIds(lockedIds,list,count,beyondSpace,accumulateSpace);
|
|
|
|
|
|
+ Long doSpace = getScenePlusLockedIds(lockedIds, plusList, totalSpace, beyondSpace, accumulateSpace);
|
|
|
|
+ beyondSpace -= doSpace;
|
|
|
|
+ getSceneLockedIds(lockedIds,list,totalSpace,beyondSpace,accumulateSpace);
|
|
}else {
|
|
}else {
|
|
- getSceneLockedIds(lockedIds,list,count,beyondSpace,accumulateSpace);
|
|
|
|
- getScenePlusLockedIds(lockedIds,plusList,count,beyondSpace,accumulateSpace);
|
|
|
|
|
|
+ Long doSpace = getSceneLockedIds(lockedIds, list, totalSpace, beyondSpace, accumulateSpace);
|
|
|
|
+ beyondSpace -= doSpace;
|
|
|
|
+ getScenePlusLockedIds(lockedIds,plusList,totalSpace,beyondSpace,accumulateSpace);
|
|
}
|
|
}
|
|
|
|
|
|
lockOrUnLockScenes(lockedIds,payStatus);
|
|
lockOrUnLockScenes(lockedIds,payStatus);
|
|
@@ -217,30 +234,32 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
- private void getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long count,Long beyondSpace,Long accumulateSpace){
|
|
|
|
|
|
+ private Long getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long count,Long beyondSpace,Long accumulateSpace){
|
|
if (list != null && list.size() > 0){
|
|
if (list != null && list.size() > 0){
|
|
for (ScenePro scenePro : list){
|
|
for (ScenePro scenePro : list){
|
|
accumulateSpace += scenePro.getSpace();
|
|
accumulateSpace += scenePro.getSpace();
|
|
- if (count ==0 && accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
|
- break;
|
|
|
|
|
|
+ if (count ==-1 && accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
|
+ return accumulateSpace - scenePro.getSpace();
|
|
}
|
|
}
|
|
lockedIds.add(scenePro.getId());
|
|
lockedIds.add(scenePro.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return accumulateSpace;
|
|
}
|
|
}
|
|
- private void getScenePlusLockedIds(List<Long> lockedIds ,List<ScenePlus> list,Long count,Long beyondSpace,Long accumulateSpace){
|
|
|
|
|
|
+ private Long getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long count, Long beyondSpace, Long accumulateSpace){
|
|
if (list != null && list.size() > 0){
|
|
if (list != null && list.size() > 0){
|
|
List<Long> plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
List<Long> plusIds = list.parallelStream().map(ScenePlus::getId).collect(Collectors.toList());
|
|
HashMap<Long, ScenePlusExt> byPlusIds = scenePlusExtService.getByPlusIds(plusIds);
|
|
HashMap<Long, ScenePlusExt> byPlusIds = scenePlusExtService.getByPlusIds(plusIds);
|
|
for (ScenePlus scenePlus : list){
|
|
for (ScenePlus scenePlus : list){
|
|
ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
|
|
ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
|
|
accumulateSpace += scenePlusExt.getSpace();
|
|
accumulateSpace += scenePlusExt.getSpace();
|
|
- if (count ==0 && accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
|
- break;
|
|
|
|
|
|
+ if (count ==-1 && accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
|
+ return accumulateSpace - scenePlusExt.getSpace();
|
|
}
|
|
}
|
|
lockedIds.add(scenePlus.getId());
|
|
lockedIds.add(scenePlus.getId());
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ return accumulateSpace;
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -401,14 +420,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
Integer count = sceneService.getCountByUserId(user.getId());
|
|
Integer count = sceneService.getCountByUserId(user.getId());
|
|
vo.setSceneNum(Long.valueOf(count));
|
|
vo.setSceneNum(Long.valueOf(count));
|
|
}
|
|
}
|
|
- if(vo.getIsFolder() == 0 && vo.getStatus() !=null){
|
|
|
|
- if(vo.getStatus() == 500){ //500状态为数据库中手动修改值,当场景本身异常,算法,算不了
|
|
|
|
- vo.setStatus(-1);
|
|
|
|
- }
|
|
|
|
- if(vo.getStatus() == -1){ //计算失败,钉钉通知之后,判定是否重算,还是修改为 500
|
|
|
|
- vo.setStatus(0);
|
|
|
|
- }
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
//设置协作者信息
|
|
//设置协作者信息
|
|
@@ -426,7 +437,19 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- List<SceneVo> sceneList = sceneVoPage.getRecords().parallelStream().filter(entity -> entity.getIsFolder() == 0).collect(Collectors.toList());
|
|
|
|
|
|
+ List<SceneVo> sceneList = sceneVoPage.getRecords().parallelStream().filter(entity -> entity.getIsFolder() == 0)
|
|
|
|
+ .peek(vo->{
|
|
|
|
+ if (ObjectUtils.isEmpty(vo.getStatus())) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (vo.getStatus().equals(500)) { //500状态为数据库中手动修改值,当场景本身异常,算法,算不了
|
|
|
|
+ vo.setStatus(-1);
|
|
|
|
+ }
|
|
|
|
+ if (vo.getStatus().equals(-1)) { //计算失败,钉钉通知之后,判定是否重算,还是修改为 500
|
|
|
|
+ vo.setStatus(0);
|
|
|
|
+ }
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+
|
|
if(sceneList.size() >0){
|
|
if(sceneList.size() >0){
|
|
folderList.addAll(sceneList);
|
|
folderList.addAll(sceneList);
|
|
}
|
|
}
|