|
|
@@ -219,21 +219,30 @@ public class NjsSceneBoxModelServiceImpl extends ServiceImpl<INjsSceneBoxModelMa
|
|
|
String uuid = UUID.randomUUID().toString();
|
|
|
String origKey = njsSceneBoxModel.getOrigKey();
|
|
|
String workDir = String.format(ConstantFilePath.SCENE_USER_PATH_V4, njsSceneBoxModel.getNum()) + "objToGlb" + File.separator + uuid + File.separator;
|
|
|
+ String srcPath = workDir + "src" + File.separator;
|
|
|
try {
|
|
|
- FileUtil.mkdir(workDir);
|
|
|
+ FileUtil.mkdir(srcPath);
|
|
|
String zipPath = workDir + FileUtil.getName(origKey);
|
|
|
fYunFileService.downloadFile(origKey, zipPath);
|
|
|
//解压
|
|
|
- ZipUtil.unzip(zipPath, workDir, CharsetUtil.CHARSET_GBK);
|
|
|
+ ZipUtil.unzip(zipPath, srcPath, CharsetUtil.CHARSET_GBK);
|
|
|
//转glb
|
|
|
String glbPath = workDir + uuid + ".glb";
|
|
|
- OBJToGLBUtil.objToGlb(workDir, glbPath);
|
|
|
+ OBJToGLBUtil.objToGlb(srcPath, glbPath);
|
|
|
//上传glb
|
|
|
if(!ComputerUtil.checkComputeCompleted(glbPath, 5, 200)){
|
|
|
throw new RuntimeException("转glb失败");
|
|
|
}
|
|
|
- String key = String.format(UploadFilePath.USER_EDIT_PATH, njsSceneBoxModel.getNum()) + "njsBoxModel" + File.separator + njsSceneBoxModel.getSid() + ".glb";
|
|
|
+ String ossDir = String.format(UploadFilePath.USER_EDIT_PATH, njsSceneBoxModel.getNum()) + "njsBoxModel" + File.separator + njsSceneBoxModel.getSid();
|
|
|
+ String key = ossDir + ".glb";
|
|
|
+ //上传结果文件
|
|
|
fYunFileService.uploadFile(glbPath, key);
|
|
|
+ //上传源文件
|
|
|
+ List<File> files = FileUtil.loopFiles(srcPath);
|
|
|
+ files.stream().forEach(v->{
|
|
|
+ String ossKey = v.getAbsolutePath().replace(srcPath, ossDir + File.separator);
|
|
|
+ fYunFileService.uploadFile(v.getAbsolutePath(), ossKey);
|
|
|
+ });
|
|
|
njsSceneBoxModel.setStatus(CommonSuccessStatus.SUCCESS.code());
|
|
|
}catch (Exception e){
|
|
|
log.error("模型编辑器-模型转换失败, num:{}, sid:{}", njsSceneBoxModel.getNum(), njsSceneBoxModel.getSid(), e);
|