Browse Source

上传b3dm文件

lyhzzz 2 years ago
parent
commit
9dc1724368

+ 8 - 4
src/main/java/com/fdkankan/fusion/common/util/FileWriterUtil.java

@@ -86,12 +86,16 @@ public class FileWriterUtil {
         }
     }
 
-    public static Boolean checkB3dmTileset(File objPathFile) {
+    public static String checkB3dmTileset(File objPathFile) {
         if(objPathFile.isDirectory()){
-            String path = objPathFile.getPath() + "/tileset.json";
-            return new File(path).exists();
+            File[] files = objPathFile.listFiles();
+            for (File file : files) {
+                if(file.getName().endsWith(".json")){
+                    return file.getName();
+                }
+            }
         }
-        return objPathFile.exists();
+        return null;
     }
 
 }

+ 8 - 5
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -156,9 +156,10 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                     if(com.fdkankan.fusion.common.util.StringUtils.isChinese(file1.getName())){
                         throw new BusinessException(-1,"压缩包中文");
                     }
-
+                    String b3dmJsonPath = null;
                     if(file1.getName().endsWith(".b3dm")  ){
-                        if(!FileWriterUtil.checkB3dmTileset(objPathFile)){
+                        b3dmJsonPath = FileWriterUtil.checkB3dmTileset(objPathFile);
+                        if(b3dmJsonPath == null){
                             throw new BusinessException(-1,"缺少tileset.json文件");
 
                         }
@@ -205,13 +206,15 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                         redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
                         String localPath = OBJToGLBUtil.OsgbToB3dm(objPathFile);
 
-                        if(!FileWriterUtil.checkB3dmTileset(new File(localPath))){
+                        String jsonPath = FileWriterUtil.checkB3dmTileset(objPathFile);
+                        if(jsonPath == null){
                             throw new BusinessException(-1,"缺少tileset.json文件");
+
                         }
 
                         redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"80");
                         ShellUtil.yunUpload(localPath,b3dmPath);
-                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath+ objPathFile.getName() +"/tileset.json"))));
+                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath+ objPathFile.getName() +"/" + jsonPath))));
                         //FileUtil.del(localPath);
                     }
                     if(name.contains(".b3dm")){
@@ -219,7 +222,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                         model.setModelType("b3dm");
                         redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
                         ShellUtil.yunUpload(objPathFile.getPath(),b3dmPath);
-                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath + objPathFile.getName() +"/tileset.json"))));
+                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath + objPathFile.getName() +"/" + b3dmJsonPath))));
                     }
 
                     setCreateStatus(model,1);