Ver Fonte

db修改

wangliang há 4 anos atrás
pai
commit
b817fe4ed8

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

@@ -19,6 +19,7 @@ import com.qmth.themis.business.enums.FinishTypeEnum;
 import com.qmth.themis.business.service.*;
 import com.qmth.themis.business.util.OssUtil;
 import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.business.util.ServletUtil;
 import com.qmth.themis.common.exception.BusinessException;
 import org.apache.commons.codec.digest.DigestUtils;
 import org.apache.commons.lang3.StringUtils;
@@ -223,7 +224,7 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         //更新场次-考试记录缓存
         ExamActivityRecordCacheUtil.setExamRecordStatus(activityId, recordId, ExamRecordCacheUtil.getStatus(recordId));
         teStudentCacheDto.setUnFinishedRecordId(recordId);
-        redisUtil.setStudent(studentId, teStudentCacheDto, null, null);
+        redisUtil.setStudent(studentId, teStudentCacheDto);
         return prepare;
     }
 
@@ -579,9 +580,9 @@ public class TEExamServiceImpl extends ServiceImpl<TEExamMapper, TEExam> impleme
         //更新场次-考试记录缓存
         ExamActivityRecordCacheUtil.setExamRecordStatus(es.getExamActivityId(), recordId, ExamRecordCacheUtil.getStatus(recordId));
         //更新未完成考试记录id
-        TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) redisUtil.getStudent(es.getStudentId());
+        TEStudentCacheDto teStudentCacheDto = (TEStudentCacheDto) ServletUtil.getRequestStudentAccount();
         teStudentCacheDto.setUnFinishedRecordId(null);
-        redisUtil.setStudent(studentId, teStudentCacheDto, null, null);
+        redisUtil.setStudent(teStudentCacheDto.getId(), teStudentCacheDto);
         return ret;
     }
 

+ 13 - 6
themis-business/src/main/java/com/qmth/themis/business/util/RedisUtil.java

@@ -7,7 +7,6 @@ import org.springframework.stereotype.Component;
 import javax.annotation.Resource;
 import java.util.List;
 import java.util.Map;
-import java.util.Objects;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 
@@ -106,13 +105,21 @@ public class RedisUtil {
      *
      * @param studentId
      * @param o
+     * @param time
+     * @param timeUnit
      */
     public void setStudent(Long studentId, Object o, Long time, TimeUnit timeUnit) {
-        if (Objects.nonNull(time) && Objects.nonNull(timeUnit)) {
-            redisTemplate.opsForValue().set(SystemConstant.STUDENT + studentId, o, time, timeUnit);
-        } else {
-            redisTemplate.opsForValue().set(SystemConstant.STUDENT + studentId, o);
-        }
+        redisTemplate.opsForValue().set(SystemConstant.STUDENT + studentId, o, time, timeUnit);
+    }
+
+    /**
+     * 设置学生信息
+     *
+     * @param studentId
+     * @param o
+     */
+    public void setStudent(Long studentId, Object o) {
+        redisTemplate.opsForValue().set(SystemConstant.STUDENT + studentId, o);
     }
 
     /**

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

@@ -152,7 +152,7 @@ public class TEStudentController {
             teStudentCacheDto = gson.fromJson(gson.toJson(teStudent), TEStudentCacheDto.class);
         }
         //添加用户缓存
-        redisUtil.setStudent(teStudent.getId(), teStudentCacheDto, null, null);
+        redisUtil.setStudent(teStudent.getId(), teStudentCacheDto);
         String source = null;
         if (Objects.equals(platform.name(), Platform.win.name()) || Objects.equals(platform.name(), Platform.mac.name())) {
             source = platform.getSource().split(",")[1];

+ 1 - 1
themis-exam/src/main/java/com/qmth/themis/exam/interceptor/AuthInterceptor.java

@@ -100,7 +100,7 @@ public class AuthInterceptor implements HandlerInterceptor {
                         TEStudent teStudent = teStudentService.getById(userId);
                         Gson gson = new Gson();
                         teStudentCacheDto = gson.fromJson(gson.toJson(teStudent), TEStudentCacheDto.class);
-                        redisUtil.setStudent(teStudent.getId(), teStudentCacheDto, null, null);
+                        redisUtil.setStudent(teStudent.getId(), teStudentCacheDto);
                     }
 
                     request.setAttribute(SystemConstant.SESSION, tbSession);

+ 6 - 0
themis-exam/src/main/java/com/qmth/themis/exam/listener/service/impl/MqOeLogicServiceImpl.java

@@ -7,7 +7,9 @@ import com.qmth.themis.business.dto.WebsocketDto;
 import com.qmth.themis.business.entity.TMRocketMessage;
 import com.qmth.themis.business.enums.FinishTypeEnum;
 import com.qmth.themis.business.enums.MqEnum;
+import com.qmth.themis.business.enums.SystemOperationEnum;
 import com.qmth.themis.business.enums.WebsocketTypeEnum;
+import com.qmth.themis.business.service.TEExamStudentLogService;
 import com.qmth.themis.business.service.TMRocketMessageService;
 import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
@@ -44,6 +46,9 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
     @Resource
     TMRocketMessageService tmRocketMessageService;
 
+    @Resource
+    TEExamStudentLogService teExamStudentLogService;
+
     /**
      * mq最大重试次数逻辑
      *
@@ -165,6 +170,7 @@ public class MqOeLogicServiceImpl implements MqOeLogicService {
 //            });
         }
         mqDto.setAck(SystemConstant.STANDARD_ACK_TYPE);
+        teExamStudentLogService.saveStudentLogInfo(mqDto.getTimestamp(), MqEnum.valueOf(String.valueOf(mqDto.getType())).getId(), mqDto.getType().getCode(), JacksonUtil.parseJson(mqDto));
         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
         tmRocketMessage.setBody(JacksonUtil.parseJson(tmRocketMessage.getBody()));
         tmRocketMessageService.saveOrUpdate(tmRocketMessage);