瀏覽代碼

增加待考列表接口

wangliang 4 年之前
父節點
當前提交
1aeb8c3b5d

+ 11 - 1
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamActivityMapper.java

@@ -6,7 +6,7 @@ import com.qmth.themis.business.entity.TEExamActivity;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 import org.apache.ibatis.annotations.Param;
 
 
-import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -70,4 +70,14 @@ public interface TEExamActivityMapper extends BaseMapper<TEExamActivity> {
      * @return
      * @return
      */
      */
     public IPage<TEExamActivity> examActivityQuery(IPage<Map> iPage, @Param("examId") Long examId, @Param("code") String code, @Param("startDate") String startDate, @Param("finishDate") String finishDate);
     public IPage<TEExamActivity> examActivityQuery(IPage<Map> iPage, @Param("examId") Long examId, @Param("code") String code, @Param("startDate") String startDate, @Param("finishDate") String finishDate);
+
+    /**
+     * 获取考试待考列表
+     *
+     * @param studentId
+     * @param examId
+     * @param examActivityId
+     * @return
+     */
+    public List<Map> getWaitingExam(@Param("studentId") Long studentId, @Param("examId") Long examId, @Param("examActivityId") Long examActivityId);
 }
 }

+ 11 - 1
themis-business/src/main/java/com/qmth/themis/business/service/TEExamActivityService.java

@@ -4,7 +4,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.baomidou.mybatisplus.extension.service.IService;
 import com.qmth.themis.business.entity.TEExamActivity;
 import com.qmth.themis.business.entity.TEExamActivity;
 
 
-import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -67,4 +67,14 @@ public interface TEExamActivityService extends IService<TEExamActivity> {
      * @return
      * @return
      */
      */
     public IPage<TEExamActivity> examActivityQuery(IPage<Map> iPage, Long examId, String code, String startDate, String finishDate);
     public IPage<TEExamActivity> examActivityQuery(IPage<Map> iPage, Long examId, String code, String startDate, String finishDate);
+
+    /**
+     * 获取考试待考列表
+     *
+     * @param studentId
+     * @param examId
+     * @param examActivityId
+     * @return
+     */
+    public List<Map> getWaitingExam(Long studentId, Long examId,Long examActivityId);
 }
 }

+ 14 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -9,6 +9,7 @@ import org.springframework.stereotype.Service;
 
 
 import javax.annotation.Resource;
 import javax.annotation.Resource;
 import java.util.Date;
 import java.util.Date;
+import java.util.List;
 import java.util.Map;
 import java.util.Map;
 
 
 /**
 /**
@@ -93,4 +94,17 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
     public IPage<TEExamActivity> examActivityQuery(IPage<Map> iPage, Long examId, String code, String startDate, String finishDate) {
     public IPage<TEExamActivity> examActivityQuery(IPage<Map> iPage, Long examId, String code, String startDate, String finishDate) {
         return teExamActivityMapper.examActivityQuery(iPage, examId, code, startDate, finishDate);
         return teExamActivityMapper.examActivityQuery(iPage, examId, code, startDate, finishDate);
     }
     }
+
+    /**
+     * 获取考试待考列表
+     *
+     * @param studentId
+     * @param examId
+     * @param examActivityId
+     * @return
+     */
+    @Override
+    public List<Map> getWaitingExam(Long studentId, Long examId, Long examActivityId) {
+        return teExamActivityMapper.getWaitingExam(studentId, examId, examActivityId);
+    }
 }
 }

+ 12 - 14
themis-business/src/main/java/com/qmth/themis/business/util/RedisUtil.java

@@ -1,17 +1,15 @@
 package com.qmth.themis.business.util;
 package com.qmth.themis.business.util;
 
 
+import com.qmth.themis.business.constant.SystemConstant;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.stereotype.Component;
+
+import javax.annotation.Resource;
 import java.util.List;
 import java.util.List;
 import java.util.Map;
 import java.util.Map;
 import java.util.Set;
 import java.util.Set;
 import java.util.concurrent.TimeUnit;
 import java.util.concurrent.TimeUnit;
 
 
