dengsixing 1 рік тому
батько
коміт
81f194c289

+ 3 - 2
src/main/java/com/fdkankan/download/service/impl/BatchDonloadServiceImpl.java

@@ -256,7 +256,8 @@ public class BatchDonloadServiceImpl implements IBatchDonloadService {
     private ILaserService laserService;
     @Autowired
     private IDownloadService downloadService;
-    public final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(5).setMaxPoolSize(5).build();
+    public final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(2).setMaxPoolSize(5).build();
+    public final static ThreadPoolExecutor laserThreadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(2).setMaxPoolSize(2).build();
 
     @Override
     public ResultData bacthDownloadByLocal(MultipartFile file) throws Exception {
@@ -375,7 +376,7 @@ public class BatchDonloadServiceImpl implements IBatchDonloadService {
         List<String> nums = FileUtil.readUtf8Lines(tempFile);
 
         for (String num : nums) {
-            threadPoolExecutor.submit(() -> {
+            laserThreadPoolExecutor.submit(() -> {
                 try {
                     downloadService.downloadLaserScene(num);
                 }catch (Exception e){

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

@@ -267,7 +267,7 @@ public class DownloadServiceImpl implements IDownloadService {
             //写入启动命令
             this.zipBat(num, "v4");
 
-            this.zip(String.format(this.sourceLocal, num, ""), String.format(zipLocalFormat, num, num));
+            this.zip(String.format(this.sourceLocal, num, ""), String.format(zipLocalFormat, DateExtUtil.format(new Date(), DateExtUtil.dateStyle6), num));
 
 //            String uploadPath = String.format(this.zipOssFormat, num);
 //            fYunFileService.uploadFile(String.format(zipLocalFormat, num, num), uploadPath);
@@ -278,6 +278,8 @@ public class DownloadServiceImpl implements IDownloadService {
             //更新进度为下载失败
             log.error("场景下载失败,num:{}", num, e);
             throw e;
+        }finally {
+            FileUtil.del(String.format(this.sourceLocal, num, ""));
         }
     }
 

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

@@ -199,6 +199,7 @@ public class LaserService  implements ILaserService {
         }finally {
             String path=sourceLocal+File.separator+num;
             FileUtil.del(path);
+            FileUtil.del("/mnt/laserOffline/" + num);
         }
         return "";
     }

+ 7 - 2
src/main/java/com/fdkankan/download/util/DownloadUtil.java

@@ -41,8 +41,12 @@ public class DownloadUtil {
             file.getParentFile().mkdirs();
         }
         try {
-            HttpUtil.downloadFileFromUrl(url,path);
-            if(FileUtil.size(new File(path)) == 0){
+            try {
+                HttpUtil.downloadFileFromUrl(url,path);
+            }catch (Exception e){
+                log.error("下载失败,url:{}, path:{}", url, path, e);
+            }
+            if(!FileUtil.exist(path) || FileUtil.size(new File(path)) == 0){
                 while (index<=50){
                     index++;
                     HttpUtil.downloadFileFromUrl(url,path);
@@ -58,6 +62,7 @@ public class DownloadUtil {
                 log.info("文件第{}次下载成功:{}", index, path);
             }
         } catch (Exception e) {
+            log.error("下载报错停止,url:{}, path:{}", url, path, e);
             throw new BusinessException(-1,"下载报错停止,"+url+","+path);
         }
     }

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

@@ -4,7 +4,7 @@ spring:
   application:
     name: 4dkankan-scene-download-tool
   redis:
-    host: r-wz9owsphxqwi4ztqlf.redis.rds.aliyuncs.com
+    host: r-wz9owsphxqwi4ztqlfpd.redis.rds.aliyuncs.com
     port: 6379
     timeout: 6000ms
     password: 3oo19bgh0cae2406&
@@ -93,7 +93,7 @@ path:
   zip-root: wwwroot/
   zip-oss: downloads/scenes/%s.zip
   laserschool: /mnt/fdkk_laser/uploadPath/offlineGenerate/
-  source-local-laser: /data/laserOffline
+  source-local-laser: /mnt/laserOffline
 download:
   dir: D:\test2\
   task: ${download.dir}task.txt