lyhzzz пре 1 година
родитељ
комит
5980a579c1

+ 7 - 11
src/main/java/com/fdkankan/fusion/common/util/OBJToGLBUtil.java

@@ -120,22 +120,18 @@ public class OBJToGLBUtil {
     }
 
     public static File lasOrPlyToBin(File srcFile) throws IOException {
-        String mntPath = srcFile.getPath().replace(FilePath.LOCAL_BASE_PATH,FilePath.MNT_BASE_PATH);
-        String mntPathEmt = srcFile.getParent().replace(FilePath.LOCAL_BASE_PATH,FilePath.MNT_BASE_PATH)+"/res";
-        File file = new File(mntPathEmt);
-        if(!file.exists()){
-            file.mkdirs();
+        if(!srcFile.exists()){
+            srcFile.mkdirs();
         }
-        FileUtil.copy(srcFile.getPath(),mntPath,true);
         String cmd = ShellUtil.LAS_TO_BIN;
-        cmd =  cmd.replace("@inPath",mntPath);
-        cmd = cmd.replace("@outPath",mntPathEmt);
+        cmd =  cmd.replace("@inPath",srcFile.getPath());
+        cmd = cmd.replace("@outPath",srcFile.getParentFile().getPath());
         ShellUtil.execCmd(cmd);
         log.info("lasOrPlyToBin---------cmd-over");
-        String cloudJs = mntPathEmt +"/webcloud/"+ "cloud.js";
+        String cloudJs = srcFile.getParentFile().getPath() +"/webcloud/"+ "cloud.js";
         JSONObject jsonObject = ShellUtil.fixCloud(cloudJs);
-        FileWriterUtil.writerJson(mntPathEmt +"/webcloud/","cloud.js",jsonObject.toJSONString());
-        return file;
+        FileWriterUtil.writerJson(srcFile.getParentFile().getPath() +"/webcloud/","cloud.js",jsonObject.toJSONString());
+        return srcFile.getParentFile();
     }
 
     public static String OsgbToB3dm(File objPathFile) {

+ 1 - 1
src/main/java/com/fdkankan/fusion/common/util/ShellCmd.java

@@ -10,6 +10,6 @@ public class ShellCmd {
 	public static final String FYUN_UPLOAD = "bash /opt/ossutil/fyun-upload.sh %s %s /%s %s %s";
 	public static final String FYUN_DOWN = "bash /opt/ossutil/fyun-download.sh %s /%s %s %s %s";
 
-	public static final String osgbTob3dmCmd = "/mnt/fusion/3dtile.sh -f osgb -i " +
+	public static final String osgbTob3dmCmd = "bash /mnt/fusion/3dtile.sh -f osgb -i " +
 			"@inputFile -o @outputFile";
 }

+ 2 - 2
src/main/java/com/fdkankan/fusion/controller/CaseFilesController.java

@@ -69,7 +69,7 @@ public class CaseFilesController extends BaseController{
         caseFilesService.save(caseFiles);
         String url = null;
         try {
-            url = uploadService.uploadFile(file, false, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
+            url = uploadService.uploadFile(file, true, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
         }catch (Exception e){
             caseFilesService.removeById(caseFiles.getFilesId());
             throw e;
@@ -153,7 +153,7 @@ public class CaseFilesController extends BaseController{
         caseFiles.setImgType(imgType);
         caseFiles.setContent(content);
         caseFilesService.saveOrUpdate(caseFiles);
-        String url = uploadService.uploadFile(file, false, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
+        String url = uploadService.uploadFile(file, true, String.format(FilePath.File_OSS_PATH,environment,caseFiles.getFilesId() + "/"));
         caseFiles.setFilesUrl(url);
         caseFilesService.saveOrUpdate(caseFiles);
         return ResultData.ok(caseFiles);

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

@@ -125,17 +125,23 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
     public PageInfo pageList(ModelPram param, String userName) {
         LambdaQueryWrapper<Model> wrapper = new LambdaQueryWrapper<>();
         List<String> deptIds = tmDepartmentService.getDeptIds();
+        deptIds.add("-1");
         if(deptIds.size() <=0){
             return PageInfo.PageInfo(new Page<>(param.getPageNum(),param.getPageSize()));
         }
         if(param.getCaseId() !=null){
             String deptId =  caseService.getDeptId(param.getCaseId());
-            wrapper.eq(Model::getDeptId,deptId);
+            wrapper.in(Model::getDeptId,Arrays.asList(deptId,"-1"));
         }
         if(StringUtils.isNotBlank(param.getDeptId())){
-            wrapper.eq(Model::getDeptId,param.getDeptId());
+            if(deptIds.contains(param.getDeptId())){
+                wrapper.in(Model::getDeptId,Arrays.asList(param.getDeptId(),"-1"));
+            }else {
+                wrapper.eq(Model::getDeptId,"-1");
+            }
+        }else {
+            wrapper.in(Model::getDeptId,deptIds);
         }
-        wrapper.in(Model::getDeptId,deptIds);
         wrapper.eq(Model::getType,3);
         wrapper.notIn(Model::getCreateStatus,-2);
         if(param.getStatus()!=null){    //参数2为成功,数据库中成功为1
@@ -152,12 +158,15 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
             if(model.getType() == 3 && StringUtils.isEmpty(model.getNum())) {
                 model.setNum(model.getModelId().toString());
             }
-            if(StringUtils.isNotBlank(model.getDeptId())){
+            if(StringUtils.isNotBlank(model.getDeptId()) && !"-1".equals(model.getDeptId())){
                 TmDepartment tmDepartment = mapByDept.get(model.getDeptId());
                 if(tmDepartment != null){
                     model.setDeptName(tmDepartment.getName());
                 }
             }
+            if("-1".equals(model.getDeptId())){
+                model.setDeptName("模型库");
+            }
         }
         return PageInfo.PageInfo(page);
     }

+ 7 - 4
src/main/java/com/fdkankan/fusion/service/impl/ThreadService.java

@@ -89,6 +89,8 @@ public class ThreadService {
                 if(!uploadToOssUtil.existKey(glbOssPath)){
                     throw new BusinessException(-1,"缺少.glb文件");
                 }
+                model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(queryPath + glbOssPath)));
+
             }
             if(name.contains(".ply")){
                 model.setModelDateType("ply");
@@ -100,14 +102,15 @@ public class ThreadService {
             }
             if("las".equals(model.getModelType()) || "ply".equals(model.getModelType()) ){
                 mntFile =  OBJToGLBUtil.lasOrPlyToBin(file1);
-                glbOssPath = mntFile.getPath().replace("/mnt/","")+"/webcloud";
+                String ossPath = mntFile.getPath().replace("/mnt/","");
                 redisUtil.set(RedisKeyUtil.modelUpload+model.getModelId(),"65");
-                uploadToOssUtil.uploadFileOss(mntFile );
-                if(!uploadToOssUtil.existKey(glbOssPath+"/cloud.js")){
+                ShellUtil.yunUpload(mntFile.getPath(),ossPath);
+
+                model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(queryPath  +ossPath +"/webcloud")));
+                if(!uploadToOssUtil.existKey(ossPath+"/webcloud/cloud.js")){
                     throw new BusinessException(-1,"缺少cloud.js文件");
                 }
             }
-            model.setModelGlbUrl(JSONArray.toJSONString(Arrays.asList(queryPath + glbOssPath)));
 
             String b3dmPath = objPathFile.getPath().replace(FilePath.LOCAL_BASE_PATH,"fusion/");
             if(name.contains(".osgb")){

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

@@ -1,5 +1,6 @@
 package com.fdkankan.fusion.service.impl;
 
+import cn.hutool.core.io.FileUtil;
 import com.fdkankan.fusion.common.FilePath;
 import com.fdkankan.fusion.common.ResultCode;
 import com.fdkankan.fusion.common.util.ShellUtil;
@@ -17,6 +18,11 @@ import javax.annotation.Resource;
 import java.io.File;
 import java.io.IOException;
 import java.net.URLEncoder;
+import java.nio.charset.StandardCharsets;
+import java.nio.file.Files;
+import java.nio.file.Path;
+import java.nio.file.Paths;
+import java.nio.file.StandardCopyOption;
 import java.util.LinkedHashSet;
 import java.util.UUID;
 
@@ -93,12 +99,12 @@ public class UploadService {
             if(fileName.length() >50){
                 fileName =  fileName.substring(0,50);
             }
+
             //localFile = File.createTempFile(fileName + suffixName,suffixName);
             localFile = new File(FilePath.MNT_PATH_TMP+ UUID.randomUUID().toString().replace("-","")+"/" + fileName + suffixName);
             if(!localFile.getParentFile().exists()){
                 localFile.getParentFile().mkdirs();
             }
-
             file.transferTo(localFile);
             String path = localFile.getPath();
             ShellUtil.yunUpload(path,filePathAdd+ fileName + suffixName);
@@ -111,7 +117,7 @@ public class UploadService {
             throw new BusinessException(ResultCode.UPLOAD_ERROR.code,ResultCode.UPLOAD_ERROR.msg);
         }finally {
             if(localFile!=null){
-                localFile.getParentFile().delete();
+                FileUtil.del(localFile.getParentFile().getPath());
             }
         }