-import javax.annotation.Resource;
-
-import org.springframework.data.redis.core.RedisTemplate;
-import org.springframework.stereotype.Component;
-
-import com.qmth.themis.business.constant.SystemConstant;
-
 /**
 /**
  * @Description: redis util
  * @Description: redis util
  * @Param:
  * @Param:
@@ -23,7 +21,7 @@ import com.qmth.themis.business.constant.SystemConstant;
 public class RedisUtil {
 public class RedisUtil {
 
 
     @Resource
     @Resource
-    RedisTemplate<String,Object> redisTemplate;
+    RedisTemplate<String, Object> redisTemplate;
 
 
     /**
     /**
      * 获取机构信息
      * 获取机构信息
@@ -250,10 +248,10 @@ public class RedisUtil {
      * @param timeout SECONDS
      * @param timeout SECONDS
      * @return
      * @return
      */
      */
-    public boolean lock(String key,long timeout) {
-    	long expireAt = System.currentTimeMillis() + (timeout*1000) + 1;
-    	Boolean b = redisTemplate.opsForValue().setIfAbsent(key, expireAt, timeout, TimeUnit.SECONDS);
-		return b;
+    public boolean lock(String key, long timeout) {
+        long expireAt = System.currentTimeMillis() + (timeout * 1000) + 1;
+        Boolean b = redisTemplate.opsForValue().setIfAbsent(key, expireAt, timeout, TimeUnit.SECONDS);
+        return b;
     }
     }
 
 
     /**
     /**
@@ -263,7 +261,7 @@ public class RedisUtil {
      * @return
      * @return
      */
      */
     public void releaseLock(String key) {
     public void releaseLock(String key) {
-    	redisTemplate.expire(key, 100, TimeUnit.MILLISECONDS);
+        redisTemplate.expire(key, 100, TimeUnit.MILLISECONDS);
     }
     }
 
 
     /**
     /**
@@ -305,6 +303,6 @@ public class RedisUtil {
      * @return
      * @return
      */
      */
     public void delete(String key) {
     public void delete(String key) {
-    	redisTemplate.expire(key,0,TimeUnit.SECONDS);
+        redisTemplate.expire(key, 0, TimeUnit.SECONDS);
     }
     }
 }
 }

+ 47 - 0
themis-business/src/main/resources/mapper/TEExamActivityMapper.xml

@@ -77,4 +77,51 @@
             </if>
             </if>
         </where>
         </where>
     </select>
     </select>
