|
@@ -2,8 +2,8 @@ package com.fdkankan.scene.service.impl;
|
|
|
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.io.FileUtil;
|
|
|
-import cn.hutool.core.util.RuntimeUtil;
|
|
|
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;
|
|
@@ -14,7 +14,6 @@ import com.fdkankan.common.constant.ErrorCode;
|
|
|
import com.fdkankan.common.constant.FileBizType;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
-import com.fdkankan.common.constant.*;
|
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
|
import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
@@ -28,48 +27,31 @@ import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.IconBean;
|
|
|
import com.fdkankan.scene.bean.LaserSceneBean;
|
|
|
import com.fdkankan.scene.bean.TagBean;
|
|
|
-import com.fdkankan.scene.constant.LaserApiConstant;
|
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
|
import com.fdkankan.scene.entity.ScenePlus;
|
|
|
import com.fdkankan.scene.entity.ScenePlusExt;
|
|
|
import com.fdkankan.scene.entity.ScenePro;
|
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
|
import com.fdkankan.scene.oss.OssUtil;
|
|
|
-import com.fdkankan.scene.service.ILaserService;
|
|
|
-import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
|
-import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
|
-import com.fdkankan.scene.service.ISceneEditInfoService;
|
|
|
-import com.fdkankan.scene.service.IScenePlusExtService;
|
|
|
-import com.fdkankan.scene.service.IScenePlusService;
|
|
|
-import com.fdkankan.scene.service.ISceneProService;
|
|
|
-import com.fdkankan.scene.service.ISceneUploadService;
|
|
|
-import com.fdkankan.scene.util.forest.HttpClient;
|
|
|
-import com.fdkankan.scene.vo.BaseDataParamVO;
|
|
|
-import com.fdkankan.scene.vo.DeleteFileParamVO;
|
|
|
-import com.fdkankan.scene.vo.DeleteHotIconParamVO;
|
|
|
-import com.fdkankan.scene.vo.DeleteHotParamVO;
|
|
|
-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.scene.service.*;
|
|
|
+import com.fdkankan.scene.vo.*;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.google.common.collect.Sets;
|
|
|
-import java.io.File;
|
|
|
-import java.io.IOException;
|
|
|
-import java.nio.charset.StandardCharsets;
|
|
|
-import java.util.*;
|
|
|
-import java.util.Map.Entry;
|
|
|
-import java.util.stream.Collectors;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
-import org.redisson.Redisson;
|
|
|
-import org.redisson.RedissonLock;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.beans.factory.annotation.Value;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.web.multipart.MultipartFile;
|
|
|
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* pro场景表 服务实现类
|
|
@@ -235,7 +217,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
private void deleteHotDataFromTourJson(String num, List<String> sidList, String bucket){
|
|
|
String key = String.format(UploadFilePath.USER_EDIT_PATH, num) + "tour.json";
|
|
|
- String tourJson = fYunFileService.getFileContent(bucket, key);
|
|
|
+ String tourJson = ossUtil.getFileContent(key);
|
|
|
if(StrUtil.isEmpty(tourJson)){
|
|
|
return;
|
|
|
}
|
|
@@ -254,7 +236,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
});
|
|
|
});
|
|
|
- fYunFileService.uploadFile(bucket, jsonArray.toJSONString().getBytes(StandardCharsets.UTF_8), key);
|
|
|
+ ossUtil.uploadFileBytes(key, jsonArray.toJSONString().getBytes(StandardCharsets.UTF_8));
|
|
|
|
|
|
}
|
|
|
|
|
@@ -747,39 +729,44 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
// return ResultData.ok();
|
|
|
// }
|
|
|
|
|
|
- /**
|
|
|
- * 老算法(dam)上传模型逻辑
|
|
|
- * @param num
|
|
|
- * @param bucket
|
|
|
- * @param dataSource
|
|
|
- * @param buildType
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private void buildModel4Dam(String num, String bucket, String dataSource, String buildType, MultipartFile file) throws Exception {
|
|
|
- //文件上传的位置可以自定义
|
|
|
- String path = dataSource + "_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(buildType)){
|
|
|
- CreateObjUtil.objToTxt(path , "1");
|
|
|
- }
|
|
|
- if("V3".equals(buildType)){
|
|
|
- CreateObjUtil.build3dModel(path , "1");
|
|
|
- }
|
|
|
-
|
|
|
- //算法计算完后,生成压缩文件,上传到oss
|
|
|
- this.uploadFileofterRebuildPanoram(path, filePath, num, bucket);
|
|
|
+ @Override
|
|
|
+ public ScenePro getByNum(String num) {
|
|
|
+ return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
|
}
|
|
|
|
|
|
+// /**
|
|
|
+// * 老算法(dam)上传模型逻辑
|
|
|
+// * @param num
|
|
|
+// * @param bucket
|
|
|
+// * @param dataSource
|
|
|
+// * @param buildType
|
|
|
+// * @throws Exception
|
|
|
+// */
|
|
|
+// private void buildModel4Dam(String num, String bucket, String dataSource, String buildType, MultipartFile file) throws Exception {
|
|
|
+// //文件上传的位置可以自定义
|
|
|
+// String path = dataSource + "_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(buildType)){
|
|
|
+// CreateObjUtil.objToTxt(path , "1");
|
|
|
+// }
|
|
|
+// if("V3".equals(buildType)){
|
|
|
+// CreateObjUtil.build3dModel(path , "1");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //算法计算完后,生成压缩文件,上传到oss
|
|
|
+// this.uploadFileofterRebuildPanoram(path, filePath, num, bucket);
|
|
|
+// }
|
|
|
+
|
|
|
/**
|
|
|
* 新算法(3dtiles)上传模型逻辑
|
|
|
* @param num
|
|
@@ -833,7 +820,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
});
|
|
|
|
|
|
//读取oss上的floors.jsoon用于校验用户上传的模型楼层数是否一一对应
|
|
|
- String ossFloorsJson = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/floors.json");
|
|
|
+ String ossFloorsJson = ossUtil.getFileContent(String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/floors.json");
|
|
|
JSONObject orginFloorsJsonObj = JSON.parseObject(ossFloorsJson);
|
|
|
JSONArray orginFloorArr = orginFloorsJsonObj.getJSONArray("floors");
|
|
|
Set<String> orginFloorNameSet = orginFloorArr.stream().map(item -> {
|
|
@@ -870,69 +857,69 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
//算法计算完后,生成压缩文件,上传到oss
|
|
|
//上传3dtiles
|
|
|
- fYunFileService.deleteFolder(bucket, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "3dtiles");
|
|
|
- fYunFileService.uploadFileByCommand(bucket, tilesPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "3dtiles");
|
|
|
+ ossUtil.deleteObject(String.format(UploadFilePath.IMG_VIEW_PATH, num) + "3dtiles");
|
|
|
+ ossUtil.uploadFileDirCmd(tilesPath, String.format(UploadFilePath.IMG_VIEW_PATH, num) + "3dtiles", false);
|
|
|
//上传mesh
|
|
|
- fYunFileService.deleteFolder(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
- fYunFileService.uploadFileByCommand(bucket, meshPath, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
+ ossUtil.deleteObject(String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
+ ossUtil.uploadFileDirCmd(meshPath, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh", false);
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void uploadFileofterRebuildPanoram(String path, String filePath, String sceneNum, String bucket) throws Exception {
|
|
|
- //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
|
|
|
- String uploadJsonPath = path + File.separator + "results" +File.separator+"upload.json";
|
|
|
- boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
|
|
|
- if(!exist){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
- }
|
|
|
- String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
- JSONObject uploadJson = null;
|
|
|
- JSONArray array = null;
|
|
|
- if(uploadData!=null) {
|
|
|
- uploadJson = JSONObject.parseObject(uploadData);
|
|
|
- array = uploadJson.getJSONArray("upload");
|
|
|
- }
|
|
|
-
|
|
|
- Map<String,String> map = new HashMap<String,String>();
|
|
|
- JSONObject fileJson = null;
|
|
|
- String fileName = "";
|
|
|
- String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
|
|
|
- for(int i = 0, len = array.size(); i < len; i++) {
|
|
|
- fileJson = array.getJSONObject(i);
|
|
|
- fileName = fileJson.getString("file");
|
|
|
- //文件不存在抛出异常
|
|
|
- if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
|
|
|
- throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
|
|
|
- }
|
|
|
-
|
|
|
- //tex文件夹
|
|
|
- if (fileJson.getIntValue("clazz") == 15) {
|
|
|
- map.put(path + File.separator + "results" + File.separator + fileName,
|
|
|
- imgViewPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
- continue;
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String damPath = path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam";
|
|
|
- CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"modeldata.txt", damPath);
|
|
|
- boolean existDam = ComputerUtil.checkComputeCompleted(damPath, 5, 2);
|
|
|
- if(!existDam){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
- }
|
|
|
-// CreateObjUtil.convertDamToLzma(path + File.separator + "results");
|
|
|
-// CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
-// 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");
|
|
|
-
|
|
|
- String ossMeshPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "mesh";
|
|
|
- //删除oss中的mesh
|
|
|
- fYunFileService.deleteFolder(bucket, ossMeshPath);
|
|
|
- //上传obj相关文件
|
|
|
- List<String> fileNames = FileUtil.listFileNames(filePath);
|
|
|
- fileNames.stream().forEach(name->map.put(filePath + name, ossMeshPath + File.separator + name));
|
|
|
-
|
|
|
- fYunFileService.uploadMulFiles(bucket, map);
|
|
|
- }
|
|
|
+// private void uploadFileofterRebuildPanoram(String path, String filePath, String sceneNum, String bucket) throws Exception {
|
|
|
+// //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
|
|
|
+// String uploadJsonPath = path + File.separator + "results" +File.separator+"upload.json";
|
|
|
+// boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, maxCheckTimes, waitTime);
|
|
|
+// if(!exist){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+// }
|
|
|
+// String uploadData = FileUtils.readFile(uploadJsonPath);
|
|
|
+// JSONObject uploadJson = null;
|
|
|
+// JSONArray array = null;
|
|
|
+// if(uploadData!=null) {
|
|
|
+// uploadJson = JSONObject.parseObject(uploadData);
|
|
|
+// array = uploadJson.getJSONArray("upload");
|
|
|
+// }
|
|
|
+//
|
|
|
+// Map<String,String> map = new HashMap<String,String>();
|
|
|
+// JSONObject fileJson = null;
|
|
|
+// String fileName = "";
|
|
|
+// String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, sceneNum);
|
|
|
+// for(int i = 0, len = array.size(); i < len; i++) {
|
|
|
+// fileJson = array.getJSONObject(i);
|
|
|
+// fileName = fileJson.getString("file");
|
|
|
+// //文件不存在抛出异常
|
|
|
+// if (!new File(path + File.separator + "results" + File.separator + fileName).exists()) {
|
|
|
+// throw new Exception(path + File.separator + "results" + File.separator + fileName + "文件不存在");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //tex文件夹
|
|
|
+// if (fileJson.getIntValue("clazz") == 15) {
|
|
|
+// map.put(path + File.separator + "results" + File.separator + fileName,
|
|
|
+// imgViewPath + ConstantFileName.modelUUID + "_50k_texture_jpg_high1/" + fileName.replace("tex/", ""));
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// String damPath = path + File.separator + "results" +File.separator+ ConstantFileName.modelUUID+"_50k.dam";
|
|
|
+// CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"modeldata.txt", damPath);
|
|
|
+// boolean existDam = ComputerUtil.checkComputeCompleted(damPath, 5, 2);
|
|
|
+// if(!existDam){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+// }
|
|
|
+//// CreateObjUtil.convertDamToLzma(path + File.separator + "results");
|
|
|
+//// CreateObjUtil.convertTxtToDam( path + File.separator + "results" +File.separator+"modeldata.txt", path + File.separator + "results" + File.separator+ConstantFileName.modelUUID+"_50k.dam");
|
|
|
+//// 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");
|
|
|
+//
|
|
|
+// String ossMeshPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "mesh";
|
|
|
+// //删除oss中的mesh
|
|
|
+// ossUtil.deleteObject(ossMeshPath);
|
|
|
+// //上传obj相关文件
|
|
|
+// List<String> fileNames = FileUtil.listFileNames(filePath);
|
|
|
+// fileNames.stream().forEach(name->map.put(filePath + name, ossMeshPath + File.separator + name));
|
|
|
+//
|
|
|
+// ossUtil.uploadMulFiles(bucket, map);
|
|
|
+// }
|
|
|
|
|
|
private void writeDataJson(String path) throws IOException {
|
|
|
JSONObject dataJson = new JSONObject();
|