|
@@ -1,13 +1,11 @@
|
|
|
package com.fdkankan.fusion.service.impl;
|
|
|
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.fdkankan.fusion.common.FilePath;
|
|
|
import com.fdkankan.fusion.common.ResultCode;
|
|
|
-import com.fdkankan.fusion.common.util.FileWriterUtil;
|
|
|
-import com.fdkankan.fusion.common.util.JwtUtil;
|
|
|
-import com.fdkankan.fusion.common.util.OBJToGLBUtil;
|
|
|
-import com.fdkankan.fusion.common.util.UploadToOssUtil;
|
|
|
+import com.fdkankan.fusion.common.util.*;
|
|
|
import com.fdkankan.fusion.entity.CaseNumEntity;
|
|
|
import com.fdkankan.fusion.entity.Model;
|
|
|
import com.fdkankan.fusion.exception.BusinessException;
|
|
@@ -99,15 +97,11 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
|
|
|
model.setModelDateType("obj");
|
|
|
model.setType(param.getType());
|
|
|
model.setModelType("pointcloud"); //深时点云类型
|
|
|
- if(param.getType() == 0 || param.getType() == 1){ //看看,看见
|
|
|
+ if(param.getType() == 0 || param.getType() == 1 || param.getType() == 4){ //看看,看见
|
|
|
model.setModelObjUrl(String.format(FilePath.OBJ_LOCAL_PATH,environment ,num) +"/mesh.obj");
|
|
|
model.setModelGlbUrl(getGlbUrl(param.getType(),num,model));
|
|
|
model.setModelType("glb");
|
|
|
}
|
|
|
- if(param.getType() == 4){ //深时obj场景
|
|
|
- getGlbSsObj(model,num);
|
|
|
- model.setModelType("glb");
|
|
|
- }
|
|
|
model.setNum(num);
|
|
|
model.setCreateStatus(1);
|
|
|
modelList.add(model);
|
|
@@ -122,63 +116,51 @@ public class CaseNumServiceImpl extends ServiceImpl<ICaseNumMapper, CaseNumEntit
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private void getGlbSsObj(Model model, String num) {
|
|
|
- String dataSource = fdKKClient.querySceneDataSource(num);
|
|
|
- if(StringUtils.isBlank(dataSource)){
|
|
|
- throw new BusinessException(ResultCode.SCENE_DATA_SOURCE_EMPTY.code,num +ResultCode.SCENE_DATA_SOURCE_EMPTY.msg);
|
|
|
- }
|
|
|
- String meshPath = dataSource +"_laserData/laserData/mesh";
|
|
|
- File meshFile = new File(meshPath);
|
|
|
- if(!meshFile.exists()){
|
|
|
- throw new BusinessException(ResultCode.SCENE_DATA_SOURCE_EMPTY.code,num +ResultCode.SCENE_DATA_SOURCE_EMPTY.msg);
|
|
|
- }
|
|
|
-
|
|
|
- String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
|
|
|
- String glbPath = String.format(FilePath.GLB_LOCAL_PATH,environment,num) +"/mesh.glb";
|
|
|
- String glbOssPath = String.format(FilePath.GLB_OSS_PATH ,environment, num);
|
|
|
-
|
|
|
- FileUtil.copy(meshPath,objPath,true);
|
|
|
- OBJToGLBUtil.objToGlb(objPath +"/mesh",glbPath );
|
|
|
- File file = new File(glbPath);
|
|
|
- model.setModelSize(FileWriterUtil.setFileSize(file.length()));
|
|
|
- uploadToOssUtil.uploadOss(glbPath,glbOssPath);
|
|
|
- FileUtil.del(objPath);
|
|
|
- String ossglbPath = queryPath +glbOssPath;
|
|
|
- model.setModelObjUrl(objPath +"/mesh");
|
|
|
- model.setModelGlbUrl(ossglbPath);
|
|
|
- }
|
|
|
|
|
|
|
|
|
private String getGlbUrl(Integer type, String num,Model model) {
|
|
|
- if(type == 0 || type == 1){ //看看,看见
|
|
|
+ if(type == 0 || type == 1 || type == 4){ //看看,看见
|
|
|
String objPath = String.format(FilePath.OBJ_LOCAL_PATH ,environment,num);
|
|
|
- String glbPath = String.format(FilePath.GLB_LOCAL_PATH,environment,num) +"/mesh.glb";
|
|
|
- String glbOssPath = String.format(FilePath.GLB_OSS_PATH ,environment, num);
|
|
|
// if(uploadToOssUtil.existKey(glbOssPath)){
|
|
|
// return queryPath + "/"+glbOssPath;
|
|
|
// }
|
|
|
- List<String> fileList = uploadToOssUtil.listKeysFromAli(String.format(FilePath.OBJ_OSS_PATH, num));
|
|
|
- for (String fileName : fileList) {
|
|
|
- File file = new File(objPath);
|
|
|
- if(!file.exists()){
|
|
|
- file.mkdirs();
|
|
|
+ ShellUtil.yunDownload(String.format(FilePath.OBJ_OSS_PATH, num) ,objPath);
|
|
|
+ List<String> localGlbPaths = new ArrayList<>();
|
|
|
+ List<String> ossGlbPaths = new ArrayList<>();
|
|
|
+ File localFile = new File(objPath);
|
|
|
+ this.toGlB(localFile,localGlbPaths);
|
|
|
+
|
|
|
+ if(localGlbPaths.size() >0){
|
|
|
+ for (String localGlbPath : localGlbPaths) {
|
|
|
+ File file = new File(localGlbPath);
|
|
|
+ if(file!=null){
|
|
|
+ model.setModelSize(FileWriterUtil.setFileSize(file.length()));
|
|
|
+ }
|
|
|
+ String ossGlbPath = localGlbPath.replace(FilePath.LOCAL_BASE_PATH,"fusion/");
|
|
|
+ uploadToOssUtil.uploadOss(localGlbPath,ossGlbPath);
|
|
|
+ ossGlbPaths.add(queryPath + "/"+ossGlbPath);
|
|
|
}
|
|
|
- String[] split = fileName.split("/");
|
|
|
- String localPath = objPath +"/"+split[split.length-1];
|
|
|
- uploadToOssUtil.downFormAli(fileName,localPath);
|
|
|
+ return JSONArray.toJSONString(ossGlbPaths);
|
|
|
}
|
|
|
- OBJToGLBUtil.objToGlb(objPath,glbPath );
|
|
|
- File file = new File(glbPath);
|
|
|
- if(file!=null){
|
|
|
- model.setModelSize(FileWriterUtil.setFileSize(file.length()));
|
|
|
- }
|
|
|
- uploadToOssUtil.uploadOss(glbPath,glbOssPath);
|
|
|
- FileUtil.del(objPath);
|
|
|
- return queryPath + "/"+glbOssPath;
|
|
|
+
|
|
|
+ //FileUtil.del(objPath);
|
|
|
}
|
|
|
return null;
|
|
|
}
|
|
|
|
|
|
+ private void toGlB(File localFile, List<String> localGlbPath) {
|
|
|
+ File[] files = localFile.listFiles();
|
|
|
+ for (File file : files) {
|
|
|
+ if(file.isDirectory()){
|
|
|
+ toGlB(file,localGlbPath);
|
|
|
+ }
|
|
|
+ if(file.getName().contains(".obj")){
|
|
|
+ String glbPath = OBJToGLBUtil.objToGlb(file.getPath(),file.getPath().replace(".obj",".glb") );
|
|
|
+ localGlbPath.add(glbPath);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private List<String> updateByNumList(Integer caseId, List<SceneNumParam> sceneNumParam) {
|
|
|
List<String> addList = new ArrayList<>();
|
|
|
for (SceneNumParam param : sceneNumParam) {
|