|
@@ -7,10 +7,15 @@ 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.ExamRecordDataService;
|
|
|
import cn.com.qmth.examcloud.core.oe.student.service.FaceProcessService;
|
|
|
import cn.com.qmth.examcloud.support.Constants;
|
|
|
+import cn.com.qmth.examcloud.support.enums.ExamRecordStatus;
|
|
|
+import cn.com.qmth.examcloud.support.examing.ExamRecordData;
|
|
|
import cn.com.qmth.examcloud.web.redis.RedisClient;
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
+import org.json.JSONArray;
|
|
|
+import org.json.JSONException;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
@@ -24,6 +29,9 @@ public class FaceProcessServiceImpl implements FaceProcessService {
|
|
|
|
|
|
private static final Logger log = LoggerFactory.getLogger(FaceProcessServiceImpl.class);
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ExamRecordDataService examRecordDataService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private ExamCaptureRepo examCaptureRepo;
|
|
|
|
|
@@ -55,6 +63,13 @@ public class FaceProcessServiceImpl implements FaceProcessService {
|
|
|
Check.isNull(req.getPass(), "人脸比对是否通过不能为空");
|
|
|
Check.isBlank(req.getFileUrl(), "图片地址不能为空");
|
|
|
|
|
|
+ ExamRecordData examRecordData = examRecordDataService.getExamRecordDataCache(req.getExamRecordDataId());
|
|
|
+ if (examRecordData == null || ExamRecordStatus.EXAM_ING != examRecordData.getExamRecordStatus()) {
|
|
|
+ // 考试记录无效
|
|
|
+ log.warn("Skip saveFaceCaptureResult... examRecordDataId = {}", req.getExamRecordDataId());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+
|
|
|
ExamCaptureEntity entity = new ExamCaptureEntity();
|
|
|
entity.setExamRecordDataId(req.getExamRecordDataId());
|
|
|
entity.setIsPass(req.getPass());
|
|
@@ -68,6 +83,19 @@ public class FaceProcessServiceImpl implements FaceProcessService {
|
|
|
entity.setUsedTime(req.getProcessTime() != null ? req.getProcessTime() : 1L);
|
|
|
entity.setExtMsg(req.getExtMsg());
|
|
|
|
|
|
+ try {
|
|
|
+ // 校验虚拟摄像头格式,必须是Json数组,如果格式不正确,则置为null
|
|
|
+ if (StringUtils.isNotEmpty(req.getCameraInfos())) {
|
|
|
+ JSONArray jsonArray = new JSONArray(req.getCameraInfos());
|
|
|
+ if (jsonArray.length() == 0) {
|
|
|
+ req.setCameraInfos(null);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } catch (JSONException e) {
|
|
|
+ req.setCameraInfos(null);
|
|
|
+ log.error("虚拟摄像头信息格式不正确!" + e.getMessage());
|
|
|
+ }
|
|
|
+
|
|
|
if (StringUtils.length(req.getCameraInfos()) >= Constants.VM_CAMERA_SIZE_LIMIT) {
|
|
|
entity.setCameraInfos(Constants.VM_CAMERA_WARN);
|
|
|
log.warn("虚拟摄像头信息超长! " + req.getExamRecordDataId());
|