|
@@ -190,23 +190,23 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<SceneEditInfoMapper, S
|
|
|
fYunFileService.uploadFile(num, subgroup, upTime, JSON.toJSONBytes(jsonArray), userEditPath + "filter.json");
|
|
|
}
|
|
|
@Override
|
|
|
- public SceneInfoVO getSceneInfo(SceneInfoParamVO param) throws Exception{
|
|
|
- SceneInfoReqType sceneInfoReqType = SceneInfoReqType.get(param.getReqType());
|
|
|
- if(Objects.isNull(param.getSubgroup())){
|
|
|
- param.setSubgroup(0);
|
|
|
+ public SceneInfoVO getSceneInfo(String num, Integer subgroup, String upTimeKey, byte reqType) throws Exception{
|
|
|
+ SceneInfoReqType sceneInfoReqType = SceneInfoReqType.get(reqType);
|
|
|
+ if(Objects.isNull(subgroup)){
|
|
|
+ subgroup = 0;
|
|
|
}
|
|
|
SceneInfoVO sceneInfo = null;
|
|
|
switch (sceneInfoReqType){
|
|
|
//如果是编辑页面请求,查数据库
|
|
|
case EDIT:
|
|
|
- sceneInfo = this.getSceneInfo4Edit(param.getNum(), param.getSubgroup(), param.getUpTimeKey());
|
|
|
+ sceneInfo = this.getSceneInfo4Edit(num, subgroup, upTimeKey);
|
|
|
//俊波要求这两个字段编辑页一定是1
|
|
|
sceneInfo.getControls().setShowDollhouse(CommonStatus.YES.code());
|
|
|
sceneInfo.getControls().setShowFloorplan(CommonStatus.YES.code());
|
|
|
break;
|
|
|
//如果是查看页面请求,查redis
|
|
|
case VIEW:
|
|
|
- sceneInfo = this.getSceneInfo4Edit(param.getNum(), param.getSubgroup(), param.getUpTimeKey());
|
|
|
+ sceneInfo = this.getSceneInfo4Edit(num, subgroup, upTimeKey);
|
|
|
sceneInfo.setScenePassword(null);
|
|
|
//俊波要求这两个字段查看页一定是0
|
|
|
sceneInfo.getControls().setShowDollhouse(CommonStatus.NO.code());
|
|
@@ -510,287 +510,287 @@ public class SceneEditInfoServiceImpl extends ServiceImpl<SceneEditInfoMapper, S
|
|
|
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public ResultData uploadPanorama(String num, Integer subgroup, String upTime, MultipartFile file) throws Exception {
|
|
|
-
|
|
|
- if(!file.getOriginalFilename().endsWith(".zip") && !file.getOriginalFilename().endsWith(".jpg")){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7007, "jpg或者zip");
|
|
|
- }
|
|
|
-
|
|
|
- Scene scenePlus = sceneService.getByNum(num, subgroup, upTime);
|
|
|
- if(scenePlus == null){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
-
|
|
|
- //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
- sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
-
|
|
|
- //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
- sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
-
|
|
|
- //原始计算根目录
|
|
|
- String numStr = RedisKey.getNumStr(num, subgroup, upTime, scenePlus.getCacheKeyHasTime());
|
|
|
- String path = String.format(ConstantFilePath.SCENE_USER_PATH_V4, numStr);
|
|
|
- //全景图计算根目录
|
|
|
- String target = path + "_images";
|
|
|
- //解压缩文件存放目录
|
|
|
- String targetImagesPath = target + "/extras/images/";
|
|
|
- //压缩文件保存目录
|
|
|
- String zipTargetFilePath = targetImagesPath + file.getOriginalFilename();
|
|
|
-
|
|
|
- //先删除本地文件
|
|
|
- FileUtil.del(targetImagesPath);
|
|
|
- File targetFile = new File(zipTargetFilePath);
|
|
|
- if(!targetFile.getParentFile().exists()){
|
|
|
- targetFile.getParentFile().mkdirs();
|
|
|
- }
|
|
|
- file.transferTo(targetFile);
|
|
|
-
|
|
|
- //如果是压缩包上传,需要解压缩
|
|
|
- int async = CommonStatus.NO.code();
|
|
|
- if(file.getOriginalFilename().endsWith(".zip")){
|
|
|
-
|
|
|
- //标记为异步处理
|
|
|
- async = CommonStatus.YES.code();
|
|
|
-
|
|
|
- //解压zip包
|
|
|
- ZipUtil.unzip(zipTargetFilePath,targetImagesPath, CharsetUtil.CHARSET_GBK);
|
|
|
- //删除压缩包
|
|
|
- FileUtil.del(zipTargetFilePath);
|
|
|
- }
|
|
|
-
|
|
|
- //判断文件夹目录结构,图片必须放在压缩包根目录下,不支持空文件夹或其他格式文件上传
|
|
|
- File[] files = new File(targetImagesPath).listFiles();
|
|
|
- Arrays.stream(files).forEach(item->{
|
|
|
- if(item.isDirectory()){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_7018);
|
|
|
- }
|
|
|
- });
|
|
|
-
|
|
|
- //获取解压后的文件列表
|
|
|
- List<String> uploadFileList = FileUtils.getFileList(targetImagesPath);
|
|
|
- if(CollUtil.isEmpty(uploadFileList)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5062);
|
|
|
- }
|
|
|
-
|
|
|
- //判断是否有可用的jpg文件
|
|
|
- boolean existJpg = false;
|
|
|
- if(CollUtil.isNotEmpty(uploadFileList)){
|
|
|
- existJpg = uploadFileList.stream().anyMatch(str -> {
|
|
|
- if(str.endsWith(".jpg")){
|
|
|
- return true;
|
|
|
- }
|
|
|
- return false;
|
|
|
- });
|
|
|
- }
|
|
|
- if(!existJpg){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5062);
|
|
|
- }
|
|
|
-
|
|
|
- //比对图片列表,不存在的要返回名称集合
|
|
|
- List<SceneFileMapping> sceneFileMappings = sceneFileMappingService.getByScene(num, subgroup, upTime);
|
|
|
- List<SceneFileMapping> panList = sceneFileMappings.stream().filter(v -> v.getKey().contains("images/pan/high/")).collect(Collectors.toList());
|
|
|
- Map<String, SceneFileMapping> panMap = panList.stream().collect(Collectors.toMap(v -> FileUtil.getName(v.getKey()), v -> v));
|
|
|
- List<String> panoramaImageList = panList.stream().map(v -> FileUtil.getName(v.getKey())).collect(Collectors.toList());
|
|
|
-
|
|
|
- List<String> notExistFileList = uploadFileList.stream().filter(filePath -> {
|
|
|
- filePath = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
|
- if(CollUtil.isEmpty(panoramaImageList) || panoramaImageList.contains(filePath)){
|
|
|
- return false;
|
|
|
- }
|
|
|
- return true;
|
|
|
- }).collect(Collectors.toList());
|
|
|
-
|
|
|
- if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
- //删除错误文件
|
|
|
- notExistFileList.parallelStream().forEach(filePath->{
|
|
|
- FileUtil.del(filePath);
|
|
|
- });
|
|
|
- }
|
|
|
-
|
|
|
- //判断成功的图片,如果成功图片为0,就直接返回,不需要执行算法
|
|
|
- uploadFileList = FileUtils.getFileList(targetImagesPath);
|
|
|
- if(CollUtil.isEmpty(uploadFileList)){
|
|
|
- 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(0,0, notExistFileList));
|
|
|
- }
|
|
|
-
|
|
|
- //上传
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
-
|
|
|
- String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
-
|
|
|
- //如果部分成功,则需要返回成功数量和失败列表
|
|
|
- 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,subgroup,upTime,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,subgroup,upTime,target,imgViewPath,uploadFileList,targetImagesPath);
|
|
|
- if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
- uploadPanoramaVO.setSuccessCnt(uploadFileList.size());
|
|
|
- uploadPanoramaVO.setFailList(notExistFileList);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- FileUtil.del(target);
|
|
|
- return ResultData.ok(uploadPanoramaVO);
|
|
|
- }
|
|
|
-
|
|
|
- public void uploadPanoramaHandler(String num, Integer subgroup, String upTime, String target, String imgViewPath, List<String> uploadFileList, String targetImagesPath) throws Exception {
|
|
|
-
|
|
|
- Map<String, String> map = new HashMap<>();
|
|
|
- String resultPath = target + File.separator + "results/";
|
|
|
- FileUtil.mkdir(resultPath);
|
|
|
-
|
|
|
- //4K
|
|
|
- String highPath = resultPath + "pan/high/";
|
|
|
- //512
|
|
|
- String lowPath = resultPath + "pan/low/";
|
|
|
- List<String> origImgs = FileUtil.listFileNames(targetImagesPath);
|
|
|
- for (String origImg : origImgs) {
|
|
|
- FileUtil.copy(targetImagesPath + origImg, highPath + origImg, true);
|
|
|
- map.put(highPath + origImg, imgViewPath + "pan/high/" + origImg);
|
|
|
- ImgUtil.scale(new File(highPath + origImg), new File(lowPath + origImg), 0.125f);
|
|
|
- map.put(lowPath + origImg, imgViewPath + "pan/low/" + origImg);
|
|
|
- }
|
|
|
-
|
|
|
- if(map.size()>0) {
|
|
|
- fYunFileService.uploadMulFiles(num, subgroup, upTime, map);
|
|
|
- }
|
|
|
-
|
|
|
- //更新数据库版本号
|
|
|
- Scene scenePlus = sceneService.getByNum(num, subgroup, upTime);
|
|
|
- SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
- this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
|
|
|
- //更新scenejson缓存和oss文件版本号
|
|
|
- this.upgradeSceneJsonVersion(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public ResultData downloadPanorama(FileParamVO param) throws Exception {
|
|
|
-
|
|
|
- String num = param.getNum();
|
|
|
- Integer subgroup = param.getSubgroup();
|
|
|
- String upTimeKey = param.getUpTimeKey();
|
|
|
- String fileName = param.getFileName();
|
|
|
-
|
|
|
- Scene scenePlus = sceneService.getByNum(num, subgroup, upTimeKey);
|
|
|
- if(Objects.isNull(scenePlus)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
- }
|
|
|
-
|
|
|
- //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
- sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(),null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
-
|
|
|
- String numStr = RedisKey.getNumStr(num, subgroup, upTimeKey, scenePlus.getCacheKeyHasTime());
|
|
|
- String cachePath = String.format(ConstantFilePath.SCENE_CACHE, numStr);
|
|
|
- String localImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, numStr);
|
|
|
-
|
|
|
- String cacheFormat = "downloads/scene/%s/caches/";
|
|
|
- String cacheImageFormat = "downloads/scene/%s/caches/images/";
|
|
|
-
|
|
|
- List<SceneFileMapping> sceneFileMappings = sceneFileMappingService.getByScene(num, subgroup, upTimeKey);
|
|
|
- List<SceneFileMapping> panList = sceneFileMappings.stream().filter(v -> v.getKey().contains("images/pan/high/")).collect(Collectors.toList());
|
|
|
- Map<String, SceneFileMapping> panMap = panList.stream().collect(Collectors.toMap(v -> FileUtil.getName(v.getKey()), v -> v));
|
|
|
-
|
|
|
+// @Override
|
|
|
+// public ResultData uploadPanorama(String num, Integer subgroup, String upTime, MultipartFile file) throws Exception {
|
|
|
+//
|
|
|
+// if(!file.getOriginalFilename().endsWith(".zip") && !file.getOriginalFilename().endsWith(".jpg")){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7007, "jpg或者zip");
|
|
|
+// }
|
|
|
+//
|
|
|
+// Scene scenePlus = sceneService.getByNum(num, subgroup, upTime);
|
|
|
+// if(scenePlus == null){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
+// sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(), null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
+//
|
|
|
+// //清除全景图异步操作记录,防止再次下载的时候请求到旧的压缩包
|
|
|
+// sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
+//
|
|
|
+// //原始计算根目录
|
|
|
+// String numStr = RedisKey.getNumStr(num, subgroup, upTime, scenePlus.getCacheKeyHasTime());
|
|
|
+// String path = String.format(ConstantFilePath.SCENE_USER_PATH_V4, numStr);
|
|
|
+// //全景图计算根目录
|
|
|
+// String target = path + "_images";
|
|
|
+// //解压缩文件存放目录
|
|
|
+// String targetImagesPath = target + "/extras/images/";
|
|
|
+// //压缩文件保存目录
|
|
|
+// String zipTargetFilePath = targetImagesPath + file.getOriginalFilename();
|
|
|
+//
|
|
|
+// //先删除本地文件
|
|
|
+// FileUtil.del(targetImagesPath);
|
|
|
+// File targetFile = new File(zipTargetFilePath);
|
|
|
+// if(!targetFile.getParentFile().exists()){
|
|
|
+// targetFile.getParentFile().mkdirs();
|
|
|
+// }
|
|
|
+// file.transferTo(targetFile);
|
|
|
+//
|
|
|
+// //如果是压缩包上传,需要解压缩
|
|
|
+// int async = CommonStatus.NO.code();
|
|
|
+// if(file.getOriginalFilename().endsWith(".zip")){
|
|
|
+//
|
|
|
+// //标记为异步处理
|
|
|
+// async = CommonStatus.YES.code();
|
|
|
+//
|
|
|
+// //解压zip包
|
|
|
+// ZipUtil.unzip(zipTargetFilePath,targetImagesPath, CharsetUtil.CHARSET_GBK);
|
|
|
+// //删除压缩包
|
|
|
+// FileUtil.del(zipTargetFilePath);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //判断文件夹目录结构,图片必须放在压缩包根目录下,不支持空文件夹或其他格式文件上传
|
|
|
+// File[] files = new File(targetImagesPath).listFiles();
|
|
|
+// Arrays.stream(files).forEach(item->{
|
|
|
+// if(item.isDirectory()){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_7018);
|
|
|
+// }
|
|
|
+// });
|
|
|
+//
|
|
|
+// //获取解压后的文件列表
|
|
|
+// List<String> uploadFileList = FileUtils.getFileList(targetImagesPath);
|
|
|
+// if(CollUtil.isEmpty(uploadFileList)){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5062);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //判断是否有可用的jpg文件
|
|
|
+// boolean existJpg = false;
|
|
|
+// if(CollUtil.isNotEmpty(uploadFileList)){
|
|
|
+// existJpg = uploadFileList.stream().anyMatch(str -> {
|
|
|
+// if(str.endsWith(".jpg")){
|
|
|
+// return true;
|
|
|
+// }
|
|
|
+// return false;
|
|
|
+// });
|
|
|
+// }
|
|
|
+// if(!existJpg){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5062);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //比对图片列表,不存在的要返回名称集合
|
|
|
+// List<SceneFileMapping> sceneFileMappings = sceneFileMappingService.getByScene(num, subgroup, upTime);
|
|
|
+// List<SceneFileMapping> panList = sceneFileMappings.stream().filter(v -> v.getKey().contains("images/pan/high/")).collect(Collectors.toList());
|
|
|
+// Map<String, SceneFileMapping> panMap = panList.stream().collect(Collectors.toMap(v -> FileUtil.getName(v.getKey()), v -> v));
|
|
|
// List<String> panoramaImageList = panList.stream().map(v -> FileUtil.getName(v.getKey())).collect(Collectors.toList());
|
|
|
-
|
|
|
- Map<String, Object> map = new HashMap<>();
|
|
|
-
|
|
|
- //标记是否是异步操作,默认是同步操作
|
|
|
- //如果入参文件名不为空,则是单个文件下载,不需要打包
|
|
|
- if(StrUtil.isNotEmpty(fileName)){
|
|
|
- if(!panMap.keySet().contains(fileName)){
|
|
|
- throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
|
- }
|
|
|
- String url = panMap.get(fileName).getKey();
|
|
|
- String downloadName = fileName;
|
|
|
- map.put("asyn", CommonStatus.NO.code());
|
|
|
- map.put("fileUrl", url);
|
|
|
- map.put("fileName", downloadName);
|
|
|
- return ResultData.ok(map);
|
|
|
- }else{
|
|
|
- //清除旧的下载记录
|
|
|
- sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code(), SceneAsynOperType.DOWNLOAD.code());
|
|
|
-
|
|
|
- //开始异步执行下载全景图压缩包操作
|
|
|
- CompletableFuture.runAsync(() -> {
|
|
|
- SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
- SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
- sceneAsynOperLog.setNum(num);
|
|
|
- sceneAsynOperLog.setSceneId(scenePlus.getId());
|
|
|
- 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 {
|
|
|
-
|
|
|
- //下载到本地目录
|
|
|
- FileUtil.del(localImagesPath);
|
|
|
- for (SceneFileMapping sceneFileMapping : panList) {
|
|
|
- customHttpClient.downloadFile(sceneFileMapping.getUrl(), localImagesPath, fileName);
|
|
|
-
|
|
|
- }
|
|
|
-
|
|
|
- String downloadName = num + "_images.zip";
|
|
|
- //打包
|
|
|
- String zipPath = cachePath + downloadName;
|
|
|
- ZipUtil.zip(localImagesPath, zipPath);
|
|
|
- //上传压缩包
|
|
|
- fYunFileService.uploadFile(num, subgroup,upTimeKey,zipPath, String.format(cacheFormat, num) + downloadName);
|
|
|
- String url = String.format(cacheFormat, num) + downloadName;
|
|
|
- //删除本地压缩包
|
|
|
- FileUtil.del(zipPath);
|
|
|
- //删除本地目录
|
|
|
- FileUtil.del(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.put("asyn", CommonStatus.YES.code());
|
|
|
- return ResultData.ok(map);
|
|
|
- }
|
|
|
- }
|
|
|
+//
|
|
|
+// List<String> notExistFileList = uploadFileList.stream().filter(filePath -> {
|
|
|
+// filePath = filePath.substring(filePath.lastIndexOf(File.separator) + 1);
|
|
|
+// if(CollUtil.isEmpty(panoramaImageList) || panoramaImageList.contains(filePath)){
|
|
|
+// return false;
|
|
|
+// }
|
|
|
+// return true;
|
|
|
+// }).collect(Collectors.toList());
|
|
|
+//
|
|
|
+// if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
+// //删除错误文件
|
|
|
+// notExistFileList.parallelStream().forEach(filePath->{
|
|
|
+// FileUtil.del(filePath);
|
|
|
+// });
|
|
|
+// }
|
|
|
+//
|
|
|
+// //判断成功的图片,如果成功图片为0,就直接返回,不需要执行算法
|
|
|
+// uploadFileList = FileUtils.getFileList(targetImagesPath);
|
|
|
+// if(CollUtil.isEmpty(uploadFileList)){
|
|
|
+// 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(0,0, notExistFileList));
|
|
|
+// }
|
|
|
+//
|
|
|
+// //上传
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
+//
|
|
|
+// String imgViewPath = String.format(UploadFilePath.IMG_VIEW_PATH, num);
|
|
|
+//
|
|
|
+// //如果部分成功,则需要返回成功数量和失败列表
|
|
|
+// 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,subgroup,upTime,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,subgroup,upTime,target,imgViewPath,uploadFileList,targetImagesPath);
|
|
|
+// if(CollUtil.isNotEmpty(notExistFileList)){
|
|
|
+// uploadPanoramaVO.setSuccessCnt(uploadFileList.size());
|
|
|
+// uploadPanoramaVO.setFailList(notExistFileList);
|
|
|
+// }
|
|
|
+// }
|
|
|
+//
|
|
|
+// FileUtil.del(target);
|
|
|
+// return ResultData.ok(uploadPanoramaVO);
|
|
|
+// }
|
|
|
+//
|
|
|
+// public void uploadPanoramaHandler(String num, Integer subgroup, String upTime, String target, String imgViewPath, List<String> uploadFileList, String targetImagesPath) throws Exception {
|
|
|
+//
|
|
|
+// Map<String, String> map = new HashMap<>();
|
|
|
+// String resultPath = target + File.separator + "results/";
|
|
|
+// FileUtil.mkdir(resultPath);
|
|
|
+//
|
|
|
+// //4K
|
|
|
+// String highPath = resultPath + "pan/high/";
|
|
|
+// //512
|
|
|
+// String lowPath = resultPath + "pan/low/";
|
|
|
+// List<String> origImgs = FileUtil.listFileNames(targetImagesPath);
|
|
|
+// for (String origImg : origImgs) {
|
|
|
+// FileUtil.copy(targetImagesPath + origImg, highPath + origImg, true);
|
|
|
+// map.put(highPath + origImg, imgViewPath + "pan/high/" + origImg);
|
|
|
+// ImgUtil.scale(new File(highPath + origImg), new File(lowPath + origImg), 0.125f);
|
|
|
+// map.put(lowPath + origImg, imgViewPath + "pan/low/" + origImg);
|
|
|
+// }
|
|
|
+//
|
|
|
+// if(map.size()>0) {
|
|
|
+// fYunFileService.uploadMulFiles(num, subgroup, upTime, map);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //更新数据库版本号
|
|
|
+// Scene scenePlus = sceneService.getByNum(num, subgroup, upTime);
|
|
|
+// SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
+// this.upgradeVersionAndImgVersionById(sceneEditInfo.getId());
|
|
|
+// //更新scenejson缓存和oss文件版本号
|
|
|
+// this.upgradeSceneJsonVersion(num, subgroup, upTime, scenePlus.getCacheKeyHasTime(), sceneEditInfo.getVersion() + 1, sceneEditInfo.getImgVersion() + 1);
|
|
|
+// }
|
|
|
+//
|
|
|
+// @Override
|
|
|
+// public ResultData downloadPanorama(FileParamVO param) throws Exception {
|
|
|
+//
|
|
|
+// String num = param.getNum();
|
|
|
+// Integer subgroup = param.getSubgroup();
|
|
|
+// String upTimeKey = param.getUpTimeKey();
|
|
|
+// String fileName = param.getFileName();
|
|
|
+//
|
|
|
+// Scene scenePlus = sceneService.getByNum(num, subgroup, upTimeKey);
|
|
|
+// if(Objects.isNull(scenePlus)){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5005);
|
|
|
+// }
|
|
|
+//
|
|
|
+// //查询是否存在等待中的异步操作记录,如果存在,抛出业务异常,终止操作
|
|
|
+// sceneAsynOperLogService.checkSceneAsynOper(scenePlus.getId(),null, SceneAsynModuleType.UPLOAD_DOWNLOAD.code() , SceneAsynFuncType.PANORAMIC_IMAGE.code());
|
|
|
+//
|
|
|
+// String numStr = RedisKey.getNumStr(num, subgroup, upTimeKey, scenePlus.getCacheKeyHasTime());
|
|
|
+// String cachePath = String.format(ConstantFilePath.SCENE_CACHE, numStr);
|
|
|
+// String localImagesPath = String.format(ConstantFilePath.SCENE_CACHE_IMAGES, numStr);
|
|
|
+//
|
|
|
+// String cacheFormat = "downloads/scene/%s/caches/";
|
|
|
+// String cacheImageFormat = "downloads/scene/%s/caches/images/";
|
|
|
+//
|
|
|
+// List<SceneFileMapping> sceneFileMappings = sceneFileMappingService.getByScene(num, subgroup, upTimeKey);
|
|
|
+// List<SceneFileMapping> panList = sceneFileMappings.stream().filter(v -> v.getKey().contains("images/pan/high/")).collect(Collectors.toList());
|
|
|
+// Map<String, SceneFileMapping> panMap = panList.stream().collect(Collectors.toMap(v -> FileUtil.getName(v.getKey()), v -> v));
|
|
|
+//
|
|
|
+//// List<String> panoramaImageList = panList.stream().map(v -> FileUtil.getName(v.getKey())).collect(Collectors.toList());
|
|
|
+//
|
|
|
+// Map<String, Object> map = new HashMap<>();
|
|
|
+//
|
|
|
+// //标记是否是异步操作,默认是同步操作
|
|
|
+// //如果入参文件名不为空,则是单个文件下载,不需要打包
|
|
|
+// if(StrUtil.isNotEmpty(fileName)){
|
|
|
+// if(!panMap.keySet().contains(fileName)){
|
|
|
+// throw new BusinessException(ErrorCode.FAILURE_CODE_5063);
|
|
|
+// }
|
|
|
+// String url = panMap.get(fileName).getKey();
|
|
|
+// String downloadName = fileName;
|
|
|
+// map.put("asyn", CommonStatus.NO.code());
|
|
|
+// map.put("fileUrl", url);
|
|
|
+// map.put("fileName", downloadName);
|
|
|
+// return ResultData.ok(map);
|
|
|
+// }else{
|
|
|
+// //清除旧的下载记录
|
|
|
+// sceneAsynOperLogService.cleanLog(scenePlus.getId(), SceneAsynModuleType.UPLOAD_DOWNLOAD.code(), SceneAsynFuncType.PANORAMIC_IMAGE.code(), SceneAsynOperType.DOWNLOAD.code());
|
|
|
+//
|
|
|
+// //开始异步执行下载全景图压缩包操作
|
|
|
+// CompletableFuture.runAsync(() -> {
|
|
|
+// SceneEditInfo sceneEditInfo = this.getByScenePlusId(scenePlus.getId());
|
|
|
+// SceneAsynOperLog sceneAsynOperLog = new SceneAsynOperLog();
|
|
|
+// sceneAsynOperLog.setNum(num);
|
|
|
+// sceneAsynOperLog.setSceneId(scenePlus.getId());
|
|
|
+// 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 {
|
|
|
+//
|
|
|
+// //下载到本地目录
|
|
|
+// FileUtil.del(localImagesPath);
|
|
|
+// for (SceneFileMapping sceneFileMapping : panList) {
|
|
|
+// customHttpClient.downloadFile(sceneFileMapping.getUrl(), localImagesPath, fileName);
|
|
|
+//
|
|
|
+// }
|
|
|
+//
|
|
|
+// String downloadName = num + "_images.zip";
|
|
|
+// //打包
|
|
|
+// String zipPath = cachePath + downloadName;
|
|
|
+// ZipUtil.zip(localImagesPath, zipPath);
|
|
|
+// //上传压缩包
|
|
|
+// fYunFileService.uploadFile(num, subgroup,upTimeKey,zipPath, String.format(cacheFormat, num) + downloadName);
|
|
|
+// String url = String.format(cacheFormat, num) + downloadName;
|
|
|
+// //删除本地压缩包
|
|
|
+// FileUtil.del(zipPath);
|
|
|
+// //删除本地目录
|
|
|
+// FileUtil.del(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.put("asyn", CommonStatus.YES.code());
|
|
|
+// return ResultData.ok(map);
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
@Override
|
|
|
public void saveTagsToSceneEditInfo(String num, Integer subgroup, String upTime, Integer cacheKeyHasTime, SceneEditInfo sceneEditInfo){
|