Forráskód Böngészése

场景批量下载

dsx 2 éve
szülő
commit
4e8cae3d12

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

@@ -61,6 +61,12 @@ public class BatchDonloadServiceImpl implements IBatchDonloadService {
     @Override
     @Override
     public ResultData getDownloadDetail(String uuid) throws Exception {
     public ResultData getDownloadDetail(String uuid) throws Exception {
 
 
+        //查询任务是否正在进行中
+        List<String> taskList = FileUtil.readUtf8Lines(taskLogPath);
+        if(CollUtil.isNotEmpty(taskList) && taskList.contains(uuid)){
+            return ResultData.ok("下载中");
+        }
+
         String dir = parentPath.concat(uuid).concat(File.separator);
         String dir = parentPath.concat(uuid).concat(File.separator);
         String origFilePath = dir.concat(uuid + ".txt");
         String origFilePath = dir.concat(uuid + ".txt");
         List<String> numList = FileUtil.readUtf8Lines(origFilePath);
         List<String> numList = FileUtil.readUtf8Lines(origFilePath);
@@ -83,7 +89,7 @@ public class BatchDonloadServiceImpl implements IBatchDonloadService {
 
 
         }).collect(Collectors.toList());
         }).collect(Collectors.toList());
 
 
-        return ResultData.error(0, "成功", collect);
+        return ResultData.ok(collect);
     }
     }
 
 
     public ResultData bacthDownload(@RequestParam(value = "file") MultipartFile file) throws Exception {
     public ResultData bacthDownload(@RequestParam(value = "file") MultipartFile file) throws Exception {
@@ -179,7 +185,7 @@ public class BatchDonloadServiceImpl implements IBatchDonloadService {
                             }
                             }
                             Thread.sleep(2000L);
                             Thread.sleep(2000L);
                             long endTime = Calendar.getInstance().getTimeInMillis();
                             long endTime = Calendar.getInstance().getTimeInMillis();
-                            if ((endTime - startTime) > 2 * 60 * 60 * 1000) {
+                            if ((endTime - startTime) > 4 * 60 * 60 * 1000) {
                                 log.info("下载超时,num:{}", num);
                                 log.info("下载超时,num:{}", num);
                                 reason = "下载超时";
                                 reason = "下载超时";
                                 go = true;
                                 go = true;