wangliang 4 سال پیش
والد
کامیت
22ba7e3e15
21فایلهای تغییر یافته به همراه268 افزوده شده و 152 حذف شده
  1. 4 4
      themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java
  2. 19 74
      themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateController.java
  3. 5 5
      themis-business/src/main/java/com/qmth/themis/business/cache/ExamActivityRecordCacheUtil.java
  4. 24 0
      themis-business/src/main/java/com/qmth/themis/business/cache/ExamRecordCacheUtil.java
  5. 3 3
      themis-business/src/main/java/com/qmth/themis/business/cache/bean/ExamActivityRecordCacheBean.java
  6. 6 2
      themis-business/src/main/java/com/qmth/themis/business/dao/TOeFaceVerifyHistoryMapper.java
  7. 11 0
      themis-business/src/main/java/com/qmth/themis/business/dto/WarningDto.java
  8. 12 0
      themis-business/src/main/java/com/qmth/themis/business/entity/TOeFaceVerifyHistory.java
  9. 12 0
      themis-business/src/main/java/com/qmth/themis/business/entity/TOeLivenessVerifyHistory.java
  10. 7 3
      themis-business/src/main/java/com/qmth/themis/business/service/TOeFaceVerifyHistoryService.java
  11. 4 5
      themis-business/src/main/java/com/qmth/themis/business/service/TOeLivenessVerifyHistoryService.java
  12. 5 5
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamServiceImpl.java
  13. 10 5
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeFaceVerifyHistoryServiceImpl.java
  14. 2 1
      themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeLivenessVerifyHistoryServiceImpl.java
  15. 8 3
      themis-business/src/main/java/com/qmth/themis/business/service/impl/WarningServiceImpl.java
  16. 44 3
      themis-business/src/main/resources/mapper/TOeFaceVerifyHistoryMapper.xml
  17. 1 1
      themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java
  18. 2 3
      themis-exam/src/main/java/com/qmth/themis/exam/config/ExamConstant.java
  19. 79 25
      themis-mq/src/main/java/com/qmth/themis/mq/service/impl/MqLogicServiceImpl.java
  20. 3 3
      themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java
  21. 7 7
      themis-task/src/main/java/com/qmth/themis/task/quartz/service/impl/QuartzLogicServiceImpl.java

+ 4 - 4
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamController.java

@@ -6,7 +6,7 @@ import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.ExamPropCountDto;
@@ -407,8 +407,8 @@ public class TEExamController {
                     if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
                         objectMap.forEach((k, v) -> {
                             Long recordId = Long.parseLong(k);
-                            ExamActivityRecordCache examActivityRecordCache = (ExamActivityRecordCache) v;
-                            ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCache.getStatus();
+                            ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
+                            ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
                             if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.PERSISTED) && !Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FINISHED)) {
                                 //客户端通讯状态
                                 WebsocketStatusEnum clientStatus = Objects.isNull(ExamRecordCacheUtil.getClientWebsocketStatus(recordId)) ? null : ExamRecordCacheUtil.getClientWebsocketStatus(recordId);
@@ -441,7 +441,7 @@ public class TEExamController {
                             }
                             //已完成
                             else if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FINISHED) || Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.PERSISTED)) {
-                                finalAlreadyComplete.add(examActivityRecordCache.getExamStudentId());
+                                finalAlreadyComplete.add(examActivityRecordCacheBean.getExamStudentId());
                             }
                         });
                     }

+ 19 - 74
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateController.java

@@ -1,43 +1,14 @@
 package com.qmth.themis.backend.api;
 
-import java.io.File;
-import java.util.ArrayList;
-import java.util.Calendar;
-import java.util.Collections;
-import java.util.Date;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-import java.util.Set;
-import java.util.concurrent.atomic.AtomicReference;
-import java.util.stream.Collectors;
-
-import javax.annotation.Resource;
-
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.web.bind.annotation.RequestBody;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RequestMethod;
-import org.springframework.web.bind.annotation.RequestParam;
-import org.springframework.web.bind.annotation.RestController;
-
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
 import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
-import com.qmth.themis.business.bean.backend.InvigilateListBean;
-import com.qmth.themis.business.bean.backend.InvigilateListDetailBean;
-import com.qmth.themis.business.bean.backend.InvigilateListHistoryBean;
-import com.qmth.themis.business.bean.backend.InvigilateListPatrolBean;
-import com.qmth.themis.business.bean.backend.InvigilateListProgressBean;
-import com.qmth.themis.business.bean.backend.InvigilateListProgressExcelBean;
-import com.qmth.themis.business.bean.backend.InvigilateListVideoBean;
+import com.qmth.themis.business.bean.backend.*;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.config.SystemConfig;
@@ -45,40 +16,10 @@ import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.dto.ExamPropCountDto;
 import com.qmth.themis.business.dto.MqDto;
