|
@@ -23,6 +23,7 @@ import com.fdkankan.ucenter.common.OssPath;
|
|
|
import com.fdkankan.ucenter.common.PageInfo;
|
|
|
import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.image.MatrixToImageWriterUtil;
|
|
|
+import com.fdkankan.ucenter.common.RedisKeyUtil;
|
|
|
import com.fdkankan.ucenter.common.constants.ConstantFilePath;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.ucenter.common.constants.NacosProperty;
|
|
@@ -32,6 +33,7 @@ import com.fdkankan.ucenter.constant.CameraConstant;
|
|
|
import com.fdkankan.ucenter.constant.LoginConstant;
|
|
|
import com.fdkankan.ucenter.entity.*;
|
|
|
import com.fdkankan.ucenter.httpClient.service.LaserService;
|
|
|
+import com.fdkankan.ucenter.httpClient.service.PayService;
|
|
|
import com.fdkankan.ucenter.mapper.ISceneProMapper;
|
|
|
import com.fdkankan.ucenter.mapper.ISceneUpgradeMapper;
|
|
|
import com.fdkankan.ucenter.service.*;
|
|
@@ -132,6 +134,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
@Autowired
|
|
|
private RabbitMqProducer mqProducer;
|
|
|
+ @Autowired
|
|
|
+ ICameraTypeService cameraTypeService;
|
|
|
|
|
|
@Override
|
|
|
public HashMap<String, SceneNumVo> findSceneNumber(String token) {
|
|
@@ -236,9 +240,6 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
this.lockOrUnLockBySpace(cameraDetail,cameraId);
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * @param payStatus -2 封存,为 1 解封
|
|
|
- */
|
|
|
@Override
|
|
|
public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId) {
|
|
|
|
|
@@ -246,6 +247,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(voList .size() <=0){
|
|
|
return;
|
|
|
}
|
|
|
+ CameraType cameraType = cameraTypeService.getByCameraType(cameraDetail.getType());
|
|
|
+
|
|
|
Long totalSpace = cameraDetailService.getTotalSpaceByCameraId(cameraDetail);
|
|
|
Long usedSpace = 0L;
|
|
|
|
|
@@ -263,18 +266,19 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
List<SimpleSceneVo> sceneVos = voList.stream().sorted(Comparator.comparing(SimpleSceneVo::getCreateTime).reversed()).collect(Collectors.toList());
|
|
|
|
|
|
if(totalSpace == -1){ // 无限容量 全部解封
|
|
|
- List<Long> sceneIds = sceneVos.stream().filter(entity -> entity.getPayStatus() !=1).map(SimpleSceneVo::getId).collect(Collectors.toList());
|
|
|
- lockOrUnLockScenes(sceneIds,1);
|
|
|
+ lockOrUnLockScenes(sceneVos,1,cameraType);
|
|
|
return;
|
|
|
}
|
|
|
+
|
|
|
//按计算完成时间由新到旧封存
|
|
|
//按计算完成时间由旧到新解封
|
|
|
- List<Long> lockedIds = new ArrayList<>();
|
|
|
+ //payStatus 1解封,-2封存
|
|
|
+ List<SimpleSceneVo> lockedIds = new ArrayList<>();
|
|
|
if(usedSpace > totalSpace){
|
|
|
sceneVos = sceneVos.stream().filter(entity -> entity.getPayStatus() ==1).collect(Collectors.toList());
|
|
|
Long space = getSceneLockedIds(lockedIds, sceneVos, usedSpace - totalSpace,cameraDetail.getUnit());
|
|
|
log.info("lockOrUnLockBySpace---cameraId:{},totalSpace:{},useSpace{},space:{},payStatus:{}", cameraId,totalSpace,usedSpace,space,-2);
|
|
|
- lockOrUnLockScenes(lockedIds,-2);
|
|
|
+ lockOrUnLockScenes(lockedIds,-2,cameraType);
|
|
|
return;
|
|
|
}
|
|
|
|
|
@@ -283,11 +287,17 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
CollectionUtil.reverse(sceneVos);
|
|
|
Long space = getSceneUnLockedIds(lockedIds, sceneVos, totalSpace - usedSpace,cameraDetail.getUnit());
|
|
|
log.info("lockOrUnLockBySpace---cameraId:{},totalSpace:{},useSpace{},space:{},payStatus:{}", cameraId,totalSpace,usedSpace,space,1);
|
|
|
- lockOrUnLockScenes(lockedIds,1);
|
|
|
+ lockOrUnLockScenes(lockedIds,1,cameraType);
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private Long getSceneUnLockedIds(List<Long> lockedIds ,List<SimpleSceneVo> list,Long beyondSpace,String unit){
|
|
|
+ private void lockOrUnLockScenes(List<SimpleSceneVo> sceneVos, Integer payStatus,CameraType cameraType){
|
|
|
+ List<String> v3NumList = sceneVos.stream().filter(e ->"v3".equals(e.getVersion())).map(SimpleSceneVo::getNum).collect(Collectors.toList());
|
|
|
+ List<String> v4NumList = sceneVos.stream().filter(e ->"v4".equals(e.getVersion())).map(SimpleSceneVo::getNum).collect(Collectors.toList());
|
|
|
+ lockOrUnLockScenes(v3NumList,v4NumList,payStatus,cameraType.getIsLaser());
|
|
|
+ }
|
|
|
+
|
|
|
+ private Long getSceneUnLockedIds(List<SimpleSceneVo> lockedIds ,List<SimpleSceneVo> list,Long beyondSpace,String unit){
|
|
|
Long space = 0L;
|
|
|
if (list != null && list.size() > 0){
|
|
|
for (SimpleSceneVo scenePro : list){
|
|
@@ -299,13 +309,13 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
break;
|
|
|
}
|
|
|
space += sceneSpace;
|
|
|
- lockedIds.add(scenePro.getId());
|
|
|
+ lockedIds.add(scenePro);
|
|
|
}
|
|
|
}
|
|
|
return space;
|
|
|
}
|
|
|
|
|
|
- private Long getSceneLockedIds(List<Long> lockedIds ,List<SimpleSceneVo> list,Long beyondSpace,String unit){
|
|
|
+ private Long getSceneLockedIds(List<SimpleSceneVo> lockedIds ,List<SimpleSceneVo> list,Long beyondSpace,String unit){
|
|
|
Long space = 0L;
|
|
|
if (list != null && list.size() > 0){
|
|
|
for (SimpleSceneVo scenePro : list){
|
|
@@ -314,7 +324,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
sceneSpace = 1L;
|
|
|
}
|
|
|
space += sceneSpace;
|
|
|
- lockedIds.add(scenePro.getId());
|
|
|
+ lockedIds.add(scenePro);
|
|
|
if (space >= beyondSpace){
|
|
|
break;
|
|
|
}
|
|
@@ -325,43 +335,47 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
// payStatus 为 -2 封存,为 1 解封
|
|
|
- public 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);
|
|
|
+ @Override
|
|
|
+ public void lockOrUnLockScenes( List<String> v3NumList,List<String> v4NumList,Integer payStatus,Integer isLaser) {
|
|
|
|
|
|
- this.updateOssStatus(lockedIds,payStatus);
|
|
|
+ if(!v3NumList.isEmpty()){
|
|
|
+ LambdaUpdateWrapper<ScenePro> updateWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updateWrapper.set(ScenePro::getPayStatus,payStatus)
|
|
|
+ .eq(ScenePro::getIsUpgrade,0)
|
|
|
+ .in(ScenePro::getNum,v3NumList);
|
|
|
+ this.update(updateWrapper);
|
|
|
+ }
|
|
|
+ if(!v4NumList.isEmpty()){
|
|
|
+ LambdaUpdateWrapper<ScenePlus> updatePlusWrapper = new LambdaUpdateWrapper<>();
|
|
|
+ updatePlusWrapper.set(ScenePlus::getPayStatus,payStatus)
|
|
|
+ .in(ScenePlus::getNum,v4NumList);
|
|
|
+ scenePlusService.update(updatePlusWrapper);
|
|
|
+ }
|
|
|
+
|
|
|
+ this.updateOssStatus(v3NumList,v4NumList,payStatus);
|
|
|
+
|
|
|
+ if(isLaser == 1){
|
|
|
+ //激光系统相机
|
|
|
+ //1:场景被删 0:计算中 1计算失败 2计算成功 3封存 4重算中'
|
|
|
+ List<String> numList = new ArrayList<>();
|
|
|
+ numList.addAll(v3NumList);
|
|
|
+ numList.addAll(v4NumList);
|
|
|
+ if(!numList.isEmpty()){
|
|
|
+ laserService.updateStatus(numList,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);
|
|
|
+ private void updateOssStatus(List<String> v3NumList ,List<String> v4NumList , Integer payStatus) {
|
|
|
+ if(!v3NumList.isEmpty()){
|
|
|
+ v3NumList.forEach(e ->this.updateOssStatus(String.format(OssPath.v3_statusPath,e),payStatus));
|
|
|
}
|
|
|
- for (ScenePlus scenePlus : plusList) {
|
|
|
- this.updateOssStatus(String.format(OssPath.v4_statusPath,scenePlus.getNum()),payStatus);
|
|
|
+ if(!v4NumList.isEmpty()){
|
|
|
+ v4NumList.forEach(e ->this.updateOssStatus(String.format(OssPath.v4_statusPath,e),payStatus));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -671,13 +685,14 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
space = ext.getSpace();
|
|
|
}
|
|
|
+ CameraType cameraType = cameraTypeService.getByCameraType(detailEntity.getType());
|
|
|
|
|
|
- Boolean canSpace = cameraDetailService.checkSpace(detailEntity,incrementType,space);
|
|
|
+ Boolean canSpace = cameraDetailService.checkSpace(detailEntity,incrementType,space,cameraType);
|
|
|
|
|
|
if(!canSpace){
|
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
|
|
|
}
|
|
|
- this.copySceneNoCheck(sceneNum);
|
|
|
+ copyScene(detailEntity,scenePro,scenePlus,cameraType);
|
|
|
|
|
|
}
|
|
|
|
|
@@ -690,22 +705,50 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(detailEntity == null){
|
|
|
throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
|
|
|
}
|
|
|
+ IncrementType incrementType = null;
|
|
|
+ UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
|
|
|
+ if(userIncrement != null && userIncrement.getIsExpired() != 1){
|
|
|
+ incrementType = incrementTypeService.getById(userIncrement.getIncrementTypeId());
|
|
|
+ }
|
|
|
+ Long space = null;
|
|
|
+ if( scenePro != null ){
|
|
|
+ space = scenePro.getSpace();
|
|
|
+ }
|
|
|
+ if( scenePlus != null ){
|
|
|
+ ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
|
|
|
+ space = ext.getSpace();
|
|
|
+ }
|
|
|
+ CameraType cameraType = cameraTypeService.getByCameraType(detailEntity.getType());
|
|
|
+
|
|
|
+ Boolean canSpace = cameraDetailService.checkSpace(detailEntity,incrementType,space,cameraType);
|
|
|
+
|
|
|
+ if(!canSpace){
|
|
|
+ throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
|
|
|
+ }
|
|
|
+
|
|
|
+ copyScene(detailEntity,scenePro,scenePlus,cameraType);
|
|
|
+ }
|
|
|
|
|
|
+ private void copyScene(CameraDetail detailEntity,ScenePro scenePro,ScenePlus scenePlus,CameraType cameraType) throws Exception {
|
|
|
String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
|
|
|
|
|
|
Long sceneId = scenePro == null ? scenePlus.getId() :scenePro.getId();
|
|
|
Long newSceneId = null;
|
|
|
FolderScene folderScene = folderSceneService.getByType(sceneId, null);
|
|
|
+ if(cameraType.getIsLaser() == 1){
|
|
|
+ String redisKey = RedisKeyUtil.laserCopyLock + newNum;
|
|
|
+ redisUtil.set(redisKey,"1",60*60);
|
|
|
+ }
|
|
|
|
|
|
if(scenePro !=null){ //v3场景复制
|
|
|
log.info("场景复制--V3--OldNum:{},oldTitle:{},newNum:{},", scenePro.getNum(),scenePro.getSceneName(),newNum);
|
|
|
|
|
|
- newSceneId = this.copyV3Scene(scenePro, newNum, detailEntity);
|
|
|
+ newSceneId = this.copyV3Scene(scenePro, newNum, detailEntity,cameraType);
|
|
|
}
|
|
|
if(scenePlus != null){ //v4场景复制
|
|
|
log.info("场景复制--V4--OldNum:{},oldTitle:{},newNum:{}", scenePlus.getNum(),scenePlus.getTitle(),newNum);
|
|
|
|
|
|
- newSceneId = scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity);
|
|
|
+ newSceneId = scenePlusService.copyV4Scene(scenePlus,newNum,detailEntity,cameraType);
|
|
|
}
|
|
|
log.info("场景复制--完成--sceneId:{}",newSceneId);
|
|
|
|
|
@@ -730,7 +773,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public Long copyV3Scene(ScenePro scenePro,String newNum,CameraDetail cameraDetail) throws Exception {
|
|
|
+ public Long copyV3Scene(ScenePro scenePro,String newNum,CameraDetail cameraDetail,CameraType cameraType) throws Exception {
|
|
|
|
|
|
String oldNum = scenePro.getNum();
|
|
|
Long sceneProId = scenePro.getId();
|
|
@@ -744,6 +787,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
scenePro.setStatus(0);
|
|
|
this.save(scenePro);
|
|
|
|
|
|
+
|
|
|
ExecutorService executor = ThreadUtil.newSingleExecutor();
|
|
|
try {
|
|
|
|
|
@@ -802,7 +846,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
String targetVoice = String.format(SceneResourcePath.voicePath, scenePro.getNum());
|
|
|
this.copyOssAndNas(oldNum,scenePro.getNum(),sourceVoice,targetVoice);
|
|
|
|
|
|
- if(scenePro.getSceneSource() == 4 || scenePro.getSceneSource() == 5){ //深时复制
|
|
|
+ if(cameraType.getIsLaser() == 1){ //深时复制
|
|
|
String laserPath = laserService.copyDataSource(oldDataSource,scenePro.getDataSource());
|
|
|
laserService.copy(oldNum,scenePro.getCameraId(),scenePro.getCreateTime(),newNum,2,laserPath,
|
|
|
oldEditScene.getSceneKey(),null,scenePro.getUserId(),"V3",scenePro.getIsObj(),scenePro.getSceneSource(),scenePro.getCreateTime(),scenePro.getShootCount());
|
|
@@ -812,9 +856,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
sceneCopyLogService.saveByNum(oldNum,newNum,scenePro.getUserId());
|
|
|
|
|
|
- Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail.getCameraId(), scenePro.getSpace());
|
|
|
+ Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail, scenePro.getSpace(),cameraType);
|
|
|
if(!checkSpace){
|
|
|
- this.lockOrUnLockScenes(Arrays.asList(scenePro.getId()),-2);
|
|
|
+ this.lockOrUnLockScenes(Arrays.asList(scenePro.getNum()),new ArrayList<>(),-2,cameraType.getIsLaser());
|
|
|
}
|
|
|
cameraDetailService.addUsedSpace(cameraDetail,scenePro.getSpace());
|
|
|
|
|
@@ -1072,6 +1116,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
sceneVo.setPayStatus(scenePro.getPayStatus());
|
|
|
sceneVo.setCreateTime(DateUserUtil.getDate(scenePro.getCreateTime()).getTime());
|
|
|
sceneVo.setSpace(scenePro.getSpace());
|
|
|
+ sceneVo.setVersion("v3");
|
|
|
voList.add(sceneVo);
|
|
|
}
|
|
|
List<ScenePlus> plusList = scenePlusService.getListByCameraId(cameraId);
|
|
@@ -1093,6 +1138,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
sceneVo.setCreateTime(DateUserUtil.getDate(time).getTime());
|
|
|
sceneVo.setSpace(ext.getSpace());
|
|
|
+ sceneVo.setVersion("v4");
|
|
|
voList.add(sceneVo);
|
|
|
}
|
|
|
return voList;
|