|
@@ -155,7 +155,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
wrapper.eq(ScenePro::getPayStatus,-2);
|
|
|
plusWr.eq(ScenePlus::getPayStatus,-2);
|
|
|
}else {
|
|
|
- if (totalSpace >= cameraDetail.getUsedSpace()) {
|
|
|
+ if (totalSpace == -1 || totalSpace >= cameraDetail.getUsedSpace()) {
|
|
|
// 总容量大于已使用容量,不予封存
|
|
|
return;
|
|
|
}
|
|
@@ -173,48 +173,58 @@ 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);
|
|
|
- Long accumulateSpace = 0L;
|
|
|
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;
|
|
|
if(payStatus == 1){
|
|
|
- Long doSpace = getScenePlusLockedIds(lockedIds, plusList, totalSpace, beyondSpace, accumulateSpace);
|
|
|
- beyondSpace -= doSpace;
|
|
|
- getSceneLockedIds(lockedIds,list,totalSpace,beyondSpace,accumulateSpace);
|
|
|
+ beyondSpace = totalSpace - cameraDetail.getTotalSpace();
|
|
|
+ getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
|
|
|
+ getSceneLockedIds(lockedIds,list,beyondSpace,accumulateSpace);
|
|
|
}else {
|
|
|
- Long doSpace = getSceneLockedIds(lockedIds, list, totalSpace, beyondSpace, accumulateSpace);
|
|
|
- beyondSpace -= doSpace;
|
|
|
- getScenePlusLockedIds(lockedIds,plusList,totalSpace,beyondSpace,accumulateSpace);
|
|
|
+ beyondSpace = cameraDetail.getUsedSpace() - totalSpace;
|
|
|
+ getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
|
|
|
+ getScenePlusLockedIds(lockedIds,plusList,beyondSpace,accumulateSpace);
|
|
|
}
|
|
|
|
|
|
lockOrUnLockScenes(lockedIds,payStatus);
|
|
|
}
|
|
|
|
|
|
- private Long getSceneLockedIds(List<Long> lockedIds ,List<ScenePro> list,Long count,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 (count ==-1 && accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
- return accumulateSpace - scenePro.getSpace();
|
|
|
+ if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
+ break;
|
|
|
}
|
|
|
lockedIds.add(scenePro.getId());
|
|
|
}
|
|
|
}
|
|
|
- return accumulateSpace;
|
|
|
}
|
|
|
- private Long getScenePlusLockedIds(List<Long> lockedIds , List<ScenePlus> list, Long count, 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);
|
|
|
for (ScenePlus scenePlus : list){
|
|
|
ScenePlusExt scenePlusExt = byPlusIds.get(scenePlus.getId());
|
|
|
accumulateSpace += scenePlusExt.getSpace();
|
|
|
- if (count ==-1 && accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
- return accumulateSpace - scenePlusExt.getSpace();
|
|
|
+ if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
+ break;
|
|
|
}
|
|
|
lockedIds.add(scenePlus.getId());
|
|
|
}
|
|
|
}
|
|
|
- return accumulateSpace;
|
|
|
}
|
|
|
|
|
|
// payStatus 为 -2 封存,为 1 解封
|