|
@@ -2,28 +2,21 @@ package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
-import cn.hutool.core.util.ZipUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fdkankan.common.constant.CommonStatus;
|
|
|
-import com.fdkankan.model.constants.ConstantFileName;
|
|
|
-import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.constant.FileBizType;
|
|
|
-import com.fdkankan.common.constant.ServerCode;
|
|
|
-import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
-import com.fdkankan.web.response.ResultData;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.model.constants.ConstantFileName;
|
|
|
+import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
+import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
|
-import com.fdkankan.common.util.FileUtils;
|
|
|
-import com.fdkankan.common.util.OkHttpUtils;
|
|
|
-import com.fdkankan.fyun.constant.FYunTypeEnum;
|
|
|
-import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.redis.constant.RedisKey;
|
|
|
import com.fdkankan.redis.constant.RedisLockKey;
|
|
|
import com.fdkankan.redis.util.RedisLockUtil;
|
|
@@ -50,6 +43,7 @@ import com.fdkankan.scene.vo.FileNameAndDataParamVO;
|
|
|
import com.fdkankan.scene.vo.HotParamVO;
|
|
|
import com.fdkankan.scene.vo.SaveTagsParamVO;
|
|
|
import com.fdkankan.scene.vo.SaveTagsVisibleParamVO;
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Sets;
|
|
|
import java.io.File;
|
|
@@ -66,7 +60,6 @@ import java.util.Set;
|
|
|
import java.util.stream.Collectors;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
-import org.springframework.beans.factory.annotation.Qualifier;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -84,14 +77,6 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
@Service
|
|
|
public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro> implements ISceneProService {
|
|
|
|
|
|
- @Value("${fyun.host}")
|
|
|
- private String ossUrlPrefix;
|
|
|
- @Value("${fyun.type}")
|
|
|
- private String fyunType;
|
|
|
- @Value("${hot.domain.list}")
|
|
|
- private String hotDomainList;
|
|
|
- @Value("${hot.delete}")
|
|
|
- private String hotDelete;
|
|
|
@Value("${main.url}")
|
|
|
private String mainUrl;
|
|
|
@Value("${scene.url}")
|
|
@@ -104,14 +89,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
private int maxCheckTimes;
|
|
|
@Value("${ecs.checkFile.waitTime:5000}")
|
|
|
private int waitTime;
|
|
|
- @Value("${http.host.4dkankanMini}")
|
|
|
- private String fkankanMiniHost;
|
|
|
- @Value("${http.api-v4.upgradeToV4ResultSync}")
|
|
|
- private String URL_UPGRADE_TO_V4_RESULT_SYNC;
|
|
|
|
|
|
@Autowired
|
|
|
- private FYunFileServiceInterface fYunFileService;
|
|
|
- @Autowired
|
|
|
private RedisLockUtil redisLockUtil;
|
|
|
@Autowired
|
|
|
private RedisUtil redisUtil;
|
|
@@ -141,8 +120,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
|
|
|
//更新缩略图url
|
|
|
- String thumbUrl = this.ossUrlPrefix + String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + param.getFileName();
|
|
|
- scenePlusExt.setThumb(thumbUrl);
|
|
|
+ // TODO: 2022/8/22
|
|
|
+// String thumbUrl = this.ossUrlPrefix + String.format(UploadFilePath.USER_EDIT_PATH, param.getNum()) + param.getFileName();
|
|
|
+// scenePlusExt.setThumb(thumbUrl);
|
|
|
scenePlusExtService.updateById(scenePlusExt);
|
|
|
|
|
|
SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
@@ -517,30 +497,18 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
String fileType = jsonObject.getString("media");
|
|
|
if(fileType.contains("photo"))
|
|
|
{
|
|
|
- fYunFileService.deleteFile(bucket,userDataPath + "hot"+sid+".jpg");
|
|
|
+ // TODO: 2022/8/22
|
|
|
+// fYunFileService.deleteFile(bucket,userDataPath + "hot"+sid+".jpg");
|
|
|
}
|
|
|
if(fileType.contains("audio") || fileType.contains("voice"))
|
|
|
{
|
|
|
- fYunFileService.deleteFile(bucket,userDataPath + "hot"+sid+".mp3");
|
|
|
+ // TODO: 2022/8/22
|
|
|
+// fYunFileService.deleteFile(bucket,userDataPath + "hot"+sid+".mp3");
|
|
|
}
|
|
|
if(fileType.contains("video"))
|
|
|
{
|
|
|
- fYunFileService.deleteFile(bucket,userDataPath + "hot"+sid+".mp4");
|
|
|
- }
|
|
|
- }
|
|
|
- if(!FYunTypeEnum.AWS.code().equals(this.fyunType)){
|
|
|
- JSONObject paramData = new JSONObject();
|
|
|
- paramData.put("hotId", sid);
|
|
|
- JSONObject hotListJson = JSONObject.parseObject(OkHttpUtils.httpGet(hotDomainList));
|
|
|
- if(hotListJson != null){
|
|
|
- JSONArray hotListArray = hotListJson.getJSONArray("data");
|
|
|
- if(hotListArray != null){
|
|
|
- for(int l = 0, len = hotListArray.size(); l < len; l++){
|
|
|
- OkHttpUtils.httpPostJson(hotListArray.getString(l) + hotDelete + "?hotId=" + sid
|
|
|
- , paramData.toJSONString());
|
|
|
- }
|
|
|
-
|
|
|
- }
|
|
|
+ // TODO: 2022/8/22
|
|
|
+// fYunFileService.deleteFile(bucket,userDataPath + "hot"+sid+".mp4");
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -625,11 +593,9 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if (!directory.exists()) {
|
|
|
directory.mkdirs();
|
|
|
}
|
|
|
- String viewImagesPath = String.format(UploadFilePath.IMG_VIEW_PATH, param.getNum());
|
|
|
- String modeldataUrl = ossUrlPrefix + viewImagesPath + "vision.modeldata?t=" + System.currentTimeMillis();
|
|
|
-
|
|
|
//如果是云存储,将vision.modeldata下载到本地,如果是本地存储,场景计算完就已经将这个文件拷贝到编辑目录了存在这个文件了,不需要再下载
|
|
|
- fYunFileService.downloadFile(bucket, viewImagesPath + "vision.modeldata", localDataPath + "vision.modeldata");
|
|
|
+ // TODO: 2022/8/22
|
|
|
+// fYunFileService.downloadFile(bucket, viewImagesPath + "vision.modeldata", localDataPath + "vision.modeldata");
|
|
|
|
|
|
//检查vision.modeldata本地是否存在,不存在抛出异常
|
|
|
File file = new File(localDataPath + "vision.modeldata");
|
|
@@ -659,7 +625,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
FileUtils.deleteFile(localDataPath + "vision.modeldata");
|
|
|
FileUtils.writeFile(localDataPath + "vision.json", json.toString());
|
|
|
ConvertUtils.convertTxtToVisionModelData(localDataPath + "vision.json", localDataPath + "vision.modeldata");
|
|
|
- fYunFileService.uploadFile(bucket, localDataPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
|
|
|
+// TODO: 2022/8/22
|
|
|
+ // fYunFileService.uploadFile(bucket, localDataPath + "vision.modeldata", viewImagesPath + "vision.modeldata");
|
|
|
|
|
|
//更新版本号
|
|
|
SceneEditInfo editInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
@@ -686,68 +653,68 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
.set(ScenePro::getUserId, userId));
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResultData uploadObjAndImg(String num, MultipartFile file) throws Exception{
|
|
|
- if(StrUtil.isEmpty(num)){
|
|
|
- throw new BusinessException(ServerCode.PARAM_REQUIRED, "num");
|
|
|
- }
|
|
|
- if(!file.getOriginalFilename().endsWith(".zip")){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
|
|
|
- }
|
|
|
-
|
|
|
- ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
- if(scenePlus == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
- String bucket = scenePlusExt.getYunFileBucket();
|
|
|
-
|
|
|
- //文件上传的位置可以自定义
|
|
|
- String path = scenePlusExt.getDataSource() + "_obj2txt";
|
|
|
- String zipPath = path + "/zip/";
|
|
|
- String filePath = path + "/extras/";
|
|
|
- String resultPath = path + "/results/";
|
|
|
-
|
|
|
- //压缩文件处理:解压缩,解压缩后复制等操作
|
|
|
- this.objAndImgFileHandler(resultPath, filePath, zipPath, file);
|
|
|
-
|
|
|
- //创建data.json
|
|
|
- this.writeDataJson(path);
|
|
|
-
|
|
|
- //调用算法,不同的类型调用不同的算法
|
|
|
- if("V2".equals(scenePlusExt.getBuildType())){
|
|
|
- CreateObjUtil.objToTxt(path , "1");
|
|
|
- }
|
|
|
- if("V3".equals(scenePlusExt.getBuildType())){
|
|
|
- CreateObjUtil.build3dModel(path , "1");
|
|
|
- }
|
|
|
-
|
|
|
- //算法计算完后,生成压缩文件,上传到oss
|
|
|
- this.uploadFileofterRebuildPanoram(path, num, bucket);
|
|
|
-
|
|
|
- //更新版本信息
|
|
|
- SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
- if(Objects.isNull(sceneEditInfo)){
|
|
|
- sceneEditInfo = new SceneEditInfo();
|
|
|
- sceneEditInfo.setScenePlusId(scenePlus.getId());
|
|
|
- sceneEditInfo.setFloorPublishVer(1);
|
|
|
- sceneEditInfo.setFloorEditVer(1);
|
|
|
- sceneEditInfo.setIsUploadObj(CommonStatus.YES.code());
|
|
|
- sceneEditInfoService.save(sceneEditInfo);
|
|
|
- }else{
|
|
|
- sceneEditInfoService.update(
|
|
|
- new LambdaUpdateWrapper<SceneEditInfo>()
|
|
|
- .setSql("version = version + 1")
|
|
|
- .setSql("floor_edit_ver = floor_edit_ver + 1")
|
|
|
- .setSql("floor_publish_ver = floor_publish_ver + 1")
|
|
|
- .setSql("img_version = img_version + 1")
|
|
|
- .set(SceneEditInfo::getIsUploadObj, CommonStatus.YES.code())
|
|
|
- .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
|
|
|
-
|
|
|
- sceneEditInfoService.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket); }
|
|
|
-
|
|
|
- return ResultData.ok();
|
|
|
- }
|
|
|
+// @Override
|
|
|
+// public ResultData uploadObjAndImg(String num, MultipartFile file) throws Exception{
|
|
|
+// if(StrUtil.isEmpty(num)){
|
|
|
+// throw new BusinessException(ServerCode.PARAM_REQUIRED, "num");
|
|
|
+// }
|
|
|
+// if(!file.getOriginalFilename().endsWith(".zip")){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
|
|
|
+// }
|
|
|
+//
|
|
|
+// ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+// if(scenePlus == null){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+// }
|
|
|
+// ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+// String bucket = scenePlusExt.getYunFileBucket();
|
|
|
+//
|
|
|
+// //文件上传的位置可以自定义
|
|
|
+// String path = scenePlusExt.getDataSource() + "_obj2txt";
|
|
|
+// String zipPath = path + "/zip/";
|
|
|
+// String filePath = path + "/extras/";
|
|
|
+// String resultPath = path + "/results/";
|
|
|
+//
|
|
|
+// //压缩文件处理:解压缩,解压缩后复制等操作
|
|
|
+// this.objAndImgFileHandler(resultPath, filePath, zipPath, file);
|
|
|
+//
|
|
|
+// //创建data.json
|
|
|
+// this.writeDataJson(path);
|
|
|
+//
|
|
|
+// //调用算法,不同的类型调用不同的算法
|
|
|
+// if("V2".equals(scenePlusExt.getBuildType())){
|
|
|
+// CreateObjUtil.objToTxt(path , "1");
|
|
|
+// }
|
|
|
+// if("V3".equals(scenePlusExt.getBuildType())){
|
|
|
+// CreateObjUtil.build3dModel(path , "1");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //算法计算完后,生成压缩文件,上传到oss
|
|
|
+// this.uploadFileofterRebuildPanoram(path, num, bucket);
|
|
|
+//
|
|
|
+// //更新版本信息
|
|
|
+// SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
+// if(Objects.isNull(sceneEditInfo)){
|
|
|
+// sceneEditInfo = new SceneEditInfo();
|
|
|
+// sceneEditInfo.setScenePlusId(scenePlus.getId());
|
|
|
+// sceneEditInfo.setFloorPublishVer(1);
|
|
|
+// sceneEditInfo.setFloorEditVer(1);
|
|
|
+// sceneEditInfo.setIsUploadObj(CommonStatus.YES.code());
|
|
|
+// sceneEditInfoService.save(sceneEditInfo);
|
|
|
+// }else{
|
|
|
+// sceneEditInfoService.update(
|
|
|
+// new LambdaUpdateWrapper<SceneEditInfo>()
|
|
|
+// .setSql("version = version + 1")
|
|
|
+// .setSql("floor_edit_ver = floor_edit_ver + 1")
|
|
|
+// .setSql("floor_publish_ver = floor_publish_ver + 1")
|
|
|
+// .setSql("img_version = img_version + 1")
|
|
|
+// .set(SceneEditInfo::getIsUploadObj, CommonStatus.YES.code())
|
|
|
+// .eq(SceneEditInfo::getId, sceneEditInfo.getId()));
|
|
|
+//
|
|
|
+// sceneEditInfoService.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket); }
|
|
|
+//
|
|
|
+// return ResultData.ok();
|
|
|
+// }
|
|
|
|
|
|
private void uploadFileofterRebuildPanoram(String path, String sceneNum, String bucket) throws Exception {
|
|
|
//因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
|
|
@@ -790,7 +757,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam.lzma", imgViewPath +ConstantFileName.modelUUID+"_50k.dam.lzma");
|
|
|
map.put(path + File.separator + "results" +File.separator+ConstantFileName.modelUUID+"_50k.dam", imgViewPath+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
|
|
|
- fYunFileService.uploadMulFiles(bucket, map);
|
|
|
+// TODO: 2022/8/22
|
|
|
+ // fYunFileService.uploadMulFiles(bucket, map);
|
|
|
}
|
|
|
|
|
|
private void writeDataJson(String path) throws IOException {
|
|
@@ -900,133 +868,137 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ResultData downloadTexData(String num) throws Exception {
|
|
|
-
|
|
|
- if(StrUtil.isEmpty(num)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
- if(scenePlus == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
- ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
- String bucket = scenePlusExt.getYunFileBucket();
|
|
|
-
|
|
|
- SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
-
|
|
|
- String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, num);
|
|
|
- if(!new File(localImagePath).exists()){
|
|
|
- new File(localImagePath).mkdirs();
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- String newData = scenePlusExt.getDataSource() + "_obj2txt/extras";
|
|
|
- String newResultData = scenePlusExt.getDataSource() + "_obj2txt/results/upload.json";
|
|
|
- String zipName = num + "_extras.zip";
|
|
|
- String zipPath = localImagePath + zipName;
|
|
|
- //如果用户上传过模型,就打包上传到oss,直接返回
|
|
|
- if(CommonStatus.YES.code().equals(sceneEditInfo.getIsUploadObj())
|
|
|
- && new File(newData).exists()
|
|
|
- && new File(newResultData).exists()){
|
|
|
- //打包
|
|
|
- ZipUtil.zip(newData, zipPath);
|
|
|
- //上传压缩包
|
|
|
- fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
- String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- return ResultData.ok(url);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- String buildType = scenePlusExt.getBuildType();
|
|
|
- if("V3".equals(buildType)){
|
|
|
- String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
- //V3版本去oss下载2048模型
|
|
|
- String meshPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num) + "mesh";
|
|
|
- FileUtils.deleteDirectory(meshPath);
|
|
|
- CreateObjUtil.ossUtilCp(dataViewPath + "mesh", meshPath);
|
|
|
- log.info("meshPath="+meshPath);
|
|
|
- if(!new File(meshPath).exists()){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
|
|
|
- }
|
|
|
- log.info(new File(meshPath).listFiles().toString());
|
|
|
- if(new File(meshPath).listFiles().length > 0){
|
|
|
- for(File file : new File(meshPath).listFiles()){
|
|
|
- if(file.isDirectory()){
|
|
|
- for (File item : file.listFiles()) {
|
|
|
- if(item.getName().endsWith(".obj") && !"output.house.obj".equals(item.getName()) &&
|
|
|
- !"mesh.obj".equals(item.getName())){
|
|
|
- item.delete();
|
|
|
- }
|
|
|
- if(item.getName().endsWith(".mtl") && !"output.house.mtl".equals(item.getName()) &&
|
|
|
- !"mesh.mtl".equals(item.getName())){
|
|
|
- item.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- continue;
|
|
|
- }
|
|
|
- if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
- !"mesh.obj".equals(file.getName())){
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
- !"mesh.mtl".equals(file.getName())){
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
- //打包
|
|
|
- ZipUtil.zip(meshPath, zipPath);
|
|
|
- //上传压缩包
|
|
|
- fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
- String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
-// FileUtil.del(zipPath);
|
|
|
- return ResultData.ok(url);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //V2版本在本地获取模型资源
|
|
|
- //修改过的资源
|
|
|
- String editData = scenePlusExt.getDataSource() + "_edit/caches/tex";
|
|
|
- String results = scenePlusExt.getDataSource() + "_edit/results";
|
|
|
- if (new File(editData).exists() && new File(results).exists()){
|
|
|
- for(File file : new File(editData).listFiles()){
|
|
|
- if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
- !"mesh.obj".equals(file.getName())){
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
- !"mesh.mtl".equals(file.getName())){
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ZipUtil.zip(editData, zipPath);
|
|
|
- //上传压缩包
|
|
|
- fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
- String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- return ResultData.ok(url);
|
|
|
- }
|
|
|
-
|
|
|
- //没上传过返回源资源
|
|
|
- String dataPath = scenePlusExt.getDataSource() + "/caches/tex";
|
|
|
- File dataFile = new File(dataPath);
|
|
|
- if(!dataFile.exists()){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_3018);
|
|
|
- }
|
|
|
- for(File file : dataFile.listFiles()){
|
|
|
- if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
- !"mesh.obj".equals(file.getName())){
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
- !"mesh.mtl".equals(file.getName())){
|
|
|
- file.delete();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- ZipUtil.zip(dataPath, zipPath);
|
|
|
- //上传压缩包
|
|
|
- fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
- String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- return ResultData.ok(url);
|
|
|
- }
|
|
|
+// public ResultData downloadTexData(String num) throws Exception {
|
|
|
+//
|
|
|
+// if(StrUtil.isEmpty(num)){
|
|
|
+// throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
+// }
|
|
|
+// ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+// if(scenePlus == null){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+// }
|
|
|
+// ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
+// String bucket = scenePlusExt.getYunFileBucket();
|
|
|
+//
|
|
|
+// SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
+//
|
|
|
+// String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, num);
|
|
|
+// if(!new File(localImagePath).exists()){
|
|
|
+// new File(localImagePath).mkdirs();
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// String newData = scenePlusExt.getDataSource() + "_obj2txt/extras";
|
|
|
+// String newResultData = scenePlusExt.getDataSource() + "_obj2txt/results/upload.json";
|
|
|
+// String zipName = num + "_extras.zip";
|
|
|
+// String zipPath = localImagePath + zipName;
|
|
|
+// //如果用户上传过模型,就打包上传到oss,直接返回
|
|
|
+// if(CommonStatus.YES.code().equals(sceneEditInfo.getIsUploadObj())
|
|
|
+// && new File(newData).exists()
|
|
|
+// && new File(newResultData).exists()){
|
|
|
+// //打包
|
|
|
+// ZipUtil.zip(newData, zipPath);
|
|
|
+// //上传压缩包
|
|
|
+//// TODO: 2022/8/22
|
|
|
+//// fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
+// String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+// return ResultData.ok(url);
|
|
|
+// }
|
|
|
+//
|
|
|
+//
|
|
|
+// String buildType = scenePlusExt.getBuildType();
|
|
|
+// if("V3".equals(buildType)){
|
|
|
+// String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
+// //V3版本去oss下载2048模型
|
|
|
+// String meshPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num) + "mesh";
|
|
|
+// FileUtils.deleteDirectory(meshPath);
|
|
|
+// CreateObjUtil.ossUtilCp(dataViewPath + "mesh", meshPath);
|
|
|
+// log.info("meshPath="+meshPath);
|
|
|
+// if(!new File(meshPath).exists()){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
|
|
|
+// }
|
|
|
+// log.info(new File(meshPath).listFiles().toString());
|
|
|
+// if(new File(meshPath).listFiles().length > 0){
|
|
|
+// for(File file : new File(meshPath).listFiles()){
|
|
|
+// if(file.isDirectory()){
|
|
|
+// for (File item : file.listFiles()) {
|
|
|
+// if(item.getName().endsWith(".obj") && !"output.house.obj".equals(item.getName()) &&
|
|
|
+// !"mesh.obj".equals(item.getName())){
|
|
|
+// item.delete();
|
|
|
+// }
|
|
|
+// if(item.getName().endsWith(".mtl") && !"output.house.mtl".equals(item.getName()) &&
|
|
|
+// !"mesh.mtl".equals(item.getName())){
|
|
|
+// item.delete();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
+// !"mesh.obj".equals(file.getName())){
|
|
|
+// file.delete();
|
|
|
+// }
|
|
|
+// if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
+// !"mesh.mtl".equals(file.getName())){
|
|
|
+// file.delete();
|
|
|
+// }
|
|
|
+// }
|
|
|
+// //打包
|
|
|
+// ZipUtil.zip(meshPath, zipPath);
|
|
|
+// //上传压缩包
|
|
|
+//// TODO: 2022/8/22
|
|
|
+//// fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
+// String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+//// FileUtil.del(zipPath);
|
|
|
+// return ResultData.ok(url);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// //V2版本在本地获取模型资源
|
|
|
+// //修改过的资源
|
|
|
+// String editData = scenePlusExt.getDataSource() + "_edit/caches/tex";
|
|
|
+// String results = scenePlusExt.getDataSource() + "_edit/results";
|
|
|
+// if (new File(editData).exists() && new File(results).exists()){
|
|
|
+// for(File file : new File(editData).listFiles()){
|
|
|
+// if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
+// !"mesh.obj".equals(file.getName())){
|
|
|
+// file.delete();
|
|
|
+// }
|
|
|
+// if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
+// !"mesh.mtl".equals(file.getName())){
|
|
|
+// file.delete();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// ZipUtil.zip(editData, zipPath);
|
|
|
+// //上传压缩包
|
|
|
+//// TODO: 2022/8/22
|
|
|
+//// fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
+// String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+// return ResultData.ok(url);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //没上传过返回源资源
|
|
|
+// String dataPath = scenePlusExt.getDataSource() + "/caches/tex";
|
|
|
+// File dataFile = new File(dataPath);
|
|
|
+// if(!dataFile.exists()){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_3018);
|
|
|
+// }
|
|
|
+// for(File file : dataFile.listFiles()){
|
|
|
+// if(file.getName().endsWith(".obj") && !"output.house.obj".equals(file.getName()) &&
|
|
|
+// !"mesh.obj".equals(file.getName())){
|
|
|
+// file.delete();
|
|
|
+// }
|
|
|
+// if(file.getName().endsWith(".mtl") && !"output.house.mtl".equals(file.getName()) &&
|
|
|
+// !"mesh.mtl".equals(file.getName())){
|
|
|
+// file.delete();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// ZipUtil.zip(dataPath, zipPath);
|
|
|
+// //上传压缩包
|
|
|
+//// TODO: 2022/8/22
|
|
|
+// // fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
+// String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+// return ResultData.ok(url);
|
|
|
+// }
|
|
|
}
|