|
@@ -601,6 +601,7 @@ public class TIeInvigilateController {
|
|
@RequestMapping(value = "/exam/finish", method = RequestMethod.POST)
|
|
@RequestMapping(value = "/exam/finish", method = RequestMethod.POST)
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
@ApiResponses({@ApiResponse(code = 200, message = "{\"success\":true}", response = Result.class)})
|
|
public Result examFinish(@ApiParam(value = "考试id", required = true) @RequestParam Long examId) {
|
|
public Result examFinish(@ApiParam(value = "考试id", required = true) @RequestParam Long examId) {
|
|
|
|
+// long start = System.currentTimeMillis();
|
|
if (Objects.isNull(examId) || Objects.equals(examId, "")) {
|
|
if (Objects.isNull(examId) || Objects.equals(examId, "")) {
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
throw new BusinessException(ExceptionResultEnum.EXAM_ID_IS_NULL);
|
|
}
|
|
}
|
|
@@ -624,94 +625,42 @@ public class TIeInvigilateController {
|
|
roomCodeSet = tbExamInvigilateUserList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
roomCodeSet = tbExamInvigilateUserList.stream().map(s -> s.getRoomCode()).collect(Collectors.toSet());
|
|
}
|
|
}
|
|
//根据roomCode获取当前老师所要监考的全部应考学生数
|
|
//根据roomCode获取当前老师所要监考的全部应考学生数
|
|
- QueryWrapper<TEExamStudent> teExamStudentQueryWrapper = new QueryWrapper<>();
|
|
|
|
- teExamStudentQueryWrapper.lambda().eq(TEExamStudent::getExamId, examId)
|
|
|
|
- .in(TEExamStudent::getRoomCode, roomCodeSet);
|
|
|
|
- List<TEExamStudent> teExamStudentList = teExamStudentService.list(teExamStudentQueryWrapper);
|
|
|
|
- Set<Long> examStudentIdSet = null;
|
|
|
|
- Set<Long> examActivityIdSet = null;
|
|
|
|
- AtomicReference<Integer> prepareCount = new AtomicReference<>(0); //已待考
|
|
|
|
- AtomicReference<Integer> examCount = new AtomicReference<>(0);//考试中
|
|
|
|
- if (Objects.nonNull(teExamStudentList) && teExamStudentList.size() > 0) {
|
|
|
|
- examStudentIdSet = new HashSet<>();
|
|
|
|
- examActivityIdSet = new HashSet<>();
|
|
|
|
- Set<Long> finalExamStudentIdSet = examStudentIdSet;
|
|
|
|
- Set<Long> finalExamActivityIdSet = examActivityIdSet;
|
|
|
|
- teExamStudentList.forEach(s -> {
|
|
|
|
- finalExamStudentIdSet.add(s.getId());
|
|
|
|
- finalExamActivityIdSet.add(s.getExamActivityId());
|
|
|
|
- });
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- Integer exceptionCount = 0, warningCount = 0, reexamCount = 0;//异常人数,预警人数,重考人数
|
|
|
|
- ExamPropCountDto examPropCountDto = new ExamPropCountDto();
|
|
|
|
|
|
+ AtomicReference<ExamPropCountDto> examPropCountDto = new AtomicReference(new ExamPropCountDto());
|
|
//获取异常人数
|
|
//获取异常人数
|
|
- if (Objects.nonNull(examStudentIdSet)) {
|
|
|
|
- QueryWrapper<TIeInvigilateExceptionInfo> tIeInvigilateExceptionInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tIeInvigilateExceptionInfoQueryWrapper.lambda().in(TIeInvigilateExceptionInfo::getExamStudentId, examStudentIdSet);
|
|
|
|
- exceptionCount = tIeInvigilateExceptionInfoService.count(tIeInvigilateExceptionInfoQueryWrapper);
|
|
|
|
-
|
|
|
|
- QueryWrapper<TIeInvigilateWarnInfo> tIeInvigilateWarnInfoQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tIeInvigilateWarnInfoQueryWrapper.lambda().in(TIeInvigilateWarnInfo::getExamStudentId, examStudentIdSet);
|
|
|
|
- warningCount = tIeInvigilateWarnInfoService.count(tIeInvigilateWarnInfoQueryWrapper);
|
|
|
|
-
|
|
|
|
- QueryWrapper<TEExamReexam> teExamReexamQueryWrapper = new QueryWrapper<>();
|
|
|
|
- teExamReexamQueryWrapper.lambda().in(TEExamReexam::getExamStudentId, examStudentIdSet).eq(TEExamReexam::getStatus, 1);
|
|
|
|
- reexamCount = teExamReexamService.count(teExamReexamQueryWrapper);
|
|
|
|
-
|
|
|
|
- examPropCountDto.setExceptionCount(exceptionCount);
|
|
|
|
- examPropCountDto.setWarningCount(warningCount);
|
|
|
|
- examPropCountDto.setReexamCount(reexamCount);
|
|
|
|
- }
|
|
|
|
- if (Objects.nonNull(examActivityIdSet)) {
|
|
|
|
- QueryWrapper<TOeExamRecord> tOeExamRecordQueryWrapper = new QueryWrapper<>();
|
|
|
|
- tOeExamRecordQueryWrapper.lambda().in(TOeExamRecord::getExamActivityId, examActivityIdSet);
|
|
|
|
- List<TOeExamRecord> examRecordList = tOeExamRecordService.list(tOeExamRecordQueryWrapper);
|
|
|
|
- //获取已待考、考试中学生
|
|
|
|
- examRecordList.forEach(s -> {
|
|
|
|
- ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(s.getExamActivityId());
|
|
|
|
- Long startTime = examActivityCacheBean.getStartTime();
|
|
|
|
- Long finishTime = examActivityCacheBean.getFinishTime();
|
|
|
|
- Integer activityMaxDurationSeconds = Objects.nonNull(examActivityCacheBean.getMaxDurationSeconds()) ? examActivityCacheBean.getMaxDurationSeconds() : null;
|
|
|
|
- Integer maxDurationSeconds = Objects.nonNull(examCacheBean.getMaxDurationSeconds()) ? examCacheBean.getMaxDurationSeconds() : null;
|
|
|
|
- Integer finalMaxDurationSeconds = Objects.nonNull(activityMaxDurationSeconds) ? activityMaxDurationSeconds : maxDurationSeconds;
|
|
|
|
- Calendar calendar = Calendar.getInstance();
|
|
|
|
- if (Objects.nonNull(finalMaxDurationSeconds)) {
|
|
|
|
- calendar.setTimeInMillis(startTime);
|
|
|
|
- calendar.add(Calendar.SECOND, finalMaxDurationSeconds.intValue());
|
|
|
|
- }
|
|
|
|
-// Date now = new Date();
|
|
|
|
-// if (now.getTime() >= calendar.getTime().getTime() && now.getTime() <= finishTime.getTime()) {
|
|
|
|
- examPropCountDto.setMaxDurationSeconds(calendar.getTime().getTime());
|
|
|
|
- if (Objects.nonNull(examCacheBean.getForceFinish()) && examCacheBean.getForceFinish() == 1) {
|
|
|
|
- examPropCountDto.setFinishTime(finishTime);
|
|
|
|
- }
|
|
|
|
-// Map<String, Object> objectMap = redisUtil.getHashEntries(RedisKeyHelper.examActivityRecordCacheKey(s));
|
|
|
|
-// if (Objects.nonNull(objectMap) && objectMap.size() > 0) {
|
|
|
|
-// objectMap.forEach((k, v) -> {
|
|
|
|
-// ExamActivityRecordCacheBean examActivityRecordCache = (ExamActivityRecordCacheBean) v;
|
|
|
|
-// ExamRecordStatusEnum examRecordStatusEnum = examActivityRecordCache.getStatus();
|
|
|
|
- ExamRecordStatusEnum examRecordStatusEnum = s.getStatus();
|
|
|
|
- WebsocketStatusEnum clientStatus = Objects.isNull(s.getClientWebsocketStatus()) ? null : s.getClientWebsocketStatus();
|
|
|
|
- //已待考
|
|
|
|
- if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.FIRST_PREPARE) && Objects.nonNull(clientStatus) && Objects
|
|
|
|
- .equals(clientStatus, WebsocketStatusEnum.ON_LINE)) {
|
|
|
|
- prepareCount.getAndSet(prepareCount.get() + 1);
|
|
|
|
- }
|
|
|
|
- //考试中
|
|
|
|
- else if (Objects.equals(examRecordStatusEnum, ExamRecordStatusEnum.ANSWERING) && Objects.nonNull(clientStatus) && Objects
|
|
|
|
- .equals(clientStatus, WebsocketStatusEnum.ON_LINE)) {
|
|
|
|
- examCount.getAndSet(examCount.get() + 1);
|
|
|
|
- }
|
|
|
|
-// });
|
|
|
|
-// }
|
|
|
|
-// }
|
|
|
|
- });
|
|
|
|
|
|
+ List<Integer> finishList = tOeExamRecordService.findByFinish(examId, roomCodeSet);
|
|
|
|
+ if (Objects.nonNull(finishList) && finishList.size() > 0) {
|
|
|
|
+ examPropCountDto.get().setExceptionCount(finishList.get(0));
|
|
|
|
+ examPropCountDto.get().setWarningCount(finishList.get(1));
|
|
|
|
+ examPropCountDto.get().setReexamCount(finishList.get(2));
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+// List<TOeExamRecord> examRecordList = tOeExamRecordService.findByOnlineInfoRecord(examId, roomCodeSet);
|
|
|
|
+// //获取已待考、考试中学生
|
|
|
|
+// examRecordList.forEach(s -> {
|
|
|
|
+// ExamActivityCacheBean examActivityCacheBean = teExamActivityService.getExamActivityCacheBean(s.getExamActivityId());
|
|
|
|
+// Long startTime = examActivityCacheBean.getStartTime();
|
|
|
|
+// Long finishTime = examActivityCacheBean.getFinishTime();
|
|
|
|
+// Integer activityMaxDurationSeconds = Objects.nonNull(examActivityCacheBean.getMaxDurationSeconds()) ? examActivityCacheBean.getMaxDurationSeconds() : null;
|
|
|
|
+// Integer maxDurationSeconds = Objects.nonNull(examCacheBean.getMaxDurationSeconds()) ? examCacheBean.getMaxDurationSeconds() : null;
|
|
|
|
+// Integer finalMaxDurationSeconds = Objects.nonNull(activityMaxDurationSeconds) ? activityMaxDurationSeconds : maxDurationSeconds;
|
|
|
|
+// Calendar calendar = Calendar.getInstance();
|
|
|
|
+// if (Objects.nonNull(finalMaxDurationSeconds)) {
|
|
|
|
+// calendar.setTimeInMillis(startTime);
|
|
|
|
+// calendar.add(Calendar.SECOND, finalMaxDurationSeconds.intValue());
|
|
|
|
+// }
|
|
|
|
+// examPropCountDto.get().setMaxDurationSeconds(calendar.getTime().getTime());
|
|
|
|
+// if (Objects.nonNull(examCacheBean.getForceFinish()) && examCacheBean.getForceFinish() == 1) {
|
|
|
|
+// examPropCountDto.get().setFinishTime(finishTime);
|
|
|
|
+// }
|
|
|
|
+// });
|
|
|
|
+
|
|
teExamService.updateInvigilateMonitorStatus(InvigilateMonitorStatusEnum.FINISHED, examId);
|
|
teExamService.updateInvigilateMonitorStatus(InvigilateMonitorStatusEnum.FINISHED, examId);
|
|
teExamService.deleteExamCacheBean(examId);
|
|
teExamService.deleteExamCacheBean(examId);
|
|
- examPropCountDto.setPrepareCount(prepareCount.get());
|
|
|
|
- examPropCountDto.setExamCount(examCount.get());
|
|
|
|
|
|
+ List<Integer> list = tOeExamRecordService.findByOnlineInfo(examId, roomCodeSet);
|
|
|
|
+ examPropCountDto.get().setPrepareCount(list.get(0));
|
|
|
|
+ examPropCountDto.get().setExamCount(list.get(1));
|
|
|
|
+// long end = System.currentTimeMillis();
|
|
|
|
+// log.info("============exam/finish耗时============:{}秒", (end - start) / 1000);
|
|
return ResultUtil.ok(examPropCountDto);
|
|
return ResultUtil.ok(examPropCountDto);
|
|
}
|
|
}
|
|
|
|
|