Procházet zdrojové kódy

管理员预警通知优化代码

wangliang před 1 rokem
rodič
revize
0ebc053fb5

+ 11 - 12
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java

@@ -3,7 +3,7 @@ package com.qmth.themis.admin.api;
 import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
 import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
-import com.qmth.themis.business.bean.admin.ExamListBean;
+import com.qmth.themis.business.bean.admin.ExamInfoBean;
 import com.qmth.themis.business.bean.admin.InvigilateListWarningBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
@@ -60,6 +60,9 @@ public class TIeInvigilateWarnInfoController {
     @Resource
     TEExamService teExamService;
 
+    @Resource
+    TEExamStudentService teExamStudentService;
+
     @ApiOperation(value = "预警提醒接口")
     @RequestMapping(value = "/notify", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"count\":1}", response = Result.class)})
@@ -89,18 +92,14 @@ public class TIeInvigilateWarnInfoController {
             }
         } else {
             //取当前用户机构id所属考试id集合
-            List<TEExam> teExamList = teExamService.list(new QueryWrapper<TEExam>().lambda().eq(TEExam::getOrgId, tbUser.getOrgId()));
-            //TODO 查询数据库拉取当前机构下所有考试批次、场次、考场编码集合(启用状态)
-            if (!CollectionUtils.isEmpty(teExamList)) {
+            List<ExamInfoBean> examInfoBeanList = teExamStudentService.getExamInfo(tbUser.getOrgId());
+            if (!CollectionUtils.isEmpty(examInfoBeanList)) {
                 List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
-                for (TEExam t : teExamList) {
-                    List<ExamListBean> examListBeanList = themisCacheService.getCurrentExamListCache(t.getId().toString());
-                    if (!CollectionUtils.isEmpty(examListBeanList)) {
-                        for (ExamListBean e : examListBeanList) {
-                            Set<String> roomCodeSet = new HashSet<>(Arrays.asList(e.getRoomCode().split(", ")));
-                            for (String s : roomCodeSet) {
-                                teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(t.getId(), e.getExamActivityId(), s));
-                            }
+                for (ExamInfoBean t : examInfoBeanList) {
+                    if (Objects.nonNull(t.getRoomCodes())) {
+                        Set<String> roomCodeSet = new HashSet<>(Arrays.asList(t.getRoomCodes().split(", ")));
+                        for (String s : roomCodeSet) {
+                            teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(t.getExamId(), t.getExamActivityId(), s));
                         }
                     }
                 }

+ 52 - 0
themis-business/src/main/java/com/qmth/themis/business/bean/admin/ExamInfoBean.java

@@ -0,0 +1,52 @@
+package com.qmth.themis.business.bean.admin;
+
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
+import io.swagger.annotations.ApiModelProperty;
+
+import java.io.Serializable;
+
+/**
+ * @Description: 考试信息bean
+ * @Param:
+ * @return:
+ * @Author: wangliang
+ * @Date: 2022/4/20
+ */
+public class ExamInfoBean implements Serializable {
+
+    @ApiModelProperty(name = "考试批次id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long examId;
+
+    @ApiModelProperty(name = "考试场次id")
+    @JsonSerialize(using = ToStringSerializer.class)
+    private Long examActivityId;
+
+    @ApiModelProperty(name = "考场编码数")
+    private String roomCodes;
+
+    public Long getExamId() {
+        return examId;
+    }
+
+    public void setExamId(Long examId) {
+        this.examId = examId;
+    }
+
+    public Long getExamActivityId() {
+        return examActivityId;
+    }
+
+    public void setExamActivityId(Long examActivityId) {
+        this.examActivityId = examActivityId;
+    }
+
+    public String getRoomCodes() {
+        return roomCodes;
+    }
+
+    public void setRoomCodes(String roomCodes) {
+        this.roomCodes = roomCodes;
+    }
+}

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -3,6 +3,7 @@ package com.qmth.themis.business.dao;
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.qmth.themis.business.base.CustomBaseMapper;
 import com.qmth.themis.business.bean.admin.ExamDeficiencyListBean;
+import com.qmth.themis.business.bean.admin.ExamInfoBean;
 import com.qmth.themis.business.bean.admin.ExamStudentLogListBean;
 import com.qmth.themis.business.bean.admin.ExamViewCountListBean;
 import com.qmth.themis.business.dto.MarkResultSimpleExportDto;
@@ -150,4 +151,12 @@ public interface TEExamStudentMapper extends CustomBaseMapper<TEExamStudent> {
      * @return
      */
     public Integer getAbsentCount(@Param("examId") Long examId, @Param("examActivityId") Long examActivityId, @Param("roomCode") String roomCode);
+
+    /**
+     * 获取考试相关信息
+     *
+     * @param orgId
+     * @return
+     */
+    public List<ExamInfoBean> getExamInfo(@Param("orgId") Long orgId);
 }

+ 9 - 0
themis-business/src/main/java/com/qmth/themis/business/service/TEExamStudentService.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.service;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.IService;
+import com.qmth.themis.business.bean.admin.ExamInfoBean;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.dto.MarkResultSimpleExportDto;
 import com.qmth.themis.business.dto.response.MarkResultDto;
@@ -131,4 +132,12 @@ public interface TEExamStudentService extends IService<TEExamStudent> {
      * @return
      */
     public Integer getAbsentCount(Long examId, Long examActivityId, String roomCode);
+
+    /**
+     * 根据机构获取考试相关信息
+     *
+     * @param orgId
+     * @return
+     */
+    public List<ExamInfoBean> getExamInfo(Long orgId);
 }

+ 12 - 0
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamStudentServiceImpl.java

@@ -2,6 +2,7 @@ package com.qmth.themis.business.service.impl;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
+import com.qmth.themis.business.bean.admin.ExamInfoBean;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamStudentCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
@@ -246,4 +247,15 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
     public Integer getAbsentCount(Long examId, Long examActivityId, String roomCode) {
         return this.baseMapper.getAbsentCount(examId, examActivityId, roomCode);
     }
+
+    /**
+     * 根据机构获取考试相关信息
+     *
+     * @param orgId
+     * @return
+     */
+    @Override
+    public List<ExamInfoBean> getExamInfo(Long orgId) {
+        return this.baseMapper.getExamInfo(orgId);
+    }
 }

+ 14 - 0
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -499,4 +499,18 @@
             and (toer.id is null or (toer.status in ('FIRST_PREPARE', 'JUNK') and toer.client_websocket_status = 'OFF_LINE' and t.already_exam_count = 0))
         </where>
     </select>
+
+    <select id="getExamInfo" resultType="com.qmth.themis.business.bean.admin.ExamInfoBean">
+        select distinct tees.exam_id as examId,
+                     tees.exam_activity_id as examActivityId,
+                     group_concat(distinct tees.room_code) as roomCodes
+        from t_e_exam_student tees
+            left join t_e_exam tee on tee.id = tees.exam_id
+            left join t_e_exam_activity teea on teea.exam_id = tee.id
+        where
+            tee.org_id = #{orgId}
+            and tee.enable = 1
+            and teea.enable = 1
+        group by tees.exam_id,tees.exam_activity_id
+    </select>
 </mapper>