Przeglądaj źródła

Merge branch 'dev'
1

wangliang 4 lat temu
rodzic
commit
a814f3fe77

+ 16 - 0
themis-business/src/main/java/com/qmth/themis/business/cache/ExamRecordCacheUtil.java

@@ -392,6 +392,10 @@ public class ExamRecordCacheUtil {
         redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorRandom", multipleFaceCountErrorRandom);
     }
 
+    public static void setRealnessErrorRandom(Long recordId, String realnessErrorRandom) {
+        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "realnessErrorRandom", realnessErrorRandom);
+    }
+
     public static void setNoFaceCountErrorRandom(Long recordId, String noFaceCountErrorRandom) {
         redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "noFaceCountErrorRandom", noFaceCountErrorRandom);
     }
@@ -420,6 +424,10 @@ public class ExamRecordCacheUtil {
         redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "eyeCloseErrorNum", eyeCloseErrorNum);
     }
 
+    public static void setRealnessErrorNum(Long recordId, Integer realnessErrorNum) {
+        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "realnessErrorNum", realnessErrorNum);
+    }
+
     public static String getMultipleFaceCountErrorRandom(Long recordId) {
         return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorRandom");
     }
@@ -436,6 +444,10 @@ public class ExamRecordCacheUtil {
         return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "eyeCloseErrorRandom");
     }
 
+    public static String getRealnessErrorRandom(Long recordId) {
+        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "realnessErrorRandom");
+    }
+
     public static Integer getMultipleFaceCountErrorNum(Long recordId) {
         return Objects.nonNull(redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorNum")) ? (Integer) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorNum") : 0;
     }
@@ -452,6 +464,10 @@ public class ExamRecordCacheUtil {
         return Objects.nonNull(redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "eyeCloseErrorNum")) ? (Integer) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "eyeCloseErrorNum") : 0;
     }
 
+    public static Integer getRealnessErrorNum(Long recordId) {
+        return Objects.nonNull(redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "realnessErrorNum")) ? (Integer) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "realnessErrorNum") : 0;
+    }
+
     public static Integer getHasAnswerFile(Long recordId) {
         return (Integer) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), ExamRecordFieldEnum.has_answer_file.getCode());
     }

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java

@@ -180,7 +180,9 @@ public class WarningServiceImpl implements WarningService {
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
         QueryWrapper<TOeFaceVerifyHistory> tOeFaceVerifyHistoryQueryWrapper = new QueryWrapper<>();
-        tOeFaceVerifyHistoryQueryWrapper.lambda().eq(TOeFaceVerifyHistory::getExamRecordId, recordId).eq(TOeFaceVerifyHistory::getException, warningEnum.name());
+        tOeFaceVerifyHistoryQueryWrapper.lambda().eq(TOeFaceVerifyHistory::getExamRecordId, recordId)
+                .eq(TOeFaceVerifyHistory::getException, warningEnum.name())
+                .eq(TOeFaceVerifyHistory::getBatchNo, warningDto.getRandom());
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         int count = faceVerifyHistoryService.count(tOeFaceVerifyHistoryQueryWrapper);
         if (count > teConfig.getRealnessCount()) {

+ 20 - 6
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -347,7 +347,24 @@ public class MqLogicServiceImpl implements MqLogicService {
             VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
             WarningDto warningDto = new WarningDto(warningEnum, faceCount, realness, recordId, photoUrl);
             if (Objects.equals(VerifyExceptionEnum.NONE, warningEnum)) {//无异常,往考生日志表里插一条
-                faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
+                if (Objects.nonNull(realness) && realness.intValue() == 0) {//真实性异常
+                    String realnessErrorRandom = ExamRecordCacheUtil.getRealnessErrorRandom(recordId);
+                    if (Objects.isNull(realnessErrorRandom)) {
+                        realnessErrorRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                        ExamRecordCacheUtil.setRealnessErrorRandom(recordId, realnessErrorRandom);
+                    }
+                    ExamRecordCacheUtil.setRealnessErrorNum(recordId, ExamRecordCacheUtil.getRealnessErrorNum(recordId) + 1);
+                    warningDto.setRandom(realnessErrorRandom);
+                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, realnessErrorRandom);
+                    Integer count = ExamRecordCacheUtil.getRealnessErrorNum(recordId);
+                    if (count > teConfig.getRealnessCount()) {
+                        ExamRecordCacheUtil.setRealnessErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
+                        ExamRecordCacheUtil.setRealnessErrorNum(recordId, 0);
+                        warningService.realnessError(warningDto);
+                    }
+                } else {
+                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
+                }
             } else {
                 if (Objects.equals(VerifyExceptionEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
                     if (faceCount > 1) {//多张人脸
@@ -389,7 +406,7 @@ public class MqLogicServiceImpl implements MqLogicService {
                     }
                     ExamRecordCacheUtil.setFaceCompareErrorNum(recordId, ExamRecordCacheUtil.getFaceCompareErrorNum(recordId) + 1);
                     warningDto.setRandom(faceCompareErrorRandom);
-                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
+                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, faceCompareErrorRandom);
                     Integer count = ExamRecordCacheUtil.getFaceCompareErrorNum(recordId);
                     if (count > teConfig.getTotalFaceCompareErrorCount()) {
                         ExamRecordCacheUtil.setFaceCompareErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
@@ -404,16 +421,13 @@ public class MqLogicServiceImpl implements MqLogicService {
                     }
                     ExamRecordCacheUtil.setEyeCloseErrorNum(recordId, ExamRecordCacheUtil.getEyeCloseErrorNum(recordId) + 1);
                     warningDto.setRandom(eyeCloseErrorRandom);
-                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
+                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, eyeCloseErrorRandom);
                     Integer count = ExamRecordCacheUtil.getEyeCloseErrorNum(recordId);
                     if (count > teConfig.getTotalEyeCloseErrorCount()) {
                         ExamRecordCacheUtil.setEyeCloseErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
                         ExamRecordCacheUtil.setEyeCloseErrorNum(recordId, 0);
                         warningService.eyeCloseError(warningDto);
                     }
-                } else {
-                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
-                    warningService.realnessError(warningDto);
                 }
             }
         } else {