Browse Source

脚本管理

lyhzzz 1 year ago
parent
commit
56d45a6ab4

+ 21 - 0
src/main/java/com/fdkankan/fusion/common/util/OBJToGLBUtil.java

@@ -35,6 +35,27 @@ public class OBJToGLBUtil {
         log.info("obj转换glb完毕:" + command);
         log.info("obj转换glb完毕:" + command);
     }
     }
 
 
+    public static String objToB3dm(String objPath, String glbPath)  {
+        log.info("obj转换glb开始,{}",objPath);
+        if(!checkObj(objPath)){
+            throw new BusinessException(-1,"obj文件错误");
+        }
+        log.info("obj转换glb开始");
+        String command = "obj2gltf -i " + objPath + " -o " + glbPath;
+        log.info("执行obj转换glb命令路径-{}", command);
+        ShellUtil.execCmd(command);
+        log.info("obj转换glb完毕:" + command);
+        return glbPath;
+    }
+    public static void objToB3dm2(String objPath,String glbPath)  {
+        log.info("obj转换glb开始,{}",objPath);
+        log.info("obj转换glb开始");
+        String command = "obj2gltf -i " + objPath + " -o " + glbPath;
+        log.info("执行obj转换glb命令路径-{}", command);
+        ShellUtil.execCmd(command);
+        log.info("obj转换glb完毕:" + command);
+    }
+
     public static boolean checkObj(String objPath) {
     public static boolean checkObj(String objPath) {
         File file = new File(objPath);
         File file = new File(objPath);
         File file1 = file.getParentFile();
         File file1 = file.getParentFile();

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

@@ -303,16 +303,16 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
             throw new BusinessException(ResultCode.MODEL_NOT_EXIST);
             throw new BusinessException(ResultCode.MODEL_NOT_EXIST);
         }
         }
         Integer oldId = modelEntity.getModelId();
         Integer oldId = modelEntity.getModelId();
+        modelEntity.setModelTitle(modelEntity.getModelTitle() +"(copy)");
         modelEntity.setModelId(null);
         modelEntity.setModelId(null);
         this.save(modelEntity);
         this.save(modelEntity);
-        if(StringUtils.isNotBlank(modelEntity.getModelGlbUrl())){
-            String modelGlbUrl = modelEntity.getModelGlbUrl();
-            copyOssResource(modelGlbUrl,oldId,modelEntity.getModelId());
-            String newModelObjUrl = modelGlbUrl.replaceAll(oldId+"",modelEntity.getModelId()+"");
-            modelEntity.setModelGlbUrl(newModelObjUrl);
-            modelEntity.setModelTitle(modelEntity.getModelTitle() +"(copy)");
-            this.updateById(modelEntity);
-        }
+//        if(StringUtils.isNotBlank(modelEntity.getModelGlbUrl())){
+//            String modelGlbUrl = modelEntity.getModelGlbUrl();
+//            copyOssResource(modelGlbUrl,oldId,modelEntity.getModelId());
+//            String newModelObjUrl = modelGlbUrl.replaceAll(oldId+"",modelEntity.getModelId()+"");
+//            modelEntity.setModelGlbUrl(newModelObjUrl);
+//            this.updateById(modelEntity);
+//        }
 
 
     }
     }