dengsixing 5 月之前
父节点
当前提交
22ff788d3d
共有 1 个文件被更改,包括 25 次插入0 次删除
  1. 25 0
      src/main/java/com/fdkankan/jp/xspace/service/impl/UnityServiceImpl.java

+ 25 - 0
src/main/java/com/fdkankan/jp/xspace/service/impl/UnityServiceImpl.java

@@ -1,8 +1,10 @@
 package com.fdkankan.jp.xspace.service.impl;
 
+import cn.hutool.core.collection.CollUtil;
 import cn.hutool.core.io.FileUtil;
 import cn.hutool.core.util.StrUtil;
 import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
 import com.fdkankan.common.constant.CommonStatus;
@@ -67,6 +69,29 @@ public class UnityServiceImpl implements IUnityService {
             fYunFileService.downloadFile(v, localMeshPath + v.replace(meshKey, ""));
         });
 
+        //如果有三维模型,需要下载三维模型原始文件
+        String sceneJsonKey = String.format(OSSPathConstant.SCENE_VIEW_DATA_DATA, bean.getNum()) + "scene.json";
+        String sceneJsonStr = fYunFileService.getFileContent(sceneJsonKey);
+        JSONObject sceneJsonObj = JSON.parseObject(sceneJsonStr);
+        String boxModelsStr = sceneJsonObj.getString("boxModels");
+        if(StrUtil.isNotEmpty(boxModelsStr)){
+            List<JSONObject> jsonObjects = JSON.parseArray(boxModelsStr, JSONObject.class);
+            if(CollUtil.isNotEmpty(jsonObjects)){
+                String userViewPath = String.format(OSSPathConstant.SCENE_VIEW_DATA_USER, bean.getNum());
+                jsonObjects.stream().forEach(item->{
+                    String sid = item.getString("sid");
+                    String origObjPath = userViewPath + "boxModels/" + sid + "/";
+                    List<String> objFileList = fYunFileService.listRemoteFiles(origObjPath);
+                    if(CollUtil.isNotEmpty(objFileList)){
+                        objFileList.stream().forEach(objKey->{
+                            fYunFileService.downloadFile(objKey, workPath + objKey.replace(OSSPathConstant.SCENE_VIEW_DATA + bean.getNum() + "/", ""));
+                        });
+                    }
+                });
+            }
+        }
+
+
         return workPath;
     }