|
@@ -32,6 +32,7 @@ import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
import org.springframework.data.domain.Example;
|
|
|
+import org.springframework.jdbc.core.JdbcTemplate;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.List;
|
|
@@ -45,6 +46,9 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(ExamCaptureQueueServiceImpl.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private JdbcTemplate jdbcTemplate;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamCaptureQueueRepo examCaptureQueueRepo;
|
|
|
|
|
@@ -280,4 +284,39 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
queue.getFileName());
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 按考试记录ID分片获取待处理的抓拍照片记录
|
|
|
+ *
|
|
|
+ * @param shardTotal 分片总数
|
|
|
+ * @param shardIndex 当前分片索引
|
|
|
+ * @param batchSize 批量条数
|
|
|
+ * @param maxErrorNum 最大重试错误次数
|
|
|
+ * @param examHandInFirst 是否优先处理“已交卷”的考试记录
|
|
|
+ * @return 考试记录ID列表
|
|
|
+ */
|
|
|
+ @Override
|
|
|
+ public List<Long> findQueuesGroupByExamRecordDataId(int shardTotal, int shardIndex, int batchSize, int maxErrorNum, boolean examHandInFirst) {
|
|
|
+ StringBuilder sql = new StringBuilder();
|
|
|
+ sql.append(" select q.exam_record_data_id");
|
|
|
+ sql.append(" from ec_oet_exam_capture_queue q");
|
|
|
+ if (examHandInFirst) {
|
|
|
+ sql.append(" inner join ec_oes_exam_record_data d on d.id = q.exam_record_data_id");
|
|
|
+ }
|
|
|
+ sql.append(" where mod(q.exam_record_data_id,").append(shardTotal).append(") = ").append(shardIndex);
|
|
|
+ sql.append(" and q.error_num < ").append(maxErrorNum);
|
|
|
+ if (examHandInFirst) {
|
|
|
+ sql.append(" and d.sync_status = 'UNSYNC'");
|
|
|
+ sql.append(" and d.exam_record_status in('EXAM_HAND_IN','EXAM_AUTO_HAND_IN')");
|
|
|
+ }
|
|
|
+ sql.append(" group by q.exam_record_data_id");
|
|
|
+ sql.append(" order by q.exam_record_data_id asc");
|
|
|
+ sql.append(" limit ").append(batchSize);
|
|
|
+
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
+ log.debug(sql.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ return jdbcTemplate.queryForList(sql.toString(), Long.class);
|
|
|
+ }
|
|
|
+
|
|
|
}
|