deason vor 11 Monaten
Ursprung
Commit
f31527536c

+ 12 - 8
examcloud-core-oe-task-service/src/main/java/cn/com/qmth/examcloud/core/oe/task/service/job/FaceVerifyJobHandler.java

@@ -15,8 +15,10 @@ import org.slf4j.LoggerFactory;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.stereotype.Component;
 
+import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
 
 
@@ -41,26 +43,28 @@ public class FaceVerifyJobHandler {
         final int batchSize = 50;
 
         // 优先取“已交卷”的考试记录ID集合
-        List<Long> todoExamRecordDataIds = examCaptureQueueService.findQueuesGroupByExamRecordDataId(shardTotal,
+        List<Long> examRecordDataIds = examCaptureQueueService.findQueuesGroupByExamRecordDataId(shardTotal,
                 shardIndex, batchSize, param.getMaxErrorNum(), true);
 
-        if (CollectionUtils.isEmpty(todoExamRecordDataIds)) {
-            // 未取到时,再按常规取一次考试记录ID集合
-            todoExamRecordDataIds = examCaptureQueueService.findQueuesGroupByExamRecordDataId(shardTotal,
-                    shardIndex, batchSize, param.getMaxErrorNum(), false);
+        if (examRecordDataIds.size() < batchSize) {
+            // 未取到或取到的数量不足时,再按常规取一次考试记录ID集合来补充
+            List<Long> moreExamRecordDataIds = examCaptureQueueService.findQueuesGroupByExamRecordDataId(shardTotal,
+                    shardIndex, batchSize - examRecordDataIds.size(), param.getMaxErrorNum(), false);
+            examRecordDataIds.addAll(moreExamRecordDataIds);
 
-            if (CollectionUtils.isEmpty(todoExamRecordDataIds)) {
+            if (CollectionUtils.isEmpty(examRecordDataIds)) {
                 log.warn("分片任务_FACE_{}_{} 当前分片暂无待处理记录!", shardTotal, shardIndex);
                 return;
             }
         }
 
-        List<ExamCaptureQueueEntity> todoQueues = examCaptureQueueRepo.findByExamRecordDataIdIn(todoExamRecordDataIds);
+        Set<Long> todoIds = new HashSet<>(examRecordDataIds);
+        List<ExamCaptureQueueEntity> todoQueues = examCaptureQueueRepo.findByExamRecordDataIdIn(todoIds);
         if (CollectionUtils.isEmpty(todoQueues)) {
             return;
         }
 
-        log.warn("分片任务_FACE_{}_{} examRecordDataIdSize:{} queueSize:{}", shardTotal, shardIndex, todoExamRecordDataIds.size(), todoQueues.size());
+        log.warn("分片任务_FACE_{}_{} examRecordDataIdSize:{} queueSize:{}", shardTotal, shardIndex, todoIds.size(), todoQueues.size());
         Map<Long, List<ExamCaptureQueueEntity>> maps = todoQueues.stream().collect(Collectors.groupingBy(ExamCaptureQueueEntity::getExamRecordDataId));
 
         for (Map.Entry<Long, List<ExamCaptureQueueEntity>> entry : maps.entrySet()) {