|
@@ -1,17 +1,16 @@
|
|
package com.qmth.themis.mq.service.impl;
|
|
package com.qmth.themis.mq.service.impl;
|
|
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
|
|
+import com.qmth.themis.business.bean.exam.ExamStartParamBean;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.ExamRecordCacheUtil;
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
import com.qmth.themis.business.cache.RedisKeyHelper;
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SpringContextHolder;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.constant.SystemConstant;
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
import com.qmth.themis.business.dto.MqDto;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.entity.*;
|
|
-import com.qmth.themis.business.enums.BreakReasonEnum;
|
|
|
|
-import com.qmth.themis.business.enums.ExamRecordStatusEnum;
|
|
|
|
-import com.qmth.themis.business.enums.MqTagEnum;
|
|
|
|
-import com.qmth.themis.business.enums.SystemOperationEnum;
|
|
|
|
|
|
+import com.qmth.themis.business.enums.*;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.templete.TaskExportTemplete;
|
|
import com.qmth.themis.business.templete.TaskExportTemplete;
|
|
import com.qmth.themis.business.templete.TaskImportTemplete;
|
|
import com.qmth.themis.business.templete.TaskImportTemplete;
|
|
@@ -81,6 +80,9 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
@Resource
|
|
@Resource
|
|
TIeExamInvigilateCallService tIeExamInvigilateCallService;
|
|
TIeExamInvigilateCallService tIeExamInvigilateCallService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ TIeInvigilateExceptionInfoService tIeInvigilateExceptionInfoService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* mq最大重试次数逻辑
|
|
* mq最大重试次数逻辑
|
|
*
|
|
*
|
|
@@ -322,14 +324,10 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
public void execMqExamBreakHistoryLogic(MqDto mqDto, String key) {
|
|
public void execMqExamBreakHistoryLogic(MqDto mqDto, String key) {
|
|
|
|
+ ExamStartParamBean examStartParamBean = JacksonUtil.readJson(JacksonUtil.parseJson(mqDto.getBody()), ExamStartParamBean.class);
|
|
//更新考试记录
|
|
//更新考试记录
|
|
- Map<String, Object> objectMap = JacksonUtil.readJson(String.valueOf(mqDto.getBody()), Map.class);
|
|
|
|
- String status=(String)objectMap.get("status");
|
|
|
|
- if(status!=null) {
|
|
|
|
- objectMap.put("status", ExamRecordStatusEnum.valueOf(status));
|
|
|
|
- }
|
|
|
|
Long recordId = Long.parseLong(mqDto.getObjId());
|
|
Long recordId = Long.parseLong(mqDto.getObjId());
|
|
-
|
|
|
|
|
|
+ Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
|
|
//先查询之前的断点记录
|
|
//先查询之前的断点记录
|
|
QueryWrapper<TOeExamBreakHistory> tOeExamBreakHistoryQueryWrapper = new QueryWrapper<>();
|
|
QueryWrapper<TOeExamBreakHistory> tOeExamBreakHistoryQueryWrapper = new QueryWrapper<>();
|
|
tOeExamBreakHistoryQueryWrapper.lambda().eq(TOeExamBreakHistory::getExamRecordId, recordId);
|
|
tOeExamBreakHistoryQueryWrapper.lambda().eq(TOeExamBreakHistory::getExamRecordId, recordId);
|
|
@@ -399,7 +397,7 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
public void execMqLogLogic(MqDto mqDto, String key) {
|
|
public void execMqLogLogic(MqDto mqDto, String key) {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
String tag = mqDto.getTag();
|
|
String tag = mqDto.getTag();
|
|
- if (tag.contains(MqTagEnum.MONITOR_LOG.name())) {
|
|
|
|
|
|
+ if (tag.contains(MqTagEnum.MONITOR_LOG.name())) {//监考日志
|
|
TIeExamInvigilateCallLog tIeExamInvigilateCallLog = JacksonUtil.readJson(JacksonUtil.parseJson(mqDto.getBody()), TIeExamInvigilateCallLog.class);
|
|
TIeExamInvigilateCallLog tIeExamInvigilateCallLog = JacksonUtil.readJson(JacksonUtil.parseJson(mqDto.getBody()), TIeExamInvigilateCallLog.class);
|
|
Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(tIeExamInvigilateCallLog.getExamRecordId()));
|
|
Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(tIeExamInvigilateCallLog.getExamRecordId()));
|
|
Long examId = null, examActivityId = null, examStudentId = null;
|
|
Long examId = null, examActivityId = null, examStudentId = null;
|
|
@@ -428,6 +426,50 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
}
|
|
}
|
|
tIeExamInvigilateCallService.saveOrUpdate(tIeExamInvigilateCall);
|
|
tIeExamInvigilateCallService.saveOrUpdate(tIeExamInvigilateCall);
|
|
tIeExamInvigilateCallLogService.saveOrUpdate(tIeExamInvigilateCallLog);
|
|
tIeExamInvigilateCallLogService.saveOrUpdate(tIeExamInvigilateCallLog);
|
|
|
|
+ } else if (tag.contains(MqTagEnum.EXCEPTION_LOG.name())) {//考试断点异常日志
|
|
|
|
+ ExamStartParamBean examStartParamBean = JacksonUtil.readJson(JacksonUtil.parseJson(mqDto.getBody()), ExamStartParamBean.class);
|
|
|
|
+ //更新考试记录
|
|
|
|
+ Long recordId = Long.parseLong(mqDto.getObjId());
|
|
|
|
+ Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examRecordCacheKey(recordId));
|
|
|
|
+ //获取最近断点时间
|
|
|
|
+ Date lastBreakTime = (Date) objectMap.get("lastBreakTime");
|
|
|
|
+ Long diff = null;
|
|
|
|
+ if (Objects.nonNull(lastBreakTime)) {
|
|
|
|
+ diff = (System.currentTimeMillis() - lastBreakTime.getTime()) / 1000 * 60;
|
|
|
|
+ }
|
|
|
|
+ //先查询之前的断点记录
|
|
|
|
+ QueryWrapper<TOeExamBreakHistory> tOeExamBreakHistoryQueryWrapper = new QueryWrapper<>();
|
|
|
|
+ tOeExamBreakHistoryQueryWrapper.lambda().eq(TOeExamBreakHistory::getExamRecordId, recordId);
|
|
|
|
+ List<TOeExamBreakHistory> tOeExamBreakHistoryList = tOeExamBreakHistoryService.list(tOeExamBreakHistoryQueryWrapper);
|
|
|
|
+ //删除历史断点缓存
|
|
|
|
+ if (Objects.nonNull(tOeExamBreakHistoryList) && tOeExamBreakHistoryList.size() > 0) {
|
|
|
|
+ tOeExamBreakHistoryList.forEach(s -> {
|
|
|
|
+ redisUtil.delete(RedisKeyHelper.examBreakCacheKey(s.getId()));
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+ //增加断点记录
|
|
|
|
+ TOeExamBreakHistory tOeExamBreakHistory = new TOeExamBreakHistory(recordId, new Date(), BreakReasonEnum.NET_TIME_OUT, BreakReasonEnum.NET_TIME_OUT.name());
|
|
|
|
+ tOeExamBreakHistoryService.save(tOeExamBreakHistory);
|
|
|
|
+ redisUtil.setForHash(RedisKeyHelper.examBreakCacheKey(tOeExamBreakHistory.getId()), SimpleBeanUtil.objectToMap(tOeExamBreakHistory));
|
|
|
|
+
|
|
|
|
+ Integer leftBreakResumeCount = Objects.isNull(ExamRecordCacheUtil.getLeftBreakResumeCount(recordId)) ? 0 : ExamRecordCacheUtil.getLeftBreakResumeCount(recordId);
|
|
|
|
+ objectMap.put("lastBreakId", tOeExamBreakHistory.getId());
|
|
|
|
+ objectMap.put("status", ExamRecordStatusEnum.RESUME_PREPARE);
|
|
|
|
+ objectMap.put("lastBreakTime", new Date());
|
|
|
|
+ objectMap.put("leftBreakResumeCount", leftBreakResumeCount--);
|
|
|
|
+ objectMap.put("lastStartTime", new Date());
|
|
|
|
+ redisUtil.setForHash(RedisKeyHelper.examRecordCacheKey(recordId), objectMap);
|
|
|
|
+
|
|
|
|
+ //增加异常日志
|
|
|
|
+ JSONObject jsonObject = (JSONObject) JSONObject.parse(examStartParamBean.getReason());
|
|
|
|
+ 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")));
|
|
|
|
+ TIeInvigilateExceptionInfo tIeInvigilateExceptionInfo = new TIeInvigilateExceptionInfo(examId, examActivityId, recordId, examStudentId, String.valueOf(jsonObject.get("reason")), ExceptionEnum.valueOf(String.valueOf(jsonObject.get("type"))), String.valueOf(diff));
|
|
|
|
+ tIeInvigilateExceptionInfoService.saveOrUpdate(tIeInvigilateExceptionInfo);
|
|
|
|
+ teExamStudentLogService.saveStudentLogInfo(mqDto.getTimestamp(), MqTagEnum.valueOf(String.valueOf(mqDto.getType())).getId(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), JacksonUtil.parseJson(mqDto));
|
|
|
|
+ } else if (tag.contains(MqTagEnum.WARNING_LOG.name())) {//考试预警日志
|
|
|
|
+
|
|
}
|
|
}
|
|
mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
|
|
mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|