|
@@ -12,9 +12,7 @@ import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
-import com.fdkankan.common.constant.ErrorCode;
|
|
|
-import com.fdkankan.common.constant.FileBizType;
|
|
|
-import com.fdkankan.common.constant.ModelKind;
|
|
|
+import com.fdkankan.common.constant.*;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.common.util.FileUtils;
|
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
@@ -22,6 +20,7 @@ import com.fdkankan.model.constants.ConstantFilePath;
|
|
|
import com.fdkankan.model.constants.UploadFilePath;
|
|
|
import com.fdkankan.common.exception.BusinessException;
|
|
|
import com.fdkankan.scene.bean.SceneBean;
|
|
|
+import com.fdkankan.scene.util.CmdBuildUtil;
|
|
|
import com.fdkankan.web.response.ResultData;
|
|
|
import com.fdkankan.model.utils.ComputerUtil;
|
|
|
import com.fdkankan.model.utils.ConvertUtils;
|
|
@@ -669,106 +668,85 @@ 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 ScenePro getByNum(String num) {
|
|
|
- return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
|
+ 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();
|
|
|
+
|
|
|
+ if(ModelKind.THREE_D_TILE.code().equals(scenePlusExt.getModelKind())){
|
|
|
+ this.buildModel43dtiles(num, bucket, scenePlusExt.getDataSource(), file);
|
|
|
+ }else{
|
|
|
+ this.buildModel4Dam(num, bucket, scenePlusExt.getDataSource(), scenePlusExt.getBuildType(), file);
|
|
|
+ }
|
|
|
+
|
|
|
+ //更新版本信息
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
-// /**
|
|
|
-// * 老算法(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);
|
|
|
-// }
|
|
|
+ /**
|
|
|
+ * 老算法(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)){
|
|
|
+ CmdBuildUtil.BuildModelCommand(path);
|
|
|
+ }
|
|
|
+
|
|
|
+ //算法计算完后,生成压缩文件,上传到oss
|
|
|
+ this.uploadFileofterRebuildPanoram(path, filePath, num, bucket);
|
|
|
+ }
|
|
|
|
|
|
/**
|
|
|
* 新算法(3dtiles)上传模型逻辑
|
|
@@ -868,61 +846,61 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
|
|
|
}
|
|
|
|
|
|
-// 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 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->{
|
|
|
+ ossUtil.uploadFile(ossMeshPath + File.separator + name, filePath + name, false);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
private void writeDataJson(String path) throws IOException {
|
|
|
JSONObject dataJson = new JSONObject();
|
|
@@ -1052,6 +1030,11 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
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到本地
|