Ver código fonte

场景obj模型转换为b3dm

lyhzzz 1 ano atrás
pai
commit
d5502fc125

+ 29 - 19
src/main/java/com/fdkankan/fusion/service/impl/CaseNumServiceImpl.java

@@ -14,6 +14,7 @@ import com.fdkankan.fusion.mapper.ICaseNumMapper;
 import com.fdkankan.fusion.request.SceneNumParam;
 import com.fdkankan.fusion.service.*;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import lombok.extern.slf4j.Slf4j;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.beans.factory.annotation.Value;
@@ -34,6 +35,7 @@ import java.util.stream.Collectors;
  * @since 2022-07-27
  */
 @Service
+@Slf4j
 public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntity> implements ICaseNumService {
 
     @Autowired
@@ -97,7 +99,8 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
                 if(param.getType() == 0 || param.getType() == 1 || param.getType() == 4 || param.getType() == 6){           //看看,看见
                     model.setModelObjUrl(String.format(FilePath.OBJ_LOCAL_PATH,environment ,num) +"/mesh.obj");
                     model.setModelGlbUrl(getGlbUrl(param.getType(),num,model));
-                    model.setModelType("glb");
+                    model.setModelType("b3dm");
+                    model.setModelDateType("b3dm");
                 }
                 model.setNum(num);
                 model.setCreateStatus(1);
@@ -116,28 +119,35 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
 
 
     private String getGlbUrl(Integer type, String num,Model model) {
-        if(type == 0 || type == 1 || type == 4 || type == 6){ //看看,看见
-            String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
-
-            ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh" ,objPath);
-            List<String> localGlbPaths = new ArrayList<>();
-            List<String> ossGlbPaths = new ArrayList<>();
-            File localFile = new File(objPath);
-            this.toGlB(localFile,localGlbPaths);
-
-            if(!localGlbPaths.isEmpty()){
-                for (String localGlbPath : localGlbPaths) {
-                    File file = new File(localGlbPath);
-                    model.setModelSize(FileWriterUtil.setFileSize(file.length()));
-                    String ossPath = localGlbPath.replace("/mnt/","");
-                    ShellUtil.yunUpload(localGlbPath,ossPath);
-                    ossGlbPaths.add(queryPath +ossPath+"/tileset.json");
+        String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
+
+        try {
+            if(type == 0 || type == 1 || type == 4 || type == 6){ //看看,看见
+
+                ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num)+"/data/mesh" ,objPath);
+                List<String> localGlbPaths = new ArrayList<>();
+                List<String> ossGlbPaths = new ArrayList<>();
+                File localFile = new File(objPath);
+                this.toGlB(localFile,localGlbPaths);
+
+                if(!localGlbPaths.isEmpty()){
+                    for (String localGlbPath : localGlbPaths) {
+                        File file = new File(localGlbPath);
+                        model.setModelSize(FileWriterUtil.setFileSize(file.length()));
+                        String ossPath = localGlbPath.replace("/mnt/","");
+                        ShellUtil.yunUpload(localGlbPath,ossPath);
+                        ossGlbPaths.add(queryPath +ossPath+"/tileset.json");
+                    }
+                    return JSONArray.toJSONString(ossGlbPaths);
                 }
-                return JSONArray.toJSONString(ossGlbPaths);
-            }
 
+            }
+        }catch (Exception e){
+            log.info("obj-to-b3dm-error:{},{}",num,model.getModelId(),e);
+        }finally {
             FileUtil.del(objPath);
         }
+
         return null;
     }