|
@@ -8,6 +8,7 @@ import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamCaptureQueueEntity;
|
|
import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamCaptureQueueStatus;
|
|
import cn.com.qmth.examcloud.core.oe.student.dao.enums.ExamCaptureQueueStatus;
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamCaptureQueueService;
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamCaptureQueueService;
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
|
|
import cn.com.qmth.examcloud.core.oe.task.service.ExamRecordDataService;
|
|
|
|
+import cn.com.qmth.examcloud.core.oe.task.service.bean.FaceApiParam;
|
|
import cn.com.qmth.examcloud.starters.face.verify.common.CommonUtils;
|
|
import cn.com.qmth.examcloud.starters.face.verify.common.CommonUtils;
|
|
import cn.com.qmth.examcloud.starters.face.verify.common.FaceVerifyException;
|
|
import cn.com.qmth.examcloud.starters.face.verify.common.FaceVerifyException;
|
|
import cn.com.qmth.examcloud.starters.face.verify.model.FaceResult;
|
|
import cn.com.qmth.examcloud.starters.face.verify.model.FaceResult;
|
|
@@ -60,7 +61,7 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
private OssClient ossClient;
|
|
private OssClient ossClient;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void handlerExamCaptureQueuesByExamRecordDataId(Long examRecordDataId) throws Exception {
|
|
|
|
|
|
+ public void handlerExamCaptureQueuesByExamRecordDataId(Long examRecordDataId, FaceApiParam param) throws Exception {
|
|
// 每个考试记录ID下通常只有几条待处理抓拍记录,直接取所有一次性处理。
|
|
// 每个考试记录ID下通常只有几条待处理抓拍记录,直接取所有一次性处理。
|
|
List<ExamCaptureQueueEntity> queues = examCaptureQueueRepo.findByExamRecordDataId(examRecordDataId);
|
|
List<ExamCaptureQueueEntity> queues = examCaptureQueueRepo.findByExamRecordDataId(examRecordDataId);
|
|
if (CollectionUtils.isEmpty(queues)) {
|
|
if (CollectionUtils.isEmpty(queues)) {
|
|
@@ -77,17 +78,21 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
// 获取学校人脸API方案配置
|
|
// 获取学校人脸API方案配置
|
|
boolean useBaiduApi = false;
|
|
boolean useBaiduApi = false;
|
|
Double baiduExpectFaceCompareScore = null;
|
|
Double baiduExpectFaceCompareScore = null;
|
|
- OrgPropertyCacheBean property1 = CacheHelper.getOrgProperty(studentCache.getRootOrgId(), Constants.FACE_COMPARE_API_PROVIDER);
|
|
|
|
|
|
+ OrgPropertyCacheBean property1 = CacheHelper.getOrgProperty(studentCache.getRootOrgId(),
|
|
|
|
+ Constants.FACE_COMPARE_API_PROVIDER);
|
|
if (property1.getHasValue() && FaceApiProvider.BAIDU.name().equals(property1.getValue())) {
|
|
if (property1.getHasValue() && FaceApiProvider.BAIDU.name().equals(property1.getValue())) {
|
|
useBaiduApi = true;
|
|
useBaiduApi = true;
|
|
}
|
|
}
|
|
- OrgPropertyCacheBean property2 = CacheHelper.getOrgProperty(studentCache.getRootOrgId(), Constants.BAIDU_EXPECT_FACE_COMPARE_SCORE);
|
|
|
|
|
|
+ OrgPropertyCacheBean property2 = CacheHelper.getOrgProperty(studentCache.getRootOrgId(),
|
|
|
|
+ Constants.BAIDU_EXPECT_FACE_COMPARE_SCORE);
|
|
if (property2.getHasValue() && StringUtils.isNotEmpty(property2.getValue())) {
|
|
if (property2.getHasValue() && StringUtils.isNotEmpty(property2.getValue())) {
|
|
baiduExpectFaceCompareScore = Double.parseDouble(property2.getValue());
|
|
baiduExpectFaceCompareScore = Double.parseDouble(property2.getValue());
|
|
}
|
|
}
|
|
|
|
|
|
- log.warn("studentId:{} examRecordDataId:{} todoCaptureQueueSize:{} api:{} {}", studentId, examRecordDataId,
|
|
|
|
- queues.size(), useBaiduApi ? "baidu" : "face++", baiduExpectFaceCompareScore);
|
|
|
|
|
|
+ log.warn(
|
|
|
|
+ "studentId:{} examRecordDataId:{} todoSize:{} useBaiduApi:{} useLocalBaiduApiForFaceLiveness:{} useLocalBaiduApiForFaceCompare:{} expectScore:{}",
|
|
|
|
+ studentId, examRecordDataId, queues.size(), useBaiduApi, param.isUseLocalBaiduApiForFaceLiveness(),
|
|
|
|
+ param.isUseLocalBaiduApiForFaceCompare(), baiduExpectFaceCompareScore);
|
|
|
|
|
|
// 将学生底照图片转成Base64格式
|
|
// 将学生底照图片转成Base64格式
|
|
ImageParm basePhoto;
|
|
ImageParm basePhoto;
|
|
@@ -108,8 +113,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
String capturePhotoUrl = ossClient.valueOfOssFilePath(FileStorageUtil.realPath(queue.getFileUrl()));
|
|
String capturePhotoUrl = ossClient.valueOfOssFilePath(FileStorageUtil.realPath(queue.getFileUrl()));
|
|
if (StringUtils.isBlank(capturePhotoUrl)) {
|
|
if (StringUtils.isBlank(capturePhotoUrl)) {
|
|
// 删除错误无效数据
|
|
// 删除错误无效数据
|
|
- log.warn("人脸抓拍图片地址错误!examRecordDataId:{} queueId:{} imgUrl:{}",
|
|
|
|
- queue.getExamRecordDataId(), queue.getId(), queue.getFileUrl());
|
|
|
|
|
|
+ log.warn("人脸抓拍图片地址错误!examRecordDataId:{} queueId:{} imgUrl:{}", queue.getExamRecordDataId(),
|
|
|
|
+ queue.getId(), queue.getFileUrl());
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -118,8 +123,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
ImageParm capturePhoto = new ImageBase64Parm(Base64.encodeBase64String(capturePhotoBytes));
|
|
ImageParm capturePhoto = new ImageBase64Parm(Base64.encodeBase64String(capturePhotoBytes));
|
|
if (StringUtils.isBlank(capturePhoto.value())) {
|
|
if (StringUtils.isBlank(capturePhoto.value())) {
|
|
// 删除错误无效数据
|
|
// 删除错误无效数据
|
|
- log.warn("人脸抓拍图片为空白!examRecordDataId:{} queueId:{} imgUrl:{}",
|
|
|
|
- queue.getExamRecordDataId(), queue.getId(), queue.getFileUrl());
|
|
|
|
|
|
+ log.warn("人脸抓拍图片为空白!examRecordDataId:{} queueId:{} imgUrl:{}", queue.getExamRecordDataId(),
|
|
|
|
+ queue.getId(), queue.getFileUrl());
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -135,7 +140,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
|
|
|
FaceResult faceCompareResult;
|
|
FaceResult faceCompareResult;
|
|
if (useBaiduApi) {
|
|
if (useBaiduApi) {
|
|
- faceCompareResult = faceVerifyService.faceCompareByBaidu(basePhoto, capturePhoto, baiduExpectFaceCompareScore);
|
|
|
|
|
|
+ faceCompareResult = faceVerifyService.faceCompareByBaidu(basePhoto, capturePhoto,
|
|
|
|
+ baiduExpectFaceCompareScore, param.isUseLocalBaiduApiForFaceCompare());
|
|
} else {
|
|
} else {
|
|
faceCompareResult = faceVerifyService.faceCompareByFacePlus(basePhoto, capturePhoto);
|
|
faceCompareResult = faceVerifyService.faceCompareByFacePlus(basePhoto, capturePhoto);
|
|
}
|
|
}
|
|
@@ -161,10 +167,12 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
}
|
|
}
|
|
} else if (faceCompareResult.getFaceNum() > 1) {
|
|
} else if (faceCompareResult.getFaceNum() > 1) {
|
|
// 是否启用陌生人检测
|
|
// 是否启用陌生人检测
|
|
- ExamRecordData examRecordDataCache = examRecordDataService.getExamRecordDataCache(examRecordDataId);
|
|
|
|
|
|
+ ExamRecordData examRecordDataCache = examRecordDataService.getExamRecordDataCache(
|
|
|
|
+ examRecordDataId);
|
|
if (examRecordDataCache != null) {
|
|
if (examRecordDataCache != null) {
|
|
ExamPropertyCacheBean examProperty = ExamCacheTransferHelper.getCachedExamProperty(
|
|
ExamPropertyCacheBean examProperty = ExamCacheTransferHelper.getCachedExamProperty(
|
|
- examRecordDataCache.getExamId(), studentId, ExamProperties.IS_STRANGER_ENABLE.name());
|
|
|
|
|
|
+ examRecordDataCache.getExamId(), studentId,
|
|
|
|
+ ExamProperties.IS_STRANGER_ENABLE.name());
|
|
if ("true".equalsIgnoreCase(examProperty.getValue())) {
|
|
if ("true".equalsIgnoreCase(examProperty.getValue())) {
|
|
queue.setIsStranger(true);
|
|
queue.setIsStranger(true);
|
|
}
|
|
}
|
|
@@ -177,8 +185,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
queue.setErrorMsg(e.getMessage());
|
|
queue.setErrorMsg(e.getMessage());
|
|
queue.setStatus(ExamCaptureQueueStatus.PROCESS_FACE_COMPARE_FAILED);
|
|
queue.setStatus(ExamCaptureQueueStatus.PROCESS_FACE_COMPARE_FAILED);
|
|
|
|
|
|
- log.error("人脸比对错误!examRecordDataId:{} queueId:{} errorNum:{} error:{}", queue.getExamRecordDataId(),
|
|
|
|
- queue.getId(), queue.getErrorNum(), e.getMessage());
|
|
|
|
|
|
+ log.error("人脸比对错误!examRecordDataId:{} queueId:{} errorNum:{} error:{}",
|
|
|
|
+ queue.getExamRecordDataId(), queue.getId(), queue.getErrorNum(), e.getMessage());
|
|
examCaptureQueueRepo.save(queue);
|
|
examCaptureQueueRepo.save(queue);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -191,7 +199,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
|
|
|
try {
|
|
try {
|
|
// 人脸活体检测开始
|
|
// 人脸活体检测开始
|
|
- FaceResult faceLivenessResult = faceVerifyService.faceVerifyByBaidu(capturePhoto);
|
|
|
|
|
|
+ FaceResult faceLivenessResult = faceVerifyService.faceVerifyByBaidu(capturePhoto,
|
|
|
|
+ param.isUseLocalBaiduApiForFaceLiveness());
|
|
queue.setFacelivenessResult(faceLivenessResult.getJsonResult());
|
|
queue.setFacelivenessResult(faceLivenessResult.getJsonResult());
|
|
|
|
|
|
if (faceLivenessResult.isApiNeedRetry()) {
|
|
if (faceLivenessResult.isApiNeedRetry()) {
|
|
@@ -208,8 +217,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
queue.setErrorMsg(e.getMessage());
|
|
queue.setErrorMsg(e.getMessage());
|
|
queue.setStatus(ExamCaptureQueueStatus.PROCESS_FACELIVENESS_FAILED);
|
|
queue.setStatus(ExamCaptureQueueStatus.PROCESS_FACELIVENESS_FAILED);
|
|
|
|
|
|
- log.error("人脸活体检测错误!examRecordDataId:{} queueId:{} errorNum:{} error:{}", queue.getExamRecordDataId(),
|
|
|
|
- queue.getId(), queue.getErrorNum(), e.getMessage());
|
|
|
|
|
|
+ log.error("人脸活体检测错误!examRecordDataId:{} queueId:{} errorNum:{} error:{}",
|
|
|
|
+ queue.getExamRecordDataId(), queue.getId(), queue.getErrorNum(), e.getMessage());
|
|
examCaptureQueueRepo.save(queue);
|
|
examCaptureQueueRepo.save(queue);
|
|
continue;
|
|
continue;
|
|
}
|
|
}
|
|
@@ -228,7 +237,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
if (examCaptureRepo.exists(example)) {
|
|
if (examCaptureRepo.exists(example)) {
|
|
// 照片处理结果中若已存在则以已有的数据为准,删除该队列记录
|
|
// 照片处理结果中若已存在则以已有的数据为准,删除该队列记录
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
- log.info("==>ExamCaptureQueue clear... examRecordDataId:{} fileName:{}", queue.getExamRecordDataId(), queue.getFileName());
|
|
|
|
|
|
+ log.info("==>ExamCaptureQueue clear... examRecordDataId:{} fileName:{}", queue.getExamRecordDataId(),
|
|
|
|
+ queue.getFileName());
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
|
|
@@ -262,7 +272,8 @@ public class ExamCaptureQueueServiceImpl implements ExamCaptureQueueService {
|
|
|
|
|
|
// 删除该队列记录
|
|
// 删除该队列记录
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
examCaptureQueueRepo.deleteById(queue.getId());
|
|
- log.info("-->ExamCaptureQueue clear... examRecordDataId:{} fileName:{}", queue.getExamRecordDataId(), queue.getFileName());
|
|
|
|
|
|
+ log.info("-->ExamCaptureQueue clear... examRecordDataId:{} fileName:{}", queue.getExamRecordDataId(),
|
|
|
|
+ queue.getFileName());
|
|
}
|
|
}
|
|
|
|
|
|
}
|
|
}
|