|
@@ -1,18 +1,18 @@
|
|
|
package com.qmth.themis.business.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
|
+import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
|
|
|
import com.qmth.themis.business.dto.WarningDto;
|
|
|
import com.qmth.themis.business.entity.TEConfig;
|
|
|
+import com.qmth.themis.business.entity.TEExamStudentLog;
|
|
|
import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
|
|
|
import com.qmth.themis.business.entity.TOeFaceVerifyHistory;
|
|
|
import com.qmth.themis.business.enums.VerifyExceptionEnum;
|
|
|
import com.qmth.themis.business.enums.WarningLevelEnum;
|
|
|
-import com.qmth.themis.business.service.TEConfigService;
|
|
|
-import com.qmth.themis.business.service.TIeInvigilateWarnInfoService;
|
|
|
-import com.qmth.themis.business.service.TOeFaceVerifyHistoryService;
|
|
|
-import com.qmth.themis.business.service.WarningService;
|
|
|
+import com.qmth.themis.business.service.*;
|
|
|
import com.qmth.themis.business.util.RedisUtil;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -20,8 +20,7 @@ import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.Map;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
|
|
|
/**
|
|
|
* @Description: 预警规则公用
|
|
@@ -46,6 +45,12 @@ public class WarningServiceImpl implements WarningService {
|
|
|
@Resource
|
|
|
TIeInvigilateWarnInfoService tIeInvigilateWarnInfoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEExamStudentLogService teExamStudentLogService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ TEExamStudentService teExamStudentService;
|
|
|
+
|
|
|
/**
|
|
|
* 人脸数量异常
|
|
|
*
|
|
@@ -62,21 +67,40 @@ public class WarningServiceImpl implements WarningService {
|
|
|
Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
if (faceCount > 1) {//多张人脸
|
|
|
- Integer count = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, true);
|
|
|
- count = Objects.isNull(count) ? 0 : count;
|
|
|
- if (count >= teConfig.getMultipleFaceCountError()) {
|
|
|
- TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(1), WarningLevelEnum.valueOf(warningEnum.getLevel().get(1)).getDesc(), warningEnum, photoUrl);
|
|
|
- tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
- this.setWarningCount(recordId);
|
|
|
+ Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, true);
|
|
|
+ if (Objects.nonNull(map) && map.size() > 0) {
|
|
|
+ Integer count = Integer.parseInt(String.valueOf(map.get("tmpCount")));
|
|
|
+ count = Objects.isNull(count) ? 0 : count;
|
|
|
+ if (count >= teConfig.getMultipleFaceCountError()) {
|
|
|
+ List photoUrls = null;
|
|
|
+ if (Objects.nonNull(map.get("photoUrls")) && !Objects.equals(map.get("photoUrls"), "")) {
|
|
|
+ photoUrls = Arrays.asList(String.valueOf(map.get("photoUrls")).split(","));
|
|
|
+ }
|
|
|
+ if (Objects.isNull(photoUrls)) {
|
|
|
+ photoUrls = new ArrayList();
|
|
|
+ }
|
|
|
+ photoUrls.add(photoUrl);
|
|
|
+ JSONObject jsonObject = new JSONObject();
|
|
|
+ jsonObject.put("PHOTOS", photoUrls);
|
|
|
+ TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(1), WarningLevelEnum.valueOf(warningEnum.getLevel().get(1)).getDesc(), warningEnum, photoUrl);
|
|
|
+ tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
+ TEExamStudentLog teExamStudentLog = new TEExamStudentLog(tIeInvigilateWarnInfo.getType().name(), tIeInvigilateWarnInfo.getType().getCode(), jsonObject.toJSONString(), examStudentCacheBean.getStudentId(), examStudentCacheBean.getId(), recordId);
|
|
|
+ teExamStudentLogService.saveOrUpdate(teExamStudentLog);
|
|
|
+ this.setWarningCount(recordId);
|
|
|
+ }
|
|
|
}
|
|
|
} else if (faceCount <= 0) {//未检测到人脸
|
|
|
- Integer count = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, false);
|
|
|
- count = Objects.isNull(count) ? 0 : count;
|
|
|
- if (count >= teConfig.getNoFaceCountError()) {
|
|
|
- TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(0), WarningLevelEnum.valueOf(warningEnum.getLevel().get(0)).getDesc(), warningEnum, photoUrl);
|
|
|
- tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
- this.setWarningCount(recordId);
|
|
|
+ Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, false);
|
|
|
+ if (Objects.nonNull(map) && map.size() > 0) {
|
|
|
+ Integer count = (Integer) map.get("tmpCount");
|
|
|
+ count = Objects.isNull(count) ? 0 : count;
|
|
|
+ if (count >= teConfig.getNoFaceCountError()) {
|
|
|
+ TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(0), WarningLevelEnum.valueOf(warningEnum.getLevel().get(0)).getDesc(), warningEnum, photoUrl);
|
|
|
+ tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
+ this.setWarningCount(recordId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -96,17 +120,20 @@ public class WarningServiceImpl implements WarningService {
|
|
|
Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
|
- Integer count = faceVerifyHistoryService.faceCompareError(recordId, warningDto.getWarningEnum().name());
|
|
|
- count = Objects.isNull(count) ? 0 : count;
|
|
|
- if (count >= teConfig.getMatchFaceCompareErrorCount()) {
|
|
|
- TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(0), WarningLevelEnum.valueOf(warningEnum.getLevel().get(0)).getDesc(), warningEnum, photoUrl);
|
|
|
- tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
- this.setWarningCount(recordId);
|
|
|
- }
|
|
|
- if (count >= teConfig.getTotalFaceCompareErrorCount()) {
|
|
|
- TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(1), WarningLevelEnum.valueOf(warningEnum.getLevel().get(1)).getDesc(), warningEnum, photoUrl);
|
|
|
- tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
- this.setWarningCount(recordId);
|
|
|
+ Map<String, Object> map = faceVerifyHistoryService.faceCompareError(recordId, warningDto.getWarningEnum().name());
|
|
|
+ if (Objects.nonNull(map) && map.size() > 0) {
|
|
|
+ Integer count = (Integer) map.get("tmpCount");
|
|
|
+ count = Objects.isNull(count) ? 0 : count;
|
|
|
+ if (count >= teConfig.getMatchFaceCompareErrorCount()) {
|
|
|
+ TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(0), WarningLevelEnum.valueOf(warningEnum.getLevel().get(0)).getDesc(), warningEnum, photoUrl);
|
|
|
+ tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
+ this.setWarningCount(recordId);
|
|
|
+ }
|
|
|
+ if (count >= teConfig.getTotalFaceCompareErrorCount()) {
|
|
|
+ TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, warningEnum.getLevel().get(1), WarningLevelEnum.valueOf(warningEnum.getLevel().get(1)).getDesc(), warningEnum, photoUrl);
|
|
|
+ tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
|
|
|
+ this.setWarningCount(recordId);
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|