dengsixing 1 Minggu lalu
induk
melakukan
887953205f

+ 5 - 4
src/main/java/com/fdkankan/scene/config/FdkkLaserConfig.java

@@ -8,6 +8,7 @@ import org.springframework.boot.context.properties.ConfigurationProperties;
 import org.springframework.stereotype.Component;
 
 import javax.annotation.PostConstruct;
+import java.io.File;
 
 /**
  * 读取项目相关配置
@@ -130,27 +131,27 @@ public class FdkkLaserConfig {
      * 获取导入上传路径
      */
     public static String getImportPath(String prefix) {
-        return FdkkLaserConfig.getProfile(prefix) + "/import";
+        return FdkkLaserConfig.getProfile(prefix) + File.separator + "import";
     }
 
     /**
      * 获取头像上传路径
      */
     public static String getAvatarPath(String prefix) {
-        return FdkkLaserConfig.getProfile(prefix) + "/avatar";
+        return FdkkLaserConfig.getProfile(prefix) +  File.separator + "avatar";
     }
 
     /**
      * 获取下载路径
      */
     public static String getDownloadPath(String prefix) {
-        return FdkkLaserConfig.getProfile(prefix) + "/download/";
+        return FdkkLaserConfig.getProfile(prefix) + File.separator + "download" + File.separator;
     }
 
     /**
      * 获取上传路径
      */
     public static String getUploadPath(String prefix) {
-        return FdkkLaserConfig.getProfile(prefix) + "/upload";
+        return FdkkLaserConfig.getProfile(prefix) + File.separator + "upload";
     }
 }

+ 11 - 3
src/main/java/com/fdkankan/scene/constant/CmdConstant.java