-import com.qmth.themis.business.entity.TBExamInvigilateUser;
-import com.qmth.themis.business.entity.TBSession;
-import com.qmth.themis.business.entity.TBUser;
-import com.qmth.themis.business.entity.TEExamBreachLog;
-import com.qmth.themis.business.entity.TEExamReexam;
-import com.qmth.themis.business.entity.TEExamStudent;
-import com.qmth.themis.business.entity.TEExamStudentLog;
-import com.qmth.themis.business.entity.TEStudent;
-import com.qmth.themis.business.entity.TIeInvigilateExceptionInfo;
-import com.qmth.themis.business.entity.TIeInvigilateWarnInfo;
-import com.qmth.themis.business.entity.TOeExamRecord;
-import com.qmth.themis.business.enums.BreachCancelTypeEnum;
-import com.qmth.themis.business.enums.BreachTypeEnum;
-import com.qmth.themis.business.enums.ExamRecordStatusEnum;
-import com.qmth.themis.business.enums.FinishTypeEnum;
-import com.qmth.themis.business.enums.InvigilateMonitorStatusEnum;
-import com.qmth.themis.business.enums.MqTagEnum;
-import com.qmth.themis.business.enums.MqTopicEnum;
-import com.qmth.themis.business.enums.RoleEnum;
-import com.qmth.themis.business.enums.VerifyExceptionEnum;
-import com.qmth.themis.business.enums.WarningLevelEnum;
+import com.qmth.themis.business.entity.*;
+import com.qmth.themis.business.enums.*;
 import com.qmth.themis.business.excel.ExportUtils;
-import com.qmth.themis.business.service.MqDtoService;
-import com.qmth.themis.business.service.TBExamInvigilateUserService;
-import com.qmth.themis.business.service.TEExamActivityService;
-import com.qmth.themis.business.service.TEExamBreachLogService;
-import com.qmth.themis.business.service.TEExamReexamService;
-import com.qmth.themis.business.service.TEExamService;
-import com.qmth.themis.business.service.TEExamStudentLogService;
-import com.qmth.themis.business.service.TEExamStudentService;
-import com.qmth.themis.business.service.TEStudentService;
-import com.qmth.themis.business.service.TIeInvigilateExceptionInfoService;
-import com.qmth.themis.business.service.TIeInvigilateWarnInfoService;
-import com.qmth.themis.business.service.TOeExamRecordService;
+import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.ServletUtil;
@@ -86,12 +27,16 @@ import com.qmth.themis.common.enums.ExceptionResultEnum;
 import com.qmth.themis.common.exception.BusinessException;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.ResultUtil;
+import io.swagger.annotations.*;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.web.bind.annotation.*;
 
-import io.swagger.annotations.Api;
-import io.swagger.annotations.ApiOperation;
-import io.swagger.annotations.ApiParam;
-import io.swagger.annotations.ApiResponse;
-import io.swagger.annotations.ApiResponses;
+import javax.annotation.Resource;
+import java.io.File;
+import java.util.*;
+import java.util.concurrent.atomic.AtomicReference;
+import java.util.stream.Collectors;
 
 /**
  * @Description: 监考信息 前端控制器
@@ -523,9 +468,9 @@ public class TIeInvigilateController {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);
-        long now =new Date().getTime();
-        if(now<examCacheBean.getEndTime()*1000){
-        	throw new BusinessException("未到考试批次结束时间");
+        long now = new Date().getTime();
+        if (now < examCacheBean.getEndTime() * 1000) {
+            throw new BusinessException("未到考试批次结束时间");
         }
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         TBSession tbSession = (TBSession) ServletUtil.getRequestSession();
@@ -603,7 +548,7 @@ public class TIeInvigilateController {
                 Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(s));
                 if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
                     objectMap.forEach((k, v) -> {
-                        ExamActivityRecordCache examActivityRecordCache = (ExamActivityRecordCache) v;
+                        ExamActivityRecordCacheBean examActivityRecordCache = (ExamActivityRecordCacheBean) v;
                         ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCache.getStatus();
                         //已待考
                         if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FIRST_PREPARE)) {
@@ -618,7 +563,7 @@ public class TIeInvigilateController {
 //                }
             });
         }
-        
+
         teExamService.updateInvigilateMonitorStatus(InvigilateMonitorStatusEnum.FINISHED, examId);
         teExamService.deleteExamCacheBean(examId);
         examPropCountDto.setPrepareCount(prepareCount.get());

+ 5 - 5
themis-business/src/main/java/com/qmth/themis/business/cache/ExamActivityRecordCacheUtil.java

@@ -1,6 +1,6 @@
 package com.qmth.themis.business.cache;
 
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
 import com.qmth.themis.business.util.RedisUtil;
 
@@ -18,12 +18,12 @@ public class ExamActivityRecordCacheUtil {
         redisUtil.delete(RedisKeyHelper.examActivityRecordCacheKey(activityId), examRecordId.toString());
     }
 
-    public static void setExamRecordStatus(Long activityId, Long examRecordId, ExamActivityRecordCache examActivityRecordCache) {
-        redisUtil.set(RedisKeyHelper.examActivityRecordCacheKey(activityId), examRecordId.toString(), examActivityRecordCache);
+    public static void setExamRecordStatus(Long activityId, Long examRecordId, ExamActivityRecordCacheBean examActivityRecordCacheBean) {
+        redisUtil.set(RedisKeyHelper.examActivityRecordCacheKey(activityId), examRecordId.toString(), examActivityRecordCacheBean);
     }
 
-    public static ExamActivityRecordCache getExamRecordStatus(Long activityId, Long examRecordId) {
-        return (ExamActivityRecordCache) redisUtil.get(RedisKeyHelper.examActivityRecordCacheKey(activityId),
+    public static ExamActivityRecordCacheBean getExamRecordStatus(Long activityId, Long examRecordId) {
+        return (ExamActivityRecordCacheBean) redisUtil.get(RedisKeyHelper.examActivityRecordCacheKey(activityId),
                 examRecordId.toString());
     }
 }

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

@@ -383,4 +383,28 @@ public class ExamRecordCacheUtil {
     public static Long getExamFinalFinishTime(Long recordId) {
         return (Long) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "finalFinishTime");
     }
+
+    public static void setMultipleFaceCountErrorRandom(Long recordId, String multipleFaceCountErrorRandom) {
+        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorRandom", multipleFaceCountErrorRandom);
+    }
+
+    public static void setNoFaceCountErrorRandom(Long recordId, String noFaceCountErrorRandom) {
+        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "noFaceCountErrorRandom", noFaceCountErrorRandom);
+    }
+
+    public static void setFaceCompareErrorRandom(Long recordId, String faceCompareErrorRandom) {
+        redisUtil.set(RedisKeyHelper.examRecordCacheKey(recordId), "faceCompareErrorRandom", faceCompareErrorRandom);
+    }
+
+    public static String getMultipleFaceCountErrorRandom(Long recordId) {
+        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "multipleFaceCountErrorRandom");
+    }
+
+    public static String getNoFaceCountErrorRandom(Long recordId) {
+        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "noFaceCountErrorRandom");
+    }
+
+    public static String getFaceCompareErrorRandom(Long recordId) {
+        return (String) redisUtil.get(RedisKeyHelper.examRecordCacheKey(recordId), "faceCompareErrorRandom");
+    }
 }

+ 3 - 3
themis-business/src/main/java/com/qmth/themis/business/cache/bean/ExamActivityRecordCache.java → themis-business/src/main/java/com/qmth/themis/business/cache/bean/ExamActivityRecordCacheBean.java

@@ -11,17 +11,17 @@ import java.io.Serializable;
  * @Author: wangliang
  * @Date: 2020/9/27
  */
