deason 11 mesiacov pred
rodič
commit
c011d86dc7

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

@@ -2,6 +2,7 @@ package cn.com.qmth.examcloud.core.oe.task.service.job;
 
 import cn.com.qmth.examcloud.commons.util.JsonMapper;
 import cn.com.qmth.examcloud.core.oe.student.dao.ExamCaptureQueueRepo;
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamCaptureQueueEntity;
 import cn.com.qmth.examcloud.core.oe.task.service.ExamCaptureQueueService;
 import cn.com.qmth.examcloud.core.oe.task.service.bean.FaceApiParam;
 import cn.com.qmth.examcloud.support.CacheConstants;
@@ -33,16 +34,30 @@ public class FaceVerifyJobHandler {
     public void run(int shardTotal, int shardIndex, String jobParam) throws Exception {
         FaceApiParam param = this.parseJobParam(jobParam);
 
-        final int batchSize = 50;// 数值太大不利于任务调度,推荐50
+        // 数值太大不利于任务调度策略,推荐50
+        final int batchSize = 50;
+
+        // 优先取“已交卷”的考试记录ID集合
         List<Long> todoExamRecordDataIds = examCaptureQueueService.findQueuesGroupByExamRecordDataId(shardTotal,
-                shardIndex, batchSize, param.getMaxErrorNum(), false);
+                shardIndex, batchSize, param.getMaxErrorNum(), true);
 
         if (CollectionUtils.isEmpty(todoExamRecordDataIds)) {
-            log.warn("分片任务_FACE_{}_{} 当前分片暂无待处理记录!", shardTotal, shardIndex);
+            // 未取到时,再取一次“不区分状态”的考试记录ID集合
+            todoExamRecordDataIds = examCaptureQueueService.findQueuesGroupByExamRecordDataId(shardTotal,
+                    shardIndex, batchSize, param.getMaxErrorNum(), false);
+
+            if (CollectionUtils.isEmpty(todoExamRecordDataIds)) {
+                log.warn("分片任务_FACE_{}_{} 当前分片暂无待处理记录!", shardTotal, shardIndex);
+                return;
+            }
+        }
+
+        List<ExamCaptureQueueEntity> queues = examCaptureQueueRepo.findByExamRecordDataIdIn(todoExamRecordDataIds);
+        if (CollectionUtils.isEmpty(queues)) {
             return;
         }
+        log.warn("分片任务_FACE_{}_{} examRecordDataIdSize:{} queueSize:{}", shardTotal, shardIndex, todoExamRecordDataIds.size(), queues.size());
 
-        log.warn("分片任务_FACE_{}_{} todoExamRecordDataIds size:{}", shardTotal, shardIndex, todoExamRecordDataIds.size());
         for (Long examRecordDataId : todoExamRecordDataIds) {
             final String lockKey = CacheConstants.LOCK_FACE_COMPARE + examRecordDataId;
             try {