lyhzzz hace 2 años
padre
commit
a2f044451c

+ 5 - 20
src/main/java/com/fdkankan/fusion/common/util/FileWriterUtil.java

@@ -80,33 +80,18 @@ public class FileWriterUtil {
                 || file1.getName().endsWith(".osgb") || file1.getName().endsWith(".b3dm")){
                     fileList.add(file1);
                 }
-//                if(file1.getName().equals("tileset.json")){
-//                    checkB3dmTileset(file1);
-//                }
             }else {
                 getCanRunList(fileList,file1);
             }
         }
     }
 
-    public static Boolean checkB3dmTileset(File jsonFile) {
-        String fileObj = FileUtil.readUtf8String(jsonFile);
-        JSONObject jsonObject = JSONObject.parseObject(fileObj);
-        JSONObject root = jsonObject.getJSONObject("root");
-        JSONArray children = root.getJSONArray("children");
-        for (Object child : children) {
-            JSONObject o = (JSONObject) child;
-            JSONObject content = o.getJSONObject("content");
-            String uri = content.getString("uri");
-            String uriPath = jsonFile.getPath().replace(jsonFile.getName(),"");
-            uriPath = uriPath + uri.replace("./","");
-            File file = new File(uriPath);
-            if(!file.exists()){
-                return false;
-            }
-
+    public static Boolean checkB3dmTileset(File objPathFile) {
+        if(objPathFile.isDirectory()){
+            String path = objPathFile.getPath() + "/tileset.json";
+            return new File(path).exists();
         }
-        return true;
+        return objPathFile.exists();
     }
 
 }

+ 18 - 2
src/main/java/com/fdkankan/fusion/service/impl/ModelServiceImpl.java

@@ -142,6 +142,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                     setCreateStatus(model,-1);
                     throw new BusinessException(ResultCode.UPLOAD_FILE_MSG_ERROR);
                 }
+
                 File file1 = fileList.get(0);
                 if(file1 == null){
                     setCreateStatus(model,-1);
@@ -151,6 +152,13 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                     setCreateStatus(model,-1);
                     throw new BusinessException(ResultCode.UPLOAD_FILE_CHINA_NAME);
                 }
+
+                if(file1.getName().endsWith(".b3dm")  ){
+                    if(!FileWriterUtil.checkB3dmTileset(objPathFile)){
+                        setCreateStatus(model,-1);
+                        throw new BusinessException(ResultCode.UPLOAD_FILE_MSG_ERROR);
+                    }
+                }
                 redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"20");
 
                 File mntFile = null;
@@ -196,16 +204,24 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                         model.setModelDateType("osgb");
                         model.setModelType("b3dm");
 
+                        redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
                         String localPath = OBJToGLBUtil.OsgbToB3dm(objPathFile);
+
+                        if(!FileWriterUtil.checkB3dmTileset(new File(localPath))){
+                            throw new BusinessException(ResultCode.UPLOAD_FILE_MSG_ERROR);
+                        }
+
+                        redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"80");
                         ShellUtil.yunUpload(localPath,b3dmPath);
-                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath))));
+                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath+ objPathFile.getName() +"/tileset.json"))));
                         //FileUtil.del(localPath);
                     }
                     if(name.contains(".b3dm")){
                         model.setModelDateType("b3dm");
                         model.setModelType("b3dm");
+                        redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
                         ShellUtil.yunUpload(objPathFile.getPath(),b3dmPath);
-                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath))));
+                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath + objPathFile.getName() +"/tileset.json"))));
                     }
 
                     setCreateStatus(model,1);