lyhzzz 2 years ago
parent
commit
ba193f87d1

+ 6 - 2
src/main/java/com/fdkankan/fusion/common/util/FileWriterUtil.java

@@ -90,8 +90,12 @@ public class FileWriterUtil {
         if(objPathFile.isDirectory()){
             File[] files = objPathFile.listFiles();
             for (File file : files) {
-                if(file.getName().endsWith(".json")){
-                    return file.getName();
+                if(file.isFile()){
+                    if(file.getName().endsWith(".json")){
+                        return file.getPath();
+                    }
+                }else {
+                    checkB3dmTileset(file);
                 }
             }
         }

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

@@ -198,7 +198,8 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                         }
                     }
                     model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(queryPath + glbOssPath)));
-                    String b3dmPath = String.format(FilePath.B3DM_OSS_PATH,environment, model.getModelId());
+
+                    String b3dmPath = objPathFile.getPath().replace(FilePath.LOCAL_BASE_PATH,"fusion/");
                     if(name.contains(".osgb")){
                         model.setModelDateType("osgb");
                         model.setModelType("b3dm");
@@ -214,15 +215,15 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
 
                         redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"80");
                         ShellUtil.yunUpload(localPath,b3dmPath);
-                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath + b3dmPath+ objPathFile.getName() +"/" + jsonPath))));
+                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath +  jsonPath.replace(FilePath.LOCAL_BASE_PATH,"fusion/")))));
                         //FileUtil.del(localPath);
                     }
-                    if(name.contains(".b3dm")){
+                    if(name.contains(".b3dm") && b3dmJsonPath != null){
                         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 + objPathFile.getName() +"/" + b3dmJsonPath))));
+                        model.setModelGlbUrl((JSONArray.toJSONString(Arrays.asList(queryPath +  b3dmJsonPath.replace(FilePath.LOCAL_BASE_PATH,"fusion/")))));
                     }
 
                     setCreateStatus(model,1);
@@ -233,13 +234,13 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                     log.error("uploadObj--ThreadError-modeId:{},error:{}",model.getModelId(),e);
                 }finally {
                     if(newObjFile!=null){
-                        FileUtil.del(newObjFile);
+                        //FileUtil.del(newObjFile);
                     }
                     if(objPathFile!=null){
-                        FileUtil.del(objPathFile);
+                        //FileUtil.del(objPathFile);
                     }
                     if(mntFile!=null){
-                       FileUtil.del(mntFile.getParentFile());
+                       //FileUtil.del(mntFile.getParentFile());
                     }
                 }
             }, executor).whenComplete((reslut, e) -> {