|
@@ -3,10 +3,14 @@ package cn.com.qmth.examcloud.core.oe.student.service.impl;
|
|
|
import cn.com.qmth.examcloud.commons.util.FileUtil;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.base.bean.CompareFaceSyncInfo;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.base.utils.Check;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.bean.FaceCaptureResult;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.bean.FaceCompareResult;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.dao.ExamCaptureRepo;
|
|
|
+import cn.com.qmth.examcloud.core.oe.student.dao.entity.ExamCaptureEntity;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.FaceProcessService;
|
|
|
import cn.com.qmth.examcloud.support.Constants;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -20,6 +24,9 @@ public class FaceProcessServiceImpl implements FaceProcessService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(FaceProcessServiceImpl.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExamCaptureRepo examCaptureRepo;
|
|
|
+
|
|
|
@Autowired
|
|
|
private RedisClient redisClient;
|
|
|
|
|
@@ -30,15 +37,45 @@ public class FaceProcessServiceImpl implements FaceProcessService {
|
|
|
Check.isBlank(req.getFileUrl(), "图片地址不能为空");
|
|
|
|
|
|
CompareFaceSyncInfo info = new CompareFaceSyncInfo();
|
|
|
+ info.setStudentId(req.getStudentId());
|
|
|
info.setIsPass(req.getPass());
|
|
|
info.setIsStranger(req.getStranger());
|
|
|
- info.setStudentId(req.getStudentId());
|
|
|
- info.setProcessTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
|
|
|
info.setFileName(FileUtil.getFileName(req.getFileUrl()));
|
|
|
info.setFileUrl(req.getFileUrl());
|
|
|
info.setFaceCompareResult(req.getFaceCompareResult());
|
|
|
+ info.setProcessTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
|
|
|
|
|
|
redisClient.set(Constants.FACE_SYNC_COMPARE_RESULT_PREFIX + req.getStudentId(), info, 5 * 60);
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void saveFaceCaptureResult(FaceCaptureResult req) {
|
|
|
+ Check.isNull(req.getStudentId(), "学生ID不能为空");
|
|
|
+ Check.isNull(req.getExamRecordDataId(), "考试记录ID不能为空");
|
|
|
+ Check.isNull(req.getPass(), "人脸比对是否通过不能为空");
|
|
|
+ Check.isBlank(req.getFileUrl(), "图片地址不能为空");
|
|
|
+
|
|
|
+ ExamCaptureEntity entity = new ExamCaptureEntity();
|
|
|
+ entity.setExamRecordDataId(req.getExamRecordDataId());
|
|
|
+ entity.setIsPass(req.getPass());
|
|
|
+ entity.setIsStranger(req.getStranger());
|
|
|
+ entity.setHasVirtualCamera(req.getHasVirtualCamera());
|
|
|
+ entity.setFileName(FileUtil.getFileName(req.getFileUrl()));
|
|
|
+ entity.setFileUrl(req.getFileUrl());
|
|
|
+ entity.setFaceCompareResult(req.getFaceCompareResult());
|
|
|
+ entity.setFacelivenessResult(req.getFacelivenessResult());
|
|
|
+ entity.setProcessTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
|
|
|
+ entity.setUsedTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
|
|
|
+ entity.setExtMsg(req.getExtMsg());
|
|
|
+
|
|
|
+ if (StringUtils.length(req.getCameraInfos()) >= Constants.VM_CAMERA_SIZE_LIMIT) {
|
|
|
+ entity.setCameraInfos(Constants.VM_CAMERA_WARN);
|
|
|
+ log.warn("虚拟摄像头信息超长! " + req.getExamRecordDataId());
|
|
|
+ } else {
|
|
|
+ entity.setCameraInfos(req.getCameraInfos());
|
|
|
+ }
|
|
|
+
|
|
|
+ examCaptureRepo.save(entity);
|
|
|
+ }
|
|
|
+
|
|
|
}
|