|
@@ -6,6 +6,7 @@ import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
+import cn.hutool.core.io.FileUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
import com.fdkankan.fusion.common.PageInfo;
|
|
@@ -84,6 +85,8 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
model.setUserName(username);
|
|
|
this.save(model);
|
|
|
File newObjFile = null;
|
|
|
+ File objPathFile = null;
|
|
|
+ File mntFile = null;
|
|
|
String objPath = String.format(OBJ_PATH , "modelId_"+model.getModelId()) ;
|
|
|
try {
|
|
|
String glbOssPath = String.format(FilePath.GLB_OSS_PATH, model.getModelId());
|
|
@@ -99,11 +102,15 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
if(fileName.toLowerCase().contains("rar")){
|
|
|
ShellUtil.unRar(newObjFile.getPath(),objPath);
|
|
|
}
|
|
|
- File objPathFile = new File(objPath );
|
|
|
+ objPathFile = new File(objPath );
|
|
|
if(!objPathFile.isDirectory()){
|
|
|
throw new BusinessException(ResultCode.UPLOAD_FILE_TYPE_ERROR);
|
|
|
}
|
|
|
File file1 = FileWriterUtil.getObjLasPlyFile(objPathFile);
|
|
|
+ if(file1 == null){
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_TYPE_ERROR);
|
|
|
+ }
|
|
|
+
|
|
|
String name = file1.getName();
|
|
|
if(name.contains("obj") || name.contains("OBJ")){
|
|
|
glbOssPath = glbOssPath.replace("mesh.glb",file1.getName().replace("obj","glb"));
|
|
@@ -121,10 +128,10 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
model.setModelType("las");
|
|
|
}
|
|
|
if("las".equals(model.getModelType()) || "ply".equals(model.getModelType()) ){
|
|
|
- glbOssPath = glbOssPath.replace("model","model_"+model.getModelId());
|
|
|
+ glbOssPath = glbOssPath.replace("model","modelId_"+model.getModelId());
|
|
|
glbOssPath = glbOssPath.replace("glb","res");
|
|
|
glbOssPath = glbOssPath.replace("mesh.glb","webcloud");
|
|
|
- File mntFile = OBJToGLBUtil.lasOrPlyToBin(file1);
|
|
|
+ mntFile = OBJToGLBUtil.lasOrPlyToBin(file1);
|
|
|
uploadToOssUtil.uploadFileOss(mntFile ,glbOssPath);
|
|
|
}
|
|
|
|
|
@@ -138,9 +145,14 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
throw e;
|
|
|
}finally {
|
|
|
if(newObjFile!=null){
|
|
|
- newObjFile.delete();
|
|
|
+ FileUtil.del(newObjFile);
|
|
|
+ }
|
|
|
+ if(objPathFile!=null){
|
|
|
+ FileUtil.del(objPathFile);
|
|
|
+ }
|
|
|
+ if(mntFile!=null){
|
|
|
+ FileUtil.del(mntFile);
|
|
|
}
|
|
|
- new File(objPath).delete();
|
|
|
}
|
|
|
|
|
|
}
|