@@ -59,9 +59,17 @@ public class CmdConstant {
     public final static String POTREE_CONVERTER = fdkkLaserConfig.buildCallPath + File.separator + "PotreeConverter.sh @param @inPath @outPath";
     public final static String POTREE_CONVERTER_WIN = fdkkLaserConfig.buildCallPath + File.separator + "PotreeConverter.bat @param @inPath @outPath";
 
-    //生成模型的命令
-    public static final String VIPSTHUMBNAIL = fdkkLaserConfig.buildCallPath + File.separator + "vips/bin/vipsthumbnail.sh @inPath -s @size -o @thumbnailPath";
-    public static final String VIPSTHUMBNAIL_WIN = fdkkLaserConfig.buildCallPath + File.separator + "vips" + File.separator + "bin" + File.separator +  "vipsthumbnail.exe @inPath -s @size -o @thumbnailPath";
+    //热点图片切图
+    public static final String VIPS = fdkkLaserConfig.buildCallPath + File.separator + "vips" + File.separator + "bin" + File.separator + "vips dzsave --tile-size @tileSize @origFilePath @workPath";
+    public static final String VIPS_WIN = fdkkLaserConfig.buildCallPath + File.separator + "vips" + File.separator + "bin" + File.separator + "vips dzsave --tile-size @tileSize @origFilePath @workPath";
+
+    //热点图片切缩略图
+    public static final String VIPS_THUMBNAIL = fdkkLaserConfig.buildCallPath + File.separator + "vips" + File.separator + "bin" + File.separator + "vips thumbnail @inPath -s @size -o @thumbnailPath";
+    public static final String VIPS_THUMBNAIL_WIN = fdkkLaserConfig.buildCallPath + File.separator + "vips" + File.separator + "bin" + File.separator +  "vipsthumbnail.exe @inPath -s @size -o @thumbnailPath";
+
+    //空间模型obj转glb
+    public static final String OBJ_TO_GLTF = fdkkLaserConfig.buildCallPath + File.separator + "obj2gltf -i @objPath -o @glbPath";
+    public static final String OBJ_TO_GLTF_WIN = fdkkLaserConfig.buildCallPath + File.separator + "obj2gltf.exe -i @objPath -o @glbPath";
 
 //    public final static String Potree_Converter = fdkkLaserConfig.buildCallPath + "PotreeConverter.sh layout_detect @in @out";
 //    public final static String Potree_Converter_win = fdkkLaserConfig.buildCallPath + "PotreeConverter.bat layout_detect @in @out";

+ 4 - 2
src/main/java/com/fdkankan/scene/constant/ConstantFileLocPath.java

@@ -1,11 +1,13 @@
 package com.fdkankan.scene.constant;
 
+import java.io.File;
+
 /**
  * @author Xiewj
  * @date 2023/3/17
  */
 public class ConstantFileLocPath {
-    public static final String SCENE_DATA_PATH_V4 = "/scene_v4/%s/data/";
-    public static final String SCENE_USER_PATH_V4 = "/scene_v4/%s/user/";
+    public static final String SCENE_DATA_PATH_V4 = File.separator + "scene_v4" + File.separator + "%s" + File.separator + "data" + File.separator;
+    public static final String SCENE_USER_PATH_V4 = File.separator + "scene_v4" + File.separator + "%s" + File.separator + "user" + File.separator;
 
 }

+ 1 - 3
src/main/java/com/fdkankan/scene/service/impl/BoxModelServiceImpl.java

@@ -64,8 +64,6 @@ public class BoxModelServiceImpl implements IBoxModelService {
     private IScenePlusExtService scenePlusExtService;
     @Autowired
     private OssUtil ossUtil;
-    @Resource
-    private FdkkLaserConfig fdkkLaserConfig;
 
     @Override
     public ResultData uploadBoxModel(String num, String sid, MultipartFile file) throws Exception {
@@ -106,7 +104,7 @@ public class BoxModelServiceImpl implements IBoxModelService {
             });
 
             //转glb
-            OBJToGLBExtUtil.objToGlb(fdkkLaserConfig.buildCallPath, srcPath, glbPath);
+            OBJToGLBExtUtil.objToGlb(srcPath, glbPath);
 
             if(!ComputerUtil.checkComputeCompleted(glbPath, 10, 2000)){
                 throw new BusinessException(ErrorCode.FAILURE_CODE_7013);

+ 9 - 33
src/main/java/com/fdkankan/scene/service/impl/SceneProServiceImpl.java

@@ -15,20 +15,10 @@ import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.fdkankan.common.constant.*;
 import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.common.util.CmdUtils;
-import com.fdkankan.common.util.FileUtils;
-import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.FileUtils;
 import com.fdkankan.model.constants.ConstantFileName;
 import com.fdkankan.model.constants.ConstantFilePath;
 import com.fdkankan.model.constants.UploadFilePath;
-import com.fdkankan.common.exception.BusinessException;
-import com.fdkankan.scene.bean.SceneBean;
-import com.fdkankan.scene.config.FdkkLaserConfig;
-import com.fdkankan.scene.constant.CmdConstant;
-import com.fdkankan.scene.util.CmdBuildUtil;
-import com.fdkankan.scene.util.SystemUtil;
-import com.fdkankan.web.response.ResultData;
 import com.fdkankan.model.utils.ComputerUtil;
 import com.fdkankan.model.utils.ConvertUtils;
 import com.fdkankan.model.utils.CreateObjUtil;
@@ -40,18 +30,14 @@ import com.fdkankan.scene.bean.IconBean;
 import com.fdkankan.scene.bean.LaserSceneBean;
 import com.fdkankan.scene.bean.SceneBean;
 import com.fdkankan.scene.bean.TagBean;
+import com.fdkankan.scene.config.FdkkLaserConfig;
 import com.fdkankan.scene.constant.ConstantFileLocPath;
-import com.fdkankan.scene.entity.SceneEditInfo;
-import com.fdkankan.scene.entity.ScenePlus;
-import com.fdkankan.scene.entity.ScenePlusExt;
-import com.fdkankan.scene.entity.ScenePro;
 import com.fdkankan.scene.entity.*;
 import com.fdkankan.scene.mapper.ISceneProMapper;
 import com.fdkankan.scene.oss.OssUtil;
 import com.fdkankan.scene.service.*;
-import com.fdkankan.scene.vo.*;
-import com.fdkankan.web.response.ResultData;
-import com.fdkankan.scene.service.*;
+import com.fdkankan.scene.util.CmdBuildUtil;
+import com.fdkankan.scene.util.SystemUtil;
 import com.fdkankan.scene.vo.*;
 import com.fdkankan.web.response.ResultData;
 import com.google.common.collect.Lists;
@@ -65,7 +51,6 @@ import org.springframework.web.multipart.MultipartFile;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 
-import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.nio.charset.StandardCharsets;
@@ -75,13 +60,6 @@ import java.util.Map.Entry;
 import java.util.concurrent.CompletableFuture;
 import java.util.stream.Collectors;
 
-import java.io.File;
-import java.io.IOException;
-import java.nio.charset.StandardCharsets;
-import java.util.*;
-import java.util.Map.Entry;
-import java.util.stream.Collectors;
-
 /**
  * <p>
  * pro场景表 服务实现类
@@ -209,15 +187,14 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             FileUtil.mkdir(workPath);
 
             //保存到本地
-            String origFilePath = workPath + "/" + sid + "." + extName;
+            String origFilePath = workPath + File.separator + sid + "." + extName;
             file.transferTo(new File(origFilePath));
 
-            String ossPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "hotspot/" + sid + "/";
+            String ossPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "hotspot" + File.separator + sid + File.separator;
             Map<String, String> uploadMap = new HashMap<>();
 
             //切图
-            String fragmentCmd = fdkkLaserConfig.buildCallPath + File.separator + "vips" + File.separator + "bin" + File.separator + "vips dzsave --tile-size "  + tileSize + " " + origFilePath + " " +  workPath;
-            CmdUtils.callLine(fragmentCmd);
+            CmdBuildUtil.vips(tileSize, origFilePath, workPath);
             if(!ComputerUtil.checkComputeCompleted(dziPath, 5, 200)){
                 throw new BusinessException(ErrorCode.FAILURE_CODE_5052);
             }
@@ -235,9 +212,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
             width = Integer.valueOf(sizeElement.getAttribute("Width"));
             Integer maxSize = height > width ? height : width;
             if(maxSize > size){
-                String thumbnailPath =  workPath + "/" + thumbnailName;
-                String scaleCmd = CmdConstant.VIPSTHUMBNAIL_WIN.replace("@inPath", origFilePath).replace("@size",String.valueOf(size)).replace("@thumbnailPath", thumbnailPath);
-                CmdUtils.callLine(scaleCmd);
+                String thumbnailPath =  workPath + File.separator + thumbnailName;
+                CmdBuildUtil.vipsThumbnail(origFilePath, size, thumbnailPath);
                 if(!ComputerUtil.checkComputeCompleted(thumbnailPath, 5, 200)){
                     throw new BusinessException(ErrorCode.FAILURE_CODE_5052);
                 }
@@ -273,7 +249,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
         ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
         ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
         param.getSidList().stream().forEach(sid->{
-            String ossPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "hotspot/" + sid + "/";
+            String ossPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + "hotspot" + File.separator + sid + File.separator;
             if(CollUtil.isNotEmpty(ossUtil.listFiles(scenePlusExt.getYunFileBucket(), ossPath))){
                 try {
                     ossUtil.deleteObject(scenePlusExt.getYunFileBucket(), ossPath);

+ 54 - 1
src/main/java/com/fdkankan/scene/util/CmdBuildUtil.java

@@ -1,5 +1,6 @@
 package com.fdkankan.scene.util;
 
+import cn.hutool.core.util.RuntimeUtil;
 import cn.hutool.system.OsInfo;
 import cn.hutool.system.SystemUtil;
 import com.fdkankan.scene.constant.CmdConstant;
@@ -89,9 +90,61 @@ public class CmdBuildUtil {
                     .replace("@inPath", inPath).replace("@outPath", outPath);
             CmdUtils.callLineSh(potreeConverterCmd);
         } else {
-            potreeConverterCmd = CmdConstant.OBJ2_TILES_WIN.replace("@param", param)
+            potreeConverterCmd = CmdConstant.POTREE_CONVERTER_WIN.replace("@param", param)
                     .replace("@inPath", inPath).replace("@outPath", outPath);
             CmdUtils.callLineWin(potreeConverterCmd);
         }
     }
+
+    public static void vips(Integer tileSize, String origFilePath, String workPath){
+        String checkLaserCmd = "";
+        if (CmdBuildUtil.OS.isLinux()) {
+            checkLaserCmd =CmdConstant.VIPS
+                    .replace("@tileSize", String.valueOf(tileSize))
+                    .replace("@origFilePath", origFilePath)
+                    .replace("@workPath", workPath);
+            CmdUtils.callLineSh(checkLaserCmd);
+        } else {
+            checkLaserCmd =CmdConstant.VIPS_WIN
+                    .replace("@tileSize", String.valueOf(tileSize))
+                    .replace("@origFilePath", origFilePath)
+                    .replace("@workPath", workPath);
+            CmdUtils.callLineWin(checkLaserCmd);
+
+        }
+    }
+
+    public static void vipsThumbnail(String inPath, Integer size, String thumbnailPath){
+        String checkLaserCmd = "";
+        if (CmdBuildUtil.OS.isLinux()) {
+            checkLaserCmd =CmdConstant.VIPS_THUMBNAIL
+                    .replace("@inPath", inPath)
+                    .replace("@size", String.valueOf(size))
+                    .replace("@thumbnailPath", thumbnailPath);
+            CmdUtils.callLineSh(checkLaserCmd);
+        } else {
+            checkLaserCmd =CmdConstant.VIPS_THUMBNAIL_WIN
+                    .replace("@inPath", inPath)
+                    .replace("@size", String.valueOf(size))
+                    .replace("@thumbnailPath", thumbnailPath);
+            CmdUtils.callLineWin(checkLaserCmd);
+
+        }
+    }
+
+    public static void objToGlb(String objPath, String glbPath) {
+        String checkLaserCmd = "";
+        if (CmdBuildUtil.OS.isLinux()) {
+            checkLaserCmd =CmdConstant.OBJ_TO_GLTF
+                    .replace("@objPath", objPath)
+                    .replace("@glbPath", glbPath);
+            CmdUtils.callLineSh(checkLaserCmd);
+        } else {
+            checkLaserCmd =CmdConstant.OBJ_TO_GLTF_WIN
+                    .replace("@objPath", objPath)
+                    .replace("@glbPath", glbPath);
+            CmdUtils.callLineWin(checkLaserCmd);
+
+        }
+    }
 }

+ 2 - 5
src/main/java/com/fdkankan/scene/util/OBJToGLBExtUtil.java

@@ -19,13 +19,10 @@ import java.util.Locale;
 @Slf4j
 public class OBJToGLBExtUtil extends OBJToGLBUtil {
 
-    public static void objToGlb(String buildCallPath, String objPath, String glbPath) {
+    public static void objToGlb(String objPath, String glbPath) {
         checkObj(objPath);
         objPath = getObj(objPath);
-        String command = buildCallPath + File.separator + "obj2gltf.exe -i " + objPath + " -o " + glbPath;
-        log.info("开始执行obj转换gbl命令-{}", command);
-        Process exec = RuntimeUtil.exec(new String[]{command});
-        log.info("结束执行obj转换gbl命令-{}", command);
+        CmdBuildUtil.objToGlb(objPath, glbPath);
     }
 
     static String getObj(String objPath) {