lyhzzz 2 gadi atpakaļ
vecāks
revīzija
349946a0f0

+ 17 - 4
src/main/java/com/fdkankan/fusion/common/util/OBJToGLBUtil.java

@@ -6,6 +6,7 @@ import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.exception.BusinessException;
 import com.fdkankan.fusion.exception.BusinessException;
 import lombok.extern.slf4j.Slf4j;
 import lombok.extern.slf4j.Slf4j;
+import org.omg.CosNaming.NamingContextExtPackage.StringNameHelper;
 
 
 import java.io.*;
 import java.io.*;
 import java.util.LinkedHashSet;
 import java.util.LinkedHashSet;
@@ -127,12 +128,24 @@ public class OBJToGLBUtil {
         return file;
         return file;
     }
     }
 
 
-    public static String OsgbToB3dm(File objPathFile,Integer modelId) {
-        String targetPath = FilePath.MNT_BASE_PATH +"osgb" +"/" + modelId +"/" + objPathFile.getName();
-        String sourcePath = FilePath.MNT_BASE_PATH +"b3dm" +"/" + modelId +"/" + objPathFile.getName();
+    public static String OsgbToB3dm(File objPathFile) {
+        String targetPath = FilePath.MNT_BASE_PATH +"osgb"  +"/" + objPathFile.getName();
+        String sourcePath = FilePath.MNT_BASE_PATH +"b3dm"  +"/" + objPathFile.getName();
 
 
         //ShellUtil.execCmd("cp -r " + objPath + " " + dockerPath+ objPathFile.getName()   );
         //ShellUtil.execCmd("cp -r " + objPath + " " + dockerPath+ objPathFile.getName()   );
-        FileUtil.copyContent(objPathFile,new File(targetPath),true);
+        File file = new File(targetPath);
+        FileUtil.copyContent(objPathFile,file,true);
+        String dirName = "";
+        if(file.exists()){
+            File[] files = file.listFiles();
+            for (File file1 : files) {
+                if(file1.isDirectory()){
+                    dirName = file1.getName();
+                }
+            }
+        }
+        targetPath +="/" + dirName;
+        sourcePath +="/" + dirName;
 
 
         String cmd = ShellCmd.osgbTob3dmCmd.replaceAll("@path",FilePath.MNT_BASE_PATH);
         String cmd = ShellCmd.osgbTob3dmCmd.replaceAll("@path",FilePath.MNT_BASE_PATH);
         cmd =cmd.replaceAll("@inputFile",targetPath);
         cmd =cmd.replaceAll("@inputFile",targetPath);

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

@@ -203,7 +203,7 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
                         model.setModelType("b3dm");
                         model.setModelType("b3dm");
 
 
                         redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
                         redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"60");
-                        String localPath = OBJToGLBUtil.OsgbToB3dm(objPathFile,model.getModelId());
+                        String localPath = OBJToGLBUtil.OsgbToB3dm(objPathFile);
 
 
                         if(!FileWriterUtil.checkB3dmTileset(new File(localPath))){
                         if(!FileWriterUtil.checkB3dmTileset(new File(localPath))){
                             throw new BusinessException(-1,"缺少tileset.json文件");
                             throw new BusinessException(-1,"缺少tileset.json文件");