deason 6 maanden geleden
bovenliggende
commit
8e1ff65d7b

+ 14 - 6
src/main/java/cn/com/qmth/examcloud/tool/service/batch_import_exam_student/BatchImportExamStudentTask.java

@@ -181,7 +181,7 @@ public class BatchImportExamStudentTask implements TaskService {
             List<List<ExamStudentInfo>> newList = this.redoList(dataList);
 
             // 数量多,多线程分批执行
-            final int concurrentSize = 10;
+            final int concurrentSize = 20;
             for (List<ExamStudentInfo> list : newList) {
                 int cutTotal = list.size();
 
@@ -193,9 +193,9 @@ public class BatchImportExamStudentTask implements TaskService {
 
                     long cost = Math.max((System.currentTimeMillis() - startTime) / 1000L, 1);
                     int runCount = successCount.get() + failCount.get();
-                    log.info("总数:{} 成功数:{} 失败数:{} 已执行:{}条 已耗时:{}秒 平均每秒{}条 进度:{}%"
-                            , total, successCount.get(), failCount.get(), runCount, cost
-                            , runCount / cost, runCount * 100f / total);
+                    log.info("总数:{} 成功数:{} 失败数:{} 已执行:{}条 已耗时:{}秒 平均每秒{}条 进度:{}% {}"
+                            , total, successCount.get(), failCount.get(), runCount, cost, runCount / cost,
+                            runCount * 100f / total, predictTime(total, runCount, cost));
                 }
             }
         }
@@ -210,6 +210,15 @@ public class BatchImportExamStudentTask implements TaskService {
         dataList.clear();
     }
 
+    private String predictTime(long totalCount, long finishCount, long curCost) {
+        if (finishCount == 0 || curCost == 0) {
+            return "";
+        }
+        float nPerSecond = (float) finishCount / curCost;
+        float second = (totalCount - finishCount) / nPerSecond;
+        return "约剩:" + second / 60f + "分钟";
+    }
+
     private void normalRun(User loginUser, List<ExamStudentInfo> batchList, AtomicInteger successCount,
                            AtomicInteger failCount, Long taskId, List<String> failRecords) {
         long startTime = System.currentTimeMillis();
@@ -316,8 +325,7 @@ public class BatchImportExamStudentTask implements TaskService {
         for (List<ExamStudentInfo> values : map.values()) {
             maxSize = Math.max(maxSize, values.size());
         }
-
-        log.info("最大重复次数:{}", maxSize);
+        log.info("单个身份证号重复最多次数:{}", maxSize);
 
         List<List<ExamStudentInfo>> newList = new ArrayList<>();
         for (int n = 0; n < maxSize; n++) {