|
@@ -2,7 +2,6 @@ package com.qmth.themis.mq.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.alibaba.fastjson.JSONObject;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
|
import com.google.gson.Gson;
|
|
import com.google.gson.Gson;
|
|
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;
|
|
@@ -11,6 +10,7 @@ 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.dto.WarningDto;
|
|
import com.qmth.themis.business.dto.WarningDto;
|
|
|
|
+import com.qmth.themis.business.dto.WebsocketDto;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.entity.*;
|
|
import com.qmth.themis.business.enums.*;
|
|
import com.qmth.themis.business.enums.*;
|
|
import com.qmth.themis.business.service.*;
|
|
import com.qmth.themis.business.service.*;
|
|
@@ -34,6 +34,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
import javax.annotation.Resource;
|
|
import javax.annotation.Resource;
|
|
import java.io.IOException;
|
|
import java.io.IOException;
|
|
import java.util.*;
|
|
import java.util.*;
|
|
|
|
+import java.util.concurrent.ConcurrentHashMap;
|
|
|
|
|
|
/**
|
|
/**
|
|
* @Description: mq执行逻辑 impl
|
|
* @Description: mq执行逻辑 impl
|
|
@@ -97,6 +98,9 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
@Resource
|
|
@Resource
|
|
WarningService warningService;
|
|
WarningService warningService;
|
|
|
|
|
|
|
|
+ @Resource
|
|
|
|
+ MqDtoService mqDtoService;
|
|
|
|
+
|
|
/**
|
|
/**
|
|
* mq最大重试次数逻辑
|
|
* mq最大重试次数逻辑
|
|
*
|
|
*
|
|
@@ -127,13 +131,16 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
String tag = mqDto.getTag();
|
|
String tag = mqDto.getTag();
|
|
if (tag.contains(MqTagEnum.USER.name())) {
|
|
if (tag.contains(MqTagEnum.USER.name())) {
|
|
- teUserLogService.saveUserLogInfo(String.valueOf(mqDto.getBody()), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), mqDto.getObjId());
|
|
|
|
|
|
+ TEUserLog teUserLog = new TEUserLog(String.valueOf(mqDto.getBody()), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), Long.parseLong(String.valueOf(mqDto.getObjId())));
|
|
|
|
+ teUserLogService.save(teUserLog);
|
|
} else if (tag.contains(MqTagEnum.STUDENT.name())) {
|
|
} else if (tag.contains(MqTagEnum.STUDENT.name())) {
|
|
|
|
+ TEExamStudentLog teExamStudentLog = null;
|
|
if (Objects.nonNull(mqDto.getProperties())) {
|
|
if (Objects.nonNull(mqDto.getProperties())) {
|
|
- teExamStudentLogService.saveStudentLogInfo(String.valueOf(mqDto.getBody()), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), mqDto.getProperties().get("remark"), mqDto.getObjId(), mqDto.getProperties().get("examStudentId"), mqDto.getProperties().get("examRecordId"));
|
|
|
|
|
|
+ teExamStudentLog = new TEExamStudentLog(String.valueOf(mqDto.getBody()), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), String.valueOf(mqDto.getProperties().get("remark")), Long.parseLong(String.valueOf(mqDto.getObjId())), Long.parseLong(String.valueOf(mqDto.getProperties().get("examStudentId"))), Long.parseLong(String.valueOf(mqDto.getProperties().get("examRecordId"))));
|
|
} else {
|
|
} else {
|
|
- teExamStudentLogService.saveStudentLogInfo(String.valueOf(mqDto.getBody()), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), mqDto.getObjId());
|
|
|
|
|
|
+ teExamStudentLog = new TEExamStudentLog(String.valueOf(mqDto.getBody()), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), Long.parseLong(String.valueOf(mqDto.getObjId())));
|
|
}
|
|
}
|
|
|
|
+ teExamStudentLogService.save(teExamStudentLog);
|
|
}
|
|
}
|
|
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);
|
|
@@ -232,12 +239,20 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.BREAK_OFF);
|
|
ExamRecordCacheUtil.setStatus(recordId, ExamRecordStatusEnum.BREAK_OFF);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
+ //发送考试暂停mq消息 start
|
|
|
|
+ MqDto mqDtoExamStop = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), MqTagEnum.EXAM_STOP.name(), recordId, MqTagEnum.EXAM_STOP, String.valueOf(recordId), String.valueOf(recordId));
|
|
|
|
+ mqDtoService.assembleSendOneWayMsg(mqDtoExamStop);
|
|
|
|
+ //发送考试暂停mq消息 end
|
|
|
|
+
|
|
//增加异常日志
|
|
//增加异常日志
|
|
Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
|
|
+ ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
TIeInvigilateExceptionInfo tIeInvigilateExceptionInfo = new TIeInvigilateExceptionInfo(examId, examActivityId, recordId, examStudentId, ExceptionEnum.NET_TIME_OUT.getCode(), ExceptionEnum.NET_TIME_OUT, diff);
|
|
TIeInvigilateExceptionInfo tIeInvigilateExceptionInfo = new TIeInvigilateExceptionInfo(examId, examActivityId, recordId, examStudentId, ExceptionEnum.NET_TIME_OUT.getCode(), ExceptionEnum.NET_TIME_OUT, diff);
|
|
tIeInvigilateExceptionInfoService.saveOrUpdate(tIeInvigilateExceptionInfo);
|
|
tIeInvigilateExceptionInfoService.saveOrUpdate(tIeInvigilateExceptionInfo);
|
|
|
|
+ TEExamStudentLog teExamStudentLog = new TEExamStudentLog(SystemOperationEnum.BREAK_OFF.name(), SystemOperationEnum.BREAK_OFF.getCode(), SystemOperationEnum.BREAK_OFF.getCode(), examStudentCacheBean.getStudentId(), examStudentId, recordId);
|
|
|
|
+ teExamStudentLogService.save(teExamStudentLog);
|
|
}
|
|
}
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|
|
TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|
|
Map map = new HashMap();
|
|
Map map = new HashMap();
|
|
@@ -365,6 +380,7 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
* @param key
|
|
* @param key
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
|
|
+ @Transactional
|
|
public void execMqExamRecordPersistedLogic(MqDto mqDto, String key) {
|
|
public void execMqExamRecordPersistedLogic(MqDto mqDto, String key) {
|
|
Gson gson = new Gson();
|
|
Gson gson = new Gson();
|
|
Map<String, Object> param = (Map<String, Object>) mqDto.getBody();
|
|
Map<String, Object> param = (Map<String, Object>) mqDto.getBody();
|
|
@@ -475,22 +491,6 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
Long examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
|
|
|
|
|
|
- //先查询之前的断点记录
|
|
|
|
- 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(ExamRecordCacheUtil.getLastBreakId(recordId), recordId, new Date(), exceptionEnum, exceptionEnum.name());
|
|
|
|
- tOeExamBreakHistoryService.save(tOeExamBreakHistory);
|
|
|
|
- redisUtil.setForHash(RedisKeyHelper.examBreakCacheKey(tOeExamBreakHistory.getId()), SimpleBeanUtil.objectToMap(tOeExamBreakHistory));
|
|
|
|
- teExamStudentLogService.saveStudentLogInfo(SystemOperationEnum.RESUME_PREPARE.name(), SystemOperationEnum.RESUME_PREPARE.getCode(), SystemOperationEnum.RESUME_PREPARE.getCode(), examStudentCacheBean.getStudentId(), examStudentId, recordId);
|
|
|
|
-
|
|
|
|
//增加异常日志
|
|
//增加异常日志
|
|
Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
Long examId = ExamRecordCacheUtil.getExamId(recordId);
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
Long examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
|
|
@@ -530,9 +530,9 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
tmRocketMessageService.saveOrUpdate(tmRocketMessage);
|
|
tmRocketMessageService.saveOrUpdate(tmRocketMessage);
|
|
redisUtil.delete(key, mqDto.getId());
|
|
redisUtil.delete(key, mqDto.getId());
|
|
}
|
|
}
|
|
-
|
|
|
|
|
|
+
|
|
/**
|
|
/**
|
|
- *更新考生信息
|
|
|
|
|
|
+ * 更新考生信息
|
|
*/
|
|
*/
|
|
@Override
|
|
@Override
|
|
@Transactional
|
|
@Transactional
|
|
@@ -546,4 +546,39 @@ public class MqLogicServiceImpl implements MqLogicService {
|
|
tmRocketMessageService.saveOrUpdate(tmRocketMessage);
|
|
tmRocketMessageService.saveOrUpdate(tmRocketMessage);
|
|
redisUtil.delete(key, mqDto.getId());
|
|
redisUtil.delete(key, mqDto.getId());
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ /**
|
|
|
|
+ * 考试断点
|
|
|
|
+ *
|
|
|
|
+ * @param mqDto
|
|
|
|
+ * @param key
|
|
|
|
+ */
|
|
|
|
+ @Override
|
|
|
|
+ @Transactional
|
|
|
|
+ public void execMqExamBreakLogic(MqDto mqDto, String key) {
|
|
|
|
+ ExceptionEnum exceptionEnum = ExceptionEnum.valueOf(String.valueOf(mqDto.getBody()));
|
|
|
|
+ Long recordId = Long.parseLong(mqDto.getObjId());
|
|
|
|
+
|
|
|
|
+ //先查询之前的断点记录
|
|
|
|
+ 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(ExamRecordCacheUtil.getLastBreakId(recordId), recordId, new Date(), exceptionEnum, exceptionEnum.name());
|
|
|
|
+ tOeExamBreakHistoryService.save(tOeExamBreakHistory);
|
|
|
|
+ redisUtil.setForHash(RedisKeyHelper.examBreakCacheKey(tOeExamBreakHistory.getId()), SimpleBeanUtil.objectToMap(tOeExamBreakHistory));
|
|
|
|
+
|
|
|
|
+ Gson gson = new Gson();
|
|
|
|
+ mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
|
|
|
|
+ TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
|
|
|
|
+ tmRocketMessage.setBody(JacksonUtil.parseJson(tmRocketMessage.getBody()));
|
|
|
|
+ tmRocketMessageService.saveOrUpdate(tmRocketMessage);
|
|
|
|
+ redisUtil.delete(key, mqDto.getId());
|
|
|
|
+ }
|
|
}
|
|
}
|