瀏覽代碼

复制不依赖相机

lyhzzz 1 年之前
父節點
當前提交
5242cfd1da

+ 2 - 0
src/main/java/com/fdkankan/ucenter/service/IScene3dNumService.java

@@ -14,4 +14,6 @@ import com.baomidou.mybatisplus.extension.service.IService;
 public interface IScene3dNumService extends IService<Scene3dNum> {
 
     String generateSceneNum(Integer type);
+
+    Integer getCameraTypeBySceneSource(Integer sceneSource);
 }

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/IScenePlusService.java

@@ -39,7 +39,7 @@ public interface IScenePlusService extends IService<ScenePlus> {
 
     ScenePlus getByNum(String sceneNum);
 
-    Long copyV4Scene(ScenePlus scenePlus,String newNum, CameraDetail cameraDetail) ;
+    Long copyV4Scene(ScenePlus scenePlus,String newNum) ;
 
     List<ScenePlus> getByIds(List<Long> plusIds);
 

+ 1 - 1
src/main/java/com/fdkankan/ucenter/service/ISceneProService.java

@@ -57,7 +57,7 @@ public interface ISceneProService extends IService<ScenePro> {
 
     ScenePro getByNum(String sceneNum);
 
-    Long copyV3Scene(ScenePro scenePro, String newNum, CameraDetail cameraDetail) throws Exception;
+    Long copyV3Scene(ScenePro scenePro, String newNum) throws Exception;
 
 
     void delete(String sceneNum,Long userId);

+ 9 - 0
src/main/java/com/fdkankan/ucenter/service/impl/Scene3dNumServiceImpl.java

@@ -56,4 +56,13 @@ public class Scene3dNumServiceImpl extends ServiceImpl<IScene3dNumMapper, Scene3
 
     }
 
+    @Override
+    public Integer getCameraTypeBySceneSource(Integer sceneSource) {
+        switch (sceneSource){
+            case 3 : return  9;       //看见
+            case 4 : return  10;      //深时
+            case 5 : return  11;      //深光
+        }
+        return 1;
+    }
 }

+ 6 - 6
src/main/java/com/fdkankan/ucenter/service/impl/ScenePlusServiceImpl.java

@@ -172,7 +172,7 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
     }
 
     @Override
-    public Long copyV4Scene(ScenePlus scenePlus,String newNum ,CameraDetail cameraDetail)  {
+    public Long copyV4Scene(ScenePlus scenePlus,String newNum )  {
         String oldNum = scenePlus.getNum();
 
         Long plusId = scenePlus.getId();
@@ -269,11 +269,11 @@ public class ScenePlusServiceImpl extends ServiceImpl<IScenePlusMapper, ScenePlu
                 this.updateById(scenePlus);
                 sceneCopyLogService.saveByNum(oldNum,newNum,scenePlus.getUserId());
 
-                Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail.getCameraId(), plusExt.getSpace());
-                if(!checkSpace){
-                    sceneProService.lockOrUnLockScenes(Arrays.asList(scenePlus.getId()),-2);
-                }
-                cameraDetailService.addUsedSpace(cameraDetail,plusExt.getSpace());
+//                Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail.getCameraId(), plusExt.getSpace());
+//                if(!checkSpace){
+//                    sceneProService.lockOrUnLockScenes(Arrays.asList(scenePlus.getId()),-2);
+//                }
+//                cameraDetailService.addUsedSpace(cameraDetail,plusExt.getSpace());
 
             }catch (Exception e){
                 log.error("复制场景失败-V4-sceneNum:{},error:{}",oldNum,e);

+ 58 - 57
src/main/java/com/fdkankan/ucenter/service/impl/SceneProServiceImpl.java

@@ -237,7 +237,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     }
 
     /**
-     * @param payStatus -2 封存,为 1 解封
+     * @param  -2 封存,为 1 解封
      */
     @Override
     public void lockOrUnLockBySpace(CameraDetail cameraDetail, Long cameraId) {
@@ -636,47 +636,47 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         if((scenePro == null || scenePro.getCameraId() == null ) && (scenePlus== null || scenePlus.getCameraId() == null)){
             throw new BusinessException(SceneConstant.FAILURE_CODE_5005, SceneConstant.FAILURE_MSG_5005);
         }
-        Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
-        Long userId = scenePro == null ? scenePlus.getUserId() :scenePro.getUserId();
-        // 判断是否有绑定会员权益
-        Long count = userIncrementService.getValidCountByCameraId(cameraId);
-        if(count <= 0){
-            throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
-        }
-        if(userId == null){
-            throw new BusinessException(SceneConstant.FAILURE_CODE_5013, SceneConstant.FAILURE_MSG_5013);
-        }
-        //只能复制自己的场景
-        User user = userService.getByUserName(userName);
-        if(user == null || !user.getId().equals(userId) ){
-            throw new BusinessException(SceneConstant.FAILURE_CODE_5013, SceneConstant.FAILURE_MSG_5013);
-        }
-        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
-        if(detailEntity == null){
-            throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
-        }
-        UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
-        if(userIncrement == null || userIncrement.getIsExpired() == 1){
-            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);
-        }
-        Long space = null;
-        if( scenePro != null ){
-            space = scenePro.getSpace();
-        }
-        if( scenePlus != null ){
-            ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
-            space = ext.getSpace();
-        }
-
-        Boolean canSpace = cameraDetailService.checkSpace(detailEntity,incrementType,space);
-
-        if(!canSpace){
-            throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
-        }
+//        Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
+//        Long userId = scenePro == null ? scenePlus.getUserId() :scenePro.getUserId();
+//        // 判断是否有绑定会员权益
+//        Long count = userIncrementService.getValidCountByCameraId(cameraId);
+//        if(count <= 0){
+//            throw new BusinessException(LoginConstant.FAILURE_CODE_3030, LoginConstant.FAILURE_MSG_3030);
+//        }
+//        if(userId == null){
+//            throw new BusinessException(SceneConstant.FAILURE_CODE_5013, SceneConstant.FAILURE_MSG_5013);
+//        }
+//        //只能复制自己的场景
+//        User user = userService.getByUserName(userName);
+//        if(user == null || !user.getId().equals(userId) ){
+//            throw new BusinessException(SceneConstant.FAILURE_CODE_5013, SceneConstant.FAILURE_MSG_5013);
+//        }
+//        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
+//        if(detailEntity == null){
+//            throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
+//        }
+//        UserIncrement userIncrement = userIncrementService.getByCameraId(cameraId);
+//        if(userIncrement == null || userIncrement.getIsExpired() == 1){
+//            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);
+//        }
+//        Long space = null;
+//        if( scenePro != null ){
+//            space = scenePro.getSpace();
+//        }
+//        if( scenePlus != null ){
+//            ScenePlusExt ext = scenePlusExtService.getByPlusId(scenePlus.getId());
+//            space = ext.getSpace();
+//        }
+//
+//        Boolean canSpace = cameraDetailService.checkSpace(detailEntity,incrementType,space);
+//
+//        if(!canSpace){
+//            throw new BusinessException(CameraConstant.FAILURE_CODE_6008, CameraConstant.FAILURE_MSG_6008);
+//        }
         this.copySceneNoCheck(sceneNum);
 
     }
