浏览代码

最后侯考时间修改

wangliang 1 年之前
父节点
当前提交
0ab60f1105

+ 163 - 104
themis-admin/src/main/java/com/qmth/themis/admin/api/TEExamController.java

@@ -51,6 +51,7 @@ import java.util.stream.Collectors;
 @RequestMapping(SystemConstant.PREFIX_URL_ADMIN + "/exam")
 @Validated
 public class TEExamController {
+
     private final static Logger log = LoggerFactory.getLogger(TEExamController.class);
 
     @Resource
@@ -101,7 +102,7 @@ public class TEExamController {
     @ApiOperation(value = "考试批次修改/新增接口")
     @RequestMapping(value = "/save", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @Logs(value = LogEnum.EXAM)
     public Result save(@ApiParam(value = "考试批次信息", required = true) @RequestBody TEExamDto teExamDto) {
         if (Objects.isNull(teExamDto) || Objects.equals(teExamDto, "")) {
@@ -136,11 +137,15 @@ public class TEExamController {
                     throw new BusinessException("监考结束的考试批次不可以修改");
                 }
                 boolean recordUpdate = true;
-                if ((Objects.nonNull(oldTeExam.getRecordSelectStrategy()) && Objects.nonNull(teExamDto.getRecordSelectStrategy()) && !Objects.equals(oldTeExam.getRecordSelectStrategy(), teExamDto.getRecordSelectStrategy()))) {
+                if ((Objects.nonNull(oldTeExam.getRecordSelectStrategy()) && Objects.nonNull(
+                        teExamDto.getRecordSelectStrategy()) && !Objects.equals(oldTeExam.getRecordSelectStrategy(),
+                        teExamDto.getRecordSelectStrategy()))) {
                     recordUpdate = false;
                 }
                 boolean objectiveUpdate = true;
-                if ((Objects.nonNull(oldTeExam.getObjectiveScorePolicy()) && Objects.nonNull(teExamDto.getObjectiveScorePolicy()) && !Objects.equals(oldTeExam.getObjectiveScorePolicy(), teExamDto.getObjectiveScorePolicy()))) {
+                if ((Objects.nonNull(oldTeExam.getObjectiveScorePolicy()) && Objects.nonNull(
+                        teExamDto.getObjectiveScorePolicy()) && !Objects.equals(oldTeExam.getObjectiveScorePolicy(),
+                        teExamDto.getObjectiveScorePolicy()))) {
                     objectiveUpdate = false;
                 }
                 QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
@@ -159,7 +164,8 @@ public class TEExamController {
                 teExamDto.setId(uidUtil.getId());
                 teExamDto.setCreateId(tbUser.getId());
             }
-            teExamDto.setMonitorStatus(Objects.nonNull(oldTeExam) ? oldTeExam.getMonitorStatus() : InvigilateMonitorStatusEnum.NOT_START);
+            teExamDto.setMonitorStatus(
+                    Objects.nonNull(oldTeExam) ? oldTeExam.getMonitorStatus() : InvigilateMonitorStatusEnum.NOT_START);
             teExam = new TEExam(teExamDto);
             if (Objects.nonNull(teExam.getEndTime()) && teExam.getEndTime().longValue() < System.currentTimeMillis()) {
                 throw new BusinessException("修改的批次结束时间只能大于当前时间");
@@ -196,7 +202,8 @@ public class TEExamController {
             }
             List<String> monitorRecordList = teExamDto.getMonitorRecord();
             if (Objects.nonNull(monitorRecordList) && monitorRecordList.size() > 1) {
-                if (monitorRecordList.contains(MonitorVideoSourceEnum.CLIENT_CAMERA) && monitorRecordList.contains(MonitorVideoSourceEnum.CLIENT_SCREEN)) {
+                if (monitorRecordList.contains(MonitorVideoSourceEnum.CLIENT_CAMERA) && monitorRecordList.contains(
+                        MonitorVideoSourceEnum.CLIENT_SCREEN)) {
                     throw new BusinessException("客户端摄像头和屏幕只能选一个");
                 }
             }
@@ -227,21 +234,30 @@ public class TEExamController {
                 teExamActivityService.updateExamActivityCacheBean(teExamActivity.getId());
             }
             //加入更新考试列表缓存方法
-            List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, teExam.getId()).eq(TEExamActivity::getEnable, 1));
+            List<TEExamActivity> teExamActivityList = teExamActivityService.list(
+                    new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, teExam.getId())
+                            .eq(TEExamActivity::getEnable, 1));
             if (!CollectionUtils.isEmpty(teExamActivityList)) {
                 for (TEExamActivity t : teExamActivityList) {
-                    if (Objects.nonNull(t) && Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1 && Objects.nonNull(teExam.getEnable()) && teExam.getEnable().intValue() == 1 && (Objects.nonNull(teExam.getEndTime()) && teExam.getEndTime().longValue() > System.currentTimeMillis())) {
+                    if (Objects.nonNull(t) && Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1
+                            && Objects.nonNull(teExam.getEnable()) && teExam.getEnable().intValue() == 1 && (
+                            Objects.nonNull(teExam.getEndTime())
+                                    && teExam.getEndTime().longValue() > System.currentTimeMillis())) {
                         themisCacheService.updateCurrentExamListCache(t.getExamId().toString(), t.getId());
-                        themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(), t.getId());
+                        themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(),
+                                t.getExamId().toString(), t.getId());
                     } else {
                         themisCacheService.removeCurrentExamListCache(t.getExamId().toString(), t.getId());
-                        themisCacheService.removeOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(), t.getId());
+                        themisCacheService.removeOrgExamListCache(teExam.getOrgId().toString(),
+                                t.getExamId().toString(), t.getId());
                     }
                 }
             }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
-            if (Objects.nonNull(teExam) && redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_PREFIX + teExam.getId(), SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_TIME_OUT)) {
+            if (Objects.nonNull(teExam) && redisUtil.lock(
+                    SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_PREFIX + teExam.getId(),
+                    SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_TIME_OUT)) {
                 try {
                     Integer value = redisUtil.getRedisActivityCodeSequenceValue(teExam.getId());
                     redisUtil.setRedisActivityCodeSequence(teExam.getId(), value - size);
@@ -268,10 +284,10 @@ public class TEExamController {
 
     @ApiOperation(value = "考试批次统计接口")
     @RequestMapping(value = "/count", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"count\":1}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"count\":1}", response = Result.class) })
     public Result count(@ApiParam(value = "考试批次编码", required = false) @RequestParam(required = false) String code,
-                        @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
-                        @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) ExamModeEnum mode) {
+            @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) ExamModeEnum mode) {
         QueryWrapper<TEExam> teExamQueryWrapper = new QueryWrapper<>();
         if (Objects.nonNull(code)) {
             teExamQueryWrapper.lambda().eq(TEExam::getCode, code);
@@ -288,40 +304,43 @@ public class TEExamController {
 
     @ApiOperation(value = "考试批次查询接口")
     @RequestMapping(value = "/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class) })
     public Result query(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId,
-                        @ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long id,
-                        @ApiParam(value = "考试批次编码", required = false) @RequestParam(required = false) String code,
-                        @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
-                        @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) String mode,
-                        @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
-                        @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type,
-                        @ApiParam(value = "查询是否结束监考", required = false) @RequestParam(required = false) Boolean finished,
-                        @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) int pageNumber,
-                        @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.SELECT_PAGE_SIZE_MAX) int pageSize) {
+            @ApiParam(value = "考试批次id", required = false) @RequestParam(required = false) Long id,
+            @ApiParam(value = "考试批次编码", required = false) @RequestParam(required = false) String code,
+            @ApiParam(value = "考试批次名称", required = false) @RequestParam(required = false) String name,
+            @ApiParam(value = "考试批次模式", required = false) @RequestParam(required = false) String mode,
+            @ApiParam(value = "是否启用", required = false) @RequestParam(required = false) Integer enable,
+            @ApiParam(value = "类型(区分实时监考台和考务)", required = false) @RequestParam(required = false) String type,
+            @ApiParam(value = "查询是否结束监考", required = false) @RequestParam(required = false) Boolean finished,
+            @ApiParam(value = "分页页码", required = true) @RequestParam @Min(SystemConstant.PAGE_NUMBER_MIN) int pageNumber,
+            @ApiParam(value = "分页数", required = true) @RequestParam @Min(SystemConstant.PAGE_SIZE_MIN) @Max(SystemConstant.SELECT_PAGE_SIZE_MAX) int pageSize) {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         AuthDto authDto = themisCacheService.addAccountAuthCache(tbUser.getId());
         if (authDto.getRoleCodes().toString().contains(RoleEnum.INSPECTION.name())) {
             userId = null;
         }
-        return ResultUtil.ok(teExamService.examQuery(new Page<>(pageNumber, pageSize), userId, id, code, name, mode, enable, tbUser.getOrgId(), type, finished));
+        return ResultUtil.ok(
+                teExamService.examQuery(new Page<>(pageNumber, pageSize), userId, id, code, name, mode, enable,
+                        tbUser.getOrgId(), type, finished));
     }
 
     @ApiOperation(value = "根据考试批次编码查询考场接口")
     @RequestMapping(value = "/examroom/query", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class) })
     public Result examroomQuery(@ApiParam(value = "考试批次编码", required = true) @RequestParam String code) {
         return ResultUtil.ok(teExamService.examroomQuery(code));
     }
 
     @ApiOperation(value = "考试批次停用/启用接口")
     @RequestMapping(value = "/toggle", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @Transactional
     public Result examToggle(@ApiJsonObject(name = "examToggle", value = {
             @ApiJsonProperty(key = "id", type = "long", example = "1", description = "考试批次ID"),
-            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用")}) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
-        if (Objects.isNull(mapParameter.get(SystemConstant.ID)) || Objects.equals(mapParameter.get(SystemConstant.ID), "")) {
+            @ApiJsonProperty(key = "enable", type = "int", example = "1", description = "是否启用") }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+        if (Objects.isNull(mapParameter.get(SystemConstant.ID)) || Objects.equals(mapParameter.get(SystemConstant.ID),
+                "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
         Long examId = Long.parseLong(String.valueOf(mapParameter.get(SystemConstant.ID)));
@@ -345,22 +364,45 @@ public class TEExamController {
         teExamService.updateExamCacheBean(teExam.getId());
 
         //加入更新考试列表缓存方法
-        List<TEExamActivity> teExamActivityList = teExamActivityService.list(new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, teExam.getId()).eq(TEExamActivity::getEnable, 1));
+        List<TEExamActivity> teExamActivityList = teExamActivityService.list(
+                new QueryWrapper<TEExamActivity>().lambda().eq(TEExamActivity::getExamId, teExam.getId())
+                        .eq(TEExamActivity::getEnable, 1));
         for (TEExamActivity t : teExamActivityList) {
-            if (Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1 && teExam.getEnable().intValue() == 1 && (Objects.nonNull(teExam.getEndTime()) && teExam.getEndTime().longValue() > System.currentTimeMillis())) {
+            if (Objects.nonNull(t.getEnable()) && t.getEnable().intValue() == 1 && teExam.getEnable().intValue() == 1
+                    && (Objects.nonNull(teExam.getEndTime())
+                    && teExam.getEndTime().longValue() > System.currentTimeMillis())) {
                 themisCacheService.updateCurrentExamListCache(t.getExamId().toString(), t.getId());
-                themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(), t.getId());
+                themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(),
+                        t.getId());
             } else {
                 themisCacheService.removeCurrentExamListCache(t.getExamId().toString(), t.getId());
-                themisCacheService.removeOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(), t.getId());
-            }
+                themisCacheService.removeOrgExamListCache(teExam.getOrgId().toString(), t.getExamId().toString(),
+                        t.getId());
+            }
+        }
+        if (Objects.nonNull(teExam.getForceFinish()) && teExam.getForceFinish().intValue() == 1) {
+            //新增quartz任务,发送mq消息start
+            Map<String, Object> prop = new HashMap<>();
+            prop.put(SystemConstant.OPER, SystemConstant.INSERT);
+            prop.put(SystemConstant.EXAM, teExam);
+            MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
+                    JacksonUtil.parseJson(teExamActivityList), MqTagEnum.EXAM_ACTIVITY, String.valueOf(teExam.getId()),
+                    prop, tbUser.getName());
+            mqDtoService.assembleSendAsyncOrderMsg(mqDto);
+            //新增quartz任务,发送mq消息end
+
+            //最后开考时间发送定时任务
+            mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.EXAM_ACTIVITY_FINAL_PREPARE_TIME.name(),
+                    JacksonUtil.parseJson(teExamActivityList), MqTagEnum.EXAM_ACTIVITY_FINAL_PREPARE_TIME,
+                    String.valueOf(teExam.getId()), prop, tbUser.getName());
+            mqDtoService.assembleSendAsyncOrderMsg(mqDto);
         }
         return ResultUtil.ok(true);
     }
 
     @ApiOperation(value = "考试批次详情接口")
     @RequestMapping(value = "/detail", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = TEExam.class) })
     public Result detail(@ApiParam(value = "考试批次id", required = true) @RequestParam Long id) {
         if (Objects.isNull(id) || Objects.equals(id, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
@@ -372,12 +414,12 @@ public class TEExamController {
 
     @ApiOperation(value = "考试批次复制接口")
     @RequestMapping(value = "/copy", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class) })
     @Transactional
     public Result copy(@ApiJsonObject(name = "examCopy", value = {
             @ApiJsonProperty(key = "sourceId", type = "long", example = "1", description = "来源批次ID"),
             @ApiJsonProperty(key = "code", description = "代码"),
-            @ApiJsonProperty(key = "name", description = "名称")}) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
+            @ApiJsonProperty(key = "name", description = "名称") }) @ApiParam(value = "考试批次信息", required = true) @RequestBody Map<String, Object> mapParameter) {
         if (Objects.isNull(mapParameter.get("sourceId")) || Objects.equals(mapParameter.get("sourceId"), "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
@@ -386,7 +428,8 @@ public class TEExamController {
             throw new BusinessException(ExceptionResultEnum.EXAM_CODE_IS_NULL);
         }
         String code = String.valueOf(mapParameter.get("code"));
-        if (Objects.isNull(mapParameter.get(SystemConstant.NAME)) || Objects.equals(mapParameter.get(SystemConstant.NAME), "")) {
+        if (Objects.isNull(mapParameter.get(SystemConstant.NAME)) || Objects.equals(
+                mapParameter.get(SystemConstant.NAME), "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_NAME_IS_NULL);
         }
         String name = String.valueOf(mapParameter.get(SystemConstant.NAME));
@@ -419,12 +462,17 @@ public class TEExamController {
                     s.setUpdateTime(null);
                     s.setCode(String.valueOf(redisUtil.getRedisActivityCodeSequence(teExam.getId())));
 
-                    if (Objects.nonNull(s) && Objects.nonNull(s.getEnable()) && s.getEnable().intValue() == 1 && Objects.nonNull(teExam.getEnable()) && teExam.getEnable().intValue() == 1 && (Objects.nonNull(teExam.getEndTime()) && teExam.getEndTime().longValue() > System.currentTimeMillis())) {
+                    if (Objects.nonNull(s) && Objects.nonNull(s.getEnable()) && s.getEnable().intValue() == 1
+                            && Objects.nonNull(teExam.getEnable()) && teExam.getEnable().intValue() == 1 && (
+                            Objects.nonNull(teExam.getEndTime())
+                                    && teExam.getEndTime().longValue() > System.currentTimeMillis())) {
                         themisCacheService.updateCurrentExamListCache(s.getExamId().toString(), s.getId());
-                        themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(), s.getExamId().toString(), s.getId());
+                        themisCacheService.updateOrgExamListCache(teExam.getOrgId().toString(),
+                                s.getExamId().toString(), s.getId());
                     } else {
                         themisCacheService.removeCurrentExamListCache(s.getExamId().toString(), s.getId());
-                        themisCacheService.removeOrgExamListCache(teExam.getOrgId().toString(), s.getExamId().toString(), s.getId());
+                        themisCacheService.removeOrgExamListCache(teExam.getOrgId().toString(),
+                                s.getExamId().toString(), s.getId());
                     }
                 });
                 teExamActivityService.saveOrUpdateBatch(teExamActivityList);
@@ -443,7 +491,9 @@ public class TEExamController {
             }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
-            if (Objects.nonNull(teExam.getId()) && redisUtil.lock(SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_PREFIX + teExam.getId(), SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_TIME_OUT)) {
+            if (Objects.nonNull(teExam.getId()) && redisUtil.lock(
+                    SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_PREFIX + teExam.getId(),
+                    SystemConstant.REDIS_LOCK_EXAM_ACTIVITY_CODE_TIME_OUT)) {
                 try {
                     Integer value = redisUtil.getRedisActivityCodeSequenceValue(teExam.getId());
                     if (!CollectionUtils.isEmpty(teExamActivityList)) {
@@ -471,8 +521,8 @@ public class TEExamController {
 
     @ApiOperation(value = "监考端获取考试批次提醒接口")
     @RequestMapping(value = "/list/count", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试批次信息", response = Result.class)})
-//    @RedisLimitAnnotation(key = "listCount", period = 1, count = 1)
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试批次信息", response = Result.class) })
+    //    @RedisLimitAnnotation(key = "listCount", period = 1, count = 1)
     public Result listCount(@ApiParam(value = "用户id", required = false) @RequestParam(required = false) Long userId) {
         TBUser tbUser = (TBUser) ServletUtil.getRequestAccount();
         return ResultUtil.ok(teExamService.examList(userId, tbUser.getOrgId()));
@@ -480,10 +530,10 @@ public class TEExamController {
 
     @ApiOperation(value = "考试属性统计接口")
     @RequestMapping(value = "/prop/count", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试属性信息", response = ExamPropCountDto.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试属性信息", response = ExamPropCountDto.class) })
     public Result propCount(@ApiParam(value = "考试id", required = true) @RequestParam Long examId,
-                            @ApiParam(value = "考试场次id") @RequestParam(required = false) Long examActivityId,
-                            @ApiParam(value = "是否刷新") @RequestParam(required = false) boolean freshen) {
+            @ApiParam(value = "考试场次id") @RequestParam(required = false) Long examActivityId,
+            @ApiParam(value = "是否刷新") @RequestParam(required = false) boolean freshen) {
         if (Objects.isNull(examId) || Objects.equals(examId, "")) {
             throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
         }
@@ -501,13 +551,14 @@ public class TEExamController {
         if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name())) {
             examInvigilateUserQueryWrapper.lambda().eq(TBExamInvigilateUser::getUserId, tbUser.getId());
         }
-        List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService
-                .list(examInvigilateUserQueryWrapper);
+        List<TBExamInvigilateUser> tbExamInvigilateUserList = tbExamInvigilateUserService.list(
+                examInvigilateUserQueryWrapper);
         Set<String> roomCodeSet = null;
         if (Objects.nonNull(tbExamInvigilateUserList) && tbExamInvigilateUserList.size() > 0) {
             roomCodeSet = tbExamInvigilateUserList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
         }
-        if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name()) && CollectionUtils.isEmpty(roomCodeSet)) {
+        if (authDto.getRoleCodes().toString().contains(RoleEnum.INVIGILATE.name()) && CollectionUtils.isEmpty(
+                roomCodeSet)) {
             throw new BusinessException("当前监考老师未设置任何监考考场");
         }
 
@@ -515,11 +566,14 @@ public class TEExamController {
         if (Objects.nonNull(examId) && Objects.nonNull(examActivityId) && !CollectionUtils.isEmpty(roomCodeSet)) {
             for (String s : roomCodeSet) {
                 if (freshen && authDto.getRoleCodes().toString().contains(RoleEnum.ADMIN.name())) {
-                    teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null, true);
+                    teExamSummaryService.examSummary(examId, examActivityId,
+                            Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null, true);
                 }
-                List<TEExamSummary> teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId, s);
+                List<TEExamSummary> teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId,
+                        s);
                 if (!CollectionUtils.isEmpty(teExamSummaryList)) {
-                    teExamSummaryService.examSummary(examId, examActivityId, Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null, true);
+                    teExamSummaryService.examSummary(examId, examActivityId,
+                            Objects.nonNull(s) ? new HashSet<>(Arrays.asList(s)) : null, true);
                     teExamSummaryList = themisCacheService.getExamSummaryCache(examId, examActivityId, s);
                 }
                 teExamSummaryAllList.addAll(teExamSummaryList);
@@ -563,7 +617,7 @@ public class TEExamController {
     @ApiOperation(value = "考试重新算分")
     @RequestMapping(value = "/score/calculate", method = RequestMethod.POST)
     @Transactional
-    @ApiResponses({@ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "{\"taskId\":0}", response = Result.class) })
     public Result scoreCalculate(@ApiParam(value = "批次ID", required = true) @RequestParam Long id) {
         //先查询考试相关信息
         ExamCacheBean examCacheBean = teExamService.getExamCacheBean(id);
@@ -599,24 +653,24 @@ public class TEExamController {
     }
 
     @ApiOperation(value = "推送考试数据到云阅卷")
-    @ApiResponses({@ApiResponse(code = 200, message = "推送考试数据到云阅卷", response = Result.class)})
+    @ApiResponses({ @ApiResponse(code = 200, message = "推送考试数据到云阅卷", response = Result.class) })
     @RequestMapping(value = "/cloud_mark/push/data", method = RequestMethod.POST)
     public Result pushData(@ApiParam(value = "考试ID", required = true) @RequestParam String examId,
-                           @ApiParam(value = "是否推送客观分", required = true) @RequestParam Boolean objectiveScorePush,
-                           @ApiParam(value = "是否推送违纪考生", required = true) @RequestParam Boolean examStudentBreachPush) {
+            @ApiParam(value = "是否推送客观分", required = true) @RequestParam Boolean objectiveScorePush,
+            @ApiParam(value = "是否推送违纪考生", required = true) @RequestParam Boolean examStudentBreachPush) {
         TBTaskHistory tbTaskHistory = null;
         try {
             ExamCacheBean examCacheBean = teExamService.getExamCacheBean(Long.parseLong(examId));
             Optional.ofNullable(examCacheBean).orElseThrow(() -> new BusinessException(ExceptionResultEnum.EXAM_NO));
 
             InvigilateMonitorStatusEnum invigilateMonitorStatusEnum = examCacheBean.getMonitorStatus();//监考状态
-            if (Objects.nonNull(invigilateMonitorStatusEnum) && !Objects
-                    .equals(invigilateMonitorStatusEnum, InvigilateMonitorStatusEnum.FINISHED)) {
+            if (Objects.nonNull(invigilateMonitorStatusEnum) && !Objects.equals(invigilateMonitorStatusEnum,
+                    InvigilateMonitorStatusEnum.FINISHED)) {
                 throw new BusinessException("当前批次监考未结束,请在结束后操作");
             }
             ScoreStatusEnum scoreStatusEnum = examCacheBean.getScoreStatus();//算分状态
-            if (Objects.nonNull(scoreStatusEnum) && (Objects.equals(scoreStatusEnum, ScoreStatusEnum.CALCULATING) || Objects
-                    .equals(scoreStatusEnum, ScoreStatusEnum.NEED_CALCULATE))) {
+            if (Objects.nonNull(scoreStatusEnum) && (Objects.equals(scoreStatusEnum, ScoreStatusEnum.CALCULATING)
+                    || Objects.equals(scoreStatusEnum, ScoreStatusEnum.NEED_CALCULATE))) {
                 throw new BusinessException("当前批次算分未结束,请在结束后操作");
             }
             QueryWrapper<TEExamCourse> teExamCourseQueryWrapper = new QueryWrapper<>();
@@ -642,11 +696,12 @@ public class TEExamController {
             QueryWrapper<TBTaskHistory> tbTaskHistoryQueryWrapper = new QueryWrapper<>();
             tbTaskHistoryQueryWrapper.lambda().eq(TBTaskHistory::getExamId, examCacheBean.getId())
                     .eq(TBTaskHistory::getType, TaskTypeEnum.CLOUD_MARK_DATA_PUSH)
-                    .orderByDesc(TBTaskHistory::getCreateTime)
-                    .last(" limit 1 ");
+                    .orderByDesc(TBTaskHistory::getCreateTime).last(" limit 1 ");
             tbTaskHistory = taskHistoryService.getOne(tbTaskHistoryQueryWrapper);
 
-            if (Objects.isNull(tbTaskHistory) || (tbTaskHistory.getStatus() == TaskStatusEnum.FINISH && (Objects.nonNull(tbTaskHistory.getProgress()) && tbTaskHistory.getProgress().doubleValue() == 100D))) {
+            if (Objects.isNull(tbTaskHistory) || (tbTaskHistory.getStatus() == TaskStatusEnum.FINISH && (
+                    Objects.nonNull(tbTaskHistory.getProgress())
+                            && tbTaskHistory.getProgress().doubleValue() == 100D))) {
                 //往任务表里插一条数据
                 tbTaskHistory = new TBTaskHistory(TaskTypeEnum.CLOUD_MARK_DATA_PUSH, TaskStatusEnum.INIT,
                         SystemConstant.DATA_PUSH_INIT, 0d, tbUser.getId(), tbUser.getOrgId());
@@ -671,9 +726,8 @@ public class TEExamController {
             transMap.put(SystemConstant.OBJECTIVE_SCORE_PUSH, objectiveScorePush);
             transMap.put(SystemConstant.EXAM_STUDENT_BREACH_PUSH, examStudentBreachPush);
             //mq发送消息start
-            MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.CLOUD_MARK_DATA_PUSH.name(),
-                    transMap, MqTagEnum.CLOUD_MARK_DATA_PUSH, String.valueOf(tbTaskHistory.getId()),
-                    tbUser.getName());
+            MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.CLOUD_MARK_DATA_PUSH.name(), transMap,
+                    MqTagEnum.CLOUD_MARK_DATA_PUSH, String.valueOf(tbTaskHistory.getId()), tbUser.getName());
             mqDtoService.assembleSendAsyncMsg(mqDto);
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
@@ -688,18 +742,19 @@ public class TEExamController {
 
     @ApiOperation(value = "修正作答记录缓存到数据库")
     @RequestMapping(value = "/persisted_answer", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    @ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
     public Result persistedAnswer(@ApiParam(value = "考试记录id") @RequestParam(required = false) Long examRecordId,
-                                  @ApiParam(value = "考试批次id") @RequestParam(required = false) Long examId,
-                                  @ApiParam(value = "考试场次id") @RequestParam(required = false) Long examActivityId,
-                                  @ApiParam(value = "考生id") @RequestParam(required = false) Long examStudentId,
-                                  @ApiParam(value = "是否批量处理") @RequestParam(required = false) Boolean batch,
-                                  @ApiParam(value = "补救措施", required = true) @RequestParam RepariEnum repariEnum,
-                                  @ApiParam(value = "考试状态") @RequestParam(required = false) ExamRecordStatusEnum status) {
+            @ApiParam(value = "考试批次id") @RequestParam(required = false) Long examId,
+            @ApiParam(value = "考试场次id") @RequestParam(required = false) Long examActivityId,
+            @ApiParam(value = "考生id") @RequestParam(required = false) Long examStudentId,
+            @ApiParam(value = "是否批量处理") @RequestParam(required = false) Boolean batch,
+            @ApiParam(value = "补救措施", required = true) @RequestParam RepariEnum repariEnum,
+            @ApiParam(value = "考试状态") @RequestParam(required = false) ExamRecordStatusEnum status) {
         List<TOeExamRecord> tOeExamRecordList = null;
         if (Objects.nonNull(batch) && batch) {
             if (repariEnum == RepariEnum.EXAM_STUDENT) {
-                List<TEExamStudent> teExamStudentList = teExamStudentService.findAlreadyExamCountZero(examId, examActivityId, examStudentId, examRecordId);
+                List<TEExamStudent> teExamStudentList = teExamStudentService.findAlreadyExamCountZero(examId,
+                        examActivityId, examStudentId, examRecordId);
                 if (!CollectionUtils.isEmpty(teExamStudentList)) {
                     for (TEExamStudent t : teExamStudentList) {
                         teExamStudentService.updateExamStudentByCache(t.getId());
@@ -729,19 +784,21 @@ public class TEExamController {
             for (TOeExamRecord t : tOeExamRecordList) {
                 try {
                     switch (repariEnum) {
-                        case ANSWER:
-                        case FINISHED_ANSWER:
-                            tOeExamRecordService.saveDataByCachePersistedAnswer(t.getId());
-                            break;
-                        case FINISHED:
-                            ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(t.getExamStudentId());
-                            teExamService.finish(examStudentCacheBean.getStudentId(), t.getId(), FinishTypeEnum.AUTO.name(), t.getDurationSeconds());
-                            break;
-                        case EXAM_STUDENT:
-                            teExamStudentService.updateExamStudentByCache(t.getExamStudentId());
-                            break;
-                        default:
-                            break;
+                    case ANSWER:
+                    case FINISHED_ANSWER:
+                        tOeExamRecordService.saveDataByCachePersistedAnswer(t.getId());
+                        break;
+                    case FINISHED:
+                        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(
+                                t.getExamStudentId());
+                        teExamService.finish(examStudentCacheBean.getStudentId(), t.getId(), FinishTypeEnum.AUTO.name(),
+                                t.getDurationSeconds());
+                        break;
+                    case EXAM_STUDENT:
+                        teExamStudentService.updateExamStudentByCache(t.getExamStudentId());
+                        break;
+                    default:
+                        break;
                     }
                 } catch (Exception e) {
                     log.error(SystemConstant.LOG_ERROR, e);
@@ -753,10 +810,10 @@ public class TEExamController {
 
     @ApiOperation(value = "删除用户缓存")
     @RequestMapping(value = "/delete_cache", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "试卷信息")})
+    @ApiResponses({ @ApiResponse(code = 200, message = "试卷信息") })
     public Result deleteCache(@ApiParam(value = "考试记录id") @RequestParam(required = false) Long examRecordId,
-                              @ApiParam(value = "考试批次id") @RequestParam(required = false) Long examId,
-                              @ApiParam(value = "考生id") @RequestParam(required = false) Long examStudentId) {
+            @ApiParam(value = "考试批次id") @RequestParam(required = false) Long examId,
+            @ApiParam(value = "考生id") @RequestParam(required = false) Long examStudentId) {
         QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
         if (Objects.nonNull(examRecordId)) {
             tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getId, examRecordId);
@@ -767,24 +824,25 @@ public class TEExamController {
         if (Objects.nonNull(examStudentId)) {
             tOeExamRecordQueryWrapper.lambda().eq(TOeExamRecord::getExamStudentId, examStudentId);
         }
-//        List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
-//        if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
-//            for (TOeExamRecord t : tOeExamRecordList) {
-//                ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(t.getExamStudentId());
-//                TEStudentCacheDto teStudent = cacheService.addStudentAccountCache(examStudentCacheBean.getStudentId());
-//                commonService.deleteExamStudentCache(t.getId(), teStudent.getId());
-//            }
-//        }
+        //        List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
+        //        if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
+        //            for (TOeExamRecord t : tOeExamRecordList) {
+        //                ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(t.getExamStudentId());
+        //                TEStudentCacheDto teStudent = cacheService.addStudentAccountCache(examStudentCacheBean.getStudentId());
+        //                commonService.deleteExamStudentCache(t.getId(), teStudent.getId());
+        //            }
+        //        }
         tOeExamRecordQueryWrapper.lambda().isNotNull(TOeExamRecord::getFirstStartTime)
-                .isNotNull(TOeExamRecord::getFinishTime)
-                .eq(TOeExamRecord::getStatus, ExamRecordStatusEnum.FINISHED);
+                .isNotNull(TOeExamRecord::getFinishTime).eq(TOeExamRecord::getStatus, ExamRecordStatusEnum.FINISHED);
         List<TOeExamRecord> tOeExamRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
         if (!CollectionUtils.isEmpty(tOeExamRecordList)) {
             for (TOeExamRecord t : tOeExamRecordList) {
                 if ((System.currentTimeMillis() - t.getFinishTime().longValue()) / 1000 / 60 >= 30) {//超过30分钟则改状态
                     try {
-                        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(t.getExamStudentId());
-                        TEStudentCacheDto teStudent = themisCacheService.addStudentAccountCache(examStudentCacheBean.getStudentId());
+                        ExamStudentCacheBean examStudentCacheBean = teExamStudentService.getExamStudentCacheBean(
+                                t.getExamStudentId());
+                        TEStudentCacheDto teStudent = themisCacheService.addStudentAccountCache(
+                                examStudentCacheBean.getStudentId());
                         commonService.persisted(t.getId(), teStudent.getId());
                     } catch (Exception e) {
                     }
@@ -796,8 +854,9 @@ public class TEExamController {
 
     @ApiOperation(value = "清除考试缓存")
     @RequestMapping(value = "/clean_exam_first_prepare_cache", method = RequestMethod.POST)
-    @ApiResponses({@ApiResponse(code = 200, message = "考试信息")})
-    public Result cleanExamFirstPrepareCache(@ApiParam(value = "考试批次ids") @RequestParam(required = false) Set<Long> examIds) {
+    @ApiResponses({ @ApiResponse(code = 200, message = "考试信息") })
+    public Result cleanExamFirstPrepareCache(
+            @ApiParam(value = "考试批次ids") @RequestParam(required = false) Set<Long> examIds) {
         if (!CollectionUtils.isEmpty(examIds)) {
             List<Map> list = tOeExamRecordService.cleanExamFirstPrepareCache(examIds);
             if (!CollectionUtils.isEmpty(list)) {

+ 10 - 25
themis-business/src/main/java/com/qmth/themis/business/service/impl/TEExamActivityServiceImpl.java

@@ -409,19 +409,6 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
                                 if (s.getFinishTime().longValue() < System.currentTimeMillis()) {
                                     throw new BusinessException("修改的场次结束时间只能大于当前时间");
                                 }
-                                if (Objects.nonNull(teExam.getForceFinish()) && teExam.getForceFinish().intValue() == 1
-                                        && s.getFinishTime().longValue() != teExamActivityDb.getFinishTime()
-                                        .longValue()) {
-                                    //删除再新增quartz任务,发送mq消息start
-                                    Map<String, Object> prop = new HashMap<>();
-                                    prop.put(SystemConstant.OPER, SystemConstant.INSERT);
-                                    prop.put(SystemConstant.EXAM, teExam);
-                                    MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
-                                            JacksonUtil.parseJson(Arrays.asList(s)), MqTagEnum.EXAM_ACTIVITY,
-                                            String.valueOf(teExam.getId()), prop, tbUser.getName());
-                                    mqDtoService.assembleSendAsyncOrderMsg(mqDto);
-                                    //删除再新增quartz任务,发送mq消息end
-                                }
                             }
                         }
                     }
@@ -473,18 +460,16 @@ public class TEExamActivityServiceImpl extends ServiceImpl<TEExamActivityMapper,
                 //                    teAudioService.sendAudioMessage(t);
                 //                }
             }
-            if (size.get() > 0 && (Objects.nonNull(teExam.getForceFinish()) && teExam.getForceFinish().intValue() == 1)) {
-                if (Objects.nonNull(teExam.getForceFinish()) && teExam.getForceFinish().intValue() == 1) {
-                    //新增quartz任务,发送mq消息start
-                    Map<String, Object> prop = new HashMap<>();
-                    prop.put(SystemConstant.OPER, SystemConstant.INSERT);
-                    prop.put(SystemConstant.EXAM, teExam);
-                    MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
-                            JacksonUtil.parseJson(teExamActivityList), MqTagEnum.EXAM_ACTIVITY,
-                            String.valueOf(teExam.getId()), prop, tbUser.getName());
-                    mqDtoService.assembleSendAsyncOrderMsg(mqDto);
-                    //新增quartz任务,发送mq消息end
-                }
+            if (Objects.nonNull(teExam.getForceFinish()) && teExam.getForceFinish().intValue() == 1) {
+                //新增quartz任务,发送mq消息start
+                Map<String, Object> prop = new HashMap<>();
+                prop.put(SystemConstant.OPER, SystemConstant.INSERT);
+                prop.put(SystemConstant.EXAM, teExam);
+                MqDto mqDto = new MqDto(mqUtil.getTopic(), MqTagEnum.EXAM_ACTIVITY.name(),
+                        JacksonUtil.parseJson(teExamActivityList), MqTagEnum.EXAM_ACTIVITY,
+                        String.valueOf(teExam.getId()), prop, tbUser.getName());
+                mqDtoService.assembleSendAsyncOrderMsg(mqDto);
+                //新增quartz任务,发送mq消息end
             }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);