|
@@ -394,12 +394,6 @@ public class SceneProServiceImpl implements ISceneProService {
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
-
|
|
|
- String tmpDirPath = FileUtil.getTmpDirPath();
|
|
|
- System.out.println(tmpDirPath);
|
|
|
- }
|
|
|
-
|
|
|
@Override
|
|
|
public ResultData saveRoam(BaseDataParamVO param) throws Exception {
|
|
|
|
|
@@ -461,335 +455,335 @@ public class SceneProServiceImpl implements ISceneProService {
|
|
|
return ResultData.ok();
|
|
|
}
|
|
|
|
|
|
- public ResultData downloadModel(String num, Integer subgroup, String upTimeKey) throws Exception {
|
|
|
-
|
|
|
- if(StrUtil.isEmpty(num)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
- }
|
|
|
- Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTimeKey);
|
|
|
- if(scenePlus == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
-
|
|
|
- //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
- sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
|
|
|
-
|
|
|
- //清除旧的下载记录
|
|
|
- sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code(), SceneAsynOperType.DOWNLOAD.code());
|
|
|
-
|
|
|
- SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
-
|
|
|
- //开始异步执行下载全景图压缩包操作
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
- sceneAsynOperLog.setNum(num);
|
|
|
- sceneAsynOperLog.setOperType(SceneAsynOperType.DOWNLOAD.code());
|
|
|
- sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
- sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
|
|
|
- sceneAsynOperLog.setVersion(sceneEditInfo.getImgVersion());
|
|
|
- sceneAsynOperLog.setSceneId(scenePlus.getId());
|
|
|
- sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
- try {
|
|
|
-
|
|
|
- String url = null;
|
|
|
- if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
|
|
|
-// url = downloadModel43dtiles(num, bucket, scenePlusExt, sceneEditInfo);
|
|
|
- }else{
|
|
|
- url = downloadModel4Dam(num, subgroup, upTimeKey, scenePlus.getCacheKeyHasTime());
|
|
|
- }
|
|
|
-
|
|
|
- sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
- sceneAsynOperLog.setUrl(url);
|
|
|
- }catch (Exception e){
|
|
|
- sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
- log.error("下载模型压缩包失败,num:" + num, e);
|
|
|
- }
|
|
|
- sceneAsynOperLogService.saveOrUpdate(sceneAsynOperLog);
|
|
|
- });
|
|
|
-
|
|
|
- return ResultData.ok();
|
|
|
- }
|
|
|
-
|
|
|
- private String downloadModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime){
|
|
|
- String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
|
|
|
- String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, numStr);
|
|
|
- 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, numStr) + "mesh";
|
|
|
- FileUtil.del(meshPath);
|
|
|
-
|
|
|
- //下载模型文件
|
|
|
- String objKey = dataViewPath+ "mesh/mesh.obj";
|
|
|
- String mtlKey = dataViewPath + "mesh/mesh.mtl";
|
|
|
- fYunFileService.downloadFile(num, subgroup, upTime, objKey, meshPath, mesh_obj);
|
|
|
- fYunFileService.downloadFile(num, subgroup, upTime, objKey, mtlKey, "mesh.mtl");
|
|
|
-
|
|
|
- log.info("meshPath="+meshPath);
|
|
|
- if(!new File(meshPath).exists() || new File(meshPath).listFiles().length < 1){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
|
|
|
- }
|
|
|
- //打包
|
|
|
- ZipUtil.zip(meshPath, zipPath);
|
|
|
- //上传压缩包
|
|
|
- fYunFileService.uploadFile(num, subgroup, upTime, zipPath, "downloads/extras/" + zipName);
|
|
|
- String url = "downloads/extras/" + zipName;
|
|
|
- FileUtil.del(zipPath);
|
|
|
- FileUtil.del(meshPath);
|
|
|
- return url;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData uploadModel(String num, Integer subgroup, String upTime, MultipartFile file) throws Exception{
|
|
|
- if(StrUtil.isEmpty(num)){
|
|
|
- throw new BusinessException(ErrorCode.PARAM_REQUIRED, "num");
|
|
|
- }
|
|
|
- if(!file.getOriginalFilename().endsWith(".zip")){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
|
|
|
- }
|
|
|
-
|
|
|
- Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
|
|
|
- if(scenePlus == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
-
|
|
|
- //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
- sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
|
|
|
-
|
|
|
- //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
- sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code());
|
|
|
-
|
|
|
-
|
|
|
- if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
|
|
|
-// this.buildModel43dtiles(num, bucket, scenePlusExt.getDataSource(), file);
|
|
|
- }else{
|
|
|
- this.buildModel4Dam(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), file);
|
|
|
- }
|
|
|
-
|
|
|
- return ResultData.ok();
|
|
|
- }
|
|
|
-
|
|
|
- /**
|
|
|
- * 老算法(dam)上传模型逻辑
|
|
|
- * @param num
|
|
|
- * @throws Exception
|
|
|
- */
|
|
|
- private void buildModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime, MultipartFile file) throws Exception {
|
|
|
-
|
|
|
- Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
|
|
|
-
|
|
|
- //文件上传的位置可以自定义
|
|
|
- String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
|
|
|
- String dataSource = String.format(ConstantFilePath.SCENE_USER_PATH_V4, numStr);
|
|
|
- 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);
|
|
|
-
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
- sceneAsynOperLog.setNum(num);
|
|
|
- sceneAsynOperLog.setSceneId(scenePlus.getId());
|
|
|
- sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
|
|
|
- sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
- sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
|
|
|
- sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
- try {
|
|
|
- //调用算法,不同的类型调用不同的算法
|
|
|
- CreateObjUtil.build3dModel(path , "1");
|
|
|
-
|
|
|
- //算法计算完后,生成压缩文件,上传到oss
|
|
|
- uploadFileofterBuildDamModel(path, filePath, num, subgroup, upTime);
|
|
|
-
|
|
|
- //更新版本信息
|
|
|
- SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
- 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, subgroup, upTime, scenePlus.getCacheKeyHasTime(), sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
|
|
|
-
|
|
|
- sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
- } catch (Exception e) {
|
|
|
- log.error("上传dam模型,num:" + num, e);
|
|
|
- sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
- }
|
|
|
- sceneAsynOperLogService.updateById(sceneAsynOperLog);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- private void objAndImgFileHandler(String resultPath, String filePath, String zipPath, MultipartFile file)
|
|
|
- throws Exception {
|
|
|
- FileUtil.del(resultPath);
|
|
|
- File targetFile = new File(filePath);
|
|
|
- if (!targetFile.exists()) {
|
|
|
- targetFile.mkdirs();
|
|
|
- }else {
|
|
|
- FileUtil.del(filePath);
|
|
|
- }
|
|
|
-
|
|
|
- targetFile = new File(zipPath);
|
|
|
- if (!targetFile.exists()) {
|
|
|
- targetFile.mkdirs();
|
|
|
- }else {
|
|
|
- FileUtil.del(zipPath);
|
|
|
- }
|
|
|
-
|
|
|
- targetFile = new File(zipPath + file.getOriginalFilename());
|
|
|
- if(!targetFile.getParentFile().exists()){
|
|
|
- targetFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- // 保存压缩包到本地
|
|
|
- if(targetFile.exists()) {
|
|
|
- FileUtil.del(zipPath + file.getOriginalFilename());
|
|
|
- }
|
|
|
- file.transferTo(targetFile);
|
|
|
-
|
|
|
- ZipUtil.unzip(zipPath + file.getOriginalFilename(), zipPath + data_dir);
|
|
|
-
|
|
|
- //源文件数据,判断是否有多个文件夹,有多个就提示错误,有一个就将文件夹里数据迁移到extras目录,无直接迁移到extras目录
|
|
|
- boolean flag = false;
|
|
|
- //目录名称,如果不为空,则压缩文件第一层是目录
|
|
|
- String targetName = "";
|
|
|
- File dataFile = new File(zipPath + data_dir);
|
|
|
- for(File data : dataFile.listFiles()){
|
|
|
- if(data.isDirectory() && flag){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
|
|
|
- }
|
|
|
- if(data.isDirectory() && !flag){
|
|
|
- flag = true;
|
|
|
- targetName = data.getName();
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- //是否包含obj文件
|
|
|
- boolean objFlag = false;
|
|
|
- //是否包含mtl文件
|
|
|
- boolean mtlFlag = false;
|
|
|
- File[] files = null;
|
|
|
- String dataPath = null;
|
|
|
- if(StrUtil.isEmpty(targetName)){
|
|
|
- files = dataFile.listFiles();
|
|
|
- dataPath = zipPath + data_dir;
|
|
|
- }else{
|
|
|
- files = new File(zipPath + data_dir + targetName).listFiles();
|
|
|
- dataPath = zipPath + data_dir + targetName + File.separator;
|
|
|
- }
|
|
|
-
|
|
|
- for(File data : files){
|
|
|
- if(data.isDirectory()){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
|
|
|
- }
|
|
|
-
|
|
|
- if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
|
|
|
- if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
- }
|
|
|
- }
|
|
|
- if(data.getName().endsWith(".obj")){
|
|
|
- if(objFlag){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
|
|
|
- }
|
|
|
- if(!data.getName().equals(mesh_obj)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5060);
|
|
|
- }
|
|
|
- if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
- }
|
|
|
-
|
|
|
- objFlag = true;
|
|
|
- FileUtil.copy(dataPath + data.getName(), filePath + mesh_obj, true);
|
|
|
- continue;
|
|
|
- }
|
|
|
-
|
|
|
- if(data.getName().endsWith(".mtl")){
|
|
|
- mtlFlag = true;
|
|
|
- }
|
|
|
-
|
|
|
- FileUtil.copy(dataPath + data.getName(), filePath + data.getName(), true);
|
|
|
- }
|
|
|
-
|
|
|
- //压缩文件中必须有且仅有一个obj和mtl文件,否则抛出异常
|
|
|
- if(!objFlag){//!mtlFlag ||
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_15059);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private void writeDataJson(String path) throws IOException {
|
|
|
- JSONObject dataJson = new JSONObject();
|
|
|
- dataJson.put("obj2txt", true);
|
|
|
- dataJson.put("split_type", "SPLIT_V6");
|
|
|
- dataJson.put("data_describe", "double spherical");
|
|
|
- dataJson.put("skybox_type", "SKYBOX_V5");
|
|
|
- FileUtil.writeUtf8String(dataJson.toString(), path + "/data.json");
|
|
|
- }
|
|
|
-
|
|
|
- private void uploadFileofterBuildDamModel(String path, String filePath, String sceneNum, Integer subgroup, String upTime) throws Exception {
|
|
|
- //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
|
|
|
- String uploadJsonPath = path + File.separator + results_dir +File.separator+"upload.json";
|
|
|
- boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 2000);
|
|
|
- if(!exist){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
- }
|
|
|
- String uploadData = FileUtil.readUtf8String(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_dir + File.separator + fileName).exists()) {
|
|
|
- throw new Exception(path + File.separator + results_dir + File.separator + fileName + "文件不存在");
|
|
|
- }
|
|
|
-
|
|
|
- //tex文件夹
|
|
|
- if (fileJson.getIntValue("clazz") == 15) {
|
|
|
- map.put(path + File.separator + results_dir + File.separator + fileName, imgViewPath + "tieta_texture/" + fileName.replace("tex/", ""));
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- String damKey = imgViewPath + "tieta.dam";
|
|
|
- String damPath = path + File.separator + results_dir +File.separator + "dam.txt";
|
|
|
- CreateObjUtil.convertTxtToDam( path + File.separator + results_dir +File.separator+"modeldata.txt", damPath);
|
|
|
- boolean existDam = ComputerUtil.checkComputeCompleted(damPath, 5, 200);
|
|
|
- if(!existDam){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
- }
|
|
|
- map.put(damPath, damKey);
|
|
|
-
|
|
|
- String ossMeshPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "mesh";
|
|
|
- //上传obj相关文件
|
|
|
- List<String> fileNames = FileUtil.listFileNames(filePath);
|
|
|
- fileNames.stream().forEach(name->map.put(filePath + name, ossMeshPath + File.separator + name));
|
|
|
-
|
|
|
- fYunFileService.uploadMulFiles(sceneNum, subgroup,upTime, map);
|
|
|
- }
|
|
|
+// public ResultData downloadModel(String num, Integer subgroup, String upTimeKey) throws Exception {
|
|
|
+//
|
|
|
+// if(StrUtil.isEmpty(num)){
|
|
|
+// throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
|
+// }
|
|
|
+// Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTimeKey);
|
|
|
+// if(scenePlus == null){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
+// sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
|
|
|
+//
|
|
|
+// //清除旧的下载记录
|
|
|
+// sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code(), SceneAsynOperType.DOWNLOAD.code());
|
|
|
+//
|
|
|
+// SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
+//
|
|
|
+// //开始异步执行下载全景图压缩包操作
|
|
|
+// CompletableFuture.runAsync(() -> {
|
|
|
+// SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
+// sceneAsynOperLog.setNum(num);
|
|
|
+// sceneAsynOperLog.setOperType(SceneAsynOperType.DOWNLOAD.code());
|
|
|
+// sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
+// sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
|
|
|
+// sceneAsynOperLog.setVersion(sceneEditInfo.getImgVersion());
|
|
|
+// sceneAsynOperLog.setSceneId(scenePlus.getId());
|
|
|
+// sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
+// try {
|
|
|
+//
|
|
|
+// String url = null;
|
|
|
+// if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
|
|
|
+//// url = downloadModel43dtiles(num, bucket, scenePlusExt, sceneEditInfo);
|
|
|
+// }else{
|
|
|
+// url = downloadModel4Dam(num, subgroup, upTimeKey, scenePlus.getCacheKeyHasTime());
|
|
|
+// }
|
|
|
+//
|
|
|
+// sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
+// sceneAsynOperLog.setUrl(url);
|
|
|
+// }catch (Exception e){
|
|
|
+// sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
+// log.error("下载模型压缩包失败,num:" + num, e);
|
|
|
+// }
|
|
|
+// sceneAsynOperLogService.saveOrUpdate(sceneAsynOperLog);
|
|
|
+// });
|
|
|
+//
|
|
|
+// return ResultData.ok();
|
|
|
+// }
|
|
|
+
|
|
|
+// private String downloadModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime){
|
|
|
+// String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
|
|
|
+// String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, numStr);
|
|
|
+// 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, numStr) + "mesh";
|
|
|
+// FileUtil.del(meshPath);
|
|
|
+//
|
|
|
+// //下载模型文件
|
|
|
+// String objKey = dataViewPath+ "mesh/mesh.obj";
|
|
|
+// String mtlKey = dataViewPath + "mesh/mesh.mtl";
|
|
|
+// fYunFileService.downloadFile(num, subgroup, upTime, objKey, meshPath, mesh_obj);
|
|
|
+// fYunFileService.downloadFile(num, subgroup, upTime, objKey, mtlKey, "mesh.mtl");
|
|
|
+//
|
|
|
+// log.info("meshPath="+meshPath);
|
|
|
+// if(!new File(meshPath).exists() || new File(meshPath).listFiles().length < 1){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7006);
|
|
|
+// }
|
|
|
+// //打包
|
|
|
+// ZipUtil.zip(meshPath, zipPath);
|
|
|
+// //上传压缩包
|
|
|
+// fYunFileService.uploadFile(num, subgroup, upTime, zipPath, "downloads/extras/" + zipName);
|
|
|
+// String url = "downloads/extras/" + zipName;
|
|
|
+// FileUtil.del(zipPath);
|
|
|
+// FileUtil.del(meshPath);
|
|
|
+// return url;
|
|
|
+// }
|
|
|
+
|
|
|
+// @Override
|
|
|
+// public ResultData uploadModel(String num, Integer subgroup, String upTime, MultipartFile file) throws Exception{
|
|
|
+// if(StrUtil.isEmpty(num)){
|
|
|
+// throw new BusinessException(ErrorCode.PARAM_REQUIRED, "num");
|
|
|
+// }
|
|
|
+// if(!file.getOriginalFilename().endsWith(".zip")){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7015);
|
|
|
+// }
|
|
|
+//
|
|
|
+// Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
|
|
|
+// if(scenePlus == null){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
+// sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
|
|
|
+//
|
|
|
+// //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
+// sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code());
|
|
|
+//
|
|
|
+//
|
|
|
+// if(ModelKind.THREE_D_TILE.code().equals(scenePlus.getModelkind())){
|
|
|
+//// this.buildModel43dtiles(num, bucket, scenePlusExt.getDataSource(), file);
|
|
|
+// }else{
|
|
|
+// this.buildModel4Dam(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), file);
|
|
|
+// }
|
|
|
+//
|
|
|
+// return ResultData.ok();
|
|
|
+// }
|
|
|
+
|
|
|
+// /**
|
|
|
+// * 老算法(dam)上传模型逻辑
|
|
|
+// * @param num
|
|
|
+// * @throws Exception
|
|
|
+// */
|
|
|
+// private void buildModel4Dam(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime, MultipartFile file) throws Exception {
|
|
|
+//
|
|
|
+// Scene scenePlus = scenePlusService.getByNum(num, subgroup, upTime);
|
|
|
+//
|
|
|
+// //文件上传的位置可以自定义
|
|
|
+// String numStr = RedisKey.getNumStr(num, subgroup, upTime, cacheKeyHasTime);
|
|
|
+// String dataSource = String.format(ConstantFilePath.SCENE_USER_PATH_V4, numStr);
|
|
|
+// 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);
|
|
|
+//
|
|
|
+// CompletableFuture.runAsync(() -> {
|
|
|
+// SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
+// sceneAsynOperLog.setNum(num);
|
|
|
+// sceneAsynOperLog.setSceneId(scenePlus.getId());
|
|
|
+// sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
|
|
|
+// sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
+// sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
|
|
|
+// sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
+// try {
|
|
|
+// //调用算法,不同的类型调用不同的算法
|
|
|
+// CreateObjUtil.build3dModel(path , "1");
|
|
|
+//
|
|
|
+// //算法计算完后,生成压缩文件,上传到oss
|
|
|
+// uploadFileofterBuildDamModel(path, filePath, num, subgroup, upTime);
|
|
|
+//
|
|
|
+// //更新版本信息
|
|
|
+// SceneEditInfo sceneEditInfo = sceneEditInfoService.getByScenePlusId(scenePlus.getId());
|
|
|
+// 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, subgroup, upTime, scenePlus.getCacheKeyHasTime(), sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
|
|
|
+//
|
|
|
+// sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
+// } catch (Exception e) {
|
|
|
+// log.error("上传dam模型,num:" + num, e);
|
|
|
+// sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
+// }
|
|
|
+// sceneAsynOperLogService.updateById(sceneAsynOperLog);
|
|
|
+// });
|
|
|
+// }
|
|
|
+
|
|
|
+// private void objAndImgFileHandler(String resultPath, String filePath, String zipPath, MultipartFile file)
|
|
|
+// throws Exception {
|
|
|
+// FileUtil.del(resultPath);
|
|
|
+// File targetFile = new File(filePath);
|
|
|
+// if (!targetFile.exists()) {
|
|
|
+// targetFile.mkdirs();
|
|
|
+// }else {
|
|
|
+// FileUtil.del(filePath);
|
|
|
+// }
|
|
|
+//
|
|
|
+// targetFile = new File(zipPath);
|
|
|
+// if (!targetFile.exists()) {
|
|
|
+// targetFile.mkdirs();
|
|
|
+// }else {
|
|
|
+// FileUtil.del(zipPath);
|
|
|
+// }
|
|
|
+//
|
|
|
+// targetFile = new File(zipPath + file.getOriginalFilename());
|
|
|
+// if(!targetFile.getParentFile().exists()){
|
|
|
+// targetFile.getParentFile().mkdirs();
|
|
|
+// }
|
|
|
+// // 保存压缩包到本地
|
|
|
+// if(targetFile.exists()) {
|
|
|
+// FileUtil.del(zipPath + file.getOriginalFilename());
|
|
|
+// }
|
|
|
+// file.transferTo(targetFile);
|
|
|
+//
|
|
|
+// ZipUtil.unzip(zipPath + file.getOriginalFilename(), zipPath + data_dir);
|
|
|
+//
|
|
|
+// //源文件数据,判断是否有多个文件夹,有多个就提示错误,有一个就将文件夹里数据迁移到extras目录,无直接迁移到extras目录
|
|
|
+// boolean flag = false;
|
|
|
+// //目录名称,如果不为空,则压缩文件第一层是目录
|
|
|
+// String targetName = "";
|
|
|
+// File dataFile = new File(zipPath + data_dir);
|
|
|
+// for(File data : dataFile.listFiles()){
|
|
|
+// if(data.isDirectory() && flag){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
|
|
|
+// }
|
|
|
+// if(data.isDirectory() && !flag){
|
|
|
+// flag = true;
|
|
|
+// targetName = data.getName();
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// //是否包含obj文件
|
|
|
+// boolean objFlag = false;
|
|
|
+// //是否包含mtl文件
|
|
|
+// boolean mtlFlag = false;
|
|
|
+// File[] files = null;
|
|
|
+// String dataPath = null;
|
|
|
+// if(StrUtil.isEmpty(targetName)){
|
|
|
+// files = dataFile.listFiles();
|
|
|
+// dataPath = zipPath + data_dir;
|
|
|
+// }else{
|
|
|
+// files = new File(zipPath + data_dir + targetName).listFiles();
|
|
|
+// dataPath = zipPath + data_dir + targetName + File.separator;
|
|
|
+// }
|
|
|
+//
|
|
|
+// for(File data : files){
|
|
|
+// if(data.isDirectory()){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5018);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(data.getName().endsWith(".jpg") || data.getName().endsWith(".png")){
|
|
|
+// if(!FileUtils.checkFileSizeIsLimit(data.length(), 1.5, "M")){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
+// }
|
|
|
+// }
|
|
|
+// if(data.getName().endsWith(".obj")){
|
|
|
+// if(objFlag){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5019);
|
|
|
+// }
|
|
|
+// if(!data.getName().equals(mesh_obj)){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5060);
|
|
|
+// }
|
|
|
+// if(!FileUtils.checkFileSizeIsLimit(data.length(), 20, "M")){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5020);
|
|
|
+// }
|
|
|
+//
|
|
|
+// objFlag = true;
|
|
|
+// FileUtil.copy(dataPath + data.getName(), filePath + mesh_obj, true);
|
|
|
+// continue;
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(data.getName().endsWith(".mtl")){
|
|
|
+// mtlFlag = true;
|
|
|
+// }
|
|
|
+//
|
|
|
+// FileUtil.copy(dataPath + data.getName(), filePath + data.getName(), true);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //压缩文件中必须有且仅有一个obj和mtl文件,否则抛出异常
|
|
|
+// if(!objFlag){//!mtlFlag ||
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_15059);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// private void writeDataJson(String path) throws IOException {
|
|
|
+// JSONObject dataJson = new JSONObject();
|
|
|
+// dataJson.put("obj2txt", true);
|
|
|
+// dataJson.put("split_type", "SPLIT_V6");
|
|
|
+// dataJson.put("data_describe", "double spherical");
|
|
|
+// dataJson.put("skybox_type", "SKYBOX_V5");
|
|
|
+// FileUtil.writeUtf8String(dataJson.toString(), path + "/data.json");
|
|
|
+// }
|
|
|
+
|
|
|
+// private void uploadFileofterBuildDamModel(String path, String filePath, String sceneNum, Integer subgroup, String upTime) throws Exception {
|
|
|
+// //因为共享目录有延迟,这里循环检测算法是否计算完毕3次,每次隔五秒
|
|
|
+// String uploadJsonPath = path + File.separator + results_dir +File.separator+"upload.json";
|
|
|
+// boolean exist = ComputerUtil.checkComputeCompleted(uploadJsonPath, 5, 2000);
|
|
|
+// if(!exist){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+// }
|
|
|
+// String uploadData = FileUtil.readUtf8String(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_dir + File.separator + fileName).exists()) {
|
|
|
+// throw new Exception(path + File.separator + results_dir + File.separator + fileName + "文件不存在");
|
|
|
+// }
|
|
|
+//
|
|
|
+// //tex文件夹
|
|
|
+// if (fileJson.getIntValue("clazz") == 15) {
|
|
|
+// map.put(path + File.separator + results_dir + File.separator + fileName, imgViewPath + "tieta_texture/" + fileName.replace("tex/", ""));
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// String damKey = imgViewPath + "tieta.dam";
|
|
|
+// String damPath = path + File.separator + results_dir +File.separator + "dam.txt";
|
|
|
+// CreateObjUtil.convertTxtToDam( path + File.separator + results_dir +File.separator+"modeldata.txt", damPath);
|
|
|
+// boolean existDam = ComputerUtil.checkComputeCompleted(damPath, 5, 200);
|
|
|
+// if(!existDam){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+// }
|
|
|
+// map.put(damPath, damKey);
|
|
|
+//
|
|
|
+// String ossMeshPath = String.format(UploadFilePath.DATA_VIEW_PATH, sceneNum) + "mesh";
|
|
|
+// //上传obj相关文件
|
|
|
+// List<String> fileNames = FileUtil.listFileNames(filePath);
|
|
|
+// fileNames.stream().forEach(name->map.put(filePath + name, ossMeshPath + File.separator + name));
|
|
|
+//
|
|
|
+// fYunFileService.uploadMulFiles(sceneNum, subgroup,upTime, map);
|
|
|
+// }
|
|
|
|
|
|
|
|
|
}
|