-public class ExamActivityRecordCache implements Serializable {
+public class ExamActivityRecordCacheBean implements Serializable {
 
     private ExamRecordStatusEnum status;
 
     private Long examStudentId;
 
-    public ExamActivityRecordCache() {
+    public ExamActivityRecordCacheBean() {
 
     }
 
-    public ExamActivityRecordCache(Long examStudentId, ExamRecordStatusEnum status) {
+    public ExamActivityRecordCacheBean(Long examStudentId, ExamRecordStatusEnum status) {
         this.examStudentId = examStudentId;
         this.status = status;
     }

+ 6 - 2
themis-business/src/main/java/com/qmth/themis/business/dao/TOeFaceVerifyHistoryMapper.java

@@ -24,16 +24,20 @@ public interface TOeFaceVerifyHistoryMapper extends BaseMapper<TOeFaceVerifyHist
      * @param exception
      * @param faceCount
      * @param multipleFace
+     * @param type
+     * @param batchNo
      * @return
      */
-    public Map<String, Object> faceCountError(@Param("recordId") Long recordId, @Param("exception") String exception, @Param("faceCount") Integer faceCount, @Param("multipleFace") Boolean multipleFace);
+    public Map<String, Object> faceCountError(@Param("recordId") Long recordId, @Param("exception") String exception, @Param("faceCount") Integer faceCount, @Param("multipleFace") Boolean multipleFace, @Param("type") String type, @Param("batchNo") String batchNo);
 
     /**
      * count人脸比对异常
      *
      * @param recordId
      * @param exception
+     * @param type
+     * @param batchNo
      * @return
      */
-    public Map<String, Object> faceCompareError(@Param("recordId") Long recordId, @Param("exception") String exception);
+    public Map<String, Object> faceCompareError(@Param("recordId") Long recordId, @Param("exception") String exception, @Param("type") String type, @Param("batchNo") String batchNo);
 }

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

@@ -32,6 +32,9 @@ public class WarningDto implements Serializable {
     @ApiModelProperty(name = "照片url")
     private String photoUrl;//照片url
 
+    @ApiModelProperty(name = "随机数")
+    private String random;
+
     public WarningDto() {
 
     }
@@ -44,6 +47,14 @@ public class WarningDto implements Serializable {
         this.photoUrl = photoUrl;
     }
 
+    public String getRandom() {
+        return random;
+    }
+
+    public void setRandom(String random) {
+        this.random = random;
+    }
+
     public String getPhotoUrl() {
         return photoUrl;
     }

+ 12 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TOeFaceVerifyHistory.java

@@ -75,6 +75,18 @@ public class TOeFaceVerifyHistory implements Serializable {
     @TableField(value = "time")
     private Long time;
 
+	@ApiModelProperty(value = "批次号")
+	@TableField(value = "batch_no")
+	private String batchNo;
+
+	public String getBatchNo() {
+		return batchNo;
+	}
+
+	public void setBatchNo(String batchNo) {
+		this.batchNo = batchNo;
+	}
+
 	public Long getId() {
 		return id;
 	}

+ 12 - 0
themis-business/src/main/java/com/qmth/themis/business/entity/TOeLivenessVerifyHistory.java

@@ -63,6 +63,18 @@ public class TOeLivenessVerifyHistory implements Serializable {
     @TableField(value = "create_time", fill = FieldFill.INSERT)
     private Long createTime;
 
+    @ApiModelProperty(value = "批次号")
+    @TableField(value = "batch_no")
+    private String batchNo;
+
+    public String getBatchNo() {
+        return batchNo;
+    }
+
+    public void setBatchNo(String batchNo) {
+        this.batchNo = batchNo;
+    }
+
     public static long getSerialVersionUID() {
         return serialVersionUID;
     }

+ 7 - 3
themis-business/src/main/java/com/qmth/themis/business/service/TOeFaceVerifyHistoryService.java

@@ -19,7 +19,7 @@ public interface TOeFaceVerifyHistoryService extends IService<TOeFaceVerifyHisto
                           Long time, String exception);
 
     void save(Long id, Long recordId, String type, String photoUrl, Integer faceCount, Double similarity, Double realness,
-              Long time, String exception);
+              Long time, String exception, String batchNo);
 
     /**
      * count人脸数量异常
@@ -28,16 +28,20 @@ public interface TOeFaceVerifyHistoryService extends IService<TOeFaceVerifyHisto
      * @param exception
      * @param faceCount
      * @param multipleFace
+     * @param type
+     * @param batchNo
      * @return
      */
-    public Map<String, Object> faceCountError(Long recordId, String exception, Integer faceCount, Boolean multipleFace);
+    public Map<String, Object> faceCountError(Long recordId, String exception, Integer faceCount, Boolean multipleFace, String type, String batchNo);
 
     /**
      * count人脸比对异常
      *
      * @param recordId
      * @param exception
+     * @param type
+     * @param batchNo
      * @return
      */
-    public Map<String, Object> faceCompareError(Long recordId, String exception);
+    public Map<String, Object> faceCompareError(Long recordId, String exception, String type, String batchNo);
 }

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

@@ -13,11 +13,10 @@ import com.qmth.themis.business.entity.TOeLivenessVerifyHistory;
  */
 public interface TOeLivenessVerifyHistoryService extends IService<TOeLivenessVerifyHistory> {
 
-	LivenessVerifyBean verify(Long recordId, String type, String actions, Integer retry, Long startTime,
-			Long finishTime, String exception);
+    LivenessVerifyBean verify(Long recordId, String type, String actions, Integer retry, Long startTime,
+                              Long finishTime, String exception);
 
 
-	void save(Long id, Long recordId, String type, String actions, Integer retry, Long startTime, Long finishTime,
-			String exception);
-
+    void save(Long id, Long recordId, String type, String actions, Integer retry, Long startTime, Long finishTime,
+              String exception, String batchNo);
 }

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

@@ -52,7 +52,7 @@ import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamingDataCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCourseCacheBean;
 import com.qmth.themis.business.cache.bean.ExamPaperCacheBean;
@@ -384,7 +384,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         // 更新考生缓存
         redisUtil.set(RedisKeyHelper.examStudentCacheKey(examStudentId), es);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
         ExamingDataCacheUtil.setUnFinishedRecordId(studentId, recordId);
         //mq发送消息start
         TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(studentId);
@@ -532,7 +532,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Object[] values = new Object[]{firstStartTime, ExamRecordStatusEnum.ANSWERING, lastStartTime};
         toeExamRecordService.dataUpdatesMq(recordId, columns, values);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
 
         //非强制交卷,换算最终交卷时间并生成一次性延时任务
         if (Objects.nonNull(exam.getForceFinish()) && exam.getForceFinish().intValue() == 0) {
@@ -854,7 +854,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Object[] values = new Object[]{lastPrepareTime, ExamRecordStatusEnum.RESUME_PREPARE};
         toeExamRecordService.dataUpdatesMq(recordId, columns, values);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
         return ret;
     }
 
@@ -973,7 +973,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         Object[] values = new Object[]{finishTime, durationSeconds, FinishTypeEnum.valueOf(type), ExamRecordStatusEnum.FINISHED};
         toeExamRecordService.dataUpdatesMq(recordId, columns, values);
         //更新场次-考试记录缓存
-        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+        ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
         //更新未完成考试记录id
         TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
         ExamingDataCacheUtil.deleteUnFinishedRecordId(studentId);

+ 10 - 5
themis-business/src/main/java/com/qmth/themis/business/service/impl/TOeFaceVerifyHistoryServiceImpl.java

@@ -65,7 +65,7 @@ public class TOeFaceVerifyHistoryServiceImpl extends ServiceImpl<TOeFaceVerifyHi
     @Transactional
     @Override
     public void save(Long id, Long recordId, String type, String photoUrl, Integer faceCount, Double similarity,
-                     Double realness, Long time, String exception) {
+                     Double realness, Long time, String exception, String batchNo) {
         TOeFaceVerifyHistory entity = new TOeFaceVerifyHistory();
         entity.setId(id);
         entity.setExamRecordId(recordId);
@@ -76,6 +76,7 @@ public class TOeFaceVerifyHistoryServiceImpl extends ServiceImpl<TOeFaceVerifyHi
         entity.setSimilarity(similarity);
         entity.setType(ExamTypeEnum.valueOf(type));
         entity.setTime(time);
+        entity.setBatchNo(batchNo);
         saveOrUpdate(entity);
     }
 
@@ -86,11 +87,13 @@ public class TOeFaceVerifyHistoryServiceImpl extends ServiceImpl<TOeFaceVerifyHi
      * @param exception
      * @param faceCount
      * @param multipleFace
+     * @param type
+     * @param batchNo
      * @return
      */
     @Override
-    public Map<String, Object> faceCountError(Long recordId, String exception, Integer faceCount, Boolean multipleFace) {
-        return tOeFaceVerifyHistoryMapper.faceCountError(recordId, exception, faceCount, multipleFace);
+    public Map<String, Object> faceCountError(Long recordId, String exception, Integer faceCount, Boolean multipleFace, String type, String batchNo) {
+        return tOeFaceVerifyHistoryMapper.faceCountError(recordId, exception, faceCount, multipleFace, type, batchNo);
     }
 
     /**
@@ -98,10 +101,12 @@ public class TOeFaceVerifyHistoryServiceImpl extends ServiceImpl<TOeFaceVerifyHi
      *
      * @param recordId
      * @param exception
+     * @param type
+     * @param batchNo
      * @return
      */
     @Override
-    public Map<String, Object> faceCompareError(Long recordId, String exception) {
-        return tOeFaceVerifyHistoryMapper.faceCompareError(recordId, exception);
+    public Map<String, Object> faceCompareError(Long recordId, String exception, String type, String batchNo) {
+        return tOeFaceVerifyHistoryMapper.faceCompareError(recordId, exception, type, batchNo);
     }
 }

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

@@ -60,7 +60,7 @@ public class TOeLivenessVerifyHistoryServiceImpl extends ServiceImpl<TOeLiveness
     @Transactional
     @Override
     public void save(Long id, Long recordId, String type, String actions, Integer retry, Long startTime,
-                     Long finishTime, String exception) {
+                     Long finishTime, String exception, String batchNo) {
         TOeLivenessVerifyHistory entity = new TOeLivenessVerifyHistory();
         entity.setId(id);
         entity.setExamRecordId(recordId);
@@ -70,6 +70,7 @@ public class TOeLivenessVerifyHistoryServiceImpl extends ServiceImpl<TOeLiveness
         entity.setStartTime(startTime);
         entity.setFinishTime(finishTime);
         entity.setException(VerifyExceptionEnum.valueOf(exception));
+        entity.setBatchNo(batchNo);
         saveOrUpdate(entity);
     }
 }

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

@@ -9,6 +9,7 @@ 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.ExamTypeEnum;
 import com.qmth.themis.business.enums.VerifyExceptionEnum;
 import com.qmth.themis.business.enums.WarningLevelEnum;
 import com.qmth.themis.business.service.*;
@@ -68,7 +69,7 @@ public class WarningServiceImpl implements WarningService {
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
         if (faceCount > 1) {//多张人脸
-            Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, true);
+            Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, true, ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
             if (Objects.nonNull(map) && map.size() > 0) {
                 Integer count = Integer.parseInt(String.valueOf(map.get("tmpCount")));
                 count = Objects.isNull(count) ? 0 : count;
@@ -77,10 +78,11 @@ public class WarningServiceImpl implements WarningService {
                     tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
                     this.setWarningCount(recordId);
                     this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
+                    ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
                 }
             }
         } else if (faceCount <= 0) {//未检测到人脸
-            Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, false);
+            Map<String, Object> map = faceVerifyHistoryService.faceCountError(recordId, warningDto.getWarningEnum().name(), faceCount, false, ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
             if (Objects.nonNull(map) && map.size() > 0) {
                 Integer count = Integer.parseInt(String.valueOf(map.get("tmpCount")));
                 count = Objects.isNull(count) ? 0 : count;
@@ -89,6 +91,7 @@ public class WarningServiceImpl implements WarningService {
                     tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
                     this.setWarningCount(recordId);
                     this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
+                    ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
                 }
             }
         }
@@ -110,7 +113,7 @@ public class WarningServiceImpl implements WarningService {
         Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
         Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
         ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
-        Map<String, Object> map = faceVerifyHistoryService.faceCompareError(recordId, warningDto.getWarningEnum().name());
+        Map<String, Object> map = faceVerifyHistoryService.faceCompareError(recordId, warningDto.getWarningEnum().name(), ExamTypeEnum.IN_PROCESS.name(), warningDto.getRandom());
         if (Objects.nonNull(map) && map.size() > 0) {
             Integer count = Integer.parseInt(String.valueOf(map.get("tmpCount")));
             count = Objects.isNull(count) ? 0 : count;
@@ -119,12 +122,14 @@ public class WarningServiceImpl implements WarningService {
                 tIeInvigilateWarnInfoService.saveOrUpdate(tIeInvigilateWarnInfo);
                 this.setWarningCount(recordId);
                 this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
+                ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
             }
             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);
                 this.setPhotoUrls(map, photoUrl, tIeInvigilateWarnInfo, examStudentCacheBean, recordId);
+                ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
             }
         }
     }

+ 44 - 3
themis-business/src/main/resources/mapper/TOeFaceVerifyHistoryMapper.xml

@@ -22,6 +22,12 @@
                 <if test="exception != null and exception != ''">
                     and tofvh.`exception` = #{exception}
                 </if>
+                <if test="type != null and type != ''">
+                    and tofvh.`type` = #{type}
+                </if>
+                <if test="batchNo != null and batchNo != ''">
+                    and tofvh.batch_no = #{batchNo}
+                </if>
                 <choose>
                     <when test="multipleFace == true">
                         and tofvh.face_count <![CDATA[ > ]]> 1
@@ -45,7 +51,13 @@
                     CONVERT((tolvh.actions->>'$.photoUrl')
                         USING utf8) as photoUrl,tolvh.create_time
                 from
-                    t_oe_liveness_verify_history tolvh
+                (
+                select
+                tolvh.actions->>'$[0]' as actions,
+                tolvh.`exception`,
+                tolvh.create_time
+                from
+                t_oe_liveness_verify_history tolvh
                 <where>
                     <if test="recordId != null and recordId != ''">
                         and tolvh.exam_record_id = #{recordId}
@@ -53,7 +65,15 @@
                     <if test="exception != null and exception != ''">
                         and tolvh.`exception` = #{exception}
                     </if>
-                </where> ) t
+                    <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
             <where>
                 <choose>
                     <when test="multipleFace == true">
@@ -87,6 +107,12 @@
                 <if test="exception != null and exception != ''">
                     and tofvh.`exception` = #{exception}
                 </if>
+                <if test="type != null and type != ''">
+                    and tofvh.`type` = #{type}
+                </if>
+                <if test="batchNo != null and batchNo != ''">
+                    and tofvh.batch_no = #{batchNo}
+                </if>
             </where>
             group by tofvh.`exception`
         union all
@@ -102,7 +128,14 @@
                 CONVERT((tolvh.actions->>'$.photoUrl')
                 USING utf8) as photoUrl,tolvh.create_time
                 from
+                (
+                select
+                tolvh.actions->>'$[0]' as actions,
+                tolvh.`exception`,
+                tolvh.create_time
+                from
                 t_oe_liveness_verify_history tolvh
+
                 <where>
                     <if test="recordId != null and recordId != ''">
                         and tolvh.exam_record_id = #{recordId}
@@ -110,7 +143,15 @@
                     <if test="exception != null and exception != ''">
                         and tolvh.`exception` = #{exception}
                     </if>
-                </where> ) t
+                    <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
             group by t.`exception`) t
     </select>
 </mapper>

