|
@@ -1,4 +1,13 @@
|
|
package com.fdkankan.scene.service.impl;
|
|
package com.fdkankan.scene.service.impl;
|
|
|
|
+import cn.hutool.core.net.multipart.UploadFile;
|
|
|
|
+import cn.hutool.core.util.CharsetUtil;
|
|
|
|
+import com.fdkankan.common.constant.CommonOperStatus;
|
|
|
|
+import com.fdkankan.common.constant.SceneAsynFuncType;
|
|
|
|
+import com.fdkankan.common.constant.SceneAsynModuleType;
|
|
|
|
+import com.fdkankan.common.constant.SceneAsynOperType;
|
|
|
|
+import com.fdkankan.scene.vo.SaveFiltersParamVO;
|
|
|
|
+import io.opencensus.metrics.LongGauge;
|
|
|
|
+import java.util.Date;
|
|
|
|
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.bean.BeanUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
import cn.hutool.core.collection.CollUtil;
|
|
@@ -44,6 +53,7 @@ import com.fdkankan.scene.bean.VertexBean;
|
|
import com.fdkankan.scene.bean.WallBean;
|
|
import com.fdkankan.scene.bean.WallBean;
|
|
import com.fdkankan.scene.entity.CameraDetail;
|
|
import com.fdkankan.scene.entity.CameraDetail;
|
|
import com.fdkankan.scene.entity.Company;
|
|
import com.fdkankan.scene.entity.Company;
|
|
|
|
+import com.fdkankan.scene.entity.SceneAsynOperLog;
|
|
import com.fdkankan.scene.entity.SceneDataDownload;
|
|
import com.fdkankan.scene.entity.SceneDataDownload;
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
import com.fdkankan.scene.entity.SceneEditControls;
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
import com.fdkankan.scene.entity.SceneEditInfo;
|
|
@@ -53,6 +63,7 @@ import com.fdkankan.scene.entity.ScenePlusExt;
|
|
import com.fdkankan.scene.mapper.ISceneEditInfoMapper;
|
|
import com.fdkankan.scene.mapper.ISceneEditInfoMapper;
|
|
import com.fdkankan.scene.service.ICameraDetailService;
|
|
import com.fdkankan.scene.service.ICameraDetailService;
|
|
import com.fdkankan.scene.service.ICompanyService;
|
|
import com.fdkankan.scene.service.ICompanyService;
|
|
|
|
+import com.fdkankan.scene.service.ISceneAsynOperLogService;
|
|
import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
import com.fdkankan.scene.service.ISceneDataDownloadService;
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
import com.fdkankan.scene.service.ISceneEditControlsService;
|
|
import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
import com.fdkankan.scene.service.ISceneEditInfoExtService;
|
|
@@ -103,6 +114,7 @@ import java.util.Map.Entry;
|
|
import java.util.Objects;
|
|
import java.util.Objects;
|
|
import java.util.Set;
|
|
import java.util.Set;
|
|
import java.util.UUID;
|
|
import java.util.UUID;
|
|
|
|
+import java.util.concurrent.CompletableFuture;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
import java.util.stream.Collectors;
|
|
import java.util.stream.Collectors;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
@@ -162,6 +174,8 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
private ICompanyService companyService;
|
|
private ICompanyService companyService;
|
|
@Autowired
|
|
@Autowired
|
|
private ISurveillanceService surveillanceService;
|
|
private ISurveillanceService surveillanceService;
|
|
|
|
+ @Autowired
|
|
|
|
+ private ISceneAsynOperLogService sceneAsynOperLogService;
|
|
|
|
|
|
@Transactional
|
|
@Transactional
|
|
@Override
|
|
@Override
|
|
@@ -272,6 +286,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
sceneJson.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
sceneJson.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
sceneJson.setSceneKind(scenePlusExt.getSceneKind());
|
|
sceneJson.setSceneKind(scenePlusExt.getSceneKind());
|
|
|
|
+ sceneJson.setModelKind(scenePlusExt.getModelKind());
|
|
if(StrUtil.isNotEmpty(scenePlusExt.getVideos())){
|
|
if(StrUtil.isNotEmpty(scenePlusExt.getVideos())){
|
|
sceneJson.setVideos(scenePlusExt.getVideos());
|
|
sceneJson.setVideos(scenePlusExt.getVideos());
|
|
}
|
|
}
|
|
@@ -304,7 +319,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
//删除发布数据中的user目录
|
|
//删除发布数据中的user目录
|
|
String publicUserPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
String publicUserPath = String.format(UploadFilePath.USER_VIEW_PATH, num);
|
|
- fYunFileService.deleteFile(bucket, publicUserPath);
|
|
|
|
|
|
+ fYunFileService.deleteFolder(bucket, publicUserPath);
|
|
|
|
|
|
//复制编辑目录到发布目录
|
|
//复制编辑目录到发布目录
|
|
String editPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum());
|
|
String editPath = String.format(UploadFilePath.USER_EDIT_PATH, param.getNum());
|
|
@@ -323,11 +338,18 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
|
|
|
|
scenePlus.setTitle(sceneEditInfo.getTitle());
|
|
scenePlus.setTitle(sceneEditInfo.getTitle());
|
|
scenePlus.setDescription(sceneEditInfo.getDescription());
|
|
scenePlus.setDescription(sceneEditInfo.getDescription());
|
|
|
|
+ scenePlus.setHouseType(this.existsHouseType(bucket, num));
|
|
scenePlusService.updateById(scenePlus);
|
|
scenePlusService.updateById(scenePlus);
|
|
|
|
|
|
return ResultData.ok();
|
|
return ResultData.ok();
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private int existsHouseType(String bucket, String num){
|
|
|
|
+ String houseTypePath = String.format(UploadFilePath.USER_VIEW_PATH, num) + "houseType.json";
|
|
|
|
+ boolean exist = fYunFileService.fileExist(bucket, houseTypePath);
|
|
|
|
+ return exist ? CommonStatus.YES.code().intValue() : CommonStatus.NO.code().intValue();
|
|
|
|
+ }
|
|
|
|
+
|
|
private void publicSurveillance(String num, Integer surveillances, String bucket) throws IOException {
|
|
private void publicSurveillance(String num, Integer surveillances, String bucket) throws IOException {
|
|
String surveillanceJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "surveillance.json";
|
|
String surveillanceJsonPath = String.format(UploadFilePath.USER_EDIT_PATH, num) + "surveillance.json";
|
|
if(surveillances == CommonStatus.NO.code().intValue()){
|
|
if(surveillances == CommonStatus.NO.code().intValue()){
|
|
@@ -358,6 +380,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
String userEditPath = String.format(UploadFilePath.USER_EDIT_PATH, num);
|
|
String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
|
|
|
|
|
+ //清除发布目录中的场景关联图片
|
|
|
|
+ fYunFileService.deleteFolder(bucket,imgViewPath + "panorama");
|
|
|
|
+
|
|
//生成links.json并上传到发布目录
|
|
//生成links.json并上传到发布目录
|
|
String linkPanKey = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
|
|
String linkPanKey = String.format(RedisKey.SCENE_LINKPAN_DATA, num);
|
|
Map<String, String> linkPanMap = redisUtil.hmget(linkPanKey);
|
|
Map<String, String> linkPanMap = redisUtil.hmget(linkPanKey);
|
|
@@ -372,7 +397,6 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
fYunFileService.uploadFile(bucket, linkPanArr.toString().getBytes(), linkScenePath);
|
|
fYunFileService.uploadFile(bucket, linkPanArr.toString().getBytes(), linkScenePath);
|
|
|
|
|
|
//拷贝编辑目录到发布目录
|
|
//拷贝编辑目录到发布目录
|
|
- fYunFileService.deleteFile(bucket,imgViewPath + "panorama");
|
|
|
|
fYunFileService.copyFileBetweenBucket(bucket, imgEditPath + "panorama", bucket, imgViewPath + "panorama");
|
|
fYunFileService.copyFileBetweenBucket(bucket, imgEditPath + "panorama", bucket, imgViewPath + "panorama");
|
|
|
|
|
|
}
|
|
}
|
|
@@ -458,6 +482,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
sceneInfoVO.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
sceneInfoVO.setSceneResolution(scenePlusExt.getSceneResolution());
|
|
sceneInfoVO.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
sceneInfoVO.setSceneFrom(scenePlusExt.getSceneFrom());
|
|
sceneInfoVO.setSceneKind(scenePlusExt.getSceneKind());
|
|
sceneInfoVO.setSceneKind(scenePlusExt.getSceneKind());
|
|
|
|
+ sceneInfoVO.setModelKind(scenePlusExt.getModelKind());
|
|
sceneInfoVO.setVideos(scenePlusExt.getVideos());
|
|
sceneInfoVO.setVideos(scenePlusExt.getVideos());
|
|
if(CommonStatus.YES.code().intValue() == sceneEditInfoExt.getMosaic()){
|
|
if(CommonStatus.YES.code().intValue() == sceneEditInfoExt.getMosaic()){
|
|
sceneInfoVO.setMosaicList(this.getMosaicList(num));
|
|
sceneInfoVO.setMosaicList(this.getMosaicList(num));
|
|
@@ -715,6 +740,10 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
result.put("version", "2.1");
|
|
result.put("version", "2.1");
|
|
|
|
|
|
String floorplanCadPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan_cad.json";
|
|
String floorplanCadPath = String.format(UploadFilePath.DATA_VIEW_PATH, num) + "floorplan_cad.json";
|
|
|
|
+ if(!fYunFileService.fileExist(bucket, floorplanCadPath)){
|
|
|
|
+ log.warn("生成houseType.json失败,原因:floorplan_cad.json文件不存在,num:{}", num);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
String floorcadStr = fYunFileService.getFileContent(bucket, floorplanCadPath);
|
|
String floorcadStr = fYunFileService.getFileContent(bucket, floorplanCadPath);
|
|
|
|
|
|
JSONObject floorcadObj = JSON.parseObject(floorcadStr);
|
|
JSONObject floorcadObj = JSON.parseObject(floorcadStr);
|
|
@@ -929,6 +958,19 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
if(scenePlus == null){
|
|
if(scenePlus == null){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
|
+ this.checkSceneAsynOper(num, null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
|
+
|
|
|
|
+ //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
|
+ sceneAsynOperLogService.remove(
|
|
|
|
+ new LambdaQueryWrapper<SceneAsynOperLog>()
|
|
|
|
+ .eq(SceneAsynOperLog::getNum, num)
|
|
|
|
+ .eq(SceneAsynOperLog::getModule, SceneAsynModuleType.UPLOAD_DOWNLOAD.code())
|
|
|
|
+ .eq(SceneAsynOperLog::getFunc, SceneAsynFuncType.PANORAMIC_IMAGE.code())
|
|
|
|
+ );
|
|
|
|
+
|
|
|
|
+
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
String bucket = scenePlusExt.getYunFileBucket();
|
|
String bucket = scenePlusExt.getYunFileBucket();
|
|
|
|
|
|
@@ -954,9 +996,14 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
file.transferTo(targetFile);
|
|
file.transferTo(targetFile);
|
|
|
|
|
|
//如果是压缩包上传,需要解压缩
|
|
//如果是压缩包上传,需要解压缩
|
|
|
|
+ int async = CommonStatus.NO.code();
|
|
if(file.getOriginalFilename().endsWith(".zip")){
|
|
if(file.getOriginalFilename().endsWith(".zip")){
|
|
|
|
+
|
|
|
|
+ //标记为异步处理
|
|
|
|
+ async = CommonStatus.YES.code();
|
|
|
|
+
|
|
//解压zip包
|
|
//解压zip包
|
|
- ZipUtil.unzip(zipTargetFilePath,targetImagesPath);
|
|
|
|
|
|
+ ZipUtil.unzip(zipTargetFilePath,targetImagesPath, CharsetUtil.CHARSET_GBK);
|
|
//删除压缩包
|
|
//删除压缩包
|
|
FileUtils.delFile(zipTargetFilePath);
|
|
FileUtils.delFile(zipTargetFilePath);
|
|
}
|
|
}
|
|
@@ -1015,7 +1062,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
}).collect(Collectors.toList());
|
|
}).collect(Collectors.toList());
|
|
}
|
|
}
|
|
- return ResultData.ok(new UploadPanoramaVO(0, notExistFileList));
|
|
|
|
|
|
+ return ResultData.ok(new UploadPanoramaVO(0,0, notExistFileList));
|
|
}
|
|
}
|
|
|
|
|
|
//上传
|
|
//上传
|
|
@@ -1061,11 +1108,77 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
if(new File(target + File.separator + "results").exists()){
|
|
if(new File(target + File.separator + "results").exists()){
|
|
FileUtils.delAllFile(target + File.separator + "results");
|
|
FileUtils.delAllFile(target + File.separator + "results");
|
|
}
|
|
}
|
|
- if(FYunTypeEnum.AWS.code().equals(fyunType)){
|
|
|
|
- //亚马逊保持旧方式,超链接capture
|
|
|
|
- CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
|
|
|
|
- }
|
|
|
|
|
|
+// if(FYunTypeEnum.AWS.code().equals(fyunType)){
|
|
|
|
+// //亚马逊保持旧方式,超链接capture
|
|
|
|
+// CreateObjUtil.createSoftConnection(path + File.separator + "capture", target + File.separator + "capture");
|
|
|
|
+// }
|
|
fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", target + File.separator + "capture/data.fdage");
|
|
fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", target + File.separator + "capture/data.fdage");
|
|
|
|
+
|
|
|
|
+ //如果部分成功,则需要返回成功数量和失败列表
|
|
|
|
+ if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
|
+ notExistFileList = notExistFileList.stream().map(filePath -> {
|
|
|
|
+ return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ UploadPanoramaVO uploadPanoramaVO = new UploadPanoramaVO();
|
|
|
|
+ uploadPanoramaVO.setAsyn(async);
|
|
|
|
+ if(async == CommonStatus.YES.code().intValue()){
|
|
|
|
+ List<String> finalUploadFileList = uploadFileList;
|
|
|
|
+ List<String> finalNotExistFileList = notExistFileList;
|
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
|
+ SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
|
+ sceneAsynOperLog.setNum(num);
|
|
|
|
+ sceneAsynOperLog.setOperType(SceneAsynOperType.UPLOAD.code());
|
|
|
|
+ sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
|
+ sceneAsynOperLog.setFunc(SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
|
+ if(CollUtil.isNotEmpty(finalNotExistFileList)){
|
|
|
|
+ Map<String, Object> extData = new HashMap<>();
|
|
|
|
+ extData.put("successCnt", finalUploadFileList.size());
|
|
|
|
+ extData.put("failList", finalNotExistFileList);
|
|
|
|
+ sceneAsynOperLog.setExtData(JSON.toJSONString(extData));
|
|
|
|
+ }
|
|
|
|
+ sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
|
+ try {
|
|
|
|
+ this.uploadPanoramaHandler(num,bucket,target,imgViewPath, finalUploadFileList,targetImagesPath);
|
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
+ log.error("上传全景图报错,num:" + num, e);
|
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
|
+ }
|
|
|
|
+ sceneAsynOperLogService.updateById(sceneAsynOperLog);
|
|
|
|
+ });
|
|
|
|
+ }else{
|
|
|
|
+ this.uploadPanoramaHandler(num,bucket,target,imgViewPath,uploadFileList,targetImagesPath);
|
|
|
|
+ if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
|
+ uploadPanoramaVO.setSuccessCnt(uploadFileList.size());
|
|
|
|
+ uploadPanoramaVO.setFailList(notExistFileList);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return ResultData.ok(uploadPanoramaVO);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void checkSceneAsynOper(String num, String operType, String module, String function){
|
|
|
|
+ LambdaQueryWrapper<SceneAsynOperLog> queryWrapper =
|
|
|
|
+ new LambdaQueryWrapper<SceneAsynOperLog>()
|
|
|
|
+ .eq(SceneAsynOperLog::getNum,num)
|
|
|
|
+ .eq(SceneAsynOperLog::getState, CommonOperStatus.WAITING.code());
|
|
|
|
+ if(StrUtil.isNotEmpty(operType)){
|
|
|
|
+ queryWrapper.eq(SceneAsynOperLog::getOperType, operType);
|
|
|
|
+ }
|
|
|
|
+ if(StrUtil.isNotEmpty(module)){
|
|
|
|
+ queryWrapper.eq(SceneAsynOperLog::getModule, module);
|
|
|
|
+ }
|
|
|
|
+ if(StrUtil.isNotEmpty(function)){
|
|
|
|
+ queryWrapper.eq(SceneAsynOperLog::getFunc, function);
|
|
|
|
+ }
|
|
|
|
+ List<SceneAsynOperLog> waittingLogList = sceneAsynOperLogService.list(queryWrapper);
|
|
|
|
+ if(CollUtil.isNotEmpty(waittingLogList)){
|
|
|
|
+ throw new BusinessException(ErrorCode.FAILURE_CODE_5066);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void uploadPanoramaHandler(String num, String bucket, String target, String imgViewPath, List<String> uploadFileList, String targetImagesPath) throws Exception {
|
|
CreateObjUtil.build3dModel(target , "1");
|
|
CreateObjUtil.build3dModel(target , "1");
|
|
|
|
|
|
String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
|
|
String uploadJsonPath= target + File.separator + "results" +File.separator+"upload.json";
|
|
@@ -1084,6 +1197,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
if(array == null){
|
|
if(array == null){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_7013);
|
|
}
|
|
}
|
|
|
|
+ Map<String, String> map = new HashMap<>();
|
|
JSONObject fileJson = null;
|
|
JSONObject fileJson = null;
|
|
String fileName = "";
|
|
String fileName = "";
|
|
for(int i = 0, len = array.size(); i < len; i++) {
|
|
for(int i = 0, len = array.size(); i < len; i++) {
|
|
@@ -1134,20 +1248,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
});
|
|
});
|
|
|
|
|
|
//更新数据库版本号
|
|
//更新数据库版本号
|
|
|
|
+ ScenePlus scenePlus = scenePlusService.getScenePlusByNum(num);
|
|
SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
|
|
this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
|
|
//更新scenejson缓存和oss文件版本号
|
|
//更新scenejson缓存和oss文件版本号
|
|
this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket);
|
|
this.upgradeSceneJsonVersion(num, sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1, bucket);
|
|
-
|
|
|
|
- //如果部分成功,则需要返回成功数量和失败列表
|
|
|
|
- if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
|
- notExistFileList = notExistFileList.stream().map(filePath -> {
|
|
|
|
- return filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
|
|
- }).collect(Collectors.toList());
|
|
|
|
- return ResultData.ok(new UploadPanoramaVO(uploadFileList.size(), notExistFileList));
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- return ResultData.ok();
|
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
@@ -1162,6 +1267,10 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
if(Objects.isNull(scenePlus)){
|
|
if(Objects.isNull(scenePlus)){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
|
+ this.checkSceneAsynOper(num,null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
|
+
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
ScenePlusExt scenePlusExt = scenePlusExtService.getScenePlusExtByPlusId(scenePlus.getId());
|
|
String bucket = scenePlusExt.getYunFileBucket();
|
|
String bucket = scenePlusExt.getYunFileBucket();
|
|
String path = scenePlusExt.getDataSource();
|
|
String path = scenePlusExt.getDataSource();
|
|
@@ -1176,8 +1285,9 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
//判断全景图缓存是否存在,如果不存在,从计算目录中拷贝到缓存目录
|
|
//判断全景图缓存是否存在,如果不存在,从计算目录中拷贝到缓存目录
|
|
this.cachePanorama(scenePlusExt.getDataSource(), num);
|
|
this.cachePanorama(scenePlusExt.getDataSource(), num);
|
|
|
|
|
|
- String url = null;
|
|
|
|
- String downloadName = null;
|
|
|
|
|
|
+ Map<String, Object> map = new HashMap<>();
|
|
|
|
+
|
|
|
|
+ //标记是否是异步操作,默认是同步操作
|
|
//如果入参文件名不为空,则是单个文件下载,不需要打包
|
|
//如果入参文件名不为空,则是单个文件下载,不需要打包
|
|
if(StrUtil.isNotEmpty(fileName)){
|
|
if(StrUtil.isNotEmpty(fileName)){
|
|
//如果是单张图片,直接提供oss url
|
|
//如果是单张图片,直接提供oss url
|
|
@@ -1187,36 +1297,65 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
}
|
|
}
|
|
fYunFileService.uploadFile(bucket, localFilePath, ossFilePath);
|
|
fYunFileService.uploadFile(bucket, localFilePath, ossFilePath);
|
|
- url = ossUrlPrefix + ossFilePath;
|
|
|
|
- downloadName = fileName;
|
|
|
|
|
|
+ String url = ossUrlPrefix + ossFilePath;
|
|
|
|
+ String downloadName = fileName;
|
|
|
|
+ map.put("asyn", CommonStatus.NO.code());
|
|
|
|
+ map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
|
|
|
|
+ map.put("fileName", downloadName);
|
|
|
|
+ return ResultData.ok(map);
|
|
}else{
|
|
}else{
|
|
if(!cn.hutool.core.io.FileUtil.exist(localImagesPath)
|
|
if(!cn.hutool.core.io.FileUtil.exist(localImagesPath)
|
|
|| cn.hutool.core.io.FileUtil.isDirEmpty(new File(localImagesPath))){
|
|
|| cn.hutool.core.io.FileUtil.isDirEmpty(new File(localImagesPath))){
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
}
|
|
}
|
|
|
|
|
|
- downloadName = num + "_images.zip";
|
|
|
|
- long start = Calendar.getInstance().getTimeInMillis();
|
|
|
|
- //打包
|
|
|
|
- String zipPath = cachePath + downloadName;
|
|
|
|
- ZipUtil.zip(localImagesPath, zipPath);
|
|
|
|
- long end1 = Calendar.getInstance().getTimeInMillis();
|
|
|
|
- log.info("打包耗时:" + (end1 - start));
|
|
|
|
- //上传压缩包
|
|
|
|
- fYunFileService.uploadFileByCommand(bucket, zipPath, String.format(cacheFormat, num) + downloadName);
|
|
|
|
- url = ossUrlPrefix + String.format(cacheFormat, num) + downloadName;
|
|
|
|
- long end2 = Calendar.getInstance().getTimeInMillis();
|
|
|
|
- log.info("上传耗时:" + (end2 - end1));
|
|
|
|
- //删除本地压缩包
|
|
|
|
- FileUtils.deleteFile(zipPath);
|
|
|
|
-// //删除本地目录
|
|
|
|
- FileUtils.deleteDirectory(localImagesPath);
|
|
|
|
- }
|
|
|
|
|
|
+ //清除旧的下载记录
|
|
|
|
+ sceneAsynOperLogService.remove(
|
|
|
|
+ new LambdaQueryWrapper<SceneAsynOperLog>()
|
|
|
|
+ .eq(SceneAsynOperLog::getNum, num)
|
|
|
|
+ .eq(SceneAsynOperLog::getOperType, SceneAsynOperType.DOWNLOAD.code())
|
|
|
|
+ .eq(SceneAsynOperLog::getModule, SceneAsynModuleType.UPLOAD_DOWNLOAD.code())
|
|
|
|
+ .eq(SceneAsynOperLog::getFunc, SceneAsynFuncType.PANORAMIC_IMAGE.code()));
|
|
|
|
+
|
|
|
|
+ //开始异步执行下载全景图压缩包操作
|
|
|
|
+ CompletableFuture.runAsync(() -> {
|
|
|
|
+ SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
|
+ SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
|
+ sceneAsynOperLog.setNum(num);
|
|
|
|
+ sceneAsynOperLog.setOperType(SceneAsynOperType.DOWNLOAD.code());
|
|
|
|
+ sceneAsynOperLog.setModule(SceneAsynModuleType.UPLOAD_DOWNLOAD.code());
|
|
|
|
+ sceneAsynOperLog.setFunc(SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
|
+ sceneAsynOperLog.setVersion(sceneEditInfo.getImgVersion());
|
|
|
|
+ sceneAsynOperLogService.save(sceneAsynOperLog);
|
|
|
|
+ try {
|
|
|
|
+ String downloadName = num + "_images.zip";
|
|
|
|
+ long start = Calendar.getInstance().getTimeInMillis();
|
|
|
|
+ //打包
|
|
|
|
+ String zipPath = cachePath + downloadName;
|
|
|
|
+ ZipUtil.zip(localImagesPath, zipPath);
|
|
|
|
+ long end1 = Calendar.getInstance().getTimeInMillis();
|
|
|
|
+ log.info("打包耗时:" + (end1 - start));
|
|
|
|
+ //上传压缩包
|
|
|
|
+ fYunFileService.uploadFileByCommand(bucket, zipPath, String.format(cacheFormat, num) + downloadName);
|
|
|
|
+ String url = String.format(cacheFormat, num) + downloadName;
|
|
|
|
+ long end2 = Calendar.getInstance().getTimeInMillis();
|
|
|
|
+ log.info("上传耗时:" + (end2 - end1));
|
|
|
|
+ //删除本地压缩包
|
|
|
|
+ FileUtils.deleteFile(zipPath);
|
|
|
|
+ //删除本地目录
|
|
|
|
+ FileUtils.deleteDirectory(localImagesPath);
|
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.SUCCESS.code());
|
|
|
|
+ sceneAsynOperLog.setUrl(url);
|
|
|
|
+ }catch (Exception e){
|
|
|
|
+ sceneAsynOperLog.setState(CommonOperStatus.FAILD.code());
|
|
|
|
+ log.error("下载全景图压缩包失败,num:" + num, e);
|
|
|
|
+ }
|
|
|
|
+ sceneAsynOperLogService.saveOrUpdate(sceneAsynOperLog);
|
|
|
|
+ });
|
|
|
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
|
- map.put("fileUrl", url + "?t=" + System.currentTimeMillis());
|
|
|
|
- map.put("fileName", downloadName);
|
|
|
|
- return ResultData.ok(map);
|
|
|
|
|
|
+ map.put("asyn", CommonStatus.YES.code());
|
|
|
|
+ return ResultData.ok(map);
|
|
|
|
+ }
|
|
}
|
|
}
|
|
|
|
|
|
private void cachePanorama(String dataSource, String num){
|
|
private void cachePanorama(String dataSource, String num){
|
|
@@ -1851,10 +1990,10 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
cn.hutool.core.io.FileUtil.del(resultPath);
|
|
cn.hutool.core.io.FileUtil.del(resultPath);
|
|
}
|
|
}
|
|
//下载data.fdage
|
|
//下载data.fdage
|
|
- if(FYunTypeEnum.AWS.code().equals(this.fyunType)){
|
|
|
|
- //亚马逊保持旧方式,超链接capture
|
|
|
|
- CreateObjUtil.createSoftConnection(path + File.separator + "capture", capturePath);
|
|
|
|
- }
|
|
|
|
|
|
+// if(FYunTypeEnum.AWS.code().equals(this.fyunType)){
|
|
|
|
+// //亚马逊保持旧方式,超链接capture
|
|
|
|
+// CreateObjUtil.createSoftConnection(path + File.separator + "capture", capturePath);
|
|
|
|
+// }
|
|
fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", capturePath + "/data.fdage");
|
|
fYunFileService.downloadFile(ConstantFilePath.OSS_PREFIX + path.replace(ConstantFilePath.BUILD_MODEL_PATH, "") + "/data.fdage", capturePath + "/data.fdage");
|
|
CreateObjUtil.build3dModel(target , "1");
|
|
CreateObjUtil.build3dModel(target , "1");
|
|
|
|
|
|
@@ -1984,14 +2123,19 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
List<String> deletDataList = redisUtil.hMultiGet(key, deleteSidList);
|
|
List<String> deletDataList = redisUtil.hMultiGet(key, deleteSidList);
|
|
if(CollUtil.isEmpty(deletDataList))
|
|
if(CollUtil.isEmpty(deletDataList))
|
|
return;
|
|
return;
|
|
|
|
+ List<String> thumbNameList = deleteSidList.stream().map(sid -> {
|
|
|
|
+ String linkPan = redisUtil.hget(key, sid);
|
|
|
|
+ JSONObject linkPanObj = JSON.parseObject(linkPan);
|
|
|
|
+ return FileUtil.getPrefix(linkPanObj.getString("thumb"));
|
|
|
|
+ }).collect(Collectors.toList());
|
|
|
|
|
|
//从redis中移除热点数据
|
|
//从redis中移除热点数据
|
|
redisUtil.hdel(key, deleteSidList.toArray());
|
|
redisUtil.hdel(key, deleteSidList.toArray());
|
|
|
|
|
|
//删除oss文件
|
|
//删除oss文件
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
String imgEditPath = String.format(UploadFilePath.IMG_EDIT_PATH, num);
|
|
- deleteSidList.stream().forEach(sid->{
|
|
|
|
- fYunFileService.deleteFolder(bucket, imgEditPath + "panorama_edit/" + sid);
|
|
|
|
|
|
+ thumbNameList.stream().forEach(thumbName->{
|
|
|
|
+ fYunFileService.deleteFolder(bucket, imgEditPath + "panorama/" + thumbName);
|
|
});
|
|
});
|
|
|
|
|
|
}
|
|
}
|
|
@@ -2601,7 +2745,7 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public ResultData saveFilter(BaseDataParamVO param) throws Exception {
|
|
|
|
|
|
+ public ResultData saveFilter(SaveFiltersParamVO param) throws Exception {
|
|
|
|
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
ScenePlus scenePlus = scenePlusService.getScenePlusByNum(param.getNum());
|
|
if(Objects.isNull(scenePlus)){
|
|
if(Objects.isNull(scenePlus)){
|
|
@@ -2622,6 +2766,11 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<ISceneEditInfoMapper,
|
|
//写本地文件,作为备份
|
|
//写本地文件,作为备份
|
|
this.writeFilter(param.getNum());
|
|
this.writeFilter(param.getNum());
|
|
|
|
|
|
|
|
+ //如果页面选择恢复默认,filters字段值为否
|
|
|
|
+ if(Objects.nonNull(param.getReset()) && param.getReset() == CommonStatus.YES.code().intValue()){
|
|
|
|
+ filters = CommonStatus.NO.code();
|
|
|
|
+ }
|
|
|
|
+
|
|
//更新数据库
|
|
//更新数据库
|
|
SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
|
|
SceneEditInfoExt sceneEditInfoExt = sceneEditInfoExtService.getByScenePlusId(scenePlus.getId());
|
|
sceneEditInfoExt.setFilters(filters);
|
|
sceneEditInfoExt.setFilters(filters);
|