wangliang 4 ani în urmă
părinte
comite
5394de8574

+ 62 - 59
themis-backend/src/main/java/com/qmth/themis/backend/api/TEExamReexamController.java

@@ -5,7 +5,6 @@ import com.qmth.themis.business.annotation.ApiJsonObject;
 import com.qmth.themis.business.annotation.ApiJsonProperty;
 import com.qmth.themis.business.bean.backend.ReexamListRequestBean;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
-import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamCacheBean;
 import com.qmth.themis.business.constant.SystemConstant;
 import com.qmth.themis.business.dto.AuthDto;
@@ -83,47 +82,49 @@ public class TEExamReexamController {
         if (Objects.isNull(mapParameter.get("reason")) || Objects.equals(mapParameter.get("reason"), "")) {
             throw new BusinessException("重考原因不能为空");
         }
-        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        ReexamReasonEnum reason = ReexamReasonEnum.valueOf(String.valueOf(mapParameter.get("reason")));
-        Long examId = null, examStudentId = null, examActivityId = null;
-        Integer reexamAuditing = null, status;
-        List<TEExamReexamAuditing> teExamReexamAuditingList = new ArrayList<>();
-        for (String s : recordIdList) {
-            //获取考试记录缓存
-            Long recordId = Long.parseLong(s);
-            examId = ExamRecordCacheUtil.getExamId(recordId);
-            if (Objects.isNull(examId)) {
-                TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(Long.parseLong(s));
-                examId = tOeExamRecord.getExamId();
-                examStudentId = tOeExamRecord.getExamStudentId();
-                examActivityId = tOeExamRecord.getExamActivityId();
-            } else {
+        if (recordIdList.size() > 0) {
+            TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+            ReexamReasonEnum reason = ReexamReasonEnum.valueOf(String.valueOf(mapParameter.get("reason")));
+            Long examId = null, examStudentId = null, examActivityId = null;
+            Integer reexamAuditing = null, status;
+            List<TEExamReexamAuditing> teExamReexamAuditingList = new ArrayList<>();
+            for (String s : recordIdList) {
+                //获取考试记录缓存
+                Long recordId = Long.parseLong(s);
                 examId = ExamRecordCacheUtil.getExamId(recordId);
-                examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
-                examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
-            }
-            ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);//考试缓存
-            if (Objects.isNull(examCacheBean)) {
-                throw new BusinessException("考试批次[" + examCacheBean + "]不存在");
-            }
-            reexamAuditing = examCacheBean.getReexamAuditing();
-            status = Objects.isNull(reexamAuditing) || reexamAuditing.intValue() == 0 ? 0 : 1;
-            TEExamReexam teExamReexam = new TEExamReexam(examId, examActivityId, Long.parseLong(s), examStudentId, model, reason, status, Objects.isNull(mapParameter.get("remark")) ? null : String.valueOf(mapParameter.get("remark")));
-            teExamReexam.setCreateId(tbUser.getId());
-            teExamReexamService.save(teExamReexam);
-            if (Objects.nonNull(status) && status.intValue() == 1) {
-                //这里查询该机构下所有为管理员角色的账号
-                List<TBUser> tbUserList = tbUserRoleService.userQueryByRole(tbUser.getOrgId(), RoleEnum.ADMIN.name());
-                if (Objects.nonNull(tbUserList) && tbUserList.size() > 0) {
-                    for (TBUser t : tbUserList) {
-                        TEExamReexamAuditing teExamReexamAuditing = new TEExamReexamAuditing(teExamReexam.getId(), t.getId());
-                        teExamReexamAuditingList.add(teExamReexamAuditing);
+                if (Objects.isNull(examId)) {
+                    TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(Long.parseLong(s));
+                    examId = tOeExamRecord.getExamId();
+                    examStudentId = tOeExamRecord.getExamStudentId();
+                    examActivityId = tOeExamRecord.getExamActivityId();
+                } else {
+                    examId = ExamRecordCacheUtil.getExamId(recordId);
+                    examStudentId = ExamRecordCacheUtil.getExamStudentId(recordId);
+                    examActivityId = ExamRecordCacheUtil.getExamActivityId(recordId);
+                }
+                ExamCacheBean examCacheBean = teExamService.getExamCacheBean(examId);//考试缓存
+                if (Objects.isNull(examCacheBean)) {
+                    throw new BusinessException("考试批次[" + examCacheBean + "]不存在");
+                }
+                reexamAuditing = examCacheBean.getReexamAuditing();
+                status = Objects.isNull(reexamAuditing) || reexamAuditing.intValue() == 0 ? 0 : 1;
+                TEExamReexam teExamReexam = new TEExamReexam(examId, examActivityId, Long.parseLong(s), examStudentId, model, reason, status, Objects.isNull(mapParameter.get("remark")) ? null : String.valueOf(mapParameter.get("remark")));
+                teExamReexam.setCreateId(tbUser.getId());
+                teExamReexamService.save(teExamReexam);
+                if (Objects.nonNull(status) && status.intValue() == 1) {
+                    //这里查询该机构下所有为管理员角色的账号
+                    List<TBUser> tbUserList = tbUserRoleService.userQueryByRole(tbUser.getOrgId(), RoleEnum.ADMIN.name());
+                    if (Objects.nonNull(tbUserList) && tbUserList.size() > 0) {
+                        for (TBUser t : tbUserList) {
+                            TEExamReexamAuditing teExamReexamAuditing = new TEExamReexamAuditing(teExamReexam.getId(), t.getId());
+                            teExamReexamAuditingList.add(teExamReexamAuditing);
+                        }
                     }
                 }
             }
-        }
-        if (Objects.nonNull(teExamReexamAuditingList) && teExamReexamAuditingList.size() > 0) {
-            teExamReexamAuditingService.saveBatch(teExamReexamAuditingList);
+            if (Objects.nonNull(teExamReexamAuditingList) && teExamReexamAuditingList.size() > 0) {
+                teExamReexamAuditingService.saveBatch(teExamReexamAuditingList);
+            }
         }
         return ResultUtil.ok(Collections.singletonMap("success", true));
     }
@@ -146,30 +147,32 @@ public class TEExamReexamController {
             if (Objects.isNull(mapParameter.get("auditingStatus")) || Objects.equals(mapParameter.get("auditingStatus"), "")) {
                 throw new BusinessException("审批状态不能为空");
             }
-            Integer auditingStatus = Integer.parseInt(String.valueOf(mapParameter.get("auditingStatus")));
-            TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-            List<TEExamReexam> teExamReexamUpdateList = new ArrayList<>();
-            for (String reexamId : reexamIdList) {
-                if (redisUtil.lock(SystemConstant.REDIS_LOCK_REEXAM_AUDITING + Long.parseLong(reexamId), SystemConstant.REDIS_LOCK_REEXAM_TIME_OUT)) {
-                    TEExamReexam teExamReexam = teExamReexamService.getById(Long.parseLong(reexamId));
-                    if (Objects.isNull(teExamReexam)) {
-                        throw new BusinessException("重考id[" + reexamId + "]记录不存在");
-                    }
-                    if (Objects.nonNull(teExamReexam.getStatus()) && teExamReexam.getStatus().intValue() == 2) {
-                        throw new BusinessException("重考id[" + reexamId + "]已经审核");
-                    } else {
-                        teExamReexam.setAuditingId(tbUser.getId());
-                        teExamReexam.setAuditingStatus(auditingStatus);
-                        teExamReexam.setAuditingTime(System.currentTimeMillis());
-                        teExamReexam.setAuditingSuggest(Objects.isNull(mapParameter.get("auditingSuggest")) ? null : String.valueOf(mapParameter.get("auditingSuggest")));
-                        teExamReexam.setStatus(2);
-                        teExamReexam.setUpdateId(tbUser.getId());
-                        teExamReexamUpdateList.add(teExamReexam);
-                        teExamReexamService.updateById(teExamReexam);
+            if (reexamIdList.size() > 0) {
+                Integer auditingStatus = Integer.parseInt(String.valueOf(mapParameter.get("auditingStatus")));
+                TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+                List<TEExamReexam> teExamReexamUpdateList = new ArrayList<>();
+                for (String reexamId : reexamIdList) {
+                    if (redisUtil.lock(SystemConstant.REDIS_LOCK_REEXAM_AUDITING + Long.parseLong(reexamId), SystemConstant.REDIS_LOCK_REEXAM_TIME_OUT)) {
+                        TEExamReexam teExamReexam = teExamReexamService.getById(Long.parseLong(reexamId));
+                        if (Objects.isNull(teExamReexam)) {
+                            throw new BusinessException("重考id[" + reexamId + "]记录不存在");
+                        }
+                        if (Objects.nonNull(teExamReexam.getStatus()) && teExamReexam.getStatus().intValue() == 2) {
+                            throw new BusinessException("重考id[" + reexamId + "]已经审核");
+                        } else {
+                            teExamReexam.setAuditingId(tbUser.getId());
+                            teExamReexam.setAuditingStatus(auditingStatus);
+                            teExamReexam.setAuditingTime(System.currentTimeMillis());
+                            teExamReexam.setAuditingSuggest(Objects.isNull(mapParameter.get("auditingSuggest")) ? null : String.valueOf(mapParameter.get("auditingSuggest")));
+                            teExamReexam.setStatus(2);
+                            teExamReexam.setUpdateId(tbUser.getId());
+                            teExamReexamUpdateList.add(teExamReexam);
+                            teExamReexamService.updateById(teExamReexam);
+                        }
                     }
                 }
+                teExamReexamService.updateBatchById(teExamReexamUpdateList);
             }
-            teExamReexamService.updateBatchById(teExamReexamUpdateList);
         } catch (Exception e) {
             log.error("请求出错", e);
             if (e instanceof BusinessException) {

+ 53 - 49
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateController.java

@@ -273,20 +273,22 @@ public class TIeInvigilateController {
         if (Objects.isNull(mapParameter.get("type")) || Objects.equals(mapParameter.get("type"), "")) {
             throw new BusinessException(ExceptionResultEnum.FINISH_TYPE_IS_NULL);
         }
-        FinishTypeEnum type = FinishTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
-        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        //发送mq给客户端强制收卷start
-        MqTagEnum mqTagEnum = null;
-        if (Objects.equals(type, FinishTypeEnum.INTERRUPT)) {
-            mqTagEnum = MqTagEnum.OE_MONITOR_FINISH;
-        } else if (Objects.equals(type, FinishTypeEnum.BREACH)) {
-            mqTagEnum = MqTagEnum.OE_WARNING_FINISH;
-        } else {
-            mqTagEnum = MqTagEnum.OE_HARD_FINISH;
+        if (recordIdList.size() > 0) {
+            FinishTypeEnum type = FinishTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
+            TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+            //发送mq给客户端强制收卷start
+            MqTagEnum mqTagEnum = null;
+            if (Objects.equals(type, FinishTypeEnum.INTERRUPT)) {
+                mqTagEnum = MqTagEnum.OE_MONITOR_FINISH;
+            } else if (Objects.equals(type, FinishTypeEnum.BREACH)) {
+                mqTagEnum = MqTagEnum.OE_WARNING_FINISH;
+            } else {
+                mqTagEnum = MqTagEnum.OE_HARD_FINISH;
+            }
+            MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), mqTagEnum.name(), JacksonUtil.parseJson(recordIdList), mqTagEnum, String.valueOf(tbUser.getId()), mapParameter, tbUser.getName());
+            mqDtoService.assembleSendOneWayMsg(mqDto);
+            //发送mq给客户端强制收卷end
         }
-        MqDto mqDto = new MqDto(MqTopicEnum.THEMIS_TOPIC.getCode(), mqTagEnum.name(), JacksonUtil.parseJson(recordIdList), mqTagEnum, String.valueOf(tbUser.getId()), mapParameter, tbUser.getName());
-        mqDtoService.assembleSendOneWayMsg(mqDto);
-        //发送mq给客户端强制收卷end
         return ResultUtil.ok(Collections.singletonMap("success", true));
     }
 
@@ -383,45 +385,47 @@ public class TIeInvigilateController {
         if (Objects.isNull(mapParameter.get("status")) || Objects.equals(mapParameter.get("status"), "")) {
             throw new BusinessException(ExceptionResultEnum.BREACH_STATUS_IS_NULL);
         }
-        Integer status = Integer.parseInt(String.valueOf(mapParameter.get("status")));
-        TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
-        List<TEExamBreachLog> teExamBreachLogList = new ArrayList<>();
-        if (status == 0) {//新建违纪
-            BreachTypeEnum type = BreachTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
-            List<TEExamBreachLog> finalTeExamBreachLogList = teExamBreachLogList;
-            for (int i = 0; i < recordIdList.size(); i++) {
-                Long l = Long.parseLong(String.valueOf(recordIdList.get(i)));
-                Long examId = ExamRecordCacheUtil.getExamId(l);
-                Long examStudentId = null;
-                Long examActivityId = null;
-                if (Objects.isNull(examId)) {
-                    TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(l);
-                    examId = tOeExamRecord.getExamId();
-                    examStudentId = tOeExamRecord.getExamStudentId();
-                    examActivityId = tOeExamRecord.getExamActivityId();
-                } else {
-                    examId = ExamRecordCacheUtil.getExamId(l);
-                    examStudentId = ExamRecordCacheUtil.getExamStudentId(l);
-                    examActivityId = ExamRecordCacheUtil.getExamActivityId(l);
+        if (recordIdList.size() > 0) {
+            Integer status = Integer.parseInt(String.valueOf(mapParameter.get("status")));
+            TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
+            List<TEExamBreachLog> teExamBreachLogList = new ArrayList<>();
+            if (status == 0) {//新建违纪
+                BreachTypeEnum type = BreachTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
+                List<TEExamBreachLog> finalTeExamBreachLogList = teExamBreachLogList;
+                for (int i = 0; i < recordIdList.size(); i++) {
+                    Long l = Long.parseLong(String.valueOf(recordIdList.get(i)));
+                    Long examId = ExamRecordCacheUtil.getExamId(l);
+                    Long examStudentId = null;
+                    Long examActivityId = null;
+                    if (Objects.isNull(examId)) {
+                        TOeExamRecord tOeExamRecord = tOeExamRecordService.getById(l);
+                        examId = tOeExamRecord.getExamId();
+                        examStudentId = tOeExamRecord.getExamStudentId();
+                        examActivityId = tOeExamRecord.getExamActivityId();
+                    } else {
+                        examId = ExamRecordCacheUtil.getExamId(l);
+                        examStudentId = ExamRecordCacheUtil.getExamStudentId(l);
+                        examActivityId = ExamRecordCacheUtil.getExamActivityId(l);
+                    }
+                    TEExamBreachLog teExamBreachLog = new TEExamBreachLog(examId, examActivityId, l, examStudentId, type.name(), description, status);
+                    teExamBreachLog.setCreateId(tbUser.getId());
+                    finalTeExamBreachLogList.add(teExamBreachLog);
                 }
-                TEExamBreachLog teExamBreachLog = new TEExamBreachLog(examId, examActivityId, l, examStudentId, type.name(), description, status);
-                teExamBreachLog.setCreateId(tbUser.getId());
-                finalTeExamBreachLogList.add(teExamBreachLog);
+            } else {//撤销违纪
+                BreachCancelTypeEnum type = BreachCancelTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
+                QueryWrapper<TEExamBreachLog> teExamBreachLogQueryWrapper = new QueryWrapper<>();
+                teExamBreachLogQueryWrapper.lambda().in(TEExamBreachLog::getExamRecordId, recordIdList);
+                teExamBreachLogList = teExamBreachLogService.list(teExamBreachLogQueryWrapper);
+                teExamBreachLogList.forEach(s -> {
+                    s.setType(type.name());
+                    s.setDescription(description);
+                    s.setStatus(status);
+                    s.setUpdateId(tbUser.getId());
+                });
             }
-        } else {//撤销违纪
-            BreachCancelTypeEnum type = BreachCancelTypeEnum.valueOf(String.valueOf(mapParameter.get("type")));
-            QueryWrapper<TEExamBreachLog> teExamBreachLogQueryWrapper = new QueryWrapper<>();
-            teExamBreachLogQueryWrapper.lambda().in(TEExamBreachLog::getExamRecordId, recordIdList);
-            teExamBreachLogList = teExamBreachLogService.list(teExamBreachLogQueryWrapper);
-            teExamBreachLogList.forEach(s -> {
-                s.setType(type.name());
-                s.setDescription(description);
-                s.setStatus(status);
-                s.setUpdateId(tbUser.getId());
-            });
+            teExamBreachLogService.saveOrUpdateBatch(teExamBreachLogList);
+            //todo 这里是否需要收卷处理
         }
-        teExamBreachLogService.saveOrUpdateBatch(teExamBreachLogList);
-        //todo 这里是否需要收卷处理
         return ResultUtil.ok(Collections.singletonMap("success", true));
     }
 

+ 13 - 11
themis-backend/src/main/java/com/qmth/themis/backend/api/TIeInvigilateWarnInfoController.java

@@ -118,18 +118,20 @@ public class TIeInvigilateWarnInfoController {
             throw new BusinessException("预警id不能为空");
         }
         List<String> warningIds = (List<String>) mapParameter.get("warningIds");
-        if (Objects.isNull(mapParameter.get("approveStatus")) || Objects.equals(mapParameter.get("approveStatus"), "")) {
-            throw new BusinessException("审阅状态不能为空");
+        if (warningIds.size() > 0) {
+            if (Objects.isNull(mapParameter.get("approveStatus")) || Objects.equals(mapParameter.get("approveStatus"), "")) {
+                throw new BusinessException("审阅状态不能为空");
+            }
+            List<Long> warningTranIds = new ArrayList<>();
+            warningIds.forEach(s -> {
+                warningTranIds.add(Long.parseLong(s));
+            });
+            Integer approveStatus = Integer.parseInt(String.valueOf(mapParameter.get("approveStatus")));
+            UpdateWrapper<TIeInvigilateWarnInfo> tIeInvigilateWarnInfoUpdateWrapper = new UpdateWrapper<>();
+            tIeInvigilateWarnInfoUpdateWrapper.lambda().set(TIeInvigilateWarnInfo::getApproveStatus, approveStatus)
+                    .in(TIeInvigilateWarnInfo::getId, warningTranIds);
+            tIeInvigilateWarnInfoService.update(tIeInvigilateWarnInfoUpdateWrapper);
         }
-        List<Long> warningTranIds = new ArrayList<>();
-        warningIds.forEach(s -> {
-            warningTranIds.add(Long.parseLong(s));
-        });
-        Integer approveStatus = Integer.parseInt(String.valueOf(mapParameter.get("approveStatus")));
-        UpdateWrapper<TIeInvigilateWarnInfo> tIeInvigilateWarnInfoUpdateWrapper = new UpdateWrapper<>();
-        tIeInvigilateWarnInfoUpdateWrapper.lambda().set(TIeInvigilateWarnInfo::getApproveStatus, approveStatus)
-                .in(TIeInvigilateWarnInfo::getId, warningTranIds);
-        tIeInvigilateWarnInfoService.update(tIeInvigilateWarnInfoUpdateWrapper);
         return ResultUtil.ok(Collections.singletonMap("success", true));
     }
 }

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

@@ -77,8 +77,8 @@ public class CommonServiceImpl implements CommonService {
 
 			examRecordService.saveDataByCache(recordId);
 			// 清除缓存
-			ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId),
-					recordId);
+//			ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId),
+//					recordId);
 			redisUtil.delete(RedisKeyHelper.examRecordCacheKey(recordId));
 			redisUtil.delete(RedisKeyHelper.examAnswerKey(recordId));
 			redisUtil.delete(RedisKeyHelper.audioLeftPlayCountKey(recordId));

+ 1 - 0
themis-business/src/main/resources/db/init.sql

@@ -740,6 +740,7 @@ INSERT INTO `t_b_role_privilege` VALUES (191, 'INVIGILATE', 155);
 INSERT INTO `t_b_role_privilege` VALUES (192, 'ADMIN', 156);
 INSERT INTO `t_b_role_privilege` VALUES (193, 'INSPECTION', 156);
 INSERT INTO `t_b_role_privilege` VALUES (194, 'STUDENT', 157);
+INSERT INTO `t_b_role_privilege` VALUES (195, 'ADMIN', 120);
 COMMIT;
 
 -- ----------------------------

+ 5 - 0
themis-task/src/main/java/com/qmth/themis/task/quartz/service/impl/QuartzLogicServiceImpl.java

@@ -1,5 +1,6 @@
 package com.qmth.themis.task.quartz.service.impl;
 
+import com.qmth.themis.business.cache.ExamActivityRecordCacheUtil;
 import com.qmth.themis.business.cache.ExamRecordCacheUtil;
 import com.qmth.themis.business.cache.RedisKeyHelper;
 import com.qmth.themis.business.cache.bean.ExamActivityCacheBean;
@@ -73,6 +74,8 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                                 ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                                 //交卷
                                 teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                // 清除缓存
+                                ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
                             }
                         }
                     });
@@ -91,6 +94,8 @@ public class QuartzLogicServiceImpl implements QuartzLogicService {
                                 ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(examStudentId);
                                 //交卷
                                 teExamService.finish(examStudentCacheBean.getStudentId(), Long.parseLong(k), FinishTypeEnum.AUTO.name(), durationSeconds);
+                                // 清除缓存
+                                ExamActivityRecordCacheUtil.removeActivityRecordCache(ExamRecordCacheUtil.getExamActivityId(recordId), recordId);
                             }
                         }
                     });