Sfoglia il codice sorgente

考试过程预警修改

wangliang 4 anni fa
parent
commit
9f64ec096a

+ 20 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TOeFaceVerifyHistoryMapper.java

@@ -3,6 +3,7 @@ package com.qmth.themis.business.dao;
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.qmth.themis.business.entity.TOeFaceVerifyHistory;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * @Description: 人脸验证记录 Mapper 接口
@@ -14,4 +15,23 @@ import org.apache.ibatis.annotations.Mapper;
 @Mapper
 public interface TOeFaceVerifyHistoryMapper extends BaseMapper<TOeFaceVerifyHistory> {
 
+    /**
+     * count人脸数量异常
+     *
+     * @param recordId
+     * @param exception
+     * @param faceCount
+     * @param multipleFace
+     * @return
+     */
+    public Integer faceCountError(@Param("recordId") Long recordId, @Param("exception") String exception, @Param("faceCount") Integer faceCount, @Param("multipleFace") Boolean multipleFace);
+
+    /**
+     * count人脸比对异常
+     *
+     * @param recordId
+     * @param exception
+     * @return
+     */
+    public Integer faceCompareError(@Param("recordId") Long recordId, @Param("exception") String exception);
 }

+ 5 - 5
themis-business/src/main/java/com/qmth/themis/business/dto/WarningDto.java

@@ -1,6 +1,6 @@
 package com.qmth.themis.business.dto;
 
-import com.qmth.themis.business.enums.WarningEnum;
+import com.qmth.themis.business.enums.VerifyExceptionEnum;
 
 import java.io.Serializable;
 
