|
@@ -36,7 +36,11 @@ import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.io.File;
|
|
|
import java.io.FileInputStream;
|
|
|
+import java.io.IOException;
|
|
|
import java.net.URLEncoder;
|
|
|
+import java.nio.file.Files;
|
|
|
+import java.nio.file.Path;
|
|
|
+import java.nio.file.Paths;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.Callable;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
@@ -105,7 +109,7 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
|
|
|
|
|
|
@Override
|
|
|
- public void downloadHandler(String num) throws Exception {
|
|
|
+ public String downloadHandler(String num) throws Exception {
|
|
|
|
|
|
//zip包路径
|
|
|
String zipPath = null;
|
|
@@ -168,6 +172,8 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
//打压缩包
|
|
|
ZipUtil.zip(String.format(this.sourceLocal, num, ""), zipPath);
|
|
|
|
|
|
+ return zipPath;
|
|
|
+
|
|
|
// TODO: 2024/1/4 生成的压缩包放哪里待定
|
|
|
// String uploadPath = String.format(this.zipOssFormat, num);
|
|
|
// fYunFileService.uploadFileByCommand(bucket, zipPath, uploadPath);
|
|
@@ -175,11 +181,7 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
}catch (Exception e){
|
|
|
//更新进度为下载失败
|
|
|
throw e;
|
|
|
- }finally {
|
|
|
- FileUtil.del(zipPath);
|
|
|
- FileUtil.del(String.format(this.sourceLocal, num, ""));
|
|
|
}
|
|
|
-
|
|
|
}
|
|
|
|
|
|
private void zipBat(String num, String version) throws Exception{
|
|
@@ -201,7 +203,12 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
|
|
|
private void zipOssFiles(String num, String resolution, int imagesVersion, Set<String> cacheKeys, String version) throws Exception{
|
|
|
|
|
|
- fYunFileService.downloadFileByCommand(String.format(sourceLocal, num, this.wwwroot), String.format(UploadFilePath.VIEW_PATH, num));
|
|
|
+// fYunFileService.downloadFileByCommand(String.format(sourceLocal, num, this.wwwroot), String.format(UploadFilePath.VIEW_PATH, num));
|
|
|
+ final List<String> strings = fYunFileService.listRemoteFiles(String.format(UploadFilePath.VIEW_PATH, num));
|
|
|
+ strings.stream().forEach(str->{
|
|
|
+ fYunFileService.downloadFile(str, String.format(sourceLocal, num, this.wwwroot).concat(str));
|
|
|
+ });
|
|
|
+// fYunFileService.downloadFile(String.format(UploadFilePath.VIEW_PATH, num), String.format(sourceLocal, num, this.wwwroot));
|
|
|
|
|
|
//特殊文件处理
|
|
|
this.reWriteFile(num);
|
|
@@ -211,7 +218,32 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
this.cutImg(num, filePath, resolution, "tiles");
|
|
|
|
|
|
//切图-场景关联
|
|
|
+ String panoramaPath = String.format(sourceLocal, num, this.wwwroot + String.format(UploadFilePath.IMG_VIEW_PATH, num) + "panorama/");
|
|
|
+ if(FileUtil.exist(panoramaPath)){
|
|
|
+ Path directoryPath = Paths.get(panoramaPath); // 替换为你要查询的目录路径
|
|
|
+ // 获取目录下的第一层子目录
|
|
|
+ List<String> panoramaIdList = Files.list(directoryPath).filter(Files::isDirectory).map(file -> file.getFileName().toString()).collect(Collectors.toList());
|
|
|
+ if(CollUtil.isNotEmpty(panoramaIdList)){
|
|
|
+ for (String panoramaId : panoramaIdList) {
|
|
|
+ this.cutImg(num, panoramaPath.concat(panoramaId).concat("/tiles/"), resolution, "panorama/".concat(panoramaId).concat("/tiles"));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
+ public static void main(String[] args) {
|
|
|
+ Path directoryPath = Paths.get("D:\\test"); // 替换为你要查询的目录路径
|
|
|
+
|
|
|
+ try {
|
|
|
+ // 获取目录下的第一层子目录
|
|
|
+ Files.list(directoryPath)
|
|
|
+ .filter(Files::isDirectory)
|
|
|
+ .forEach(file -> {
|
|
|
+ System.out.println(file.getFileName().toString());
|
|
|
+ });
|
|
|
+ } catch (IOException e) {
|
|
|
+ e.printStackTrace();
|
|
|
+ }
|
|
|
}
|
|
|
@Override
|
|
|
public void cutImg(String num, String path, String resolution, String subPath) throws Exception {
|
|
@@ -268,35 +300,35 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
//
|
|
|
// }
|
|
|
|
|
|
- public void ProcessFiles(String num, String key, String prefix, Set<String> cacheKeys) throws Exception{
|
|
|
- if(cacheKeys.contains(key)){
|
|
|
- return;
|
|
|
- }
|
|
|
- if(key.equals(String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json")){
|
|
|
- return;
|
|
|
- }
|
|
|
- cacheKeys.add(key);
|
|
|
- String fileName = key.substring(key.lastIndexOf("/") + 1);
|
|
|
- String url = this.resourceUrl + key.replace(fileName, URLEncoder.encode(fileName, "UTF-8")) + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
- if(key.contains("hot.json") || key.contains("link-scene.json")){
|
|
|
- String content = fYunFileService.getFileContent(key);
|
|
|
- if(StrUtil.isEmpty(content)){
|
|
|
- return;
|
|
|
- }
|
|
|
- content = content.replace(publicUrl, "")
|
|
|
-// .replace(publicUrl+"v3/", "")
|
|
|
- .replace("https://spc.html","spc.html")
|
|
|
- .replace("https://smobile.html", "smobile.html");
|
|
|
-
|
|
|
- FileUtil.writeUtf8String(content, String.format(sourceLocal, num, prefix + key));
|
|
|
- }else{
|
|
|
- try {
|
|
|
- this.downloadFile(url, String.format(sourceLocal, num, prefix + key));
|
|
|
- }catch (Exception e){
|
|
|
- log.info("下载文件报错,path:{}", String.format(sourceLocal, num, prefix + key));
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
+// public void ProcessFiles(String num, String key, String prefix, Set<String> cacheKeys) throws Exception{
|
|
|
+// if(cacheKeys.contains(key)){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// if(key.equals(String.format(UploadFilePath.DATA_VIEW_PATH, num) + "scene.json")){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// cacheKeys.add(key);
|
|
|
+// String fileName = key.substring(key.lastIndexOf("/") + 1);
|
|
|
+// String url = this.resourceUrl + key.replace(fileName, URLEncoder.encode(fileName, "UTF-8")) + "?t=" + Calendar.getInstance().getTimeInMillis();
|
|
|
+// if(key.contains("hot.json") || key.contains("link-scene.json")){
|
|
|
+// String content = fYunFileService.getFileContent(key);
|
|
|
+// if(StrUtil.isEmpty(content)){
|
|
|
+// return;
|
|
|
+// }
|
|
|
+// content = content.replace(publicUrl, "")
|
|
|
+//// .replace(publicUrl+"v3/", "")
|
|
|
+// .replace("https://spc.html","spc.html")
|
|
|
+// .replace("https://smobile.html", "smobile.html");
|
|
|
+//
|
|
|
+// FileUtil.writeUtf8String(content, String.format(sourceLocal, num, prefix + key));
|
|
|
+// }else{
|
|
|
+// try {
|
|
|
+// this.downloadFile(url, String.format(sourceLocal, num, prefix + key));
|
|
|
+// }catch (Exception e){
|
|
|
+// log.info("下载文件报错,path:{}", String.format(sourceLocal, num, prefix + key));
|
|
|
+// }
|
|
|
+// }
|
|
|
+// }
|
|
|
|
|
|
private void reWriteFile(String num){
|
|
|
String filePath = String.format(sourceLocal, num, this.wwwroot + String.format(UploadFilePath.USER_VIEW_PATH, num) + "hot.json");
|
|
@@ -449,4 +481,6 @@ public class DownloadServiceImpl implements IDownloadService {
|
|
|
|
|
|
return map;
|
|
|
}
|
|
|
+
|
|
|
+
|
|
|
}
|