|
@@ -4,7 +4,6 @@ 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.util.RuntimeUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.core.util.ZipUtil;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
@@ -14,63 +13,45 @@ 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.*;
|
|
|
+import com.fdkankan.common.exception.BusinessException;
|
|
|
+import com.fdkankan.common.util.FileUtils;
|
|
|
+import com.fdkankan.fyun.face.FYunFileServiceInterface;
|
|
|
import com.fdkankan.model.constants.ConstantFileName;
|
|
|
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.web.response.ResultData;
|
|
|
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;
|
|
|
import com.fdkankan.redis.util.RedisUtil;
|
|
|
import com.fdkankan.scene.bean.IconBean;
|
|
|
+import com.fdkankan.scene.bean.SceneBean;
|
|
|
import com.fdkankan.scene.bean.TagBean;
|
|
|
-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.entity.*;
|
|
|
import com.fdkankan.scene.mapper.ISceneProMapper;
|
|
|
-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.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.Qualifier;
|
|
|
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 javax.annotation.Resource;
|
|
|
+import java.io.File;
|
|
|
+import java.io.IOException;
|
|
|
+import java.nio.charset.StandardCharsets;
|
|
|
+import java.util.*;
|
|
|
+import java.util.Map.Entry;
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+
|
|
|
/**
|
|
|
* <p>
|
|
|
* pro场景表 服务实现类
|
|
@@ -92,7 +73,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
@Value("${ecs.checkFile.waitTime:5000}")
|
|
|
private int waitTime;
|
|
|
|
|
|
- @Autowired
|
|
|
+ @Resource
|
|
|
private FYunFileServiceInterface fYunFileService;
|
|
|
@Autowired
|
|
|
private RedisLockUtil redisLockUtil;
|
|
@@ -106,6 +87,8 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
private IScenePlusExtService scenePlusExtService;
|
|
|
@Autowired
|
|
|
private ISceneUploadService sceneUploadService;
|
|
|
+ @Autowired
|
|
|
+ private ISceneAsynOperLogService sceneAsynOperLogService;
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
@@ -633,7 +616,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
String currentPanoId = jo.getString("panoID");
|
|
|
JSONArray visibles = jo.getJSONArray("visibles");
|
|
|
JSONArray visibles3 = jo.getJSONArray("visibles3");
|
|
|
- if (pano.getString("uuid").equals(currentPanoId)) {
|
|
|
+ if (pano.getString("uuid").replaceAll("-", "").equals(currentPanoId)) {
|
|
|
pano.put("visibles", visibles);
|
|
|
pano.put("visibles3", visibles3);
|
|
|
}
|
|
@@ -668,7 +651,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public ResultData uploadObjAndImg(String num, MultipartFile file) throws Exception{
|
|
|
+ public ResultData uploadModel(String num, MultipartFile file) throws Exception{
|
|
|
if(StrUtil.isEmpty(num)){
|
|
|
throw new BusinessException(ServerCode.PARAM_REQUIRED, "num");
|
|
|
}
|
|
@@ -680,6 +663,13 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(scenePlus == null){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
+
|
|
|
+ //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
+ sceneAsynOperLogService.checkSceneAsynOper(num, null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
|
|
|
+
|
|
|
+ //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
+ sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code());
|
|
|
+
|
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
|
String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
@@ -689,31 +679,10 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
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
|
|
@@ -735,16 +704,46 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
//创建data.json
|
|
|
this.writeDataJson(path);
|
|
|
|
|
|
- //调用算法,不同的类型调用不同的算法
|
|
|
- if("V2".equals(buildType)){
|
|
|
- CreateObjUtil.objToTxt(path , "1");
|
|
|
- }
|
|
|
- if("V3".equals(buildType)){
|
|
|
- CreateObjUtil.build3dModel(path , "1");
|
|
|
- }
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
+ sceneAsynOperLog.setNum(num);
|
|
|
+ sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
|
|
|
+ sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
+ sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
|
|
|
+ sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
+ try {
|
|
|
+ //调用算法,不同的类型调用不同的算法
|
|
|
+ if("V2".equals(buildType)){
|
|
|
+ CreateObjUtil.objToTxt(path , "1");
|
|
|
+ }
|
|
|
+ if("V3".equals(buildType)){
|
|
|
+ CreateObjUtil.build3dModel(path , "1");
|
|
|
+ }
|
|
|
|
|
|
- //算法计算完后,生成压缩文件,上传到oss
|
|
|
- this.uploadFileofterRebuildPanoram(path, filePath, num, bucket);
|
|
|
+ //算法计算完后,生成压缩文件,上传到oss
|
|
|
+ uploadFileofterBuildDamModel(path, filePath, num, bucket);
|
|
|
+
|
|
|
+ //更新版本信息
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ 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, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket);
|
|
|
+
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("上传dam模型,num:" + num, e);
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
+ }
|
|
|
+ sceneAsynOperLogService.updateById(sceneAsynOperLog);
|
|
|
+ });
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -769,18 +768,27 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
file.transferTo(zipFile);
|
|
|
ZipUtil.unzip(zipFilePath, meshPath);
|
|
|
|
|
|
+ String jsonName = "";
|
|
|
+ if(fYunFileService.fileExist(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/floors.json")){
|
|
|
+ jsonName = "floors.json";
|
|
|
+ }
|
|
|
+ if(fYunFileService.fileExist(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/mesh.json")){
|
|
|
+ jsonName = "mesh.json";
|
|
|
+ }
|
|
|
+
|
|
|
//检测文件
|
|
|
- String floorsJsonPath = meshPath + File.separator + "floors.json";
|
|
|
+ String floorsJsonPath = meshPath + File.separator + jsonName;
|
|
|
if(!FileUtil.exist(floorsJsonPath)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5068);
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5068.code(), "json file is not exist!");
|
|
|
}
|
|
|
String floorsJsonStr = FileUtil.readUtf8String(floorsJsonPath);
|
|
|
JSONObject floorsJsonObj = JSON.parseObject(floorsJsonStr);
|
|
|
JSONArray floorArr = floorsJsonObj.getJSONArray("floors");
|
|
|
if(CollUtil.isEmpty(floorArr)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5069);
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5069.code(), "json content is error");
|
|
|
}
|
|
|
Set<String> floorNameSet = new HashSet<>();
|
|
|
+ String finalJsonName = jsonName;
|
|
|
floorArr.stream().forEach(item->{
|
|
|
JSONObject itemObj = (JSONObject) item;
|
|
|
//楼层目录是否存在
|
|
@@ -789,9 +797,23 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
}
|
|
|
//检测obj文件是否存在
|
|
|
- String objPath = itemObj.getString("objPath");
|
|
|
- if(StrUtil.isEmpty(objPath) || !FileUtil.exist(path + objPath)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
+ if("floors.json".equals(finalJsonName)){
|
|
|
+ String objPath = itemObj.getString("objPath");
|
|
|
+ if(StrUtil.isEmpty(objPath) || !FileUtil.exist(path + objPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ JSONArray lods = itemObj.getJSONArray("lods");
|
|
|
+ if(CollUtil.isEmpty(lods)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5069.code(), "json content is error");
|
|
|
+ }
|
|
|
+ for (Object lod : lods) {
|
|
|
+ JSONObject lodObj = (JSONObject) lod;
|
|
|
+ String objPath = lodObj.getString("objPath");
|
|
|
+ if(StrUtil.isEmpty(objPath) || !FileUtil.exist(path + objPath)){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5070);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
if(floorNameSet.contains(name)){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5069);
|
|
@@ -800,7 +822,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 = fYunFileService.getFileContent(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/" + jsonName);
|
|
|
JSONObject orginFloorsJsonObj = JSON.parseObject(ossFloorsJson);
|
|
|
JSONArray orginFloorArr = orginFloorsJsonObj.getJSONArray("floors");
|
|
|
Set<String> orginFloorNameSet = orginFloorArr.stream().map(item -> {
|
|
@@ -816,36 +838,64 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
+ sceneAsynOperLog.setNum(num);
|
|
|
+ sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
|
|
|
+ sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
+ sceneAsynOperLog.setFunc(SceneAsynFuncType.MODEL.code());
|
|
|
+ sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
+ try {
|
|
|
+ //调用算法
|
|
|
+ String command = "bash /home/ubuntu/bin/Obj2Tiles.sh " + path;
|
|
|
+ log.info("上传3dtiles模型开始, num:{}, targetPath:{}", num, path);
|
|
|
+ CreateObjUtil.callshell(command);
|
|
|
+ log.info("上传3dtiles模型结束, num:{}, targetPath:{}", num, path);
|
|
|
+
|
|
|
+ //检测计算结果
|
|
|
+ String tilesPath = path + "3dtiles";
|
|
|
+ String tilesetJsonPath = tilesPath + File.separator + "tileset.json";
|
|
|
+ boolean success = ComputerUtil.checkComputeCompleted(tilesetJsonPath, maxCheckTimes, waitTime);
|
|
|
+ if(!success){
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
+ }
|
|
|
|
|
|
- //调用算法
|
|
|
- String command = "bash /home/ubuntu/bin/Obj2Tiles.sh " + path;
|
|
|
- log.info("上传3dtiles模型开始, num:{}, targetPath:{}", num, path);
|
|
|
-// RuntimeUtil.exec(command);
|
|
|
- CreateObjUtil.callshell(command);
|
|
|
- log.info("上传3dtiles模型结束, num:{}, targetPath:{}", num, path);
|
|
|
-
|
|
|
- //检测计算结果
|
|
|
- String tilesPath = path + "3dtiles";
|
|
|
- String tilesetJsonPath = tilesPath + File.separator + "tileset.json";
|
|
|
- boolean success = ComputerUtil.checkComputeCompleted(tilesetJsonPath, maxCheckTimes, waitTime);
|
|
|
- if(!success){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
|
- }
|
|
|
-
|
|
|
- //删除logs
|
|
|
- FileUtil.del(tilesPath + File.separator + "logs");
|
|
|
-
|
|
|
- //算法计算完后,生成压缩文件,上传到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");
|
|
|
- //上传mesh
|
|
|
- fYunFileService.deleteFolder(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
- fYunFileService.uploadFileByCommand(bucket, meshPath, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
+ //删除logs
|
|
|
+ FileUtil.del(tilesPath + File.separator + "logs");
|
|
|
+
|
|
|
+ //算法计算完后,生成压缩文件,上传到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");
|
|
|
+ //上传mesh
|
|
|
+ fYunFileService.deleteFolder(bucket, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
+ fYunFileService.uploadFileByCommand(bucket, meshPath, String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh");
|
|
|
+
|
|
|
+ //更新版本信息
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
|
+ 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, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket);
|
|
|
+
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
+ } catch (Exception e) {
|
|
|
+ log.error("上传全景图报错,num:" + num, e);
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
+ }
|
|
|
+ sceneAsynOperLogService.updateById(sceneAsynOperLog);
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
|
- private void uploadFileofterRebuildPanoram(String path, String filePath, String sceneNum, String bucket) throws Exception {
|
|
|
+ private void uploadFileofterBuildDamModel(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);
|
|
@@ -1008,7 +1058,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- public ResultData downloadTexData(String num) throws Exception {
|
|
|
+ public ResultData downloadModel(String num) throws Exception {
|
|
|
|
|
|
if(StrUtil.isEmpty(num)){
|
|
|
throw new BusinessException(ErrorCode.PARAM_REQUIRED);
|
|
@@ -1017,16 +1067,46 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
if(scenePlus == null){
|
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
}
|
|
|
+
|
|
|
+ //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
+ sceneAsynOperLogService.checkSceneAsynOper(num,null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.MODEL.code());
|
|
|
+
|
|
|
+ //清除旧的下载记录
|
|
|
+ sceneAsynOperLogService.cleanLog(num, SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.MODEL.code(), SceneAsynOperType.DOWNLOAD.code());
|
|
|
+
|
|
|
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);
|
|
|
- }
|
|
|
+ //开始异步执行下载全景图压缩包操作
|
|
|
+ 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());
|
|
|
+ sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
+ try {
|
|
|
+
|
|
|
+ String url = null;
|
|
|
+ if(ModelKind.THREE_D_TILE.code().equals(scenePlusExt.getModelKind())){
|
|
|
+ url = downloadModel43dtiles(num, bucket, scenePlusExt, sceneEditInfo);
|
|
|
+ }else{
|
|
|
+ url = downloadModel4Dam(num, bucket);
|
|
|
+ }
|
|
|
|
|
|
- return this.downloadModel4Dam(num, bucket);
|
|
|
+ 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();
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -1034,7 +1114,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
return this.getOne(new LambdaQueryWrapper<ScenePro>().eq(ScenePro::getNum, num));
|
|
|
}
|
|
|
|
|
|
- private ResultData downloadModel43dtiles(String num, String bucket, ScenePlusExt scenePlusExt, SceneEditInfo sceneEditInfo){
|
|
|
+ private String downloadModel43dtiles(String num, String bucket, ScenePlusExt scenePlusExt, SceneEditInfo sceneEditInfo){
|
|
|
|
|
|
//下载mesh到本地
|
|
|
String meshOssPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "mesh/";
|
|
@@ -1051,19 +1131,17 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
FileUtil.del(meshLocalPath);
|
|
|
FileUtil.del(zipFilePath);
|
|
|
String url = "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- return ResultData.ok(url);
|
|
|
+ return url;
|
|
|
}
|
|
|
|
|
|
- public static void main(String[] args) {
|
|
|
+ public static void main(String[] args) throws Exception {
|
|
|
|
|
|
- Date time = Calendar.getInstance().getTime();
|
|
|
- time = DateUtil.beginOfDay(DateUtil.offset(time, DateField.MONTH, -12));
|
|
|
- System.out.println(time);
|
|
|
+ ConvertUtils.convertVisionModelDataToTxt( "D:\\test\\vision.modeldata", "D:\\test\\vision.json");
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
- private ResultData downloadModel4Dam(String num, String bucket){
|
|
|
+ private String downloadModel4Dam(String num, String bucket){
|
|
|
String localImagePath = String.format(ConstantFilePath.IMAGESBUFFER_FORMAT, num);
|
|
|
if(!new File(localImagePath).exists()){
|
|
|
new File(localImagePath).mkdirs();
|
|
@@ -1110,7 +1188,7 @@ public class SceneProServiceImpl extends ServiceImpl<ISceneProMapper, ScenePro>
|
|
|
fYunFileService.uploadFile(bucket, zipPath, "downloads/extras/" + zipName);
|
|
|
String url = "downloads/extras/" + zipName + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
FileUtil.del(zipPath);
|
|
|
- return ResultData.ok(url);
|
|
|
+ return url;
|
|
|
}
|
|
|
|
|
|
@Override
|