|
@@ -1,6 +1,8 @@
|
|
package com.fdkankan.scene.service.impl;
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
|
+import cn.hutool.core.date.DateField;
|
|
|
|
+import cn.hutool.core.date.DateUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.io.FileUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.StrUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
import cn.hutool.core.util.ZipUtil;
|
|
@@ -17,6 +19,9 @@ import com.fdkankan.common.util.FileUtils;
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
|
+import com.fdkankan.scene.bean.SceneBean;
|
|
|
|
+import com.fdkankan.web.response.ResultData;
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
import com.fdkankan.model.utils.CreateObjUtil;
|
|
@@ -1025,133 +1030,116 @@ 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());
|
|
|
|
+
|
|
|
|
+ if(ModelKind.THREE_D_TILE.code().equals(scenePlusExt.getModelKind())){
|
|
|
|
+ return this.downloadModel43dtiles(num, bucket, scenePlusExt, sceneEditInfo);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ return this.downloadModel4Dam(num, bucket);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public ScenePro getByNum(String num) {
|
|
|
|
+ return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private ResultData downloadModel43dtiles(String num, String bucket, ScenePlusExt scenePlusExt, SceneEditInfo sceneEditInfo){
|
|
|
|
+
|
|
|
|
+ //下载mesh到本地
|
|
|
|
+ String meshOssPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/";
|
|
|
|
+ String meshLocalPath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + "mesh";
|
|
|
|
+ String zipName = num + "_mesh.zip";
|
|
|
|
+ String zipFilePath = String.format(ConstantFilePath.SCENE_DATA_PATH_V4, num) + zipName;
|
|
|
|
+ //下载
|
|
|
|
+ fYunFileService.downloadFileByCommand(bucket, meshLocalPath, meshOssPath);
|
|
|
|
+ //打包
|
|
|
|
+ ZipUtil.zip(meshLocalPath,zipFilePath);
|
|
|
|
+ //上传压缩包
|
|
|
|
+ fYunFileService.uploadFile(bucket, zipFilePath, "downloads/extras/" + zipName);
|
|
|
|
+ //删除本地文件
|
|
|
|
+ FileUtil.del(meshLocalPath);
|
|
|
|
+ FileUtil.del(zipFilePath);
|
|
|
|
+ String url = ossUrlPrefix + "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
|
+ return ResultData.ok(url);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public static void main(String[] args) {
|
|
|
|
+
|
|
|
|
+ Date time = Calendar.getInstance().getTime();
|
|
|
|
+ time = DateUtil.beginOfDay(DateUtil.offset(time, DateField.MONTH, -12));
|
|
|
|
+ System.out.println(time);
|
|
|
|
+
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private ResultData downloadModel4Dam(String num, String bucket){
|
|
|
|
+ String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, num);
|
|
|
|
+ if(!new File(localImagePath).exists()){
|
|
|
|
+ new File(localImagePath).mkdirs();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ String zipName = num + "_extras.zip";
|
|
|
|
+ String zipPath = localImagePath + zipName;
|
|
|
|
+
|
|
|
|
+ String dataViewPath = String.format(UploadFilePath.DATA_VIEW_PATH, num);
|
|
|
|
+ //V3版本去oss下载2048模型
|
|
|
|
+ String meshPath = String.format(ConstantFilePath.DATABUFFER_FORMAT, num) + "mesh";
|
|
|
|
+ FileUtils.deleteDirectory(meshPath);
|
|
|
|
+ fYunFileService.downloadFileByCommand(bucket, meshPath, dataViewPath + "mesh");
|
|
|
|
+ log.info("meshPath="+meshPath);
|
|
|
|
+ if(!new File(meshPath).exists() || new File(meshPath).listFiles().length < 1){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
|
|
|
|
+ }
|
|
|
|
+ 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);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public List<SceneBean> listCleanOrigScene(int cleanOrigMonth) {
|
|
|
|
+ Date time = Calendar.getInstance().getTime();
|
|
|
|
+ time = DateUtil.beginOfDay(DateUtil.offset(time, DateField.MONTH, -cleanOrigMonth));
|
|
|
|
+ return this.baseMapper.selectCleanOrigScene(time);
|
|
|
|
+ }
|
|
|
|
+
|
|
}
|
|
}
|