+ 1 - 1
themis-exam/src/main/java/com/qmth/themis/exam/api/TEStudentController.java

@@ -262,7 +262,7 @@ public class TEStudentController {
                             mqDtoService.assembleSendOneWayMsg(mqDtoBreak);
                             //考试断点异常原因 发送mq end
                             //更新场次-考试记录缓存
-                            ExamActivityRecordCacheUtil.setExamRecordStatus(examActivityId, recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+                            ExamActivityRecordCacheUtil.setExamRecordStatus(examActivityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
                         }
                         ExamUnFinishBean examUnFinishBean = this.unFinishCommon(recordId, ec, examStudentCacheBean, examActivityCacheBean, examStudentId);
                         map.put("unFinished", examUnFinishBean);

+ 2 - 3
themis-exam/src/main/java/com/qmth/themis/exam/config/ExamConstant.java

@@ -2,7 +2,7 @@ package com.qmth.themis.exam.config;
 
 import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
@@ -18,7 +18,6 @@ import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.exam.websocket.WebSocketMobileServer;
 import com.qmth.themis.exam.websocket.WebSocketOeServer;
 
-import java.util.Date;
 import java.util.HashMap;
 import java.util.Map;
 import java.util.Objects;
@@ -133,7 +132,7 @@ public class ExamConstant {
             mqDtoService.assembleSendOneWayMsg(mqDtoBreak);
             //考试断点异常原因 发送mq end
             //更新场次-考试记录缓存
-            ExamActivityRecordCacheUtil.setExamRecordStatus(examStudentCacheBean.getExamActivityId(), recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+            ExamActivityRecordCacheUtil.setExamRecordStatus(examStudentCacheBean.getExamActivityId(), recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
         }
     }
 }

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

@@ -1,5 +1,6 @@
 package com.qmth.themis.mq.service.impl;
 
+import com.alibaba.fastjson.JSONArray;
 import com.alibaba.fastjson.JSONObject;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
@@ -7,7 +8,7 @@ import com.google.gson.Gson;
 import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SpringContextHolder;
@@ -40,6 +41,7 @@ import java.lang.reflect.Method;
 import java.util.List;
 import java.util.Map;
 import java.util.Objects;
+import java.util.UUID;
 
 /**
  * @Description: mq执行逻辑 impl
@@ -267,7 +269,7 @@ public class MqLogicServiceImpl implements MqLogicService {
                 mqDtoService.assembleSendOneWayMsg(mqDtoBreak);
                 //考试断点异常原因 发送mq end
                 //更新场次-考试记录缓存
-                ExamActivityRecordCacheUtil.setExamRecordStatus(examActivityId, recordId, new ExamActivityRecordCache(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
+                ExamActivityRecordCacheUtil.setExamRecordStatus(examActivityId, recordId, new ExamActivityRecordCacheBean(ExamRecordCacheUtil.getExamStudentId(recordId), ExamRecordCacheUtil.getStatus(recordId)));
             }
             //发送移动端监考退出考试mq消息 start
             MqDto mqDtoExamStop = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STOP.name(), recordId, MqTagEnum.EXAM_STOP, String.valueOf(recordId), String.valueOf(recordId));
@@ -319,7 +321,6 @@ public class MqLogicServiceImpl implements MqLogicService {
         Double realness = (Double) param.get("realness");
         Long time = (Long) param.get("time");
         String exception = (String) param.get("exception");
-        faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception);
         if (Objects.equals(type.toUpperCase(), ExamTypeEnum.IN_PROCESS.name())) {
             VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
             WarningDto warningDto = new WarningDto(warningEnum, faceCount, realness, recordId, photoUrl);
@@ -329,13 +330,39 @@ public class MqLogicServiceImpl implements MqLogicService {
                 JSONObject jsonObject = new JSONObject();
                 jsonObject.put(PhotoTypeEnum.FACE_VERIFY_PHOTO.name(), photoUrl);
                 TEExamStudentLog teExamStudentLog = new TEExamStudentLog(type, ExamTypeEnum.valueOf(type).getCode(), jsonObject.toJSONString(), examStudentCacheBean.getStudentId(), examStudentCacheBean.getId(), recordId);
+                faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
                 teExamStudentLogService.saveOrUpdate(teExamStudentLog);
             } else {
                 if (Objects.equals(VerifyExceptionEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
+                    if (faceCount > 1) {//多张人脸
+                        String multipleFaceRandom = ExamRecordCacheUtil.getMultipleFaceCountErrorRandom(recordId);
+                        if (Objects.isNull(multipleFaceRandom)) {
+                            multipleFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                            ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, multipleFaceRandom);
+                        }
+                        warningDto.setRandom(multipleFaceRandom);
+                        faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, multipleFaceRandom);
+                    } else if (faceCount <= 0) {
+                        String noFaceRandom = ExamRecordCacheUtil.getNoFaceCountErrorRandom(recordId);
+                        if (Objects.isNull(noFaceRandom)) {
+                            noFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                            ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, noFaceRandom);
+                        }
+                        warningDto.setRandom(noFaceRandom);
+                        faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, noFaceRandom);
+                    }
                     warningService.faceCountError(warningDto);
                 } else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
+                    String faceCompareErrorRandom = ExamRecordCacheUtil.getFaceCompareErrorRandom(recordId);
+                    if (Objects.isNull(faceCompareErrorRandom)) {
+                        faceCompareErrorRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                        ExamRecordCacheUtil.setFaceCompareErrorRandom(recordId, faceCompareErrorRandom);
+                    }
+                    warningDto.setRandom(faceCompareErrorRandom);
+                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
                     warningService.faceCompareError(warningDto);
                 } else {
+                    faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
                     if (realness.intValue() == 0) {//真实性异常
                         warningService.realnessError(warningDto);
                     }
@@ -368,28 +395,55 @@ public class MqLogicServiceImpl implements MqLogicService {
         Long startTime = (Long) param.get("startTime");
         Long finishTime = (Long) param.get("finishTime");
         String exception = (String) param.get("exception");
-        livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception);
-//        if (Objects.equals(type.toUpperCase(), ExamTypeEnum.IN_PROCESS.name())) {
-//            VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
-//            JSONArray jsonArray = JSONArray.parseArray(actions);
-//            Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
-//            ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
-//            for (int i = 0; i < jsonArray.size(); i++) {
-//                JSONObject jsonObject = jsonArray.getJSONObject(i);
-//                if (Objects.equals(VerifyExceptionEnum.NONE, warningEnum)) {//无异常,往考生日志表里插一条
-//                    JSONObject object = new JSONObject();
-//                    object.put(PhotoTypeEnum.LIVENESS_VERIFY_PHOTO.name(), String.valueOf(jsonObject.get("photoUrl")));
-//                    TEExamStudentLog teExamStudentLog = new TEExamStudentLog(type, LivenessTypeEnum.valueOf(type).getTitle(), object.toJSONString(), examStudentCacheBean.getStudentId(), examStudentCacheBean.getId(), recordId);
-//                    teExamStudentLogService.saveOrUpdate(teExamStudentLog);
-//                } else {
-//                    if (Objects.equals(VerifyExceptionEnum.FACE_COUNT_ERROR, warningEnum)) {//人脸数量异常
-//                        warningService.faceCountError(new WarningDto(warningEnum, Integer.parseInt(String.valueOf(jsonObject.get("faceCount"))), null, recordId, String.valueOf(jsonObject.get("photoUrl"))));
-//                    } else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
-//                        warningService.faceCompareError(new WarningDto(warningEnum, null, null, recordId, String.valueOf(jsonObject.get("photoUrl"))));
-//                    }
-//                }
-//            }
-//        }
+        if (Objects.equals(type.toUpperCase(), ExamTypeEnum.IN_PROCESS.name())) {
+            VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
+            JSONArray jsonArray = JSONArray.parseArray(actions);
+            Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+            ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
+            for (int i = 0; i < jsonArray.size(); i++) {
+                JSONObject jsonObject = jsonArray.getJSONObject(i);
+                if (Objects.equals(VerifyExceptionEnum.NONE, warningEnum)) {//无异常,往考生日志表里插一条
+                    JSONObject object = new JSONObject();
+                    object.put(PhotoTypeEnum.LIVENESS_VERIFY_PHOTO.name(), String.valueOf(jsonObject.get("photoUrl")));
+                    TEExamStudentLog teExamStudentLog = new TEExamStudentLog(type, LivenessTypeEnum.valueOf(type).getTitle(), object.toJSONString(), examStudentCacheBean.getStudentId(), examStudentCacheBean.getId(), recordId);
+                    livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);
+                    teExamStudentLogService.saveOrUpdate(teExamStudentLog);
+                } else {
+                    if (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")));
+                        if (faceCount > 1) {//多张人脸
+                            String multipleFaceRandom = ExamRecordCacheUtil.getMultipleFaceCountErrorRandom(recordId);
+                            if (Objects.isNull(multipleFaceRandom)) {
+                                multipleFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                                ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, multipleFaceRandom);
+                            }
+                            warningDto.setRandom(multipleFaceRandom);
+                            livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, multipleFaceRandom);
+                        } else if (faceCount <= 0) {
+                            String noFaceRandom = ExamRecordCacheUtil.getNoFaceCountErrorRandom(recordId);
+                            if (Objects.isNull(noFaceRandom)) {
+                                noFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                                ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, noFaceRandom);
+                            }
+                            warningDto.setRandom(noFaceRandom);
+                            livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, noFaceRandom);
+                        }
+                        warningService.faceCountError(warningDto);
+                    } else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
+                        WarningDto warningDto = new WarningDto(warningEnum, null, null, recordId, String.valueOf(jsonObject.get("photoUrl")));
+                        String faceCompareErrorRandom = ExamRecordCacheUtil.getFaceCompareErrorRandom(recordId);
+                        if (Objects.isNull(faceCompareErrorRandom)) {
+                            faceCompareErrorRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
+                            ExamRecordCacheUtil.setFaceCompareErrorRandom(recordId, faceCompareErrorRandom);
+                        }
+                        warningDto.setRandom(faceCompareErrorRandom);
+                        livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, faceCompareErrorRandom);
+                        warningService.faceCompareError(warningDto);
+                    }
+                }
+            }
+        }
         mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
         tmRocketMessage.setBody(JacksonUtil.parseJson(tmRocketMessage.getBody()));

+ 3 - 3
themis-task/src/main/java/com/qmth/themis/task/quartz/MqActivityJob.java

@@ -3,7 +3,7 @@ package com.qmth.themis.task.quartz;
 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.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.entity.TEExam;
 import com.qmth.themis.business.entity.TEExamActivity;
@@ -63,8 +63,8 @@ public class MqActivityJob extends QuartzJobBean {
                         Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(teExamActivity.getId()));
                         if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
                             objectMap.forEach((k, v) -> {
-                                ExamActivityRecordCache examActivityRecordCache = (ExamActivityRecordCache) v;
-                                ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCache.getStatus();
+                                ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
+                                ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
                                 //获取该考试批次下所有未交卷的考生的考试记录
                                 if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
                                     Long recordId = Long.parseLong(k);

+ 7 - 7
themis-task/src/main/java/com/qmth/themis/task/quartz/service/impl/QuartzLogicServiceImpl.java

@@ -4,7 +4,7 @@ import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
-import com.qmth.themis.business.cache.bean.ExamActivityRecordCache;
+import com.qmth.themis.business.cache.bean.ExamActivityRecordCacheBean;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.enums.ExamRecordStatusEnum;
@@ -64,8 +64,8 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
             if (Objects.nonNull(forceFinish) && forceFinish.intValue() == 1) {//强制收卷
                 if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
                     objectMap.forEach((k, v) -> {
-                        ExamActivityRecordCache examActivityRecordCache = (ExamActivityRecordCache) v;
-                        ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCache.getStatus();
+                        ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
+                        ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
                         //获取该考试批次下所有未交卷的考生的考试记录
                         if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum)) {
                             Long recordId = Long.parseLong(k);
@@ -77,7 +77,7 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                                 //交卷
                                 teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
                                 // 清除缓存
-                                ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
+//                                ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
                             }
                         }
                     });
@@ -85,8 +85,8 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
             } else {
                 if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
                     objectMap.forEach((k, v) -> {
-                        ExamActivityRecordCache examActivityRecordCache = (ExamActivityRecordCache) v;
-                        ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCache.getStatus();
+                        ExamActivityRecordCacheBean examActivityRecordCacheBean = (ExamActivityRecordCacheBean) v;
+                        ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCacheBean.getStatus();
                         //获取该考试批次下所有未交卷的考生的考试记录
                         if (Objects.nonNull(examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.FINISHED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.PERSISTED, examRecordStatusEnum) && !Objects.equals(ExamRecordStatusEnum.ANSWERING, examRecordStatusEnum)) {
                             Long recordId = Long.parseLong(k);
@@ -98,7 +98,7 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                                 //交卷
                                 teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
                                 // 清除缓存
-                                ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
+//                                ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
                             }
                         }
                     });