|
@@ -4,6 +4,7 @@ import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.Arrays;
|
|
|
import java.util.List;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
@@ -86,14 +87,12 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
model.setModelType("glb");
|
|
|
model.setModelSize(file.getSize());
|
|
|
model.setUserName(username);
|
|
|
- this.save(model);
|
|
|
File newObjFile = null;
|
|
|
try {
|
|
|
- String objPath = String.format(OBJ_PATH , "modelId_"+model.getModelId());
|
|
|
- String glbPath = String.format(GLB_PATH , "modelId_"+model.getModelId()) +"/"+modelName +"/mesh.glb";
|
|
|
+ String objPath = String.format(OBJ_PATH , "modelId_"+model.getModelId()) ;
|
|
|
+ String glbPath = String.format(GLB_PATH , "modelId_"+model.getModelId());
|
|
|
String glbOssPath = String.format(FilePath.GLB_OSS_PATH, model.getModelId());
|
|
|
|
|
|
-
|
|
|
newObjFile = new File(objPath +"/" + fileName);
|
|
|
if(!newObjFile.getParentFile().exists()){
|
|
|
newObjFile.mkdirs();
|
|
@@ -105,16 +104,43 @@ public class ModelServiceImpl extends ServiceImpl<IModelMapper, Model> implement
|
|
|
if(fileName.toLowerCase().contains("rar")){
|
|
|
ShellUtil.unRar(newObjFile.getPath(),objPath);
|
|
|
}
|
|
|
-
|
|
|
- OBJToGLBUtil.objToGlb(objPath+"/"+modelName,glbPath);
|
|
|
+ File objPathFile = new File(objPath + "/"+modelName);
|
|
|
+ if(!objPathFile.isDirectory()){
|
|
|
+ throw new BusinessException(ResultCode.UPLOAD_FILE_TYPE_ERROR);
|
|
|
+ }
|
|
|
+ File[] files = objPathFile.listFiles();
|
|
|
+ for (File file1 : files) {
|
|
|
+ String name = file1.getName();
|
|
|
+ if(name.contains("obj") || name.contains("OBJ")){
|
|
|
+ String glbName = "";
|
|
|
+ if(glbPath.contains(".obj")){
|
|
|
+ glbName = name.replace(".obj",".glb");
|
|
|
+ }
|
|
|
+ if(glbPath.contains(".OBJ")){
|
|
|
+ glbName = name.replace(".OBJ",".glb");
|
|
|
+ }
|
|
|
+ OBJToGLBUtil.objToGlb(objPath+"/"+modelName,name, glbPath+"/"+glbName);
|
|
|
+ glbOssPath = glbOssPath.replace("mesh.glb",glbName);
|
|
|
+ }
|
|
|
+ if(name.contains(".ply")){
|
|
|
+ glbOssPath = glbOssPath.replace("mesh.glb",name);
|
|
|
+ model.setModelDateType("ply");
|
|
|
+ model.setModelType("ply");
|
|
|
+ }
|
|
|
+ if(name.contains(".las")){
|
|
|
+ glbOssPath = glbOssPath.replace("mesh.glb",name);
|
|
|
+ model.setModelDateType("las");
|
|
|
+ model.setModelType("las");
|
|
|
+ }
|
|
|
+ }
|
|
|
uploadToOssUtil.upload(glbPath,glbOssPath);
|
|
|
model.setModelObjUrl(objPath);
|
|
|
model.setModelGlbUrl(queryPath + glbOssPath);
|
|
|
model.setCreateStatus(1); //上传成功
|
|
|
- this.updateById(model);
|
|
|
+ this.saveOrUpdate(model);
|
|
|
}catch (Exception e){
|
|
|
model.setCreateStatus(-1);
|
|
|
- this.updateById(model);
|
|
|
+ this.saveOrUpdate(model);
|
|
|
throw e;
|
|
|
}finally {
|
|
|
if(newObjFile!=null){
|