@@ -13,7 +13,7 @@ import java.io.Serializable;
  */
 public class WarningDto implements Serializable {
 
-    private WarningEnum warningEnum;//预警类型
+    private VerifyExceptionEnum warningEnum;//预警类型
     private Integer faceCount;//人脸数量,0:没有人脸,大于1:多张人脸
     private Double realness;//真实性结果,-1:没有,0:异常,1:正常
     private Long recordId;//考试记录id
@@ -22,18 +22,18 @@ public class WarningDto implements Serializable {
 
     }
 
-    public WarningDto(WarningEnum warningEnum, Integer faceCount, Double realness, Long recordId) {
+    public WarningDto(VerifyExceptionEnum warningEnum, Integer faceCount, Double realness, Long recordId) {
         this.warningEnum = warningEnum;
         this.faceCount = faceCount;
         this.realness = realness;
         this.recordId = recordId;
     }
 
-    public WarningEnum getWarningEnum() {
+    public VerifyExceptionEnum getWarningEnum() {
         return warningEnum;
     }
 
-    public void setWarningEnum(WarningEnum warningEnum) {
+    public void setWarningEnum(VerifyExceptionEnum warningEnum) {
         this.warningEnum = warningEnum;
     }
 

+ 5 - 5
themis-business/src/main/java/com/qmth/themis/business/entity/TIeInvigilateWarnInfo.java

@@ -3,7 +3,7 @@ package com.qmth.themis.business.entity;
 import com.baomidou.mybatisplus.annotation.FieldFill;
 import com.baomidou.mybatisplus.annotation.TableField;
 import com.baomidou.mybatisplus.annotation.TableId;
-import com.qmth.themis.business.enums.WarningEnum;
+import com.qmth.themis.business.enums.VerifyExceptionEnum;
 import com.qmth.themis.common.contanst.Constants;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -53,7 +53,7 @@ public class TIeInvigilateWarnInfo implements Serializable {
 
     @ApiModelProperty(value = "类别")
     @TableField(value = "type")
-    private WarningEnum type;
+    private VerifyExceptionEnum type;
 
     @ApiModelProperty(value = "备注")
     @TableField(value = "remark")
@@ -75,7 +75,7 @@ public class TIeInvigilateWarnInfo implements Serializable {
 
     }
 
-    public TIeInvigilateWarnInfo(Long examId, Long examActivityId, Long examRecordId, Long examStudentId, String level, String info, WarningEnum type) {
+    public TIeInvigilateWarnInfo(Long examId, Long examActivityId, Long examRecordId, Long examStudentId, String level, String info, VerifyExceptionEnum type) {
         this.id = Constants.idGen.next();
         this.examId = examId;
         this.examActivityId = examActivityId;
@@ -147,11 +147,11 @@ public class TIeInvigilateWarnInfo implements Serializable {
         this.level = level;
     }
 
-    public WarningEnum getType() {
+    public VerifyExceptionEnum getType() {
         return type;
     }
 
-    public void setType(WarningEnum type) {
+    public void setType(VerifyExceptionEnum type) {
         this.type = type;
     }
 

+ 25 - 8
themis-business/src/main/java/com/qmth/themis/business/enums/VerifyExceptionEnum.java

@@ -1,5 +1,8 @@
 package com.qmth.themis.business.enums;
 
+import java.util.Arrays;
+import java.util.List;
+
 /**
  * 人脸、活检验证异常
  * 
@@ -9,18 +12,32 @@ package com.qmth.themis.business.enums;
  */
 public enum VerifyExceptionEnum {
 
-	NONE("无异常"),
+	FACE_COUNT_ERROR("人脸数量异常", Arrays.asList("D4", "D8")),
+
+	FACE_COMPARE_ERROR("人脸比对异常", Arrays.asList("D6", "D14")),
+
+	EYE_CLOSE_ERROR("闭眼检测异常", Arrays.asList("-1")),
+
+	LIVENESS_ACTION_ERROR("活检动作错误", Arrays.asList("-1")),
 
-	FACE_COUNT_ERROR("人脸数量异常"), FACE_COMPARE_ERROR("人脸比对异常"), EYE_CLOSE_ERROR("闭眼检测异常"),
-	LIVENESS_ACTION_ERROR("活检动作错误");
+	NONE("无异常", Arrays.asList("-1")),
 
-	private String title;
+	REALNESS("真实性检测", Arrays.asList("D15"));
+
+	private String code;
+
+	private List<String> level;
+
+	private VerifyExceptionEnum(String code, List<String> level) {
+		this.code = code;
+		this.level = level;
+	}
 
-	private VerifyExceptionEnum(String title) {
-		this.title = title;
+	public String getCode() {
+		return code;
 	}
 
-	public String getTitle() {
-		return title;
+	public List<String> getLevel() {
+		return level;
 	}
 }

+ 0 - 46
themis-business/src/main/java/com/qmth/themis/business/enums/WarningEnum.java

@@ -1,46 +0,0 @@
-package com.qmth.themis.business.enums;
-
-import com.google.common.collect.Maps;
-
-import java.util.Arrays;
-import java.util.List;
-import java.util.Objects;
-
-/**
- * @Description: 预警类型 enum
- * @Param:
- * @return:
- * @Author: wangliang
- * @Date: 2020/7/29
- */
-public enum WarningEnum {
-
-    FACE_COUNT_ERROR("人脸数量异常", Arrays.asList("D4", "D8")),
-
-    FACE_COMPARE_ERROR("人脸比对异常", Arrays.asList("D6", "D14")),
-
-    EYE_CLOSE_ERROR("闭眼检测异常", Arrays.asList("-1")),
-
-    LIVENESS_ACTION_ERROR("活检动作错误", Arrays.asList("-1")),
-
-    NONE("无异常", Arrays.asList("-1")),
-
-    REALNESS("真实性检测", Arrays.asList("D15"));
-
-    private String code;
-
-    private List<String> level;
-
-    private WarningEnum(String code, List<String> level) {
-        this.code = code;
-        this.level = level;
-    }
-
-    public String getCode() {
-        return code;
-    }
-
-    public List<String> getLevel() {
-        return level;
-    }
-}

+ 24 - 4
themis-business/src/main/java/com/qmth/themis/business/service/TOeFaceVerifyHistoryService.java

@@ -13,9 +13,29 @@ import com.qmth.themis.business.entity.TOeFaceVerifyHistory;
  */
 public interface TOeFaceVerifyHistoryService extends IService<TOeFaceVerifyHistory> {
 
-	FaceVerifyBean verify(Long recordId, String type, String photoUrl, Integer faceCount, Double similarity, Double realness,
-			Long time, String exception);
-	void save(Long id,Long recordId, String type, String photoUrl, Integer faceCount, Double similarity, Double realness,
-			Long time, String exception);
+    FaceVerifyBean verify(Long recordId, String type, String photoUrl, Integer faceCount, Double similarity, Double realness,
+                          Long time, String exception);
 
+    void save(Long id, Long recordId, String type, String photoUrl, Integer faceCount, Double similarity, Double realness,
+              Long time, String exception);
+
+    /**
+     * count人脸数量异常
+     *
+     * @param recordId
+     * @param exception
+     * @param faceCount
+     * @param multipleFace
+     * @return
+     */
+    public Integer faceCountError(Long recordId, String exception, Integer faceCount, Boolean multipleFace);
+
+    /**
+     * count人脸比对异常
+     *
+     * @param recordId
+     * @param exception
+     * @return
+     */
+    public Integer faceCompareError(Long recordId, String exception);
 }

+ 78 - 58
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeFaceVerifyHistoryServiceImpl.java

@@ -1,12 +1,5 @@
 package com.qmth.themis.business.service.impl;
 
-import java.util.Date;
-
-import javax.annotation.Resource;
-
-import org.springframework.stereotype.Service;
-import org.springframework.transaction.annotation.Transactional;
-
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
 import com.qmth.themis.business.bean.exam.FaceVerifyBean;
 import com.qmth.themis.business.cache.FaceVerifyCacheUtil;
@@ -18,8 +11,11 @@ import com.qmth.themis.business.enums.VerifyExceptionEnum;
 import com.qmth.themis.business.service.TOeExamBreakHistoryService;
 import com.qmth.themis.business.service.TOeExamRecordService;
 import com.qmth.themis.business.service.TOeFaceVerifyHistoryService;
-import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.common.contanst.Constants;
+import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+
+import javax.annotation.Resource;
 
 /**
  * @Description: 人脸验证记录 服务实现类
@@ -31,56 +27,80 @@ import com.qmth.themis.common.contanst.Constants;
 @Service
 public class TOeFaceVerifyHistoryServiceImpl extends ServiceImpl<TOeFaceVerifyHistoryMapper, TOeFaceVerifyHistory> implements TOeFaceVerifyHistoryService {
 
-	
-	@Resource
-	RedisUtil redisUtil;
-	
-	@Resource
-	TOeExamBreakHistoryService examBreakHistoryService;
-	
-	@Resource
-	TOeExamRecordService examRecordService;
-	
-	@Override
-	public FaceVerifyBean verify(Long recordId, String type, String photoUrl, Integer faceCount, Double similarity,
-			Double realness, Long time, String exception) {
-		FaceVerifyCacheBean cache=new FaceVerifyCacheBean();
-		cache.setId(Constants.idGen.next());
-		cache.setExamRecordId(recordId);
-		cache.setFaceCount(faceCount);
-		cache.setException(VerifyExceptionEnum.valueOf(exception));
-		cache.setPhotoUrl(photoUrl);
-		cache.setRealness(realness);
-		cache.setSimilarity(similarity);
-		cache.setType(ExamTypeEnum.valueOf(type));
-		cache.setTime(time);
-		FaceVerifyCacheUtil.setFaceVerifyCacheBean(recordId, cache.getId(), cache);
-		FaceVerifyBean ret=new FaceVerifyBean();
-		ret.setId(cache.getId());
-		ret.setUpdateTime(System.currentTimeMillis());
-		if(ExamTypeEnum.RESUME_START.equals(cache.getType())) {
-			examBreakHistoryService.saveAuthenticationResult(recordId, cache.getId(), cache.getException());
-		}else {
-			examRecordService.saveFaceVerify(cache.getType(),recordId, cache.getId(), cache.getException());
-		}
-		return ret;
-	}
+    @Resource
+    TOeExamBreakHistoryService examBreakHistoryService;
+
+    @Resource
+    TOeExamRecordService examRecordService;
+
+    @Resource
+    TOeFaceVerifyHistoryMapper tOeFaceVerifyHistoryMapper;
+
+    @Override
+    public FaceVerifyBean verify(Long recordId, String type, String photoUrl, Integer faceCount, Double similarity,
+                                 Double realness, Long time, String exception) {
+        FaceVerifyCacheBean cache = new FaceVerifyCacheBean();
+        cache.setId(Constants.idGen.next());
+        cache.setExamRecordId(recordId);
+        cache.setFaceCount(faceCount);
+        cache.setException(VerifyExceptionEnum.valueOf(exception));
+        cache.setPhotoUrl(photoUrl);
+        cache.setRealness(realness);
+        cache.setSimilarity(similarity);
+        cache.setType(ExamTypeEnum.valueOf(type));
+        cache.setTime(time);
+        FaceVerifyCacheUtil.setFaceVerifyCacheBean(recordId, cache.getId(), cache);
+        FaceVerifyBean ret = new FaceVerifyBean();
+        ret.setId(cache.getId());
+        ret.setUpdateTime(System.currentTimeMillis());
+        if (ExamTypeEnum.RESUME_START.equals(cache.getType())) {
+            examBreakHistoryService.saveAuthenticationResult(recordId, cache.getId(), cache.getException());
+        } else {
+            examRecordService.saveFaceVerify(cache.getType(), recordId, cache.getId(), cache.getException());
+        }
+        return ret;
+    }
+
+    @Transactional
+    @Override
+    public void save(Long id, Long recordId, String type, String photoUrl, Integer faceCount, Double similarity,
+                     Double realness, Long time, String exception) {
+        TOeFaceVerifyHistory entity = new TOeFaceVerifyHistory();
+        entity.setId(id);
+        entity.setExamRecordId(recordId);
+        entity.setFaceCount(faceCount);
+        entity.setException(VerifyExceptionEnum.valueOf(exception));
+        entity.setPhotoUrl(photoUrl);
+        entity.setRealness(realness);
+        entity.setSimilarity(similarity);
+        entity.setType(ExamTypeEnum.valueOf(type));
+        entity.setTime(time);
+        saveOrUpdate(entity);
+    }
 
-	@Transactional
-	@Override
-	public void save(Long id, Long recordId, String type, String photoUrl, Integer faceCount, Double similarity,
-			Double realness, Long time, String exception) {
-		TOeFaceVerifyHistory entity=new TOeFaceVerifyHistory();
-		entity.setId(id);
-		entity.setExamRecordId(recordId);
-		entity.setFaceCount(faceCount);
-		entity.setException(VerifyExceptionEnum.valueOf(exception));
-		entity.setPhotoUrl(photoUrl);
-		entity.setRealness(realness);
-		entity.setSimilarity(similarity);
-		entity.setType(ExamTypeEnum.valueOf(type));
-		entity.setTime(time);
-		saveOrUpdate(entity);
-	}
+    /**
+     * count人脸数量异常
+     *
+     * @param recordId
+     * @param exception
+     * @param faceCount
+     * @param multipleFace
+     * @return
+     */
+    @Override
+    public Integer faceCountError(Long recordId, String exception, Integer faceCount, Boolean multipleFace) {
+        return tOeFaceVerifyHistoryMapper.faceCountError(recordId, exception, faceCount, multipleFace);
+    }
 
+    /**
+     * count人脸比对异常
+     *
+     * @param recordId
+     * @param exception
+     * @return
+     */
+    @Override
+    public Integer faceCompareError(Long recordId, String exception) {
+        return tOeFaceVerifyHistoryMapper.faceCompareError(recordId, exception);
+    }
 }

+ 11 - 12
themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java

@@ -6,7 +6,7 @@ import com.qmth.themis.business.dto.WarningDto;
 import com.qmth.themis.business.entity.TEConfig;
 import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
 import com.qmth.themis.business.entity.TOeFaceVerifyHistory;
-import com.qmth.themis.business.enums.WarningEnum;
+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;
@@ -20,6 +20,7 @@ import org.springframework.transaction.annotation.Transactional;
 
 import javax.annotation.Resource;
 import java.util.Map;
+import java.util.Objects;
 
 /**
  * @Description: 预警规则公用
@@ -54,23 +55,22 @@ public class WarningServiceImpl implements WarningService {
     public void faceCountError(WarningDto warningDto) {
         Long recordId = warningDto.getRecordId();
         Integer faceCount = warningDto.getFaceCount();
-        WarningEnum warningEnum = warningDto.getWarningEnum();
+        VerifyExceptionEnum warningEnum = warningDto.getWarningEnum();
         TEConfig teConfig = teConfigService.getGlobalConfig();
         Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
         Long examId = Long.parseLong(String.valueOf(objectMap.get("examId")));
         Long examStudentId = Long.parseLong(String.valueOf(objectMap.get("examStudentId")));
         Long examActivityId = Long.parseLong(String.valueOf(objectMap.get("examActivityId")));
-        QueryWrapper<TOeFaceVerifyHistory> tOeFaceVerifyHistoryQueryWrapper = new QueryWrapper<>();
         if (faceCount > 1) {//多张人脸
-            tOeFaceVerifyHistoryQueryWrapper.lambda().eq(TOeFaceVerifyHistory::getExamRecordId, recordId).ge(TOeFaceVerifyHistory::getFaceCount, 1).eq(TOeFaceVerifyHistory::getException, warningEnum.name());
-            int count = faceVerifyHistoryService.count(tOeFaceVerifyHistoryQueryWrapper);
+            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);
                 tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
             }
         } else if (faceCount <= 0) {//未检测到人脸
-            tOeFaceVerifyHistoryQueryWrapper.lambda().eq(TOeFaceVerifyHistory::getExamRecordId, recordId).le(TOeFaceVerifyHistory::getFaceCount, 0).eq(TOeFaceVerifyHistory::getException, warningEnum.name());
-            int count = faceVerifyHistoryService.count(tOeFaceVerifyHistoryQueryWrapper);
+            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);
                 tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
@@ -87,15 +87,14 @@ public class WarningServiceImpl implements WarningService {
     @Transactional
     public void faceCompareError(WarningDto warningDto) {
         Long recordId = warningDto.getRecordId();
-        WarningEnum warningEnum = warningDto.getWarningEnum();
+        VerifyExceptionEnum warningEnum = warningDto.getWarningEnum();
         TEConfig teConfig = teConfigService.getGlobalConfig();
         Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
         Long examId = Long.parseLong(String.valueOf(objectMap.get("examId")));
         Long examStudentId = Long.parseLong(String.valueOf(objectMap.get("examStudentId")));
         Long examActivityId = Long.parseLong(String.valueOf(objectMap.get("examActivityId")));
-        QueryWrapper<TOeFaceVerifyHistory> tOeFaceVerifyHistoryQueryWrapper = new QueryWrapper<>();
-        tOeFaceVerifyHistoryQueryWrapper.lambda().eq(TOeFaceVerifyHistory::getExamRecordId, recordId).eq(TOeFaceVerifyHistory::getException, warningEnum.name());
-        int count = faceVerifyHistoryService.count(tOeFaceVerifyHistoryQueryWrapper);
+        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);
             tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
@@ -135,7 +134,7 @@ public class WarningServiceImpl implements WarningService {
     @Transactional
     public void realnessError(WarningDto warningDto) {
         Long recordId = warningDto.getRecordId();
-        WarningEnum warningEnum = warningDto.getWarningEnum();
+        VerifyExceptionEnum warningEnum = warningDto.getWarningEnum();
         TEConfig teConfig = teConfigService.getGlobalConfig();
         Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
         Long examId = Long.parseLong(String.valueOf(objectMap.get("examId")));

+ 2 - 0
themis-business/src/main/resources/db/init.sql

@@ -1372,6 +1372,7 @@ CREATE TABLE `t_oe_face_verify_history` (
   `type` varchar(30) DEFAULT NULL COMMENT 'first:初次开考,recover:恢复开考,process:过程中',
   `exception` varchar(30) DEFAULT NULL COMMENT '异常类型',
   `photo_url` varchar(100) DEFAULT NULL COMMENT '图片保存路径',
+  `time` bigint DEFAULT NULL COMMENT '时间戳',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='人脸验证记录';
 
@@ -1388,6 +1389,7 @@ CREATE TABLE `t_oe_liveness_verify_history` (
   `pass` tinyint DEFAULT NULL COMMENT '本地验证是否通过,0:不通过,1:通过',
   `start_time` datetime DEFAULT NULL COMMENT '开始时间',
   `finish_time` datetime DEFAULT NULL COMMENT '完成时间',
+  `exception` varchar(30) DEFAULT NULL COMMENT '异常类型',
   PRIMARY KEY (`id`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='活体验证记录';
 

+ 86 - 0
themis-business/src/main/resources/mapper/TOeFaceVerifyHistoryMapper.xml

@@ -2,4 +2,90 @@
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
 <mapper namespace="com.qmth.themis.business.dao.TOeFaceVerifyHistoryMapper">
 
+    <select id="faceCountError" resultType="java.lang.Integer">
+        select
+            sum(t.tmpCount) as tmpCount
+        from
+            (
+            select
+                count(1) as tmpCount
+            from
+                t_oe_face_verify_history tofvh
+            <where>
+                <if test="recordId != null and recordId != ''">
+                    and tofvh.exam_record_id = #{recordId}
+                </if>
+                <if test="exception != null and exception != ''">
+                    and tofvh.`exception` = #{exception}
+                </if>
+                <choose>
+                    <when test="multipleFace == true">
+                        and tofvh.face_count <![CDATA[ > ]]> 1
+                    </when>
+                    <otherwise>
+                        and tofvh.face_count = 0
+                    </otherwise>
+                </choose>
+            </where>
+        union all
+            select
+                count(1) as tmpCount
+            from
+                (
+                select
+                    CONVERT((tolvh.actions->>'$.faceCount')
+                        USING utf8) as faceCount, tolvh.`exception`
+                from
+                    t_oe_liveness_verify_history tolvh
+                <where>
+                    <if test="recordId != null and recordId != ''">
+                        and tolvh.exam_record_id = #{recordId}
+                    </if>
+                    <if test="exception != null and exception != ''">
+                        and tolvh.`exception` = #{exception}
+                    </if>
+                </where> ) t
+            <where>
+                <choose>
+                    <when test="multipleFace == true">
+                        and t.faceCount <![CDATA[ > ]]> 1
+                    </when>
+                    <otherwise>
+                        and t.faceCount = 0
+                    </otherwise>
+                </choose>
+            </where> ) t
+    </select>
+
+    <select id="faceCompareError" resultType="java.lang.Integer">
+        select
+            sum(t.tmpCount) as tmpCount
+        from
+            (
+            select
+                count(1) as tmpCount
+            from
+                t_oe_face_verify_history tofvh
+            <where>
+                <if test="recordId != null and recordId != ''">
+                    and tofvh.exam_record_id = #{recordId}
+                </if>
+                <if test="exception != null and exception != ''">
+                    and tofvh.`exception` = #{exception}
+                </if>
+            </where>
+        union all
+            select
+                count(1) as tmpCount
+            from
+                t_oe_liveness_verify_history tolvh
+            <where>
+                <if test="recordId != null and recordId != ''">
+                    and tolvh.exam_record_id = #{recordId}
+                </if>
+                <if test="exception != null and exception != ''">
+                    and tolvh.`exception` = #{exception}
+                </if>
+            </where> ) t
+    </select>
 </mapper>

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

@@ -283,11 +283,11 @@ public class MqLogicServiceImpl implements MqLogicService {
         Long time = (Long) param.get("time");
         String exception = (String) param.get("exception");
         faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception);
-        WarningEnum warningEnum = WarningEnum.valueOf(exception);
+        VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
         WarningDto warningDto = new WarningDto(warningEnum, faceCount, realness, recordId);
-        if (Objects.equals(WarningEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
+        if (Objects.equals(VerifyExceptionEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
             warningService.faceCountError(warningDto);
-        } else if (Objects.equals(WarningEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
+        } else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
             warningService.faceCompareError(warningDto);
         } else {
             if (realness.intValue() == 0) {//真实性异常
@@ -321,11 +321,11 @@ public class MqLogicServiceImpl implements MqLogicService {
         Long finishTime = (Long) param.get("finishTime");
         String exception = (String) param.get("exception");
         livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception);
-        WarningEnum warningEnum = WarningEnum.valueOf(exception);
-        if (Objects.equals(WarningEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
+        VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
+        if (Objects.equals(VerifyExceptionEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
             JSONObject jsonObject = JSONObject.parseObject(actions);
             warningService.faceCountError(new WarningDto(warningEnum, Integer.parseInt(String.valueOf(jsonObject.get("faceCount"))), null, recordId));
-        } else if (Objects.equals(WarningEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
+        } else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
             warningService.faceCompareError(new WarningDto(warningEnum, null, null, recordId));
         }
         mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);