+
+    <select id="getWaitingExam" resultType="java.util.Map">
+         select
+            teea.id,
+            tees.course_code as courseCode,
+            teec.course_name as courseName,
+            tee.prepare_seconds as prepareSeconds,
+            tee.min_duration_seconds as minDurationSeconds,
+            tee.max_duration_seconds as maxDurationSeconds,
+            tee.exam_count as examCount,
+            tee.force_finish as fouceFinish,
+            tee.entry_authentication_policy as entryAuthenticationPolicy,
+            tee.in_process_face_verify as inProcessFaceVerify,
+            tee.in_process_face_stranger_ignore as inProcessFaceStrangerIgnore,
+            tee.in_process_liveness_verify as inProcessLivenessVerify,
+            tee.in_process_liveness_interval_seconds as inProcessLivenessIntervalSeconds,
+            tee.in_process_liveness_judge_policy as inProcessLivenessJudgePolicy,
+            tee.in_process_liveness_retry_count as inProcessLivenessRetryCount,
+            tee.client_video_push as clientVideoPush,
+            tee.wxapp_video_push as wxappVideoPush,
+            tee.camera_photo_upload as cameraPhotoUpload,
+            tee.wxapp_photo_upload as wxappPhotoUpload,
+            tee.wxapp_video_record as wxappVideoRecord
+        from
+            t_e_exam_student tees
+        left join t_e_exam_course teec on
+            teec.course_code = tees.course_code
+        left join t_e_exam tee on
+            tee.id = tees.exam_id
+        left join t_e_exam_activity teea on
+            teea.id = tees.exam_activity_id
+        <where>
+            <if test="examActivityId != null and examActivityId != ''">
+                and teea.id = #{examActivityId}
+            </if>
+            <if test="examId != null and examId != ''">
+                and teea.exam_id = #{examId}
+            </if>
+            <if test="studentId != null and studentId != ''">
+                and tees.student_id = #{studentId}
+            </if>
+            and tee.enable = 1
+            and teea.enable = 1
+            and tees.enable = 1
+            and teea.start_time <![CDATA[ >= ]]> date_add(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
+        </where>
+    </select>
 </mapper>
 </mapper>

+ 15 - 37
themis-business/src/main/resources/mapper/TEExamMapper.xml

@@ -25,38 +25,12 @@
 
 
     <select id="getWaitingExam" resultType="java.util.Map">
     <select id="getWaitingExam" resultType="java.util.Map">
         select
         select
-            tee.id,
-            teea.id as examActivityId,
-            tee.name,
-            tee.mode,
-            tee.pre_notice as preNotice,
-            tee.pre_notice_stay_seconds as preNoticeStaySeconds,
-            tee.post_notice as postNotice,
-            tee.code as examCode,
-            teea.code as examActivityCode,
-            tee.start_time as examStartTime,
-            tee.end_time as examEndTime,
-            teea.start_time as examActivityStartTime,
-            teea.finish_time as examActivityFinishTime,
-            tees.course_code as courseCode,
-            teec.course_name as courseName,
-            tee.prepare_seconds as prepareSeconds,
-            tee.min_duration_seconds as minDurationSeconds,
-            tee.max_duration_seconds as maxDurationSeconds,
-            tee.exam_count as examCount,
-            tee.force_finish as fouceFinish,
-            tee.entry_authentication_policy as entryAuthenticationPolicy,
-            tee.in_process_face_verify as inProcessFaceVerify,
-            tee.in_process_face_stranger_ignore as inProcessFaceStrangerIgnore,
-            tee.in_process_liveness_verify as inProcessLivenessVerify,
-            tee.in_process_liveness_interval_seconds as inProcessLivenessIntervalSeconds,
-            tee.in_process_liveness_judge_policy as inProcessLivenessJudgePolicy,
-            tee.in_process_liveness_retry_count as inProcessLivenessRetryCount,
-            tee.client_video_push as clientVideoPush,
-            tee.wxapp_video_push as wxappVideoPush,
-            tee.camera_photo_upload as cameraPhotoUpload,
-            tee.wxapp_photo_upload as wxappPhotoUpload,
-            tee.wxapp_video_record as wxappVideoRecord
+        t.*
+        from
+        (
+            select
+            distinct tee.id,teea.id as examActivityId, tee.name, tee.mode, tee.pre_notice as preNotice, tee.pre_notice_stay_seconds as
+            preNoticeStaySeconds, tee.post_notice as postNotice, datediff(now(), teea.start_time) as reallyTime
         from
         from
         t_e_exam_student tees
         t_e_exam_student tees
         left join t_e_exam_course teec on
         left join t_e_exam_course teec on
@@ -69,11 +43,15 @@
             <if test="studentId != null and studentId != ''">
             <if test="studentId != null and studentId != ''">
                 and tees.student_id = #{studentId}
                 and tees.student_id = #{studentId}
             </if>
             </if>
-            and tee.enable = 1
-            and teea.enable = 1
-            and tees.enable = 1
-            and teea.start_time <![CDATA[ <= ]]> now()
-            and teea.finish_time <![CDATA[ >= ]]> now()
+                and tee.enable = 1
+                and teea.enable = 1
+                and tees.enable = 1
+                and teea.start_time <![CDATA[ >= ]]> date_add(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
+        </where>
+            ) t
+        <where>
+            t.reallyTime = -1
+            or t.reallyTime = 0
         </where>
         </where>
     </select>
     </select>
 </mapper>
 </mapper>

+ 1 - 2
themis-business/src/main/resources/mapper/TOeExamRecordMapper.xml

@@ -53,8 +53,7 @@
             and tee.enable = 1
             and tee.enable = 1
             and teea.enable = 1
             and teea.enable = 1
             and tees.enable = 1
             and tees.enable = 1
-            and teea.start_time <![CDATA[ <= ]]> now()
-            and teea.finish_time <![CDATA[ >= ]]> now()
+            and teea.start_time <![CDATA[ >= ]]> date_add(now(), interval IFNULL(teea.opening_seconds, tee.opening_seconds) second)
         </where>
         </where>
     </select>
     </select>
 </mapper>
 </mapper>

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

@@ -6,6 +6,7 @@ import com.qmth.themis.business.dto.AuthDto;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TBSession;
 import com.qmth.themis.business.entity.TEConfig;
 import com.qmth.themis.business.entity.TEConfig;
 import com.qmth.themis.business.entity.TEStudent;
 import com.qmth.themis.business.entity.TEStudent;
+import com.qmth.themis.business.entity.TOeExamRecord;
 import com.qmth.themis.business.enums.MqEnum;
 import com.qmth.themis.business.enums.MqEnum;
 import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.enums.RoleEnum;
 import com.qmth.themis.business.enums.SystemOperationEnum;
 import com.qmth.themis.business.enums.SystemOperationEnum;
@@ -29,7 +30,6 @@ import com.qmth.themis.exam.util.ServletUtil;
 import com.qmth.themis.mq.service.MqDtoService;
 import com.qmth.themis.mq.service.MqDtoService;
 import io.swagger.annotations.*;
 import io.swagger.annotations.*;
 import org.apache.commons.lang3.RandomStringUtils;
 import org.apache.commons.lang3.RandomStringUtils;
-import org.springframework.cache.CacheManager;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMapping;
 import org.springframework.web.bind.annotation.RequestMethod;
 import org.springframework.web.bind.annotation.RequestMethod;
@@ -72,6 +72,9 @@ public class TEStudentController {
     @Resource
     @Resource
     TEExamService teExamService;
     TEExamService teExamService;
 
 
+    @Resource
+    TEExamActivityService examActivityService;
+
     @Resource
     @Resource
     TOeExamRecordService tOeExamRecordService;
     TOeExamRecordService tOeExamRecordService;
 
 
@@ -144,6 +147,13 @@ public class TEStudentController {
         Map unFinishExam = tOeExamRecordService.getUnFinishExam(teStudent.getId());
         Map unFinishExam = tOeExamRecordService.getUnFinishExam(teStudent.getId());
         if (Objects.isNull(unFinishExam)) {
         if (Objects.isNull(unFinishExam)) {
             List<Map> list = teExamService.getWaitingExam(teStudent.getId());
             List<Map> list = teExamService.getWaitingExam(teStudent.getId());
+            if (Objects.nonNull(list) && list.size() > 0) {
+                for (int i = 0; i < list.size(); i++) {
+                    Map m = list.get(i);
+                    List<Map> teExamActivityList = examActivityService.getWaitingExam(teStudent.getId(), Long.parseLong(String.valueOf(m.get("id"))), Long.parseLong(String.valueOf(m.get("examActivityId"))));
+                    m.put("activities", teExamActivityList);
+                }
+            }
             map.put("waiting", list);
             map.put("waiting", list);
         } else {
         } else {
             map.put("unFinished", unFinishExam);
             map.put("unFinished", unFinishExam);

+ 0 - 1
themis-exam/src/main/java/com/qmth/themis/exam/websocketTemplete/WebSocketOeMessageTemplete.java

@@ -2,7 +2,6 @@ package com.qmth.themis.exam.websocketTemplete;
 
 
 import com.alibaba.fastjson.JSONObject;
 import com.alibaba.fastjson.JSONObject;
 import com.qmth.themis.common.util.Result;
 import com.qmth.themis.common.util.Result;
-import com.qmth.themis.exam.websocket.WebSocketServer;
 import org.slf4j.Logger;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Component;
 import org.springframework.stereotype.Component;

+ 13 - 15
themis-mq/src/main/java/com/qmth/themis/mq/listener/RocketSessionConsumer.java

@@ -1,10 +1,15 @@
 package com.qmth.themis.mq.listener;
 package com.qmth.themis.mq.listener;
 
 
-import java.util.List;
-import java.util.Objects;
-
-import javax.annotation.Resource;
-
+import com.google.gson.Gson;
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TBSession;
+import com.qmth.themis.business.entity.TMRocketMessage;
+import com.qmth.themis.business.service.TBSessionService;
+import com.qmth.themis.business.service.TMRocketMessageService;
+import com.qmth.themis.business.util.JacksonUtil;
+import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.mq.dto.MqDto;
 import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
 import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -20,16 +25,9 @@ import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 
 
-import com.google.gson.Gson;
-import com.qmth.themis.business.constant.SystemConstant;
-import com.qmth.themis.business.entity.TBSession;
-import com.qmth.themis.business.entity.TMRocketMessage;
-import com.qmth.themis.business.service.TBSessionService;
-import com.qmth.themis.business.service.TMRocketMessageService;
-import com.qmth.themis.business.util.JacksonUtil;
-import com.qmth.themis.business.util.RedisUtil;
-import com.qmth.themis.common.contanst.Constants;
-import com.qmth.themis.mq.dto.MqDto;
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Objects;
 
 
 /**
 /**
  * @Description: 普通消息监听 session_topic
  * @Description: 普通消息监听 session_topic

+ 28 - 30
themis-mq/src/main/java/com/qmth/themis/mq/listener/RocketTaskConsumer.java

@@ -1,27 +1,5 @@
 package com.qmth.themis.mq.listener;
 package com.qmth.themis.mq.listener;
 
 
-import java.io.IOException;
-import java.util.List;
-import java.util.Map;
-import java.util.Objects;
-
-import javax.annotation.Resource;
-
-import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
-import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
-import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
-import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
-import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
-import org.apache.rocketmq.common.message.Message;
-import org.apache.rocketmq.common.message.MessageExt;
-import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
-import org.apache.rocketmq.spring.annotation.SelectorType;
-import org.apache.rocketmq.spring.core.RocketMQListener;
-import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
-import org.slf4j.Logger;
-import org.slf4j.LoggerFactory;
-import org.springframework.stereotype.Service;
-
 import com.google.gson.Gson;
 import com.google.gson.Gson;
 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;
@@ -37,6 +15,26 @@ import com.qmth.themis.business.util.JacksonUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.business.util.RedisUtil;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.common.contanst.Constants;
 import com.qmth.themis.mq.dto.MqDto;
 import com.qmth.themis.mq.dto.MqDto;
+import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
+import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
+import org.apache.rocketmq.client.consumer.listener.MessageListenerConcurrently;
+import org.apache.rocketmq.common.consumer.ConsumeFromWhere;
+import org.apache.rocketmq.common.message.Message;
+import org.apache.rocketmq.common.message.MessageExt;
+import org.apache.rocketmq.spring.annotation.RocketMQMessageListener;
+import org.apache.rocketmq.spring.annotation.SelectorType;
+import org.apache.rocketmq.spring.core.RocketMQListener;
+import org.apache.rocketmq.spring.core.RocketMQPushConsumerLifecycleListener;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.List;
+import java.util.Map;
+import java.util.Objects;
 
 
 /**
 /**
  * @Description: 普通消息监听 task
  * @Description: 普通消息监听 task
@@ -76,7 +74,7 @@ public class RocketTaskConsumer {
                     mqDto = JacksonUtil.readJson(new String(messageExt.getBody(), Constants.CHARSET), MqDto.class);
                     mqDto = JacksonUtil.readJson(new String(messageExt.getBody(), Constants.CHARSET), MqDto.class);
                     log.info(":{}-:{} task import Consumer接收到的消息:{}", threadId, threadName, JacksonUtil.parseJson(mqDto));
                     log.info(":{}-:{} task import Consumer接收到的消息:{}", threadId, threadName, JacksonUtil.parseJson(mqDto));
 //                    log.info(":{}-:{} task import Consumer mqDto sequence:{},tag:{}", threadId, threadName, mqDto.getSequence(), mqDto.getTag());
 //                    log.info(":{}-:{} task import Consumer mqDto sequence:{},tag:{}", threadId, threadName, mqDto.getSequence(), mqDto.getTag());
-                    if (Objects.nonNull(mqDto.getAck()) && mqDto.getAck().intValue() != SystemConstant.STANDARD_ACK_TYPE && Objects.nonNull(redisUtil.get(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST, mqDto.getId())) && redisUtil.lock(SystemConstant.REDIS_LOCK_MQ_PREFIX+mqDto.getId(), SystemConstant.REDIS_LOCK_MQ_TIME_OUT)) {
+                    if (Objects.nonNull(mqDto.getAck()) && mqDto.getAck().intValue() != SystemConstant.STANDARD_ACK_TYPE && Objects.nonNull(redisUtil.get(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST, mqDto.getId())) && redisUtil.lock(SystemConstant.REDIS_LOCK_MQ_PREFIX + mqDto.getId(), SystemConstant.REDIS_LOCK_MQ_TIME_OUT)) {
                         Map<String, Object> map = (Map<String, Object>) mqDto.getBody();
                         Map<String, Object> map = (Map<String, Object>) mqDto.getBody();
                         String tag = mqDto.getTag();
                         String tag = mqDto.getTag();
                         myThreadPool.arbitratePoolTaskExecutor.execute(() -> {
                         myThreadPool.arbitratePoolTaskExecutor.execute(() -> {
@@ -85,8 +83,8 @@ public class RocketTaskConsumer {
                                 taskImportTemplete = new TaskExamStudentImportTemplete();
                                 taskImportTemplete = new TaskExamStudentImportTemplete();
                             } else if (tag.contains("roomCodeImport")) {
                             } else if (tag.contains("roomCodeImport")) {
                                 taskImportTemplete = new TaskRoomCodeImportTemplete();
                                 taskImportTemplete = new TaskRoomCodeImportTemplete();
-                            } else if(tag.contains("examPaperImport")) {
-                            	taskImportTemplete = SpringContextHolder.getBean("taskExamPaperImportTemplete");
+                            } else if (tag.contains("examPaperImport")) {
+                                taskImportTemplete = SpringContextHolder.getBean("taskExamPaperImportTemplete");
                             }
                             }
                             try {
                             try {
                                 taskImportTemplete.importTask(map);
                                 taskImportTemplete.importTask(map);
@@ -98,7 +96,7 @@ public class RocketTaskConsumer {
                         mqDto.setBody(JacksonUtil.parseJson(mqDto.getBody()));
                         mqDto.setBody(JacksonUtil.parseJson(mqDto.getBody()));
                         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
                         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
                         tmRocketMessageService.saveOrUpdate(tmRocketMessage);
                         tmRocketMessageService.saveOrUpdate(tmRocketMessage);
-                        redisUtil.delete(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST+ mqDto.getId());
+                        redisUtil.delete(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST + mqDto.getId());
                         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                     } else {
                     } else {
                         log.info(":{}-:{} 消息ack未确认,重发", threadId, threadName);
                         log.info(":{}-:{} 消息ack未确认,重发", threadId, threadName);
@@ -110,7 +108,7 @@ public class RocketTaskConsumer {
                 return ConsumeConcurrentlyStatus.RECONSUME_LATER;//重试
                 return ConsumeConcurrentlyStatus.RECONSUME_LATER;//重试
             } finally {
             } finally {
                 if (Objects.nonNull(mqDto)) {
                 if (Objects.nonNull(mqDto)) {
-                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_MQ_PREFIX+mqDto.getId());
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_MQ_PREFIX + mqDto.getId());
                 }
                 }
             }
             }
             return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功
             return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功
@@ -176,7 +174,7 @@ public class RocketTaskConsumer {
                     mqDto = JacksonUtil.readJson(new String(messageExt.getBody(), Constants.CHARSET), MqDto.class);
                     mqDto = JacksonUtil.readJson(new String(messageExt.getBody(), Constants.CHARSET), MqDto.class);
                     log.info(":{}-:{} task export Consumer接收到的消息:{}", threadId, threadName, JacksonUtil.parseJson(mqDto));
                     log.info(":{}-:{} task export Consumer接收到的消息:{}", threadId, threadName, JacksonUtil.parseJson(mqDto));
 //                    log.info(":{}-:{} task ExamStudentImport Consumer mqDto sequence:{},tag:{}", threadId, threadName, mqDto.getSequence(), mqDto.getTag());
 //                    log.info(":{}-:{} task ExamStudentImport Consumer mqDto sequence:{},tag:{}", threadId, threadName, mqDto.getSequence(), mqDto.getTag());
-                    if (Objects.nonNull(mqDto.getAck()) && mqDto.getAck().intValue() != SystemConstant.STANDARD_ACK_TYPE && Objects.nonNull(redisUtil.get(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST, mqDto.getId())) && redisUtil.lock(SystemConstant.REDIS_LOCK_MQ_PREFIX+ mqDto.getId(), SystemConstant.REDIS_LOCK_MQ_TIME_OUT)) {
+                    if (Objects.nonNull(mqDto.getAck()) && mqDto.getAck().intValue() != SystemConstant.STANDARD_ACK_TYPE && Objects.nonNull(redisUtil.get(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST, mqDto.getId())) && redisUtil.lock(SystemConstant.REDIS_LOCK_MQ_PREFIX + mqDto.getId(), SystemConstant.REDIS_LOCK_MQ_TIME_OUT)) {
                         Map<String, Object> map = (Map<String, Object>) mqDto.getBody();
                         Map<String, Object> map = (Map<String, Object>) mqDto.getBody();
                         String tag = mqDto.getTag();
                         String tag = mqDto.getTag();
                         myThreadPool.arbitratePoolTaskExecutor.execute(() -> {
                         myThreadPool.arbitratePoolTaskExecutor.execute(() -> {
@@ -194,7 +192,7 @@ public class RocketTaskConsumer {
                         mqDto.setBody(JacksonUtil.parseJson(mqDto.getBody()));
                         mqDto.setBody(JacksonUtil.parseJson(mqDto.getBody()));
                         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
                         TMRocketMessage tmRocketMessage = gson.fromJson(gson.toJson(mqDto), TMRocketMessage.class);
                         tmRocketMessageService.saveOrUpdate(tmRocketMessage);
                         tmRocketMessageService.saveOrUpdate(tmRocketMessage);
-                        redisUtil.delete(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST+mqDto.getId());
+                        redisUtil.delete(SystemConstant.TASKLOG_TOPIC_BUFFER_LIST + mqDto.getId());
                         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;
                     } else {
                     } else {
                         log.info(":{}-:{} 消息ack未确认,重发", threadId, threadName);
                         log.info(":{}-:{} 消息ack未确认,重发", threadId, threadName);
@@ -206,7 +204,7 @@ public class RocketTaskConsumer {
                 return ConsumeConcurrentlyStatus.RECONSUME_LATER;//重试
                 return ConsumeConcurrentlyStatus.RECONSUME_LATER;//重试
             } finally {
             } finally {
                 if (Objects.nonNull(mqDto)) {
                 if (Objects.nonNull(mqDto)) {
-                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_MQ_PREFIX+ mqDto.getId());
+                    redisUtil.releaseLock(SystemConstant.REDIS_LOCK_MQ_PREFIX + mqDto.getId());
                 }
                 }
             }
             }
             return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功
             return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功

+ 17 - 19
themis-mq/src/main/java/com/qmth/themis/mq/listener/RocketUserLogConsumer.java

@@ -1,10 +1,17 @@
 package com.qmth.themis.mq.listener;
 package com.qmth.themis.mq.listener;
 
 
-import java.util.List;
-import java.util.Objects;
-
-import javax.annotation.Resource;
-
+import com.google.gson.Gson;
+import com.qmth.themis.business.constant.SystemConstant;
+import com.qmth.themis.business.entity.TMRocketMessage;
+import com.qmth.themis.business.enums.MqEnum;
+import com.qmth.themis.business.enums.SystemOperationEnum;
+import com.qmth.themis.business.service.TEExamStudentLogService;
+import com.qmth.themis.business.service.TEUserLogService;
+import com.qmth.themis.business.service.TMRocketMessageService;
+import com.qmth.themis.business.util.JacksonUtil;
+import com.qmth.themis.business.util.RedisUtil;
+import com.qmth.themis.common.contanst.Constants;
+import com.qmth.themis.mq.dto.MqDto;
 import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
 import org.apache.rocketmq.client.consumer.DefaultMQPushConsumer;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyContext;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
 import org.apache.rocketmq.client.consumer.listener.ConsumeConcurrentlyStatus;
@@ -21,18 +28,9 @@ import org.slf4j.LoggerFactory;
 import org.springframework.stereotype.Service;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.transaction.annotation.Transactional;
 
 
-import com.google.gson.Gson;
-import com.qmth.themis.business.constant.SystemConstant;
-import com.qmth.themis.business.entity.TMRocketMessage;
-import com.qmth.themis.business.enums.MqEnum;
-import com.qmth.themis.business.enums.SystemOperationEnum;
-import com.qmth.themis.business.service.TEExamStudentLogService;
-import com.qmth.themis.business.service.TEUserLogService;
-import com.qmth.themis.business.service.TMRocketMessageService;
-import com.qmth.themis.business.util.JacksonUtil;
-import com.qmth.themis.business.util.RedisUtil;
-import com.qmth.themis.common.contanst.Constants;
-import com.qmth.themis.mq.dto.MqDto;
+import javax.annotation.Resource;
+import java.util.List;
+import java.util.Objects;
 
 
 /**
 /**
  * @Description: 普通消息监听 用户日志
  * @Description: 普通消息监听 用户日志
@@ -80,7 +78,7 @@ public class RocketUserLogConsumer implements MessageListenerConcurrently {
                     o = redisUtil.get(SystemConstant.STUDENTLOG_TOPIC_BUFFER_LIST, mqDto.getId());
                     o = redisUtil.get(SystemConstant.STUDENTLOG_TOPIC_BUFFER_LIST, mqDto.getId());
                     mqTopic = SystemConstant.STUDENTLOG_TOPIC_BUFFER_LIST;
                     mqTopic = SystemConstant.STUDENTLOG_TOPIC_BUFFER_LIST;
                 }
                 }
-                if (Objects.nonNull(mqDto.getAck()) && mqDto.getAck().intValue() != SystemConstant.STANDARD_ACK_TYPE && Objects.nonNull(o) && redisUtil.lock(SystemConstant.REDIS_LOCK_MQ_PREFIX+mqDto.getId(), SystemConstant.REDIS_LOCK_MQ_TIME_OUT)) {
+                if (Objects.nonNull(mqDto.getAck()) && mqDto.getAck().intValue() != SystemConstant.STANDARD_ACK_TYPE && Objects.nonNull(o) && redisUtil.lock(SystemConstant.REDIS_LOCK_MQ_PREFIX + mqDto.getId(), SystemConstant.REDIS_LOCK_MQ_TIME_OUT)) {
                     log.info(":{}-:{} 插入用户轨迹日志", threadId, threadName);
                     log.info(":{}-:{} 插入用户轨迹日志", threadId, threadName);
                     if (tag.contains("user")) {
                     if (tag.contains("user")) {
                         teUserLogService.saveUserLogInfo(mqDto.getTimestamp(), mqDto.getObjId(), MqEnum.valueOf(String.valueOf(mqDto.getType())).getId(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), JacksonUtil.parseJson(mqDto));
                         teUserLogService.saveUserLogInfo(mqDto.getTimestamp(), mqDto.getObjId(), MqEnum.valueOf(String.valueOf(mqDto.getType())).getId(), SystemOperationEnum.valueOf(String.valueOf(mqDto.getBody())).getCode(), JacksonUtil.parseJson(mqDto));
@@ -102,7 +100,7 @@ public class RocketUserLogConsumer implements MessageListenerConcurrently {
             return ConsumeConcurrentlyStatus.RECONSUME_LATER;//重试
             return ConsumeConcurrentlyStatus.RECONSUME_LATER;//重试
         } finally {
         } finally {
             if (Objects.nonNull(mqDto)) {
             if (Objects.nonNull(mqDto)) {
-                redisUtil.releaseLock(SystemConstant.REDIS_LOCK_MQ_PREFIX+mqDto.getId());
+                redisUtil.releaseLock(SystemConstant.REDIS_LOCK_MQ_PREFIX + mqDto.getId());
             }
             }
         }
         }
         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功
         return ConsumeConcurrentlyStatus.CONSUME_SUCCESS;//成功