Browse Source

Merge branch 'obt-copyDataAndBuild'

tianboguang 2 năm trước cách đây
mục cha
commit
f20322f568

+ 6 - 0
src/main/java/com/fdkankan/contro/controller/SceneFileController.java

@@ -113,4 +113,10 @@ public class SceneFileController{
         return map;
     }
 
+
+    @GetMapping("copyDataAndBuild")
+    public ResultData copyDataAndBuild(@RequestParam(value = "dataSource") String dataSource,@RequestParam(value = "sceneVer") String sceneVer,
+                                       @RequestParam(value = "sourceBucket",required = false) String sourceBucket) throws Exception {
+        return sceneFileBuildService.copyDataAndBuild(sourceBucket,dataSource ,sceneVer);
+    }
 }

+ 1 - 1
src/main/java/com/fdkankan/contro/entity/ScenePlusExt.java

@@ -155,7 +155,7 @@ public class ScenePlusExt implements Serializable {
      * A正常,I删除
      */
     @TableField("rec_status")
-    @TableLogic("A")
+    @TableLogic(value = "A",delval = "I")
     private String recStatus;
 
     /**

+ 2 - 2
src/main/java/com/fdkankan/contro/mq/listener/AbstrackBuildSceneListener.java

@@ -21,7 +21,6 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
         String msg = new String(message.getBody(), StandardCharsets.UTF_8);
         log.info("开始准备场景计算资源,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
         BuildSceneCallMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneCallMessage.class);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
         if(ObjectUtils.isEmpty(buildSceneMessage.getBuildContext())){
             buildSceneMessage.setBuildContext(new HashMap<>());
         }
@@ -30,6 +29,7 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
         }
         buildSceneService.buildScenePre(buildSceneMessage);
         log.info("准备场景计算资源完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
     }
 
     @Override
@@ -38,8 +38,8 @@ public class AbstrackBuildSceneListener implements IBuildSceneListener {
         String msg = new String(message.getBody(), StandardCharsets.UTF_8);
         log.info("场景计算完成,开始处理场景计算结果,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
         BuildSceneResultMqMessage buildSceneMessage = JSONObject.parseObject(msg, BuildSceneResultMqMessage.class);
-        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
         buildSceneService.buildScenePost(buildSceneMessage);
         log.info("场景计算结果处理完成,队列名:{},id:{},消息体:{}", queueName, messageId, msg);
+        channel.basicAck(message.getMessageProperties().getDeliveryTag(), false);
     }
 }

+ 2 - 0
src/main/java/com/fdkankan/contro/mq/service/impl/BuildSceneServiceImpl.java

@@ -259,6 +259,8 @@ public class BuildSceneServiceImpl implements IBuildSceneService {
                     .forEach(entry-> uploadHouseTypeJson(sceneCode,entry.getKey()));
 
             //写scene.json
+
+
             log.info("生成scene.json上传oss并设置缓存,num:{}", sceneCode);
             CameraDetail cameraDetail = cameraDetailService.getByCameraId(scenePlus.getCameraId());
             Company company = !ObjectUtils.isEmpty(cameraDetail.getCompanyId()) ? companyService.getById(cameraDetail.getCompanyId()) : null;

+ 4 - 19
src/main/java/com/fdkankan/contro/mq/service/impl/BuildV3SceneServiceImpl.java

@@ -176,7 +176,7 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
                 return;
             }
 
-            Map<String, String> uploadFiles = getUploadFiles(path,cameraType,fdageData);
+            Map<String, String> uploadFiles = getUploadFiles(sceneCode,path,cameraType,fdageData);
 
             //建模成功走以下逻辑
             log.info("cameraType:{}",cameraType);
@@ -260,16 +260,7 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
         }
     }
 
-    private Map<String, String> getUploadFiles(String path,Integer cameraType,JSONObject fdageData) throws Exception {
-        ScenePro scenePro = sceneProService.getOne(
-                new LambdaQueryWrapper<ScenePro>().like(ScenePro::getDataSource, path));
-        if (ObjectUtils.isEmpty(scenePro)) {
-            throw new Exception("未找到场景信息:" + path);
-        }
-
-        String projectNum = scenePro.getNum();
-
-
+    private Map<String, String> getUploadFiles(String projectNum,String path,Integer cameraType,JSONObject fdageData) throws Exception {
         String dataViewPath = String.format(ConstantFilePath.DATA_PATH_FORMAT, projectNum);
         String imagesPath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, projectNum);
         String videoPath = String.format(ConstantFilePath.VIDEO_PATH_FORMAT, projectNum);
@@ -559,13 +550,8 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
     }
 
     private ScenePro updateDbPlus(String num, Long space, String videosJson, Long computeTime,boolean isObj){
-        ScenePro scenePro = sceneProService.getByNum(num);
-        if (ObjectUtils.isEmpty(scenePro)) {
-            return null;
-        }
-
         sceneProService.update(new LambdaUpdateWrapper<ScenePro>()
-                .in(ScenePro::getId, scenePro.getId())
+                .eq(ScenePro::getNum, num)
                 .set(ScenePro::getStatus, SceneStatus.NO_DISPLAY.code())
                 .set(ScenePro::getUpdateTime, new Date())
                 .set(ScenePro::getCreateTime, new Date())
@@ -574,8 +560,7 @@ public class BuildV3SceneServiceImpl implements IBuildSceneService {
                 .set(ScenePro::getVideos, videosJson)
                 .set(ScenePro::getIsObj, isObj ? 1 : 0)
                 .set(ScenePro::getPayStatus, PayStatus.PAY.code()));
-
-        return scenePro;
+       return sceneProService.getByNum(num);
     }
 
     private int getPayStatus(Long cameraId, Long space) throws Exception{

+ 1 - 0
src/main/java/com/fdkankan/contro/service/ISceneFileBuildService.java

@@ -27,4 +27,5 @@ public interface ISceneFileBuildService extends IService<SceneFileBuild> {
 
     ResultData rebuildScene(String num,Boolean force,Boolean deleteExtras) throws IOException;
 
+    ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer) throws Exception;
 }

+ 396 - 36
src/main/java/com/fdkankan/contro/service/impl/SceneFileBuildServiceImpl.java

@@ -278,8 +278,28 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             log.error("大场景序号为空:" + sceneNum);
             throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
         }
+        String dataSource = cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
+                fileId + File.separator + unicode;
+        if (cameraType == 14) {
+            dataSource = ConstantFilePath.BUILD_MODEL_LASER_PATH +dataSource;
+        } else {
+            dataSource = ConstantFilePath.BUILD_MODEL_PATH + dataSource;
+        }
+
+        String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
+
+        String icon = null;
+        if (!ObjectUtils.isEmpty(jsonObject.getString("icon"))) {
+            fYunFileService.copyFileInBucket(ConstantFilePath.OSS_PREFIX + prefix + jsonObject.getString("icon"),imgViewPath + jsonObject.getString("icon"));
+            icon = fYunFileConfig.getHost() + imgViewPath + jsonObject.getString("icon");
+            log.info("上传icon成功....");
+        }
 
+        return buildScenePost(dataSource, jsonObject, buildType, cameraType, sceneNum, cameraDetail, rebuild,icon);
+    }
 
+    private ScenePlusVO buildScenePost(String dataSource, JSONObject jsonObject, String buildType, long cameraType,
+                                       String sceneNum, CameraDetail cameraDetail, int rebuild,String icon) throws Exception {
         String localDataPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, sceneNum);
         String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
         String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum);
@@ -290,13 +310,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             userName = ObjectUtils.isEmpty(user) ? null : user.getUserName();
         }
 
-        String icon = null;
-        if (!ObjectUtils.isEmpty(jsonObject.getString("icon"))) {
-            fYunFileService.copyFileInBucket(ConstantFilePath.OSS_PREFIX + prefix + jsonObject.getString("icon"),imgViewPath + jsonObject.getString("icon"));
-            icon = fYunFileConfig.getHost() + imgViewPath + jsonObject.getString("icon");
-            log.info("上传icon成功....");
-        }
-
         JSONObject firmwareVersion = new JSONObject();
         if (!ObjectUtils.isEmpty(jsonObject.getString("camSoftwareVersion"))) {
             firmwareVersion.put("camSoftwareVersion", jsonObject.getString("camSoftwareVersion"));
@@ -311,7 +324,6 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         //重算的场景,先移除该场景对应的容量
         if (rebuild == 1) {
             scenePlusService.resetSpace(sceneNum);
-
             //删除oss的houst_floor.json(国际版可能会卡住)
             fYunFileService.deleteFile(dataViewPath + "houst_floor.json");
         } else {
@@ -321,8 +333,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         }
         String algorithm = jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam";
 
-        ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, camera.getId(), camera.getChildName(), jsonObject.getString("creator"),
-                jsonObject.getString("pwd"), unicode,cameraType, fileId, icon,  cameraDetail.getUserId(), userName,algorithm,
+        ScenePlusVO scenePlusVO = this.createScenePlus(sceneNum, cameraDetail.getCameraId(), jsonObject.getString("creator"),
+                jsonObject.getString("pwd"),cameraType, dataSource, icon,  cameraDetail.getUserId(), userName,algorithm,
                 jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
                 jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), rebuild,
                 jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType, cameraDetail.getCooperationUser());
@@ -521,12 +533,17 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
         String buildType = "V2";
         Long cameraType = 10L;
+
+        if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
+            log.error("data.fdage文件不存在");
+            throw new BusinessException(CameraConstant.FAILURE_6009);
+        }
+
         JSONObject fdageJson = JSONObject.parseObject(fYunFileService.getFileContent(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage"));
         if(ObjectUtils.isEmpty(fdageJson)){
-            log.info("data.fdage文件不存在");
+            log.info("data.fdage文件为空!");
             throw new BusinessException(CameraConstant.FAILURE_6009);
         }
-
         //根据videoVersion判断是V2还是V3版本的算法和页面
         if (fdageJson.containsKey("videoVersion") && StrUtil.isNotEmpty(fdageJson.getString("videoVersion"))) {
             if (fdageJson.getIntValue("videoVersion") >= 4) {
@@ -633,9 +650,14 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         //云目录
         StringBuilder prefixBuffer = new StringBuilder(mac).append(File.separator).append(fileId).append(File.separator).append(folderName).append(File.separator);
 
+        if(!fYunFileService.fileExist(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage")){
+            log.error("data.fdage文件不存在");
+            throw new BusinessException(CameraConstant.FAILURE_6009);
+        }
+
         JSONObject fdageJson = JSONObject.parseObject(fYunFileService.getFileContent(ConstantFilePath.OSS_PREFIX + prefixBuffer + "data.fdage"));
         if(ObjectUtils.isEmpty(fdageJson)){
-            log.info("data.fdage文件不存在");
+            log.info("data.fdage文件为空");
             throw new BusinessException(CameraConstant.FAILURE_6009);
         }
         String buildType = "V3";
@@ -686,8 +708,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         return ResultData.ok();
     }
 
-    public ScenePlusVO createScenePlus(String projectNum, Long cameraId, String cameraName, String phoneId, String sceneKey,
-                                     String unicode, Long cameraType, String fileId, String pic, Long userId, String userName,
+    public ScenePlusVO createScenePlus(String projectNum, Long cameraId, String phoneId, String sceneKey,
+                                     Long cameraType, String dataSource, String pic, Long userId, String userName,
                                      String algorithm, Integer sceneShootCount, String sceneName,
                                      String sceneDec, Integer sceneType, String gps,Integer type,
                                      Integer resolution, String firmwareVersion, String url, String buildType,
@@ -700,17 +722,8 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
         scenePlus.setCameraId(cameraId);
         scenePlus.setPhoneId(phoneId);
         scenePlus.setNum(projectNum);
-
         scenePlus.setSceneSource(1);
-         if(cameraType.longValue() == 14){
-            scenePlusExt.setDataSource(ConstantFilePath.BUILD_MODEL_LASER_PATH +
-                    cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
-                    fileId + File.separator + unicode);
-        }else{
-            scenePlusExt.setDataSource(ConstantFilePath.BUILD_MODEL_PATH +
-                    cameraName.replace("4DKKPRO_", "").replace("-fdage", "").toLowerCase() + File.separator +
-                    fileId + File.separator + unicode);
-        }
+        scenePlusExt.setDataSource(dataSource);
 
         if(resolution == null || resolution.intValue() == 0){
             scenePlusExt.setSceneScheme(cameraType.intValue());
@@ -1154,19 +1167,13 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
             }
             Camera cameraEntity = cameraService.getById(scenePro.getCameraId());
             fdkkLaserService.saveScene(scenePro, null, cameraEntity, userName, true);
-            BuildSceneCallMessage buildSceneMqMessage = this.getBuildSceneMqMessage(
-                    num, cameraType,
-                    fdageData.getString("location") != null && "1".equals(fdageData.getString("location")) ? "sfm" : "slam",
-                    fdageData.getInteger("resolution"), buildType, path);
-            rabbitMqProducer.sendByWorkQueue(queueV3ModelingPre, buildSceneMqMessage);
-        } else {
-            BuildSceneCallMessage buildSceneMqMessage = this.getBuildSceneMqMessage(
-                    num, cameraType, fdageData.getString("location") != null && "1".equals(fdageData.getString("location")) ? "sfm" : "slam",
-                    fdageData.getInteger("resolution"), buildType,
-                    path);
-            rabbitMqProducer.sendByWorkQueue(queueV3ModelingPre, buildSceneMqMessage);
         }
 
+        BuildSceneCallMessage buildSceneMqMessage = this.getBuildSceneMqMessage(
+                num, cameraType, fdageData.getString("location") != null && "1".equals(fdageData.getString("location")) ? "sfm" : "slam",
+                fdageData.getInteger("resolution"), buildType, path);
+        rabbitMqProducer.sendByWorkQueue(queueV3ModelingPre, buildSceneMqMessage);
+
         //重算的场景,先移除该场景对应的容量
         sceneProService.update(new LambdaUpdateWrapper<ScenePro>()
                 .set(ScenePro::getStatus, SceneStatus.wait.code())
@@ -1175,4 +1182,357 @@ public class SceneFileBuildServiceImpl extends ServiceImpl<ISceneFileBuildMapper
 
         return ResultData.ok();
     }
+
+    @Override
+    public ResultData copyDataAndBuild(String sourceBucet,String dataSource,String sceneVer) throws Exception {
+        if(!StringUtils.equals(sceneVer,"V3") && ! StringUtils.equals(sceneVer,"V4")){
+            throw new BusinessException(ErrorCode.PARAM_FORMAT_ERROR.code(),"版本有误,请填写 V3 或者 V4");
+        }
+
+        String fYunPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+        if(!ObjectUtils.isEmpty(sourceBucet)){
+            fYunFileService.copyFileBetweenBucket(sourceBucet,fYunPath,fYunFileConfig.getBucket(),fYunPath);
+        }
+        // 下载data.fdage
+        JSONObject fdageData = JSONObject.parseObject(fYunFileService.getFileContent(fYunPath + "/data.fdage"));
+        if(ObjectUtils.isEmpty(fdageData)){
+            throw new BusinessException(ErrorCode.SYSTEM_ERROR.code(),"4dage 文件不存在");
+        }
+        String cameraName = fdageData.getJSONObject("cam").getString("uuid");
+        Camera cameraEntity = cameraService.getByChildName(cameraName);
+        if(cameraEntity ==  null){
+            log.error("该相机不存在:" + cameraName);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
+        }
+
+        CameraDetail detailEntity = cameraDetailService.getByCameraId(cameraEntity.getId());
+        if(detailEntity ==  null){
+            log.error("该相机详情不存在:" + cameraName);
+            throw new BusinessException(ErrorCode.FAILURE_CODE_6003);
+        }
+
+        Long cameraType = 11L;
+        //判断是否转台相机
+        if (detailEntity.getType() == 9) {
+            cameraType = 13L;
+        }
+
+        if (detailEntity.getType() == 10) {
+            cameraType = 14L;
+        }
+        String sceneNum = scene3dNumService.generateSceneNum(detailEntity.getType());
+
+        String icon = null;
+        String imgViewPath = null;
+        switch (sceneVer) {
+            case "V3":
+                List<ScenePro> pros = sceneProService.list(new LambdaQueryWrapper<ScenePro>()
+                        .like(ScenePro::getDataSource, dataSource));
+                if (pros.size() > 0) {
+                    return ResultData.error(ErrorCode.PARAM_ERROR.code(),"该场景资源已存在,请勿重复添加!");
+                }
+
+                imgViewPath = String.format(ConstantFilePath.IMAGE_PATH_FORMAT, sceneNum);
+                if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
+                    String ossPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                            .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+                    fYunFileService.copyFileInBucket(ossPath + File.separator + fdageData.getString("icon"),imgViewPath + fdageData.getString("icon"));
+                    icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
+                    log.info("上传icon成功....");
+                }
+                buildV3Scene2(dataSource,fdageData,cameraType,sceneNum,cameraEntity,detailEntity,icon);
+                break;
+            case "V4":
+                List<ScenePlusExt> plusExts = scenePlusExtService.list(new LambdaQueryWrapper<ScenePlusExt>()
+                        .like(ScenePlusExt::getDataSource, dataSource));
+                if (plusExts.size() > 0) {
+                    return ResultData.error(ErrorCode.PARAM_ERROR.code(),"该场景资源已存在,请勿重复添加!");
+                }
+
+                imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
+                if(fdageData.containsKey("icon") && StringUtils.isNotEmpty(fdageData.getString("icon"))){
+                    String ossPath = ConstantFilePath.OSS_PREFIX + dataSource.replace(ConstantFilePath.BUILD_MODEL_PATH, "")
+                            .replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, "");
+                    fYunFileService.copyFileInBucket(ossPath + File.separator + fdageData.getString("icon"),imgViewPath + fdageData.getString("icon"));
+                    icon = fYunFileConfig.getHost() + imgViewPath + fdageData.getString("icon");
+                    log.info("上传icon成功....");
+                }
+                buildScenePost(dataSource,fdageData,"V3",cameraType,sceneNum,detailEntity,0,icon);
+                break;
+        }
+        Map<String,Object> result = new HashMap<>();
+        result.put("code",sceneNum);
+        return ResultData.ok(result);
+    }
+
+    private void buildV3Scene2(String dataSource,JSONObject jsonObject,long cameraType,String sceneNum,Camera cameraEntity,CameraDetail detailEntity,String icon) throws Exception {
+
+        String cameraName = jsonObject.getJSONObject("cam").getString("uuid");
+
+        log.info("查询相机:" + cameraName);
+
+        String userName = null;
+        if(detailEntity.getUserId() != null){
+            SSOUser user = userService.getSSOUserByUserId(detailEntity.getUserId());
+            userName = user.getUserName();
+        }
+
+        JSONObject firmwareVersion = new JSONObject();
+        if(jsonObject.containsKey("camSoftwareVersion") && StringUtils.isNotEmpty(jsonObject.getString("camSoftwareVersion"))){
+            firmwareVersion.put("camSoftwareVersion", jsonObject.getString("camSoftwareVersion"));
+        }
+
+        if(jsonObject.containsKey("version") && StringUtils.isNotEmpty(jsonObject.getString("version"))){
+            firmwareVersion.put("version", jsonObject.getString("version"));
+        }
+
+
+        String buildType = "V3";
+        String sceneUrl = mainUrl + "/" + sceneProNewUrl;
+
+        boolean isObj = jsonObject.containsKey("exportMeshObj") && jsonObject.getIntValue("exportMeshObj") == 1;
+
+        ScenePro scenePro = createScenePro(sceneNum, detailEntity.getCameraId(), jsonObject.getString("creator"),
+                jsonObject.getString("pwd"),
+                cameraType, dataSource, "", icon, detailEntity.getUserId(), userName,
+                jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam",
+                jsonObject.getJSONArray("points").size(), jsonObject.getString("name"), jsonObject.getString("info"),
+                jsonObject.getInteger("scenetype"), jsonObject.getString("gps"), 0,
+                jsonObject.getInteger("resolution"), firmwareVersion.toString(), sceneUrl, buildType,
+                detailEntity.getCooperationUser(), isObj);
+
+        // 通知激光场景系统开始构建场景
+        if(cameraType == 14){
+            fdkkLaserService.saveScene(scenePro, null, cameraEntity, userName, true);
+        }
+
+        BuildSceneCallMessage buildSceneMqMessage = this.getBuildSceneMqMessage(
+                sceneNum, cameraType, jsonObject.getString("location") != null && "1".equals(jsonObject.getString("location")) ? "sfm" : "slam",
+                jsonObject.getInteger("resolution"), buildType, dataSource);
+        rabbitMqProducer.sendByWorkQueue(queueV3ModelingPre, buildSceneMqMessage);
+
+    }
+
+    public ScenePro createScenePro(String projectNum, Long cameraId, String phoneId, String sceneKey,
+                                         Long cameraType, String dataSource, String imgsName,
+                                         String pic, Long userId, String userName, String algorithm,
+                                         Integer sceneShootCount, String sceneName, String sceneDec, Integer sceneType,
+                                         String gps, Integer type, Integer resolution, String firmwareVersion, String url,
+                                         String buildType, Long cooperationUser,Boolean isObj) throws Exception {
+        ScenePro scene;
+        SceneProEdit sceneEdit;
+        if (type == 0) {
+            scene = new ScenePro();
+            sceneEdit = new SceneProEdit();
+        } else {
+            scene = sceneProService.getByNum(projectNum);
+            sceneEdit = sceneProEditService.getByProId(scene.getId());
+        }
+        //先返回链接地址
+        scene.setWebSite(url + projectNum);
+        scene.setCameraId(cameraId);
+        scene.setPhoneId(phoneId);
+        scene.setNum(projectNum);
+
+        scene.setSceneSource(1);
+        scene.setDataSource(dataSource);
+        if (cameraType.longValue() == 5 || cameraType.longValue() == 6) {
+            //场景来源双目相机
+            scene.setSceneSource(2);
+        }
+
+        if (resolution == null || resolution.intValue() == 0) {
+            scene.setSceneScheme(cameraType.intValue());
+        } else {
+            scene.setSceneScheme(4);
+        }
+
+        //场景来源双目相机,sceneScheme为4,加载high,low图
+        if (cameraType.longValue() == 5 || cameraType.longValue() == 6) {
+            scene.setSceneScheme(4);
+        }
+
+        //转台相机用4k图
+        if (cameraType.longValue() == 13) {
+            scene.setSceneSource(3);
+            scene.setSceneScheme(10);
+        }
+
+        //激光相机
+        if (cameraType.longValue() == 14) {
+            scene.setSceneSource(4);
+            scene.setSceneScheme(10);
+        }
+
+        if (pic != null && pic.length() > 5) {
+            scene.setThumb(pic);
+        } else {
+            scene.setThumb(ConstantUrl.DEFAULT_SCENE_PIC);
+        }
+        scene.setThumb(scene.getThumb().concat("?t=") + System.currentTimeMillis());
+        if (!ObjectUtils.isEmpty(userName)) {
+            scene.setUserId(userId);
+        }
+
+        if (sceneShootCount == null) {
+            scene.setShootCount(0);
+        } else {
+            scene.setShootCount(sceneShootCount);
+        }
+        if (sceneName != null) {
+            scene.setSceneName(sceneName);
+        }
+        if (sceneDec != null) {
+            scene.setSceneDec("<p>" + new String(sceneDec.getBytes("UTF-8")) + "</p>");
+        }
+
+        if (sceneType != null) {
+            scene.setSceneType(sceneType);
+        }
+
+        if (gps != null && !gps.trim().equals("")) {
+            scene.setGps(gps);
+        }
+
+        scene.setAlgorithm(algorithm);
+        scene.setFilesName(imgsName);
+        if (!org.springframework.util.StringUtils.isEmpty(firmwareVersion)) {
+            scene.setFirmwareVersion(firmwareVersion);
+        }
+        scene.setBuildType(buildType);
+        log.info("场景记录添加到数据库:" + projectNum);
+        //type=0为新生成场景,其余为重新计算场景
+
+
+        if (type == 0) {
+            scene.setIsObj(ObjectUtils.isEmpty(isObj) || !isObj ? 0 : 1);
+            sceneProService.save(scene);
+
+            sceneEdit = new SceneProEdit();
+            sceneEdit.setNeedKey(0);
+
+            if (sceneKey == null) {
+                sceneKey = "";
+            }
+            sceneEdit.setSceneKey(sceneKey);
+            if (!sceneKey.equals("")) {
+                sceneEdit.setNeedKey(1);
+            } else {
+                sceneEdit.setNeedKey(0);
+            }
+
+            sceneEdit.setProId(scene.getId());
+            sceneEdit.setMapVisi(1);
+            sceneEdit.setTourVisi(1);
+            sceneEdit.setVrVisi(1);
+            sceneEdit.setRulerVisi(0);
+            sceneEdit.setCadImgVisi(1);
+            sceneEdit.setPanoVisi(1);
+            sceneEdit.setM2dVisi(1);
+            sceneEdit.setM3dVisi(1);
+            sceneEdit.setMeasureVisi(0);
+            sceneEdit.setFloorLogoSize(100);
+            sceneEdit.setCreateTime(new Date());
+            sceneProEditService.save(sceneEdit);
+
+            //新增场景时,同时新增场景协作信息
+            if (cooperationUser != null) {
+                SceneCooperation sceneCooperationEntity = new SceneCooperation();
+                sceneCooperationEntity.setNum(projectNum);
+                sceneCooperationEntity.setUserId(cooperationUser);
+                sceneCooperationService.save(sceneCooperationEntity);
+
+                List<SceneResourceCamera> resourceCameraList = sceneResourceCameraService.findListByCameraId(cameraId);
+
+                SceneResourceCooperation sceneResourceCooperationEntity = null;
+                if (resourceCameraList != null && resourceCameraList.size() > 0) {
+                    for (SceneResourceCamera sceneResourceCameraEntity : resourceCameraList) {
+                        sceneResourceCooperationEntity = new SceneResourceCooperation();
+                        sceneResourceCooperationEntity.setSceneResourceId(sceneResourceCameraEntity.getSceneResourceId());
+                        sceneResourceCooperationEntity.setSceneCooperationId(sceneCooperationEntity.getId());
+                        sceneResourceCooperationService.save(sceneResourceCooperationEntity);
+                    }
+                }
+            }
+        } else {
+            scene.setStatus(0);
+            scene.setPayStatus(0);
+            scene.setRecStatus("A");
+            scene.setCreateTime(new Date());
+            if (sceneName != null) {
+                scene.setSceneName(sceneName);
+            }
+            if (sceneType != null) {
+                scene.setSceneType(sceneType);
+            }
+            sceneProService.updateById(scene);
+
+            sceneEdit.setNeedKey(0);
+            if (cameraType.longValue() != 14 && !ObjectUtils.isEmpty(sceneKey)) {
+                sceneEdit.setNeedKey(1);
+                sceneEdit.setSceneKey(sceneKey);
+            }
+            sceneEdit.setProId(scene.getId());
+            sceneEdit.setMapVisi(1);
+            sceneEdit.setTourVisi(1);
+            sceneEdit.setVrVisi(1);
+            sceneEdit.setCadImgVisi(1);
+            sceneEdit.setPanoVisi(1);
+            sceneEdit.setOverlay(null);
+            sceneEdit.setM2dVisi(1);
+            sceneEdit.setPlayData(null);
+            sceneEdit.setFloorLogo("0");
+            sceneEdit.setM3dVisi(1);
+            sceneEdit.setJumpScene(false);
+            sceneEdit.setMeasureVisi(0);
+            sceneEdit.setFloorLogoSize(100);
+            sceneEdit.setUpdateTime(new Date());
+            sceneEdit.setRecStatus("A");
+            sceneEdit.setFloorPublishVer(sceneEdit.getFloorEditVer() + 1);
+            sceneEdit.setFloorEditVer(sceneEdit.getFloorEditVer() + 1);
+            sceneEdit.setVersion(sceneEdit.getVersion() + 1);
+            sceneEdit.setImagesVersion(sceneEdit.getImagesVersion() + 1);
+
+            sceneProEditService.updateById(sceneEdit);
+
+
+        }
+
+        JSONObject scenejson = JSONObject.parseObject(JSONObject.toJSONString(scene));
+        scenejson.put("thumbImg", 0);
+        scenejson.put("version", sceneEdit.getVersion());
+        scenejson.put("floorLogo", 0);
+        if (!ObjectUtils.isEmpty(sceneKey)) {
+            scenejson.put("sceneKey", sceneKey);
+            scenejson.put("public", 1);
+        } else {
+            scenejson.put("sceneKey", "");
+            scenejson.put("public", 0);
+        }
+        if (cameraType.longValue() < 4 || cameraType.longValue() == 5 || cameraType.longValue() == 6) {
+            scenejson.put("visions", 1);
+        } else {
+            scenejson.put("visions", 2);
+        }
+        scenejson.put("createTime", new DateTime(new Date()).toString("yyyy-MM-dd HH:mm"));
+
+        scenejson.put("floorPublishVer", sceneEdit.getFloorPublishVer());
+        scenejson.put("floorEditVer", sceneEdit.getFloorEditVer());
+        scenejson.put("rulerVisi", sceneEdit.getRulerVisi());
+        scenejson.put("entry", null);
+
+        if (!org.springframework.util.StringUtils.isEmpty(sceneEdit.getHotsIds())) {
+            scenejson.put("hots", 1);
+        }
+
+        File file = new File(ConstantFilePath.SCENE_PATH + "data/data" + projectNum);
+        if (!file.exists() || !file.isDirectory()) {
+            file.mkdirs();
+        }
+        FileUtils.writeFile(ConstantFilePath.SCENE_PATH + "data/data" + projectNum + File.separator + "scene.json", scenejson.toString());
+
+        return scene;
+    }
+
 }