dengsixing 1 年之前
父節點
當前提交
384f1e6e2b

+ 19 - 12
src/main/java/com/fdkankan/download/service/impl/DownloadServiceImpl.java

@@ -210,14 +210,14 @@ 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).concat(String.format(UploadFilePath.VIEW_PATH, num)), String.format(UploadFilePath.VIEW_PATH, num));
-        FileUtil.del(String.format(sourceLocal, num, this.wwwroot).concat(String.format(UploadFilePath.IMG_VIEW_PATH, num)).concat("tiles"));
-//        List<String> strings = fYunFileService.listRemoteFiles(String.format(UploadFilePath.VIEW_PATH, num));
-//        strings.stream().forEach(str->{
-//            if(!str.contains("/tiles/4k/") && !str.contains("/tiles/2k/")){
-//                fYunFileService.downloadFile(str, String.format(sourceLocal, num, this.wwwroot).concat(str));
-//            }
-//        });
+//        fYunFileService.downloadFileByCommand(String.format(sourceLocal, num, this.wwwroot).concat(String.format(UploadFilePath.VIEW_PATH, num)), String.format(UploadFilePath.VIEW_PATH, num));
+//        FileUtil.del(String.format(sourceLocal, num, this.wwwroot).concat(String.format(UploadFilePath.IMG_VIEW_PATH, num)).concat("tiles"));
+        List<String> strings = fYunFileService.listRemoteFiles(String.format(UploadFilePath.VIEW_PATH, num));
+        strings.stream().forEach(str->{
+            if(!str.contains("/tiles/4k/") && !str.contains("/tiles/2k/")){
+                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));
 
         //特殊文件处理
@@ -417,7 +417,7 @@ public class DownloadServiceImpl implements IDownloadService {
                 //key.split("/" + resolution + "/")[0] + "/" +
                 var fky = dir + "/" + imageType.getName() +  num + "_" + item.getI()  + "_" + item.getJ() + ext;
 
-                this.downloadFile(url, path + fky);
+                this.downloadFile(url, path + fky,1);
 //                this.downloadFile(url, path);
                 });
 //            }
@@ -425,13 +425,18 @@ public class DownloadServiceImpl implements IDownloadService {
 
     }
 
-    public void downloadFile(String url, String path){
+    public void downloadFile(String url, String path,int index){
         File file = new File(path);
         if(!file.getParentFile().exists()){
             file.getParentFile().mkdirs();
         }
         try {
-            DownloadUtil.downFile(url,path);
+//            DownloadUtil.downFile(url,path);
+            HttpUtil.downloadFileFromUrl(url,path);
+            if(FileUtil.size(new File(path)) == 0 && index < 4){
+                index++;
+                this.downloadFile(url,path,index);
+            }
         } catch (Exception e) {
             log.info("下载文件报错,url{},path:{}",url, path);
         }
@@ -505,7 +510,9 @@ public class DownloadServiceImpl implements IDownloadService {
     }
 
     private void zip(String sourcePath, String zipPath) throws Exception {
-        String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " " + "*";
+        zipPath = zipPath.replace("mnt", "data");
+        String target = String.format("/mnt/scenes/%s", DateExtUtil.format(new Date(), DateExtUtil.dateStyle6));
+        String cmd = "cd " + sourcePath + " && zip -r " + zipPath + " * && mv -f " + zipPath + " "  + target;
         CmdUtils.callLineSh(cmd, 200);
         if(!FileUtil.exist(zipPath)){
             throw new RuntimeException("打包失败");

+ 1 - 1
src/main/java/com/fdkankan/download/service/impl/GenSceneRunnerImpl.java

@@ -53,7 +53,7 @@ public class GenSceneRunnerImpl implements CommandLineRunner {
     @Autowired
     private RabbitMqProducer mqProducer;
 
-    private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(30).setMaxPoolSize(30).build();
+    private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(10).setMaxPoolSize(10).build();
 
     @Autowired
     ILaserService laserService;

+ 9 - 4
src/main/java/com/fdkankan/download/service/impl/LaserService.java

@@ -107,7 +107,7 @@ public class LaserService  implements ILaserService {
                                         this.downloadFile(laserResourceUrl + key, sourceLocal +
                                                 File.separator + num +
                                                 File.separator + "www" +
-                                                File.separator + num + srcPath);
+                                                File.separator + num + srcPath,1);
                                     }
                                 } else {
                                     String srcPath = datum.getKey();
@@ -137,7 +137,7 @@ public class LaserService  implements ILaserService {
                                             File.separator + "data" +
                                             File.separator + datum.getSceneCode() +
                                             File.separator + "depthmap" +
-                                            File.separator + FileUtil.getName(key));
+                                            File.separator + FileUtil.getName(key),1);
                                 }
 //                            }else{
 //                                String srcPath=datum.getKey();
@@ -218,13 +218,18 @@ public class LaserService  implements ILaserService {
         return FileUtil.file(moveZipPath);
 
     }
-    public void downloadFile(String url, String path){
+    public void downloadFile(String url, String path,int index){
         File file = new File(path);
         if(!file.getParentFile().exists()){
             file.getParentFile().mkdirs();
         }
         try {
-            DownloadUtil.downFile(url,path);
+//            DownloadUtil.downFile(url,path);
+            HttpUtil.downloadFileFromUrl(url,path);
+            if(FileUtil.size(new File(path)) == 0 && index < 4){
+                index++;
+                this.downloadFile(url,path,index);
+            }
         } catch (Exception e) {
             log.info("下载文件报错,url{},path:{}",url, path);
         }

+ 1 - 1
src/main/resources/application-prod.yml

@@ -87,7 +87,7 @@ zip:
   nThreads: 10
 path:
   v4school: /mnt/scene_download_statics/v4local/
-  source-local: /mnt/downloads/scenes/%s/%s
+  source-local: /data/downloads/scenes/%s/%s
   zip-local: /mnt/scenes/%s/%s.zip
   zip-root: wwwroot/
   zip-oss: downloads/scenes/%s.zip