@@ -685,13 +685,14 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     public synchronized void copySceneNoCheck(String sceneNum) throws Exception {
         ScenePro scenePro = this.getByNum(sceneNum);
         ScenePlus scenePlus = scenePlusService.getByNum(sceneNum);
-        Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
-        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
-        if(detailEntity == null){
-            throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
-        }
-
-        String newNum = scene3dNumService.generateSceneNum(detailEntity.getType());
+//        Long cameraId = scenePro == null ? scenePlus.getCameraId() : scenePro.getCameraId();
+//        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraId);
+//        if(detailEntity == null){
+//            throw new BusinessException(CameraConstant.FAILURE_CODE_6029, CameraConstant.FAILURE_MSG_6029);
+//        }
+        Integer sceneSource = scenePro == null ? scenePlus.getSceneSource() : scenePro.getSceneSource();
+        Integer cameraType = scene3dNumService.getCameraTypeBySceneSource(sceneSource);
+        String newNum = scene3dNumService.generateSceneNum(cameraType);
 
         Long sceneId = scenePro == null ? scenePlus.getId() :scenePro.getId();
         Long newSceneId = null;
@@ -700,12 +701,12 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         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);
         }
         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);
         }
         log.info("场景复制--完成--sceneId:{}",newSceneId);
 
@@ -730,7 +731,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) throws Exception {
 
         String oldNum = scenePro.getNum();
         Long sceneProId = scenePro.getId();
@@ -812,11 +813,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
 
                 sceneCopyLogService.saveByNum(oldNum,newNum,scenePro.getUserId());
 
-                Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail.getCameraId(), scenePro.getSpace());
-                if(!checkSpace){
-                    this.lockOrUnLockScenes(Arrays.asList(scenePro.getId()),-2);
-                }
-                cameraDetailService.addUsedSpace(cameraDetail,scenePro.getSpace());
+//                Boolean checkSpace = cameraDetailService.checkSpace(cameraDetail.getCameraId(), scenePro.getSpace());
+//                if(!checkSpace){
+//                    this.lockOrUnLockScenes(Arrays.asList(scenePro.getId()),-2);
+//                }
+//                cameraDetailService.addUsedSpace(cameraDetail,scenePro.getSpace());
 
             }catch ( Exception e){
                 log.error("复制场景失败-sceneNum:{},error:{}",oldNum,e);