|
@@ -1,6 +1,5 @@
|
|
package cn.com.qmth.examcloud.core.oe.student.face.starter.config;
|
|
package cn.com.qmth.examcloud.core.oe.student.face.starter.config;
|
|
|
|
|
|
-import cn.com.qmth.examcloud.commons.exception.StatusException;
|
|
|
|
import cn.com.qmth.examcloud.commons.helpers.concurrency.simple.ConcurrentTask;
|
|
import cn.com.qmth.examcloud.commons.helpers.concurrency.simple.ConcurrentTask;
|
|
import cn.com.qmth.examcloud.commons.util.Util;
|
|
import cn.com.qmth.examcloud.commons.util.Util;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamCaptureQueueEntity;
|
|
import cn.com.qmth.examcloud.core.oe.common.entity.ExamCaptureQueueEntity;
|
|
@@ -8,26 +7,16 @@ import cn.com.qmth.examcloud.core.oe.common.repository.ExamCaptureQueueRepo;
|
|
import cn.com.qmth.examcloud.core.oe.student.face.service.impl.ExamCaptureProcessStatisticController;
|
|
import cn.com.qmth.examcloud.core.oe.student.face.service.impl.ExamCaptureProcessStatisticController;
|
|
import cn.com.qmth.examcloud.core.oe.student.face.service.impl.FacePPCompareWorker;
|
|
import cn.com.qmth.examcloud.core.oe.student.face.service.impl.FacePPCompareWorker;
|
|
import cn.com.qmth.examcloud.exchange.inner.api.SmsCloudService;
|
|
import cn.com.qmth.examcloud.exchange.inner.api.SmsCloudService;
|
|
-import cn.com.qmth.examcloud.exchange.inner.api.client.SmsCloudServiceClient;
|
|
|
|
-import cn.com.qmth.examcloud.exchange.inner.api.request.SendSmsReq;
|
|
|
|
-import cn.com.qmth.examcloud.support.cache.CacheHelper;
|
|
|
|
-import cn.com.qmth.examcloud.support.cache.bean.SysPropertyCacheBean;
|
|
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
import cn.com.qmth.examcloud.web.bootstrap.PropertyHolder;
|
|
-import com.google.common.collect.Lists;
|
|
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.Log;
|
|
import org.apache.commons.logging.LogFactory;
|
|
import org.apache.commons.logging.LogFactory;
|
|
-import org.slf4j.Logger;
|
|
|
|
-import org.slf4j.LoggerFactory;
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
import org.springframework.boot.ApplicationArguments;
|
|
import org.springframework.boot.ApplicationArguments;
|
|
import org.springframework.boot.ApplicationRunner;
|
|
import org.springframework.boot.ApplicationRunner;
|
|
import org.springframework.core.annotation.Order;
|
|
import org.springframework.core.annotation.Order;
|
|
import org.springframework.stereotype.Component;
|
|
import org.springframework.stereotype.Component;
|
|
|
|
|
|
-import java.util.Arrays;
|
|
|
|
import java.util.List;
|
|
import java.util.List;
|
|
-import java.util.Timer;
|
|
|
|
-import java.util.TimerTask;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
* 启动人脸比对任务
|
|
* 启动人脸比对任务
|
|
@@ -38,7 +27,6 @@ public class ProcessFaceCompareQueueTask implements ApplicationRunner {
|
|
|
|
|
|
@Autowired
|
|
@Autowired
|
|
ExamCaptureQueueRepo examCaptureQueueRepo;
|
|
ExamCaptureQueueRepo examCaptureQueueRepo;
|
|
- private static final Logger log = LoggerFactory.getLogger(ProcessFaceCompareQueueTask.class);
|
|
|
|
private final Log captureLog = LogFactory.getLog("PROCESS_EXAM_CAPTURE_TASK_LOGGER");
|
|
private final Log captureLog = LogFactory.getLog("PROCESS_EXAM_CAPTURE_TASK_LOGGER");
|
|
private final ExamCaptureProcessStatisticController statisticController = new ExamCaptureProcessStatisticController();
|
|
private final ExamCaptureProcessStatisticController statisticController = new ExamCaptureProcessStatisticController();
|
|
//失败率预警阈值
|
|
//失败率预警阈值
|
|
@@ -49,12 +37,10 @@ public class ProcessFaceCompareQueueTask implements ApplicationRunner {
|
|
SmsCloudService smsCloudService;
|
|
SmsCloudService smsCloudService;
|
|
|
|
|
|
private void start() {
|
|
private void start() {
|
|
- sendAlarmSmsIfNecessary();
|
|
|
|
-
|
|
|
|
ConcurrentTask concurrentTask = new ConcurrentTask();
|
|
ConcurrentTask concurrentTask = new ConcurrentTask();
|
|
concurrentTask.setMaxActiveThreadSize(PropertyHolder.getInt("$capture.thread.maxActiveThreadSize", 100));
|
|
concurrentTask.setMaxActiveThreadSize(PropertyHolder.getInt("$capture.thread.maxActiveThreadSize", 100));
|
|
concurrentTask.setMinThreadSize(PropertyHolder.getInt("$capture.thread.minThreadSize", 2));
|
|
concurrentTask.setMinThreadSize(PropertyHolder.getInt("$capture.thread.minThreadSize", 2));
|
|
- concurrentTask.setWorker(new FacePPCompareWorker(statisticController));
|
|
|
|
|
|
+ concurrentTask.setWorker(new FacePPCompareWorker());
|
|
concurrentTask.start();
|
|
concurrentTask.start();
|
|
//当前获取数据的批次号(默认用时间戳)
|
|
//当前获取数据的批次号(默认用时间戳)
|
|
String processBatchNum = "A_" + System.currentTimeMillis();
|
|
String processBatchNum = "A_" + System.currentTimeMillis();
|
|
@@ -93,43 +79,13 @@ public class ProcessFaceCompareQueueTask implements ApplicationRunner {
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} catch (Exception e) {
|
|
} catch (Exception e) {
|
|
- log.error("300001", "启动图片队列出现异常", e);
|
|
|
|
-
|
|
|
|
captureLog.error("[PROCESS_FACEPP." + processBatchNum + "] 百度活体检测出出异常,3秒后重试", e);
|
|
captureLog.error("[PROCESS_FACEPP." + processBatchNum + "] 百度活体检测出出异常,3秒后重试", e);
|
|
Util.sleep(3);
|
|
Util.sleep(3);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- /**
|
|
|
|
- * 如果有必要则发短信
|
|
|
|
- */
|
|
|
|
- private void sendAlarmSmsIfNecessary() {
|
|
|
|
- //每分钟判断是否需要发短信报警
|
|
|
|
- Timer timer = new Timer();
|
|
|
|
- timer.scheduleAtFixedRate(new TimerTask() {
|
|
|
|
- @Override
|
|
|
|
- public void run() {
|
|
|
|
- //如果每分钟失败率超过50%则发短信报警,且总数不少于10次则短信报警
|
|
|
|
- if (statisticController.getCount() > COUNT_WARN_THRESHOLD &&
|
|
|
|
- statisticController.getFailureRate() > RATE_WARN_THRESHOLD) {
|
|
|
|
- SysPropertyCacheBean smsPhoneProperty = CacheHelper.getSysProperty("capture.sms.phones");
|
|
|
|
- if (!smsPhoneProperty.getHasValue()) {
|
|
|
|
- throw new StatusException("300001", "未配置图片处理失败的通知手机号");
|
|
|
|
- }
|
|
|
|
- List<String> phoneList = Arrays.asList(smsPhoneProperty.getValue().toString().split(","));
|
|
|
|
- SendSmsReq sendSmsReq = new SendSmsReq();
|
|
|
|
- sendSmsReq.setPhoneList(phoneList);
|
|
|
|
- sendSmsReq.setSmsAssemblyCode("CAPTURE");
|
|
|
|
- sendSmsReq.setParams(null);
|
|
|
|
- smsCloudService.sendSms(sendSmsReq);
|
|
|
|
- }
|
|
|
|
- //每1分钟重置一次总数量与失败数量
|
|
|
|
- statisticController.resetCount();
|
|
|
|
- statisticController.resetFailureCount();
|
|
|
|
- }
|
|
|
|
- }, 100, 60 * 1000);
|
|
|
|
- }
|
|
|
|
|
|
+
|
|
|
|
|
|
@Override
|
|
@Override
|
|
public void run(ApplicationArguments args) {
|
|
public void run(ApplicationArguments args) {
|