dengsixing 1 year ago
parent
commit
e2cf1e957f

+ 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(15).setMaxPoolSize(15).build();
+    private final static ThreadPoolExecutor threadPoolExecutor = ExecutorBuilder.create().setWorkQueue(new LinkedBlockingQueue<>(10000)).setCorePoolSize(30).setMaxPoolSize(30).build();
 
     @Autowired
     ILaserService laserService;

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

@@ -6,6 +6,7 @@ import cn.hutool.core.util.RuntimeUtil;
 import cn.hutool.http.HttpUtil;
 import com.fdkankan.common.exception.BusinessException;
 import com.fdkankan.common.util.CmdUtils;
+import lombok.extern.slf4j.Slf4j;
 
 import java.io.File;
 
@@ -13,6 +14,7 @@ import java.io.File;
  * @author Xiewj
  * @date 2024/1/12
  */
+@Slf4j
 public class DownloadUtil {
     public final static String WGET_CMD = "wget -t 10 -N -O @out @url";
 
@@ -26,17 +28,21 @@ public class DownloadUtil {
             file.getParentFile().mkdirs();
         }
         try {
-            if(FileUtil.size(new File(path)) == 0 ){
+            DownloadUtil.downFile(url,path);
+            if(FileUtil.size(new File(path)) == 0){
                 while (index<=50){
                     index++;
                     DownloadUtil.downFile(url,path);
                     if (FileUtil.size(new File(path))>0){
+                        log.info("文件第{}次下载成功:{}", index, path);
                         return;
                     }
-                    ThreadUtil.safeSleep(500);
+                    ThreadUtil.safeSleep(200);
 
 //                    HttpUtil.downloadFileFromUrl(url,path);
                 }
+            }else{
+                log.info("文件第{}次下载成功:{}", index, path);
             }
         } catch (Exception e) {
             throw new BusinessException(-1,"下载报错停止,"+url+","+path);