|
@@ -28,8 +28,6 @@ import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
-import org.apache.commons.logging.Log;
|
|
|
-import org.apache.commons.logging.LogFactory;
|
|
|
import org.json.JSONException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -54,8 +52,6 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(ExamCaptureServiceImpl.class);
|
|
|
|
|
|
- private final Log captureLog = LogFactory.getLog("PROCESS_EXAM_CAPTURE_TASK_LOGGER");
|
|
|
-
|
|
|
@Autowired
|
|
|
private ExamCaptureRepo examCaptureRepo;
|
|
|
|
|
@@ -96,7 +92,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
|
|
|
//仅用于日志时间计算
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对开始...");
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对开始...");
|
|
|
|
|
|
//调用face++API执行人脸比对,得到返回结果
|
|
|
JsonHttpResponseHolder jsonHttpResponseHolder = null;
|
|
@@ -114,14 +110,14 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
examCaptureQueue.setFaceCompareResult(e.getDesc());
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对无法处理的图片地址,保存人脸检测最终结果并删除队列,errMsg=" + e.getDesc());
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对无法处理的图片地址,保存人脸检测最终结果并删除队列,errMsg=" + e.getDesc());
|
|
|
return;
|
|
|
}
|
|
|
throw e;
|
|
|
}
|
|
|
|
|
|
- if (captureLog.isDebugEnabled()) {
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] 调用face++API执行人脸比对,得到返回结果faceCompareResult:" + faceCompareResult);
|
|
|
+ if (log.isDebugEnabled()) {
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] 调用face++API执行人脸比对,得到返回结果faceCompareResult:" + faceCompareResult);
|
|
|
}
|
|
|
examCaptureQueue.setFaceCompareResult(faceCompareResult.toString());
|
|
|
|
|
@@ -131,7 +127,8 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
|
|
|
//如果API并发次数超过上限,则保存错误信息到队列,并抛出异常,用于协调满载队列线程
|
|
|
if (errMsg.contains(Constants.FACE_COMPARE_CONCURRENCY_LIMIT_EXCEEDED)) {
|
|
|
- captureLog.error("[FaceCompareQueue] FacePlusPlus_QPS_CONCURRENCY_LIMITED");
|
|
|
+
|
|
|
+ log.error("[FaceCompareQueue] FacePlusPlus_QPS_CONCURRENCY_LIMITED");
|
|
|
|
|
|
examCaptureQueueService.saveExamCaptureQueueEntityByFailed(examCaptureQueue.getId(),
|
|
|
"SatusCode:" + jsonHttpResponseHolder.getStatusCode() + " | " + faceCompareResult.toString(),
|
|
@@ -152,7 +149,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
if (errMsg.contains(notRetryErrMsgsArr[i])) {
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对无法处理的图片,保存人脸检测最终结果并删除队列,errMsg=" + errMsg);
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对无法处理的图片,保存人脸检测最终结果并删除队列,errMsg=" + errMsg);
|
|
|
|
|
|
return;
|
|
|
}
|
|
@@ -162,7 +159,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
if (errMsg.contains(Constants.FACE_COMPARE_IMAGE_DOWNLOAD_TIMEOUT)) {
|
|
|
faceCompareTimeOutTimes++;
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对超时,将进行第" + faceCompareTimeOutTimes + "次重试");
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对超时,将进行第" + faceCompareTimeOutTimes + "次重试");
|
|
|
|
|
|
//如果没有达到最大重试次数,则继续重试
|
|
|
if (faceCompareTimeOutTimes < maxRetryTimes) {
|
|
@@ -172,17 +169,17 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
//超过最大重试次数,则直接保存最终结果
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对超过最大检测次数:" + maxRetryTimes + ",停止重试,直接保存最终结果");
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对超过最大检测次数:" + maxRetryTimes + ",停止重试,直接保存最终结果");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对出现错误,即将重试,errMsg:" + errMsg);
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对出现错误,即将重试,errMsg:" + errMsg);
|
|
|
// 其它错误类型,保存错误信息到队列中,待自动重新服务处理
|
|
|
examCaptureQueueService.saveExamCaptureQueueEntityByFailed(examCaptureQueue.getId(),
|
|
|
"SatusCode:" + jsonHttpResponseHolder.getStatusCode() + " | " + faceCompareResult.toString(),
|
|
|
ExamCaptureQueueStatus.PROCESS_FACE_COMPARE_FAILED);
|
|
|
ExamCaptureProcessStatisticController.increaseFaceCompareFailedCount();//增加错误次数
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对出现错误,增加错误次数后failedCount:" +
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对出现错误,增加错误次数后failedCount:" +
|
|
|
ExamCaptureProcessStatisticController.getFaceCompareFailedCount() + ",totalCount=" +
|
|
|
ExamCaptureProcessStatisticController.getFaceCompareCount());
|
|
|
}
|
|
@@ -197,7 +194,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
examCaptureQueue.setStatus(ExamCaptureQueueStatus.PROCESS_FACE_COMPARE_COMPLETE);
|
|
|
disposeFaceCompareSuccessful(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对完成,即将进行百度活体检测,耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对完成,即将进行百度活体检测,耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
|
//face++ 没有检测到人脸,直接保存人脸检测最终结果并删除队列
|
|
|
else {
|
|
@@ -205,7 +202,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
examCaptureQueue.setStranger(false);
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_FACE_COMPARE] face++人脸比对完成,且未检测到人脸,耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
+ log.debug("[DISPOSE_FACE_COMPARE] face++人脸比对完成,且未检测到人脸,耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
|
}
|
|
|
} while (retry);
|
|
@@ -238,7 +235,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
|
|
|
//仅用于日志时间计算
|
|
|
long startTime = System.currentTimeMillis();
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测开始...");
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测开始...");
|
|
|
|
|
|
//获取百度活检结果
|
|
|
JsonHttpResponseHolder jsonHttpResponseHolder = null;
|
|
@@ -253,7 +250,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
examCaptureQueue.setFacelivenessResult(e.getDesc());
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活检无法处理的图片地址,保存人脸检测最终结果并删除队列,errMsg=" + e.getDesc());
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活检无法处理的图片地址,保存人脸检测最终结果并删除队列,errMsg=" + e.getDesc());
|
|
|
return;
|
|
|
}
|
|
|
throw e;
|
|
@@ -267,8 +264,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
|
|
|
//如果API并发次数超过上限,则保存错误信息到队列,并抛出异常,用于协调满载队列线程
|
|
|
if (errCode.equals(Constants.BAIDU_FACELIVENESS_QPS_LIMIT_EXCEEDED_CODE)) {
|
|
|
-
|
|
|
- captureLog.error("[FaceLivenessQueue] Baidu_QPS_CONCURRENCY_LIMITED");
|
|
|
+ log.error("[FaceLivenessQueue] Baidu_QPS_CONCURRENCY_LIMITED");
|
|
|
|
|
|
examCaptureQueueService.saveExamCaptureQueueEntityByFailed(examCaptureQueue.getId(),
|
|
|
"SatusCode:" + jsonHttpResponseHolder.getStatusCode() + " | " + faceLivenessResultJson.toString(),
|
|
@@ -287,7 +283,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
for (int i = 0; i < notRetryErrMsgsArr.length; i++) {
|
|
|
//如果是配置中的无法处理的图片,则保存人脸检测最终结果并删除队列
|
|
|
if (errCode.equals(notRetryErrMsgsArr[i])) {
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测,无法处理的图片,将保存人脸检测最终结果并删除队列,errCode=" + errCode);
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测,无法处理的图片,将保存人脸检测最终结果并删除队列,errCode=" + errCode);
|
|
|
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
return;
|
|
@@ -298,7 +294,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
if (errCode.equals(Constants.BAIDU_FACELIVENESS_CONNECTION_OR_READ_DATA_TIME_OUT_CODE)) {
|
|
|
facelivenessTimeOutTimes++;
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测超时,将进行第" + facelivenessTimeOutTimes + "次重试");
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测超时,将进行第" + facelivenessTimeOutTimes + "次重试");
|
|
|
|
|
|
//如果没有达到最大重试次数,则继续重试
|
|
|
if (facelivenessTimeOutTimes < maxRetryTimes) {
|
|
@@ -309,23 +305,23 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
//超过最大重试次数,则直接保存最终结果
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测超过最大检测次数:" + maxRetryTimes + ",停止重试,直接保存最终结果");
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测超过最大检测次数:" + maxRetryTimes + ",停止重试,直接保存最终结果");
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测出现错误,即将重试,错误码:" + errCode);
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测出现错误,即将重试,错误码:" + errCode);
|
|
|
// 其它错误类型,保存错误信息到队列中,待自动重新服务处理
|
|
|
examCaptureQueueService.saveExamCaptureQueueEntityByFailed(examCaptureQueue.getId(),
|
|
|
"SatusCode:" + jsonHttpResponseHolder.getStatusCode() + " | " + faceLivenessResultJson.toString(), ExamCaptureQueueStatus.PROCESS_FACELIVENESS_FAILED);
|
|
|
ExamCaptureProcessStatisticController.increaseFaceLivenessDetectFailedCount();//增加错误次数
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测出现错误,增加错误次数后failedCount:" + ExamCaptureProcessStatisticController.getFaceLivenessDetectFailedCount());
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测出现错误,增加错误次数后failedCount:" + ExamCaptureProcessStatisticController.getFaceLivenessDetectFailedCount());
|
|
|
}
|
|
|
//百度活体检测成功,则保存最终检测结果,并删除临时的图片处理队列
|
|
|
else {
|
|
|
examCaptureQueue.setFacelivenessResult(faceLivenessResultJson.toString());
|
|
|
saveExamCaptureAndDeleteQueue(examCaptureQueue);
|
|
|
|
|
|
- captureLog.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测完成,耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
+ log.debug("[DISPOSE_BAIDUFACELIVENESS] 百度活体检测完成,耗时:" + (System.currentTimeMillis() - startTime) + " ms");
|
|
|
}
|
|
|
} while (retry);
|
|
|
}
|
|
@@ -373,7 +369,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
compareFaceSyncInfo.setExistsSystemError(true);
|
|
|
compareFaceSyncInfo.setErrorMsg(e.getDesc());
|
|
|
|
|
|
- captureLog.error("[COMPARE_FACE_SYNC] face++人脸比对无法处理的图片地址,errMsg=" + e.getDesc(), e);
|
|
|
+ log.error("[COMPARE_FACE_SYNC] face++人脸比对无法处理的图片地址,errMsg=" + e.getDesc(), e);
|
|
|
return compareFaceSyncInfo;
|
|
|
}
|
|
|
throw e;
|
|
@@ -382,7 +378,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
compareFaceSyncInfo.setExistsSystemError(true);
|
|
|
compareFaceSyncInfo.setErrorMsg("系统异常");
|
|
|
|
|
|
- captureLog.error("[COMPARE_FACE_SYNC] 未处理的系统异常,errMsg=" + e.getMessage(), e);
|
|
|
+ log.error("[COMPARE_FACE_SYNC] 未处理的系统异常,errMsg=" + e.getMessage(), e);
|
|
|
return compareFaceSyncInfo;
|
|
|
}
|
|
|
if (facePPResult.containsKey(Constants.ERROR_MSG)) {
|
|
@@ -393,7 +389,7 @@ public class ExamCaptureServiceImpl implements ExamCaptureService {
|
|
|
compareFaceSyncInfo.setExistsSystemError(true);
|
|
|
}
|
|
|
if (errMsg.contains(Constants.FACE_COMPARE_CONCURRENCY_LIMIT_EXCEEDED)) {
|
|
|
- captureLog.error("[FaceCompare] FacePlusPlus_QPS_CONCURRENCY_LIMITED");
|
|
|
+ log.error("[FaceCompare] FacePlusPlus_QPS_CONCURRENCY_LIMITED");
|
|
|
compareFaceSyncInfo.setExistsSystemError(true);
|
|
|
}
|
|
|
compareFaceSyncInfo.setErrorMsg("facePP called failed : " + facePPResult.toString());
|