瀏覽代碼

下载全景图数据
下载点位数据

dengsixing 2 年之前
父節點
當前提交
71ddf1a05c

+ 18 - 0
src/main/java/com/fdkankan/scene/controller/SceneEditController.java

@@ -410,6 +410,24 @@ public class SceneEditController extends BaseController {
         return sceneProService.uploadObjAndImg(sceneNum, file);
     }
 
+    /**
+     * 下载全景图数据
+     */
+    @CheckCurrentUser(description = "下载全景图数据")
+    @RequestMapping(value = "/downloadPanoramaData")
+    public ResultData downloadPanoramaData(@RequestParam("sceneNum") String sceneNum) throws Exception{
+        return sceneProService.downloadPanoramaData(sceneNum);
+    }
+
+    /**
+     * 下载点位数据
+     */
+    @CheckCurrentUser(description = "下载点位数据")
+    @RequestMapping(value = "/downloadVisionData")
+    public ResultData downloadVisionData(@RequestParam("sceneNum") String sceneNum) throws Exception{
+        return sceneProService.downloadVisionData(sceneNum);
+    }
+
 
 
 }

+ 4 - 0
src/main/java/com/fdkankan/scene/service/ISceneProService.java

@@ -93,4 +93,8 @@ public interface ISceneProService extends IService<ScenePro> {
 
     Result createScene(RequestScene param) throws Exception;
 
+    ResultData downloadPanoramaData(String sceneNum) throws Exception;
+
+    ResultData downloadVisionData(String sceneNum) throws Exception;
+
 }

+ 72 - 0
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -122,6 +122,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
     private int maxCheckTimes;
     @Value("${ecs.checkFile.waitTime:5000}")
     private int waitTime;
+    @Value("${fyun.host}")
+    private String fyunHost;
 
     @Override
     public ResultData upgradeToV4ResultSync(RequestSceneProV4 param) throws Exception {
@@ -3380,4 +3382,74 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         return Result.success(mainUrl + "/" + sceneProNewUrl + param.getNum());
 
     }
+
+
+    @Override
+    public ResultData downloadPanoramaData(String sceneNum) throws Exception {
+        ScenePro sceneProEntity = findBySceneNum(sceneNum);
+        if(sceneProEntity == null){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+        }
+        StringBuffer imagesBuf = new StringBuffer().append("images").append(File.separator)
+            .append("images").append(sceneProEntity.getNum()).append(File.separator);
+
+        StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
+
+        String highPath = sceneProEntity.getDataSource() + "/results/high";
+        if(!new File(highPath).exists()){
+            fYunFileService.downloadFileByCommand(highPath, sceneProEntity.getDataSource().replace(ConstantFilePath.BUILD_MODEL_LASER_PATH,ConstantFilePath.OSS_PREFIX).replace(ConstantFilePath.BUILD_MODEL_PATH,ConstantFilePath.OSS_PREFIX)+"_results/results/high/");
+            if(!new File(highPath).exists()){
+                throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
+            }
+        }
+
+        //获取高清图,拷贝高清图
+        String content = FileUtils.readFile(sceneProEntity.getDataSource() + "/results/vision.txt");
+        if (!ObjectUtils.isEmpty(content)) {
+            File file = new File(highPath.concat("/pano"));
+            if(!file.exists()){
+                file.mkdirs();
+            }
+            JSONObject.parseObject(content).getJSONArray("sweepLocations").stream()
+                .map(o -> (JSONObject) o)
+                .map(o -> o.getString("uuid"))
+                .forEach(fileName -> FileUtils.copyFile(sceneProEntity.getDataSource().concat("/caches/images/").concat(fileName).concat(".jpg"),
+                    highPath.concat("/pano/").concat(fileName).concat(".jpg"), true)
+
+                );
+        }
+        if(!new File(imagesBuffer.toString()).exists()){
+            new File(imagesBuffer.toString()).mkdirs();
+        }
+        ZipUtil.zip(highPath, imagesBuffer.toString() + sceneNum + "-high.zip");
+        fYunFileService.uploadFileByCommand(imagesBuffer.toString() + sceneNum + "-high.zip", imagesBuf.toString() + sceneNum + "-high.zip");
+        return ResultData.ok(fyunHost + imagesBuf.toString() + sceneNum + "-high.zip?t=" + System.currentTimeMillis());
+    }
+
+    @Override
+    public ResultData downloadVisionData(String sceneNum) throws Exception {
+        ScenePro sceneProEntity = findBySceneNum(sceneNum);
+        if(sceneProEntity == null){
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
+        }
+        StringBuffer dataBuf = new StringBuffer().append("data").append(File.separator)
+            .append("data").append(sceneProEntity.getNum()).append(File.separator);
+
+        StringBuffer imagesBuf = new StringBuffer().append("images").append(File.separator)
+            .append("images").append(sceneProEntity.getNum()).append(File.separator);
+
+        StringBuffer dataBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(dataBuf.toString());
+        StringBuffer imagesBuffer = new StringBuffer(ConstantFilePath.SCENE_PATH).append(imagesBuf.toString());
+
+
+        fYunFileService.downloadFile(imagesBuf.toString() + "vision.modeldata", dataBuffer.toString() + "vision.modeldata");
+        File file = new File(dataBuffer.toString() + "vision.modeldata");
+        if(!file.exists()) {
+            throw new BusinessException(ErrorCode.FAILURE_CODE_5012);
+        }
+        ConvertUtils.convertVisionModelDataToTxt(dataBuffer.toString() + "vision.modeldata", dataBuffer.toString() + "vision.json");
+
+        fYunFileService.uploadFile(dataBuffer.toString() + "vision.json", dataBuf.toString() + "vision.json");
+        return ResultData.ok(fyunHost + dataBuf.toString() + "vision.json?t=" + System.currentTimeMillis());
+    }
 }