|
@@ -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
|
|
@@ -106,6 +108,9 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
|
@Resource
|
|
|
MqDtoService mqDtoService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ TEConfigService teConfigService;
|
|
|
+
|
|
|
/**
|
|
|
* mq最大重试次数逻辑
|
|
|
*
|
|
@@ -267,7 +272,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 +324,7 @@ 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);
|
|
|
+ TEConfig teConfig = teConfigService.getGlobalConfig();
|
|
|
if (Objects.equals(type.toUpperCase(), ExamTypeEnum.IN_PROCESS.name())) {
|
|
|
VerifyExceptionEnum warningEnum = VerifyExceptionEnum.valueOf(exception);
|
|
|
WarningDto warningDto = new WarningDto(warningEnum, faceCount, realness, recordId, photoUrl);
|
|
@@ -329,18 +334,65 @@ 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)) {//人脸数量异常
|
|
|
- warningService.faceCountError(warningDto);
|
|
|
+ if (faceCount > 1) {//多张人脸
|
|
|
+ String multipleFaceRandom = ExamRecordCacheUtil.getMultipleFaceCountErrorRandom(recordId);
|
|
|
+ if (Objects.isNull(multipleFaceRandom)) {
|
|
|
+ multipleFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, multipleFaceRandom);
|
|
|
+ }
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorNum(recordId, ExamRecordCacheUtil.getMultipleFaceCountErrorNum(recordId) + 1);
|
|
|
+ warningDto.setRandom(multipleFaceRandom);
|
|
|
+ faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, multipleFaceRandom);
|
|
|
+ Integer count = ExamRecordCacheUtil.getMultipleFaceCountErrorNum(recordId);
|
|
|
+ if (count >= teConfig.getMultipleFaceCountError()) {
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorNum(recordId, 0);
|
|
|
+ warningService.faceCountError(warningDto);
|
|
|
+ }
|
|
|
+ } else if (faceCount <= 0) {
|
|
|
+ String noFaceRandom = ExamRecordCacheUtil.getNoFaceCountErrorRandom(recordId);
|
|
|
+ if (Objects.isNull(noFaceRandom)) {
|
|
|
+ noFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, noFaceRandom);
|
|
|
+ }
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorNum(recordId, ExamRecordCacheUtil.getNoFaceCountErrorNum(recordId) + 1);
|
|
|
+ warningDto.setRandom(noFaceRandom);
|
|
|
+ faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, noFaceRandom);
|
|
|
+ Integer count = ExamRecordCacheUtil.getNoFaceCountErrorNum(recordId);
|
|
|
+ if (count >= teConfig.getNoFaceCountError()) {
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorNum(recordId, 0);
|
|
|
+ warningService.faceCountError(warningDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
} else if (Objects.equals(VerifyExceptionEnum.FACE_COMPARE_ERROR, warningEnum)) {//人脸比对异常
|
|
|
- warningService.faceCompareError(warningDto);
|
|
|
+ String faceCompareErrorRandom = ExamRecordCacheUtil.getFaceCompareErrorRandom(recordId);
|
|
|
+ if (Objects.isNull(faceCompareErrorRandom)) {
|
|
|
+ faceCompareErrorRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorRandom(recordId, faceCompareErrorRandom);
|
|
|
+ }
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorNum(recordId, ExamRecordCacheUtil.getFaceCompareErrorNum(recordId) + 1);
|
|
|
+ warningDto.setRandom(faceCompareErrorRandom);
|
|
|
+ faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
|
|
|
+ Integer count = ExamRecordCacheUtil.getFaceCompareErrorNum(recordId);
|
|
|
+ if (count >= teConfig.getTotalFaceCompareErrorCount()) {
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorNum(recordId, 0);
|
|
|
+ warningService.faceCountError(warningDto);
|
|
|
+ }
|
|
|
} else {
|
|
|
+ faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
|
|
|
if (realness.intValue() == 0) {//真实性异常
|
|
|
warningService.realnessError(warningDto);
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+ } else {
|
|
|
+ faceVerifyHistoryService.save(id, recordId, type, photoUrl, faceCount, similarity, realness, time, exception, null);
|
|
|
}
|
|
|
mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
|
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|
|
@@ -368,28 +420,77 @@ 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"))));
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
-// }
|
|
|
+ TEConfig teConfig = teConfigService.getGlobalConfig();
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorNum(recordId, ExamRecordCacheUtil.getMultipleFaceCountErrorNum(recordId) + 1);
|
|
|
+ warningDto.setRandom(multipleFaceRandom);
|
|
|
+ livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, multipleFaceRandom);
|
|
|
+ Integer count = ExamRecordCacheUtil.getMultipleFaceCountErrorNum(recordId);
|
|
|
+ if (count >= teConfig.getMultipleFaceCountError()) {
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
|
|
|
+ ExamRecordCacheUtil.setMultipleFaceCountErrorNum(recordId, 0);
|
|
|
+ warningService.faceCountError(warningDto);
|
|
|
+ }
|
|
|
+ } else if (faceCount <= 0) {
|
|
|
+ String noFaceRandom = ExamRecordCacheUtil.getNoFaceCountErrorRandom(recordId);
|
|
|
+ if (Objects.isNull(noFaceRandom)) {
|
|
|
+ noFaceRandom = String.valueOf(UUID.randomUUID()).replaceAll("-", "");
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, noFaceRandom);
|
|
|
+ }
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorNum(recordId, ExamRecordCacheUtil.getMultipleFaceCountErrorNum(recordId) + 1);
|
|
|
+ warningDto.setRandom(noFaceRandom);
|
|
|
+ livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, noFaceRandom);
|
|
|
+ Integer count = ExamRecordCacheUtil.getNoFaceCountErrorNum(recordId);
|
|
|
+ if (count >= teConfig.getNoFaceCountError()) {
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
|
|
|
+ ExamRecordCacheUtil.setNoFaceCountErrorNum(recordId, 0);
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorNum(recordId, ExamRecordCacheUtil.getFaceCompareErrorNum(recordId) + 1);
|
|
|
+ warningDto.setRandom(faceCompareErrorRandom);
|
|
|
+ livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, faceCompareErrorRandom);
|
|
|
+ Integer count = ExamRecordCacheUtil.getFaceCompareErrorNum(recordId);
|
|
|
+ if (count >= teConfig.getTotalFaceCompareErrorCount()) {
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorRandom(recordId, String.valueOf(UUID.randomUUID()).replaceAll("-", ""));
|
|
|
+ ExamRecordCacheUtil.setFaceCompareErrorNum(recordId, 0);
|
|
|
+ warningService.faceCountError(warningDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ livenessVerifyHistoryService.save(id, recordId, type, actions, retry, startTime, finishTime, exception, null);
|
|
|
+ }
|
|
|
mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
|
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|
|
|
tmRocketMessage.setBody(JacksonUtil.parseJson(tmRocketMessage.getBody()));
|
|
@@ -490,6 +591,7 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
|
tIeExamInvigilateCallLog.setExamId(examId);
|
|
|
tIeExamInvigilateCallLog.setExamActivityId(examActivityId);
|
|
|
tIeExamInvigilateCallLog.setExamStudentId(examStudentId);
|
|
|
+
|
|
|
QueryWrapper<TIeExamInvigilateCall> tIeExamInvigilateCallQueryWrapper = new QueryWrapper<>();
|
|
|
tIeExamInvigilateCallQueryWrapper.lambda().eq(TIeExamInvigilateCall::getExamRecordId, tIeExamInvigilateCallLog.getExamRecordId()).eq(TIeExamInvigilateCall::getSource, tIeExamInvigilateCallLog.getSource());
|
|
|
TIeExamInvigilateCall tIeExamInvigilateCall = tIeExamInvigilateCallService.getOne(tIeExamInvigilateCallQueryWrapper);
|