Kaynağa Gözat

活体验证逻辑修改

wangliang 2 yıl önce
ebeveyn
işleme
66391b030c

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

@@ -756,6 +756,12 @@ public class ExamRecordCacheUtil {
         }
     }
 
+    public static void setLivenessActionErrorRandom(Long recordId, String livenessActionErrorRandom) {
+        if (Objects.nonNull(getId(recordId))) {
+            redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "livenessActionErrorRandom", livenessActionErrorRandom);
+        }
+    }
+
     public static void setNoFaceCountErrorRandom(Long recordId, String noFaceCountErrorRandom) {
         if (Objects.nonNull(getId(recordId))) {
             redisUtil
@@ -827,6 +833,10 @@ public class ExamRecordCacheUtil {
         return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "realnessErrorRandom");
     }
 
+    public static String getLivenessActionErrorRandom(Long recordId) {
+        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "livenessActionErrorRandom");
+    }
+
     public static AtomicInteger getMultipleFaceCountErrorNum(Long recordId) {
         return Objects
                 .nonNull(redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorNum")) ?

+ 1 - 1
themis-business/src/main/java/com/qmth/themis/business/dao/TOeLivenessVerifyHistoryMapper.java

@@ -18,5 +18,5 @@ import java.util.Map;
 public interface TOeLivenessVerifyHistoryMapper extends BaseMapper<TOeLivenessVerifyHistory> {
 
     @SuppressWarnings("MybatisXMapperMethodInspection")
-    public Map<String, Object> livenessActionError(@Param("recordId") Long recordId, @Param("exception") String exception, @Param("type") String type);
+    public Map<String, Object> livenessActionError(@Param("recordId") Long recordId, @Param("exception") String exception, @Param("type") String type, @Param("batchNo") String batchNo);
 }

+ 2 - 1
themis-business/src/main/java/com/qmth/themis/business/service/TOeLivenessVerifyHistoryService.java

@@ -28,7 +28,8 @@ public interface TOeLivenessVerifyHistoryService extends IService<TOeLivenessVer
      * @param recordId
      * @param exception
      * @param type
+     * @param batchNo
      * @return
      */
-    public Map<String, Object> livenessActionError(Long recordId, String exception, String type);
+    public Map<String, Object> livenessActionError(Long recordId, String exception, String type, String batchNo);
 }

+ 5 - 4
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeLivenessVerifyHistoryServiceImpl.java

@@ -44,7 +44,7 @@ public class TOeLivenessVerifyHistoryServiceImpl
 
     @Override
     public LivenessVerifyBean verify(Long recordId, String type, String actions, Integer retry, Long startTime,
-            Long finishTime, String exception) {
+                                     Long finishTime, String exception) {
         LivenessVerifyCacheBean cache = new LivenessVerifyCacheBean();
         cache.setId(uidUtil.getId());
         cache.setExamRecordId(recordId);
@@ -69,7 +69,7 @@ public class TOeLivenessVerifyHistoryServiceImpl
     @Transactional
     @Override
     public void save(Long id, Long recordId, String type, String actions, Integer retry, Long startTime,
-            Long finishTime, String exception, String batchNo) {
+                     Long finishTime, String exception, String batchNo) {
         TOeLivenessVerifyHistory entity = new TOeLivenessVerifyHistory();
         entity.setId(id);
         entity.setExamRecordId(recordId);
@@ -89,10 +89,11 @@ public class TOeLivenessVerifyHistoryServiceImpl
      * @param recordId
      * @param exception
      * @param type
+     * @param batchNo
      * @return
      */
     @Override
-    public Map<String, Object> livenessActionError(Long recordId, String exception, String type) {
-        return tOeLivenessVerifyHistoryMapper.livenessActionError(recordId, exception, type);
+    public Map<String, Object> livenessActionError(Long recordId, String exception, String type, String batchNo) {
+        return tOeLivenessVerifyHistoryMapper.livenessActionError(recordId, exception, type, batchNo);
     }
 }

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

@@ -219,7 +219,6 @@ public class WarningServiceImpl implements WarningService {
     @Transactional
     public void livenessActionError(WarningDto warningDto) {
         Long recordId = warningDto.getRecordId();
-        VerifyExceptionEnum warningEnum = warningDto.getWarningEnum();
         String photoUrl = warningDto.getPhotoUrl();
         Long examId = ExamRecordCacheUtil.getExamId(recordId);
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
@@ -231,7 +230,7 @@ public class WarningServiceImpl implements WarningService {
             examActivityId = tOeExamRecord.getExamActivityId();
         }
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
-        Map<String, Object> map = tOeLivenessVerifyHistoryService.livenessActionError(recordId, warningDto.getWarningEnum().name(), ExamTypeEnum.IN_PROCESS.name());
+        Map<String, Object> map = tOeLivenessVerifyHistoryService.livenessActionError(recordId, warningDto.getWarningEnum().name(), ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
         if (Objects.nonNull(map) && map.size() > 0) {
             TIeInvigilateWarnInfo tIeInvigilateWarnInfo = new TIeInvigilateWarnInfo(examId, examActivityId, recordId, examStudentId, VerifyExceptionEnum.LIVENESS_ACTION_ERROR.getLevel().get(0), VerifyExceptionEnum.LIVENESS_ACTION_ERROR.getTitle(), VerifyExceptionEnum.LIVENESS_ACTION_ERROR, photoUrl, Objects.nonNull(ExamRecordCacheUtil.getBreachStatus(recordId)) ? ExamRecordCacheUtil.getBreachStatus(recordId) : 1);
             tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);

+ 6 - 3
themis-business/src/main/resources/mapper/TOeLivenessVerifyHistoryMapper.xml

@@ -12,12 +12,12 @@
         select
         CONVERT((tolvh.actions->>'$.faceCount')
         USING utf8) as faceCount, tolvh.`exception`,
-        CONVERT((tolvh.actions->>'$.photoUrl')
-        USING utf8) as photoUrl,tolvh.create_time
+        REPLACE(REPLACE(substring_index(substring_index(CONVERT((tolvh.actions->>'$[*].photoUrl')
+        USING utf8), ']', 1), '[',-1),' "','"'),'"','') as photoUrl,tolvh.create_time
         from
         (
         select
-        tolvh.actions->>'$[0]' as actions,
+        tolvh.actions->>'$[*]' as actions,
         tolvh.`exception`,
         tolvh.create_time
         from
@@ -32,6 +32,9 @@
             <if test="type != null and type != ''">
                 and tolvh.`type` = #{type}
             </if>
+            <if test="batchNo != null and batchNo != ''">
+                and tolvh.batch_no = #{batchNo}
+            </if>
         </where>
         ) tolvh
         ) t

+ 12 - 16
themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java

@@ -580,23 +580,19 @@ public class MqLogicServiceImpl implements MqLogicService {
             }
         } else if (Objects.equals(type.toUpperCase(), ExamTypeEnum.IN_PROCESS.name())) {
             VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
-            JSONArray jsonArray = JSONArray.parseArray(actions);
-            for (int i = 0; i < jsonArray.size(); i++) {
-                JSONObject jsonObject = jsonArray.getJSONObject(i);
-                if (Objects.equals(VerifyExceptionEnum.NONE, warningEnum)) {//无异常,往考生日志表里插一条
-                    livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);
-                } else {
-                    if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum) || Objects.equals(VerifyExceptionEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
-                        Integer faceCount = Integer.parseInt(String.valueOf(jsonObject.get("faceCount")));
-                        WarningDto warningDto = new WarningDto(warningEnum, faceCount, null, recordId, String.valueOf(jsonObject.get("photoUrl")));
-                        livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);
-                        warningService.livenessActionError(warningDto);
-                    } else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum) || Objects.equals(VerifyExceptionEnum.LIVENESS_ACTION_ERROR, warningEnum)) {//活检动作错误
-                        WarningDto warningDto = new WarningDto(warningEnum, null, null, recordId, String.valueOf(jsonObject.get("photoUrl")));
-                        livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);
-                        warningService.livenessActionError(warningDto);
-                    }
+            if (Objects.equals(VerifyExceptionEnum.NONE, warningEnum)) {//无异常,往考生日志表里插一条
+                livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);
+            } else {
+                String livenessActionErrorRandom = ExamRecordCacheUtil.getLivenessActionErrorRandom(recordId);
+                if (Objects.isNull(livenessActionErrorRandom)) {
+                    livenessActionErrorRandom = SystemConstant.getNanoId();
+                    ExamRecordCacheUtil.setLivenessActionErrorRandom(recordId, livenessActionErrorRandom);
                 }
+                WarningDto warningDto = new WarningDto(warningEnum, null, null, recordId, null);
+                warningDto.setRandom(livenessActionErrorRandom);
+                livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, livenessActionErrorRandom);
+                ExamRecordCacheUtil.setLivenessActionErrorRandom(recordId, SystemConstant.getNanoId());
+                warningService.livenessActionError(warningDto);
             }
         } else {
             livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);