Browse Source

Merge branch 'dev_v1.2.8' into dev_v1.2.9
merge

wangliang 1 year ago
parent
commit
3e39315601

+ 43 - 20
themis-admin/src/main/java/com/qmth/themis/admin/api/TIeInvigilateWarnInfoController.java

@@ -67,7 +67,7 @@ public class TIeInvigilateWarnInfoController {
     @RequestMapping(value = "/notify", method = RequestMethod.POST)
     @ApiResponses({@ApiResponse(code = 200, message = "{\"count\":1}", response = Result.class)})
 //    @RedisLimitAnnotation(key = "warnNotify", period = 1, count = 1)
-    public Result notify(@ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long examId,
+    public Result notify(@ApiParam(value = "考试批次id", required = true) @RequestParam Long examId,
                          @ApiParam(value = "考试场次id", required = false) @RequestParam(required = false) Long examActivityId,
                          @ApiParam(value = "虚拟考场代码", required = false) @RequestParam(required = false) String roomCode) {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
@@ -77,34 +77,57 @@ public class TIeInvigilateWarnInfoController {
         Long userId = null;
         if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name())) {
             userId = tbUser.getId();
-            List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(new QueryWrapper<TBExamInvigilateUser>().lambda()
-                    .eq(TBExamInvigilateUser::getOrgId, tbUser.getOrgId())
-                    .eq(TBExamInvigilateUser::getUserId, userId));
-            if (!CollectionUtils.isEmpty(tbExamInvigilateUserList)) {
-                List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
-                for (TBExamInvigilateUser t : tbExamInvigilateUserList) {
-                    List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, t.getExamId()));
-                    for (TEExamActivity teExamActivity : teExamActivityList) {
-                        teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(t.getExamId(), teExamActivity.getId(), t.getRoomCode()));
+            List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
+            if (Objects.nonNull(examId) && Objects.nonNull(examActivityId) && Objects.nonNull(roomCode)) {
+                teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(examId, examActivityId, roomCode));
+            } else {
+                QueryWrapper<TBExamInvigilateUser> tbExamInvigilateUserQueryWrapper = new QueryWrapper<TBExamInvigilateUser>();
+                tbExamInvigilateUserQueryWrapper.lambda()
+                        .eq(TBExamInvigilateUser::getOrgId, tbUser.getOrgId())
+                        .eq(TBExamInvigilateUser::getUserId, userId);
+                if (Objects.nonNull(examId)) {
+                    tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getExamId, examId);
+                }
+                if (Objects.nonNull(roomCode)) {
+                    tbExamInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getRoomCode, roomCode);
+                }
+                List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(tbExamInvigilateUserQueryWrapper);
+                if (!CollectionUtils.isEmpty(tbExamInvigilateUserList)) {
+                    Map<Long, List<TEExamActivity>> examActivityMap = new HashMap<>();
+                    for (TBExamInvigilateUser t : tbExamInvigilateUserList) {
+                        List<TEExamActivity> teExamActivityList = null;
+                        if (CollectionUtils.isEmpty(examActivityMap.get(t.getExamId()))) {
+                            teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, t.getExamId()));
+                            examActivityMap.put(t.getExamId(), teExamActivityList);
+                        } else {
+                            teExamActivityList = examActivityMap.get(t.getExamId());
+                        }
+                        for (TEExamActivity teExamActivity : teExamActivityList) {
+                            teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(t.getExamId(), teExamActivity.getId(), t.getRoomCode()));
+                        }
                     }
                 }
-                count = teExamSummaryAllList.stream().mapToInt(s -> s.getWarningStudentUnread()).sum();
             }
+            count = teExamSummaryAllList.stream().mapToInt(s -> s.getWarningStudentUnread()).sum();
         } else {
             //取当前用户机构id所属考试id集合
-            List<ExamInfoBean> examInfoBeanList = teExamStudentService.getExamInfo(tbUser.getOrgId());
-            if (!CollectionUtils.isEmpty(examInfoBeanList)) {
-                List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
-                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));
+            List<TEExamSummary> teExamSummaryAllList = new ArrayList<>();
+            if (Objects.nonNull(examId) && Objects.nonNull(examActivityId) && Objects.nonNull(roomCode)) {
+                teExamSummaryAllList.addAll(themisCacheService.getExamSummaryCache(examId, examActivityId, roomCode));
+            } else {
+                List<ExamInfoBean> examInfoBeanList = teExamStudentService.getExamInfo(tbUser.getOrgId(), examId, roomCode);
+                if (!CollectionUtils.isEmpty(examInfoBeanList)) {
+                    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));
+                            }
                         }
                     }
                 }
-                count = teExamSummaryAllList.stream().mapToInt(s -> s.getWarningStudentUnread()).sum();
             }
+            count = teExamSummaryAllList.stream().mapToInt(s -> s.getWarningStudentUnread()).sum();
         }
         return ResultUtil.ok(Collections.singletonMap(SystemConstant.COUNT, Objects.isNull(count) ? 0 : count));
     }

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/dao/TEExamStudentMapper.java

@@ -156,7 +156,9 @@ public interface TEExamStudentMapper extends CustomBaseMapper<TEExamStudent> {
      * 获取考试相关信息
      *
      * @param orgId
+     * @param examId
+     * @param roomCode
      * @return
      */
-    public List<ExamInfoBean> getExamInfo(@Param("orgId") Long orgId);
+    public List<ExamInfoBean> getExamInfo(@Param("orgId") Long orgId, @Param("examId") Long examId, @Param("roomCode") String roomCode);
 }

+ 3 - 1
themis-business/src/main/java/com/qmth/themis/business/service/TEExamStudentService.java

@@ -137,7 +137,9 @@ public interface TEExamStudentService extends IService<TEExamStudent> {
      * 根据机构获取考试相关信息
      *
      * @param orgId
+     * @param examId
+     * @param roomCode
      * @return
      */
-    public List<ExamInfoBean> getExamInfo(Long orgId);
+    public List<ExamInfoBean> getExamInfo(Long orgId, Long examId, String roomCode);
 }

+ 3 - 2
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamStudentServiceImpl.java

@@ -252,10 +252,11 @@ public class TEExamStudentServiceImpl extends ServiceImpl<TEExamStudentMapper, T
      * 根据机构获取考试相关信息
      *
      * @param orgId
+     * @param examId
      * @return
      */
     @Override
-    public List<ExamInfoBean> getExamInfo(Long orgId) {
-        return this.baseMapper.getExamInfo(orgId);
+    public List<ExamInfoBean> getExamInfo(Long orgId, Long examId, String roomCode) {
+        return this.baseMapper.getExamInfo(orgId, examId, roomCode);
     }
 }

+ 11 - 2
themis-business/src/main/resources/mapper/TEExamStudentMapper.xml

@@ -511,10 +511,19 @@
         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.id = tees.exam_activity_id
-        where
-            tee.org_id = #{orgId}
+        <where> 1 = 1
+            <if test="orgId != null and orgId != ''">
+                and tee.org_id = #{orgId}
+            </if>
+            <if test="examId != null and examId != ''">
+                and tees.exam_id = #{examId}
+            </if>
+            <if test="roomCode != null and roomCode != ''">
+                and tees.room_code = #{roomCode}
+            </if>
             and tee.enable = 1
             and teea.enable = 1
+        </where>
         group by tees.exam_id,tees.exam_activity_id
     </select>
 </mapper>