|
@@ -15,10 +15,8 @@ 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.text.SimpleDateFormat;
|
|
|
+import java.util.*;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
import java.util.concurrent.atomic.AtomicInteger;
|
|
@@ -43,6 +41,9 @@ public class FaceVerifyJobHandler {
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
FaceApiParam param = this.parseJobParam(jobParam);
|
|
|
|
|
|
+ // 补偿机制:定期重置“错误次数”为0
|
|
|
+ this.resetExamCaptureQueueErrorNum(param.getMaxErrorNum());
|
|
|
+
|
|
|
// 根据任务调度策略,推荐50
|
|
|
final int batchSize = 50;
|
|
|
|
|
@@ -118,6 +119,28 @@ public class FaceVerifyJobHandler {
|
|
|
todoQueues.clear();
|
|
|
}
|
|
|
|
|
|
+ private void resetExamCaptureQueueErrorNum(int maxErrorNum) {
|
|
|
+ final String lockKey = CacheConstants.LOCK_FACE_COMPARE_RESET;
|
|
|
+ try {
|
|
|
+ long startTime = System.currentTimeMillis();
|
|
|
+ SequenceLockHelper.getLockSimple(lockKey);
|
|
|
+
|
|
|
+ Calendar c = Calendar.getInstance();
|
|
|
+ c.setTime(new Date());
|
|
|
+ c.add(Calendar.HOUR_OF_DAY, -6);// N个小时前的时间
|
|
|
+ String beforeCreationTime = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss").format(c.getTime());
|
|
|
+
|
|
|
+ int resetCount = examCaptureQueueRepo.resetExamCaptureQueueErrorNum(maxErrorNum, beforeCreationTime);
|
|
|
+
|
|
|
+ long cost = System.currentTimeMillis() - startTime;
|
|
|
+ log.warn("【人脸比对任务】 重置错误次数为0!影响条数:{} maxErrorNum:{} cost:{}ms", resetCount, maxErrorNum, cost);
|
|
|
+ } catch (Exception e) {
|
|
|
+ // ignore
|
|
|
+ } finally {
|
|
|
+ SequenceLockHelper.releaseLockSimple(lockKey);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
private FaceApiParam parseJobParam(String jobParam) {
|
|
|
JsonNode jsonParams = new JsonMapper().getNode(jobParam);
|
|
|
if (jsonParams == null) {
|