瀏覽代碼

提交代码

tianboguang 3 年之前
父節點
當前提交
9a393db954

+ 37 - 34
4dkankan-center-scene/src/main/java/com/fdkankan/scene/service/impl/SceneEditInfoServiceImpl.java

@@ -1039,6 +1039,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
         //比对图片列表,不存在的要返回名称集合
         String visionPath = path + "/results/vision.txt";
+        if(!new File(visionPath).exists()){
+            uploadToOssUtil.download(String.format("images/images%s/vision.txt", num),path + "/results/vision.txt");
+        }
         List<String> panoramaImageList = SceneUtil.getPanoramaImageList(visionPath);
         List<String> notExistFileList = uploadFileList.stream().filter(filePath -> {
             filePath = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
@@ -1050,36 +1053,37 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
         if(CollUtil.isNotEmpty(notExistFileList)){
             //删除错误文件
-            notExistFileList.parallelStream().forEach(filePath->{
-                FileUtils.deleteFile(filePath);
-            });
+            notExistFileList.parallelStream().forEach(FileUtils::deleteFile);
         }
 
         //判断成功的图片,如果成功图片为0,就直接返回,不需要执行算法
         uploadFileList = FileUtil.getFileList(targetImagesPath);
         if(CollUtil.isEmpty(uploadFileList)){
             if(CollUtil.isNotEmpty(notExistFileList)){
-                notExistFileList = notExistFileList.stream().map(filePath -> {
-                    return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
-                }).collect(Collectors.toList());
+                notExistFileList = notExistFileList.stream()
+                        .map(filePath -> filePath.substring(filePath.lastIndexOf(File.separator) + 1))
+                        .collect(Collectors.toList());
             }
             return ResultData.ok(new UploadPanoramaVO(0, notExistFileList));
         }
 
         //上传
         Map<String, String> map = new HashMap<>();
-//        uploadFileList.stream().forEach(filePath->{
-//            map.put(filePath, filePath.replace(targetImagesPath, imgCachePath));
-//        });
 
         String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
-        FileUtils.downLoadFromUrl(ossUrlPrefix + imgViewPath + "vision.modeldata" + "?m="+new Date().getTime(),
-            "vision.modeldata", target + File.separator + "extras" + File.separator);
-        CreateObjUtil.convertVisionmodeldataToTxt(target + File.separator + "extras" + File.separator + "vision.modeldata",
-            target + File.separator + "extras" + File.separator + "vision.txt");
 
-        FileUtils.copyFile(path + File.separator + "data.json", target + File.separator+"data.json", true);
-        FileUtils.copyFile(path + File.separator + "project.json", target + File.separator+"project.json", true);
+        FileUtils.copyFile(path + "/results/vision.txt", target + File.separator + "extras" + File.separator + "vision.txt", true);
+        if (new File(path + File.separator + "data.json").exists()) {
+            FileUtils.copyFile(path + File.separator + "data.json", target + File.separator + "data.json", true);
+        } else {
+            CreateObjUtil.ossUtilCp(path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, ConstantFilePath.OSS_PREFIX).replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX) + "_results/data.json", target);
+        }
+
+        if (new File(path + File.separator + "project.json").exists()) {
+            FileUtils.copyFile(path + File.separator + "project.json", target + File.separator + "project.json", true);
+        } else {
+            CreateObjUtil.ossUtilCp(path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, ConstantFilePath.OSS_PREFIX).replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX) + "_results/project.json", target);
+        }
 
         //data.json增加extras为执行重建算法
         String data = FileUtils.readFile(target + File.separator+"data.json");
@@ -1113,10 +1117,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         if(new File(target + File.separator + "results").exists()){
             FileUtils.delAllFile(target + File.separator + "results");
         }
-        if(StorageType.AWS.code().equals(this.type)){
-            //亚马逊保持旧方式,超链接capture
-            CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
-        }
+
         CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", target + File.separator + "capture/");
         CreateObjUtil.build3dModel(target , "1");
 
@@ -1142,10 +1143,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             fileJson = array.getJSONObject(i);
             fileName = fileJson.getString("file");
             //文件不存在抛出异常
-            if (!new File(target + File.separator + "results" + File.separator + fileName)
-                .exists()) {
-                throw new Exception(
-                    target + File.separator + "results" + File.separator + fileName + "文件不存在");
+            if (!new File(target + File.separator + "results" + File.separator + fileName).exists()) {
+                throw new Exception(target + File.separator + "results" + File.separator + fileName + "文件不存在");
             }
 
             //high文件夹
@@ -1164,7 +1163,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
             //tiles文件夹,亚马逊没有裁剪图片api,不需要上传4k图
             if (fileJson.getIntValue("clazz") == 5) {
                 map.put(target + File.separator + "results" + File.separator + fileName,
-                    imgViewPath + fileName);
+                        imgViewPath + fileName);
                 continue;
             }
 
@@ -1181,9 +1180,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
 
         //拷贝修改后的全景图到缓存目录
         String cachedImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
-        uploadFileList.stream().forEach(srcPath->{
-            cn.hutool.core.io.FileUtil.copy(srcPath, srcPath.replace(targetImagesPath, cachedImagesPath), true);
-        });
+        uploadFileList.stream().forEach(srcPath->
+            cn.hutool.core.io.FileUtil.copy(srcPath, srcPath.replace(targetImagesPath, cachedImagesPath), true));
 
         //更新数据库版本号
         SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
@@ -1218,6 +1216,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         String path = scenePlusExt.getDataSource();
 
         String cachePath = String.format(ConstantFilePath.SCENE_CACHE, num);
+
         String imgCachePath = String.format(UploadFilePath.IMG_CACHES_PATH, num);
         String localImagesPath =  String.format(ConstantFilePath.SCENE_CACHE_IMAGES, num);
 
@@ -1830,8 +1829,17 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         file.transferTo(targetFile);
 
         //调用算法切全景图
-        FileUtils.copyFile(path + File.separator + "data.json", target + File.separator+"data.json", true);
-        FileUtils.copyFile(path + File.separator + "project.json", target + File.separator+"project.json", true);
+        if (new File(path + File.separator + "data.json").exists()) {
+            FileUtils.copyFile(path + File.separator + "data.json", target + File.separator + "data.json", true);
+        } else {
+            CreateObjUtil.ossUtilCp(path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, ConstantFilePath.OSS_PREFIX).replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX) + "_results/data.json", target);
+        }
+
+        if (new File(path + File.separator + "project.json").exists()) {
+            FileUtils.copyFile(path + File.separator + "project.json", target + File.separator + "project.json", true);
+        } else {
+            CreateObjUtil.ossUtilCp(path.replace(ConstantFilePath.BUILD_MODEL_LASER_PATH, ConstantFilePath.OSS_PREFIX).replace(ConstantFilePath.BUILD_MODEL_PATH, ConstantFilePath.OSS_PREFIX) + "_results/project.json", target);
+        }
         JSONObject visionJson = new JSONObject();
         JSONArray visionArray = new JSONArray();
         visionJson.put("uuid", sid);
@@ -1885,11 +1893,6 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
         if(cn.hutool.core.io.FileUtil.exist(resultPath)){
             cn.hutool.core.io.FileUtil.del(resultPath);
         }
-        //下载data.fdage
-        if(StorageType.AWS.code().equals(this.type)){
-            //亚马逊保持旧方式,超链接capture
-            CreateObjUtil.createSoftConnection(path + File.separator + "capture", capturePath);
-        }
         CreateObjUtil.ossUtilCp(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", capturePath);
         CreateObjUtil.build3dModel(target , "1");