|
@@ -21,6 +21,8 @@ import com.fdkankan.manage.httpClient.client.FdKKClient;
|
|
|
import com.fdkankan.manage.httpClient.service.LaserService;
|
|
|
import com.fdkankan.manage.entity.*;
|
|
|
import com.fdkankan.manage.mapper.ISceneProMapper;
|
|
|
+import com.fdkankan.manage.mq.common.MqQueueUtil;
|
|
|
+import com.fdkankan.manage.mq.param.ScenePayStatusVo;
|
|
|
import com.fdkankan.manage.service.*;
|
|
|
import com.fdkankan.manage.util.Dateutils;
|
|
|
import com.fdkankan.manage.util.SceneStatusUtil;
|
|
@@ -28,6 +30,7 @@ import com.fdkankan.manage.vo.request.SceneParam;
|
|
|
import com.fdkankan.manage.vo.response.CameraDataVo;
|
|
|
import com.fdkankan.manage.vo.response.GroupByCount;
|
|
|
import com.fdkankan.manage.vo.response.SceneVo;
|
|
|
+import com.fdkankan.rabbitmq.util.RabbitMqProducer;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -91,6 +94,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
ISceneResourceCameraService sceneResourceCameraService;
|
|
|
@Autowired
|
|
|
ISceneDelLogService sceneDelLogService;
|
|
|
+ @Autowired
|
|
|
+ RabbitMqProducer rabbitMqProducer;
|
|
|
|
|
|
|
|
|
@Override
|
|
@@ -143,155 +148,18 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
*/
|
|
|
@Override
|
|
|
public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId, Integer payStatus) {
|
|
|
- if(cameraDetail == null){
|
|
|
- cameraDetail = cameraDetailService.getByCameraId(cameraId);
|
|
|
- }
|
|
|
- LambdaQueryWrapper<ScenePro> wrapper = new LambdaQueryWrapper<>();
|
|
|
- LambdaQueryWrapper<ScenePlus> plusWr = new LambdaQueryWrapper<>();
|
|
|
- wrapper.eq(ScenePro::getStatus,-2);
|
|
|
- plusWr.eq(ScenePlus::getSceneStatus,-2);
|
|
|
- Long totalSpace = cameraDetail.getTotalSpace();
|
|
|
- UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
- if(userIncrement!=null){
|
|
|
- IncrementType incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
- if(incrementType!=null){
|
|
|
- if(incrementType.getCameraCapacity() == -1){
|
|
|
- totalSpace = -1L;
|
|
|
- }else {
|
|
|
- totalSpace = incrementType.getCameraCapacity() * 1024* 1024 * 1024L;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- log.info("lockOrUnLockBySpace---cameraId:{},payStatus:{},totalSpace:{},useSpace{}",
|
|
|
- cameraId,payStatus,totalSpace,cameraDetail.getUsedSpace());
|
|
|
- if(payStatus == 1){ //解封,判断用户权益,用户会员权益无限容量
|
|
|
- wrapper.orderByAsc(ScenePro::getCreateTime);
|
|
|
- plusWr.orderByAsc(ScenePlus::getCreateTime);
|
|
|
- wrapper.eq(ScenePro::getPayStatus,-2);
|
|
|
- plusWr.eq(ScenePlus::getPayStatus,-2);
|
|
|
- }else {
|
|
|
- if (totalSpace == -1 || totalSpace >= cameraDetail.getUsedSpace()) {
|
|
|
- // 总容量大于已使用容量,不予封存
|
|
|
- return;
|
|
|
- }
|
|
|
- wrapper.orderByDesc(ScenePro::getCreateTime);
|
|
|
- plusWr.orderByDesc(ScenePlus::getCreateTime);
|
|
|
- wrapper.eq(ScenePro::getPayStatus,1);
|
|
|
- plusWr.eq(ScenePlus::getPayStatus,1);
|
|
|
- }
|
|
|
-
|
|
|
- wrapper.eq(ScenePro::getCameraId,cameraId)
|
|
|
- .eq(ScenePro::getIsUpgrade,0);
|
|
|
-
|
|
|
- plusWr.eq(ScenePlus::getCameraId,cameraId);
|
|
|
-
|
|
|
- List<ScenePro> list = this.list(wrapper);
|
|
|
- List<ScenePlus> plusList = scenePlusService.list(plusWr);
|
|
|
-
|
|
|
- List<Long> lockedIds = new ArrayList<>();
|
|
|
-
|
|
|
- if(totalSpace == -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){
|
|
|
- beyondSpace = totalSpace - cameraDetail.getUsedSpace();
|
|
|
- getScenePlusLockedIds(lockedIds, plusList, beyondSpace, accumulateSpace);
|
|
|
- getSceneLockedIds(lockedIds,list,beyondSpace,accumulateSpace);
|
|
|
- }else {
|
|
|
- beyondSpace = cameraDetail.getUsedSpace() - totalSpace;
|
|
|
- getSceneLockedIds(lockedIds, list, beyondSpace, accumulateSpace);
|
|
|
- getScenePlusLockedIds(lockedIds,plusList,beyondSpace,accumulateSpace);
|
|
|
- }
|
|
|
-
|
|
|
- lockOrUnLockScenes(lockedIds,payStatus);
|
|
|
+ ScenePayStatusVo scenePayStatusVo = new ScenePayStatusVo(cameraDetail.getCameraId());
|
|
|
+ rabbitMqProducer.sendByWorkQueue(MqQueueUtil.ucenterScenePayStatus, JSONObject.toJSONString(scenePayStatusVo));
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
public void lockOrUnLockBySpace(ScenePro scenePro, ScenePlus scenePlus,Integer payStatus) {
|
|
|
- List<Long> lockedIds = new ArrayList<>();
|
|
|
- if(scenePro!= null){
|
|
|
- lockedIds.add(scenePro.getId());
|
|
|
- }
|
|
|
- if(scenePlus!= null){
|
|
|
- lockedIds.add(scenePlus.getId());
|
|
|
- }
|
|
|
- lockOrUnLockScenes(lockedIds,payStatus); // 无限容量 全部解封
|
|
|
- }
|
|
|
-
|
|
|
- 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()== null ? 0 : scenePro.getSpace();
|
|
|
- if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
- break;
|
|
|
- }
|
|
|
- lockedIds.add(scenePro.getId());
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- 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() == null ? 0 : scenePlusExt.getSpace();
|
|
|
- if (accumulateSpace.compareTo(beyondSpace) > 0){
|
|
|
- break;
|
|
|
- }
|
|
|
- lockedIds.add(scenePlus.getId());
|
|
|
- }
|
|
|
- }
|
|
|
+ Long sceneId = scenePro == null ? scenePlus.getId() : scenePro.getId();
|
|
|
+ ScenePayStatusVo scenePayStatusVo = new ScenePayStatusVo(sceneId,payStatus);
|
|
|
+ rabbitMqProducer.sendByWorkQueue(MqQueueUtil.ucenterScenePayStatus, JSONObject.toJSONString(scenePayStatusVo));
|
|
|
}
|
|
|
|
|
|
- // payStatus 为 -2 封存,为 1 解封
|
|
|
- private void lockOrUnLockScenes(List<Long> lockedIds,Integer payStatus) {
|
|
|
- if (lockedIds == null || lockedIds.size() == 0){
|
|
|
- return;
|
|
|
- }
|
|
|
- LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updateWrapper.set(ScenePro::getPayStatus,payStatus)
|
|
|
- .eq(ScenePro::getIsUpgrade,0)
|
|
|
- .in(ScenePro::getId,lockedIds);
|
|
|
- this.update(updateWrapper);
|
|
|
-
|
|
|
- LambdaUpdateWrapper<ScenePlus> updatePlusWrapper = new LambdaUpdateWrapper<>();
|
|
|
- updatePlusWrapper.set(ScenePlus::getPayStatus,payStatus)
|
|
|
- .in(ScenePlus::getId,lockedIds);
|
|
|
- scenePlusService.update(updatePlusWrapper);
|
|
|
-
|
|
|
- this.updateOssStatus(lockedIds,payStatus);
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 修改oss status.json中 payStatus
|
|
|
- */
|
|
|
- private void updateOssStatus(List<Long> lockedIds, Integer payStatus) {
|
|
|
- LambdaQueryWrapper<ScenePro> proWr = new LambdaQueryWrapper<>();
|
|
|
- proWr.eq(ScenePro::getIsUpgrade,0);
|
|
|
- proWr.in(ScenePro::getId,lockedIds);
|
|
|
- List<ScenePro> proList = this.list(proWr);
|
|
|
-
|
|
|
- LambdaQueryWrapper<ScenePlus> pluWr = new LambdaQueryWrapper<>();
|
|
|
- pluWr.in(ScenePlus::getId,lockedIds);
|
|
|
- List<ScenePlus> plusList = scenePlusService.list(pluWr);
|
|
|
- for (ScenePro scenePro : proList) {
|
|
|
- this.updateOssStatus(String.format(OssPath.v3_statusPath,scenePro.getNum()),payStatus,"payStatus");
|
|
|
- }
|
|
|
- for (ScenePlus scenePlus : plusList) {
|
|
|
- this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),payStatus,"payStatus");
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
|
|
|
/**
|
|
|
* 从oss中获取文件,并重写,上传替换
|