From 196fef938f1b17a8bbe641fcd80710f8bae3cc41 Mon Sep 17 00:00:00 2001 From: dlaren Date: Sun, 14 Sep 2025 16:27:32 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=201?= =?UTF-8?q?=E3=80=81=E4=BA=A4=E4=BA=92=E6=8E=A5=E5=8F=A3=EF=BC=8C=E5=AD=A6?= =?UTF-8?q?=E7=94=9F=E7=AB=AF=E5=AE=9A=E6=97=B6=E4=B8=8E=E5=90=8E=E5=8F=B0?= =?UTF-8?q?=E4=BA=A4=E4=BA=92=EF=BC=8C=E8=8E=B7=E5=8F=96=E4=BA=A4=E4=BA=92?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E5=AD=98=E5=85=A5=E7=BC=93=E5=AD=98=EF=BC=9B?= =?UTF-8?q?2=E3=80=81=E6=9B=B4=E6=8D=A2PC=E7=AD=94=E9=A2=98=EF=BC=8C?= =?UTF-8?q?=E4=BD=BF=E7=94=A8=E4=BA=A4=E4=BA=92=E6=97=B6=E9=97=B4=E8=BF=9B?= =?UTF-8?q?=E8=A1=8C=E5=88=A4=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../paper/EducationPaperPersonController.java | 1 - .../dal/dataobject/monitor/MonitorDO.java | 5 + .../dal/mysql/paper/EducationPaperMapper.java | 65 +++-- .../service/monitor/MonitorServiceImpl.java | 35 +-- .../EducationPaperPersonServiceImpl.java | 2 +- .../paper/EducationPaperServiceImpl.java | 7 +- .../service/paper/IEducationPaperService.java | 2 + .../mapper/exam/EducationPaperMapper.xml | 230 +++++++++++------- .../admin/autoTools/AutoToolsController.java | 69 +++++- .../admin/autoTools/vo/StuSideReqVo.java | 13 + 10 files changed, 271 insertions(+), 158 deletions(-) create mode 100644 exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/vo/StuSideReqVo.java diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java index cce39871..4249fbb0 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/paper/EducationPaperPersonController.java @@ -135,7 +135,6 @@ public class EducationPaperPersonController { } else { return CommonResult.error(DEMO03_PAPER_STUDENT_EXISTS); } - } /** diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/MonitorDO.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/MonitorDO.java index 627f0531..72407c1f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/MonitorDO.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/monitor/MonitorDO.java @@ -81,4 +81,9 @@ public class MonitorDO extends BaseDO { */ private String startTime; + /** + * 交互时间 + */ + private String interactiveTime; + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java index 9ec00bda..5435ff6e 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/paper/EducationPaperMapper.java @@ -21,8 +21,7 @@ import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; * @date 2025-04-15 */ @Mapper -public interface EducationPaperMapper extends BaseMapperX -{ +public interface EducationPaperMapper extends BaseMapperX { /** * 查询试卷 * @@ -31,22 +30,27 @@ public interface EducationPaperMapper extends BaseMapperX */ public EducationPaper selectEducationPaperByPaperId(String paperId); + /** + * 根据试卷编号查询试卷 + * @param paperNum 试卷编号 + * @return 试卷ID + */ + String selectPaperByPaperNum(String paperNum); + /** * 查询试卷列表 * - * @return 试卷集合 */ // public List selectEducationPaperList(EducationPaper educationPaper); - default PageResult selectEducationPaperList(PaperPageVo paperPageVo) { return selectPage(paperPageVo, new LambdaQueryWrapperX() .likeIfPresent(EducationPaper::getTaskId, paperPageVo.getTaskId()) - .likeIfPresent(EducationPaper::getIsAb , paperPageVo.getIsAb()) - .likeIfPresent(EducationPaper::getPaperId , paperPageVo.getPaperId()) - .likeIfPresent(EducationPaper::getCounts , paperPageVo.getCounts()) - .likeIfPresent(EducationPaper::getRollUp , paperPageVo.getRollUp()) - .likeIfPresent(EducationPaper::getStatus , paperPageVo.getStatus()) + .likeIfPresent(EducationPaper::getIsAb, paperPageVo.getIsAb()) + .likeIfPresent(EducationPaper::getPaperId, paperPageVo.getPaperId()) + .likeIfPresent(EducationPaper::getCounts, paperPageVo.getCounts()) + .likeIfPresent(EducationPaper::getRollUp, paperPageVo.getRollUp()) + .likeIfPresent(EducationPaper::getStatus, paperPageVo.getStatus()) ); } @@ -83,36 +87,40 @@ public interface EducationPaperMapper extends BaseMapperX public int deleteEducationPaperByPaperIds(@Param("paperIds") String[] paperIds); - List selectQuByPaperScheme(@Param("pointName") List pointName - ,@Param("keywordList") List keywordList - ,@Param("educationPaperScheme") EducationPaperScheme educationPaperScheme - ,@Param("taskSpecialty") String taskSpecialty - ,@Param("tId") Long tId ); + , @Param("keywordList") List keywordList + , @Param("educationPaperScheme") EducationPaperScheme educationPaperScheme + , @Param("taskSpecialty") String taskSpecialty + , @Param("tId") Long tId); + + String selectTaskIdByPaperId(String paperId); - String selectTaskIdByPaperId(String paperId); //查找方案下所有试卷id - List selectPaperByTaskId(String taskId); + List selectPaperByTaskId(String taskId); + //根据试卷id,批量设置试卷格式 - public int updateEducationByids(@Param("strings")List strings); + public int updateEducationByids(@Param("strings") List strings); List selectPaperRandomByTaskId(String taskId); - int updateRandomByids(@Param("strings")List strings); + int updateRandomByids(@Param("strings") List strings); void updatePaperGuByRollup(String taskId); /** * 根据试卷任务id查找试卷id集合 + * * @param taskId * @return */ - List selectPaperByTaskIdAndRoll(@Param("taskId")String taskId); + List selectPaperByTaskIdAndRoll(@Param("taskId") String taskId); + //查找该方案所有的试卷 List getPaperByTaskIdByType(String taskId); /** * 查找选中方案下已分配的试卷 + * * @param row * @return */ @@ -120,13 +128,15 @@ public interface EducationPaperMapper extends BaseMapperX /** * 批量设置试卷抽卷方式(自选) + * * @param strings * @return */ - int updateEducationByidsThree(@Param("strings")List strings); + int updateEducationByidsThree(@Param("strings") List strings); /** * 分局任务id查找任务下的 试卷 + * * @param taskId * @return */ @@ -134,27 +144,31 @@ public interface EducationPaperMapper extends BaseMapperX /** * 批量插入试卷 + * * @param educationPapers */ void insertEducationPaperList(List educationPapers); /** * 改变试卷状态 + * * @param paperId * @param status * @return */ int changeStatus(@Param("paperId") String paperId - ,@Param("status") String status); + , @Param("status") String status); /** * 查找试卷个数 + * * @return */ int selectCountPaperList(); /** * 查找试卷列表 + * * @param paperPageVo * @return */ @@ -165,21 +179,22 @@ public interface EducationPaperMapper extends BaseMapperX .eq(EducationPaper::getStatus, 0) ); } + /** * 根据方案获取试卷下拉 */ - List selectPaperIdAndNumByTaskId(String taskId); + List selectPaperIdAndNumByTaskId(String taskId); int countPapersByTaskId(String taskId); - List selectTaskNumByids(@Param("cannotDeleteTaskIds")List cannotDeleteTaskIds); + List selectTaskNumByids(@Param("cannotDeleteTaskIds") List cannotDeleteTaskIds); // 查询所有正在考试的 试卷id @TenantIgnore List selectSpecilayCounts(Long loginTenantId); //查询学生的考试分数 - double selctStuScoreByStuIdAndPaperId(@Param("stuId") String stuId - , @Param("paperId") String paperId); + double selctStuScoreByStuIdAndPaperId(@Param("stuId") String stuId + , @Param("paperId") String paperId); } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java index 096365a6..2d2fe52f 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorServiceImpl.java @@ -194,7 +194,6 @@ public class MonitorServiceImpl implements MonitorService { for (SpecialtyVo specialtyVo : taskInVo) { String specialtyId = specialtyVo.getSpecialtyId(); if (!authSpecialtyIds.contains(specialtyId)) continue; - String specialtyName = specialtyVo.getSpecialtyName(); Integer currentCount = specialtyVo.getCounts(); Integer authCount = authMap.getOrDefault(specialtyId, 0); @@ -238,13 +237,10 @@ public class MonitorServiceImpl implements MonitorService { } } } - if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) { EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId()); String counts = educationPaper.getCounts(); - int count = 0; - try { count = Integer.parseInt(counts); } catch (NumberFormatException | NullPointerException e) { @@ -255,14 +251,14 @@ public class MonitorServiceImpl implements MonitorService { educationPaperMapper.updateById(educationPaper); info.setPaperNum(educationPaper.getNum()); } - info.setExamStatus("1"); LocalDateTime nowTime = LocalDateTime.now(); - DateTimeFormatter formatter1 = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); - info.setStartTime(nowTime.format(formatter1)); + DateTimeFormatter formatterNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + info.setStartTime(nowTime.format(formatterNow)); + // 考试考试的时候初始化交互时间为当前时间 + info.setInteractiveTime(nowTime.format(formatterNow)); info.setTemporaryId(stuMonitorPaperVo.getTemporaryId()); info.setIp(stuMonitorPaperVo.getIp()); - if (info.getRemainingTime() == null) { stringRedisTemplate.opsForValue().set("userCache:" + stuMonitorPaperVo.getTaskId() + ":" + stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info)); monitorMapper.updateById(info); @@ -271,15 +267,12 @@ public class MonitorServiceImpl implements MonitorService { EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(stuMonitorPaperVo.getTaskId()); //测评时长 Time examTime = educationPaperParam.getExamTime(); - //判断是否开启测评时长限制 //开启测评时长限制 开启场次 判断场次时间 ,,,,没开启测评时长限制 开启场次 -判断场次时间 if ("0".equals(educationPaperParam.getIsSession())) { //获得场次开始时间, 结束时间 判断是否在 时间范围内 - EducationPaperPerson educationPaperPerson = educationPaperPersonMapper.selectByTaskIdAndPersonId(stuMonitorPaperVo.getTaskId(), stuMonitorPaperVo.getStuId()); EducationPaperSession educationPaperSession = educationPaperSessionMapper.selectEducationPaperSessionBySessionId(educationPaperPerson.getSessionId()); - if (educationPaperSession == null) { throw new MonitorSpecialtyException("未分配考场,请联系教师!"); } @@ -291,17 +284,14 @@ public class MonitorServiceImpl implements MonitorService { String allowEntry = educationPaperSession.getAllowEntry(); //开始考试后分钟,禁止入场 String endAllowEntry = educationPaperSession.getEndAllowEntry(); - + // 开始转换时间 LocalDateTime now = LocalDateTime.now(); LocalDateTime start = DateUtil.toLocalDateTime(startTime); LocalDateTime end = DateUtil.toLocalDateTime(endTime); - // 考试开始前允许入场时间(分钟) int allowEntryMin = Integer.parseInt(allowEntry); - // 考试开始后允许入场时间(分钟) int endAllowEntryMin = Integer.parseInt(endAllowEntry); - // 入场允许范围: [start-allowEntryMin , end + endAllowEntryMin] LocalDateTime entryStart = start.minusMinutes(allowEntryMin); LocalDateTime entryEnd = end.plusMinutes(endAllowEntryMin); @@ -331,9 +321,7 @@ public class MonitorServiceImpl implements MonitorService { info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay()); stringRedisTemplate.opsForValue().set("userCache:" + stuMonitorPaperVo.getTaskId() + ":" + stuMonitorPaperVo.getStuId(), JsonUtils.toJsonString(info)); monitorMapper.updateById(info); - return (long) examTime.toLocalTime().toSecondOfDay(); - } return 0L; } @@ -350,9 +338,6 @@ public class MonitorServiceImpl implements MonitorService { return false; } stringRedisTemplate.opsForValue().set(keychoice, JsonUtils.toJsonString(stuMonitorQuVo)); - // 更新缓存 -// redisTemplate.opsForValue().set(key, info); -// monitorMapper.updateById(info); } return true; @@ -364,11 +349,9 @@ public class MonitorServiceImpl implements MonitorService { String taskId = educationPaper.getTaskId(); String key = "userCache:" + taskId + ":" + stuMonitorPaperEndVo.getStuId(); // 获取学生分数 - StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(Long.valueOf(stuMonitorPaperEndVo.getStuId()), - stuMonitorPaperEndVo.getPaperId(), - stuMonitorPaperEndVo.getTemporaryId()); + StuScoreVo stuScoreVo = stuPaperScoreService.getStuScore(Long.valueOf(stuMonitorPaperEndVo.getStuId()), stuMonitorPaperEndVo.getPaperId(), stuMonitorPaperEndVo.getTemporaryId()); BigDecimal score = stuScoreVo.getScore(); - + // 获取缓存 MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class); if (info != null) { long usedTime = info.getRemainingTime(); @@ -382,15 +365,15 @@ public class MonitorServiceImpl implements MonitorService { long remainingTime = duration.getSeconds() < 0 ? 0 : duration.getSeconds(); info.setRemainingTime(usedTime - remainingTime); } - // 重置开始时间 + // 重置开始时间&交互时间 if (info != null) { info.setStartTime(null); + info.setInteractiveTime(null); } MonitorDO monitorDOs = null; if (info != null) { monitorDOs = getMonitor(info.getMonitorId()); } - EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); if ("1".equals(educationPaperParam.getSaveGrades())) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java index 9744ab30..5ee32726 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperPersonServiceImpl.java @@ -222,9 +222,9 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer info.setPaperNum(""); info.setTaskName(name); info.setTaskType(educationPaperTask.getTaskType()); + info.setInteractiveTime(null); stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); monitorMapper.insert(info); - educationPaperPerson.setPersonId(studentId); educationPaperPerson.setSessionId(sessionId); educationPaperPerson.setBatch(batch); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java index 8f48a12e..b91ad596 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperServiceImpl.java @@ -62,12 +62,10 @@ public class EducationPaperServiceImpl implements IEducationPaperService private EducationPaperSchemeMapper educationPaperSchemeMapper; @Autowired private EducationPaperTaskMapper educationPaperTaskMapper; - @Autowired private EducationPaperSessionMapper educationPaperSessionMapper; @Autowired private EducationPaperQuMapper educationPaperQuMapper; - @Autowired private EducationPaperPersonMapper educationPaperPersonMapper; @@ -967,5 +965,10 @@ public class EducationPaperServiceImpl implements IEducationPaperService } } + @Override + public String selectPaperByPaperNum(String paperNum) { + return educationPaperMapper.selectPaperByPaperNum(paperNum); + } + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java index 4848233a..97be6e67 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/IEducationPaperService.java @@ -130,5 +130,7 @@ public interface IEducationPaperService void addPaperBypaper(PaperSubmitDTO dto); + String selectPaperByPaperNum(String paperNum); + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml index 085dd733..58c6e8b8 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/EducationPaperMapper.xml @@ -5,56 +5,69 @@ - - - - - - - - - - - - - - + + + + + + + + + + + + + + - - + + - - - - - - - - - - - - - - - - - - - - - - + + + + + + + + + + + + + + + + + + + + + + - select paper_id, task_id, num,counts, paper_score,roll_up, is_ab, status ,create_time,update_time,creator,updater ,deleted from education_paper + select paper_id, + task_id, + num, + counts, + paper_score, + roll_up, + is_ab, + status, + create_time, + update_time, + creator, + updater, + deleted + from education_paper @@ -62,59 +75,84 @@ where paper_id = #{paperId} + + + + select count(*) + from education_paper + SELECT COALESCE(SUM(score), 0.0) FROM exam_stu_paper_score - WHERE stu_id = #{stuId} AND paper_id = #{paperId} + WHERE stu_id = #{stuId} + AND paper_id = #{paperId} @@ -191,7 +237,8 @@ select task_id from education_paper where paper_id=#{paperId} INSERT INTO education_paper (paper_id, task_id,num ,counts,paper_score, roll_up, is_ab, status ) VALUES ( - #{item.paperId}, #{item.taskId}, #{item.num},#{item.counts},#{item.paperScore}, #{item.rollUp}, #{item.isAb}, #{item.status} + #{item.paperId}, #{item.taskId}, #{item.num},#{item.counts},#{item.paperScore}, #{item.rollUp}, + #{item.isAb}, #{item.status} ) @@ -216,12 +263,12 @@ select task_id from education_paper where paper_id=#{paperId} - UPDATE education_paper - SET roll_up = '2', is_ab = null - WHERE paper_id IN - - #{paperId} - + UPDATE education_paper + SET roll_up = '2', is_ab = null + WHERE paper_id IN + + #{paperId} + UPDATE education_paper @@ -233,8 +280,10 @@ select task_id from education_paper where paper_id=#{paperId} UPDATE education_paper - SET roll_up = null, is_ab = null - where task_id=#{taskId} and roll_up ='1' + SET roll_up = null, + is_ab = null + where task_id = #{taskId} + and roll_up = '1' UPDATE education_paper @@ -247,12 +296,14 @@ select task_id from education_paper where paper_id=#{paperId} UPDATE education_paper SET status = #{status} - where paper_id =#{paperId} + where paper_id = #{paperId} - delete from education_paper where paper_id = #{paperId} + delete + from education_paper + where paper_id = #{paperId} @@ -265,7 +316,4 @@ select task_id from education_paper where paper_id=#{paperId} - - - \ No newline at end of file diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java index 64671efb..75fe55c4 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/AutoToolsController.java @@ -28,20 +28,17 @@ import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.student.StuScoreVo; import pc.exam.pp.module.exam.service.paper.IEducationPaperParamService; import pc.exam.pp.module.exam.service.paper.IEducationPaperQuService; +import pc.exam.pp.module.exam.service.paper.IEducationPaperService; import pc.exam.pp.module.exam.service.stuPaperScore.StuPaperScoreService; import pc.exam.pp.module.exam.service.stu_paper_file.StuPaperFileService; import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.*; import pc.exam.pp.module.judgement.service.TaskManager; -import pc.exam.pp.module.system.dal.dataobject.oauth2.OAuth2AccessTokenDO; import java.time.Duration; import java.time.Instant; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; -import java.util.Date; -import java.util.List; -import java.util.Map; -import java.util.Objects; +import java.util.*; import java.util.concurrent.atomic.AtomicInteger; import java.util.function.Function; import java.util.stream.Collectors; @@ -76,6 +73,8 @@ public class AutoToolsController { IEducationPaperQuService educationPaperQuService; @Resource StuPaperFileService stuPaperFileService; + @Resource + IEducationPaperService educationPaperService; @GetMapping("/getStuScoreInfo") @Operation(summary = "通过学生ID、试卷ID获取") @@ -109,6 +108,34 @@ public class AutoToolsController { return CommonResult.success(stuPaperScoreInfoVos); } + /** + * 学生端进行交互 + * @param taskId 方案ID + * @return 是否完成 + */ + @GetMapping("/getStuSideStatus") + public CommonResult getStuSideStatus(@RequestParam("taskId") String taskId) { + // 获取登录用户 + LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); + if (loginUser != null) { + // 获取ID + long userId = loginUser.getId(); + // 通过方案ID获取学生考试状态 + String key = "userCache:" + taskId + ":" + userId; + MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key), MonitorDO.class); + if (info != null) { + // 更新交互时间 + LocalDateTime nowTime = LocalDateTime.now(); + DateTimeFormatter formatterNow = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); + // 考试考试的时候初始化交互时间为当前时间 + info.setInteractiveTime(nowTime.format(formatterNow)); + // 更新缓存 + stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); + } + } + return CommonResult.success(true); + } + /** * 开始考试 通过websocket进行传输时间 * @@ -186,16 +213,33 @@ public class AutoToolsController { // 学生端重新登录,判断是否上一次考试没有结束就退出了 @GetMapping("/reStartExamStatus") public CommonResult reStartExamStatus() { - HttpServletRequest request = ServletUtils.getRequest(); // 获取学生ID LoginUser loginUser = SecurityFrameworkUtils.getLoginUser(); - if (loginUser != null) { - long userId = loginUser.getId(); - String key = taskManager.getTaskById(String.valueOf(userId)); - if (key == null) { - return CommonResult.success("0"); + long userId = loginUser.getId(); + Set userCaches = stringRedisTemplate.keys("userCache:*"); + for (String userCache : userCaches) { + // 获取所有试卷的数据 + Set userCacheInfos = stringRedisTemplate.keys(userCache); + for (String userCacheInfo : userCacheInfos) { + MonitorDO monitorDO = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(userCacheInfo), MonitorDO.class); + if (monitorDO.getStuId().equals(String.valueOf(userId))) { + if (monitorDO.getExamStatus().equals("1")) { + // 说明考试没有结束 + String key = taskManager.getTaskById(String.valueOf(userId)); + if (key != null) { + return CommonResult.success(key); + } else { + // 通过试卷number查找试卷ID + String paperNum = monitorDO.getPaperNum(); + String paperId = educationPaperService.selectPaperByPaperNum(paperNum); + key = loginUser.getId() + "_" + monitorDO.getTaskId() + "_" + paperId; + return CommonResult.success(key); + } + } else { + return CommonResult.success("0"); + } + } } - return CommonResult.success(key); } return CommonResult.success("0"); } @@ -270,6 +314,7 @@ public class AutoToolsController { } return CommonResult.error(1_0001_002,"没有找到对应的学生信息"); } + /** * 停止考试 * diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/vo/StuSideReqVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/vo/StuSideReqVo.java new file mode 100644 index 00000000..39601d6d --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/admin/autoTools/vo/StuSideReqVo.java @@ -0,0 +1,13 @@ +package pc.exam.pp.module.judgement.controller.admin.autoTools.vo; + + +import io.swagger.v3.oas.annotations.media.Schema; +import lombok.Data; + +@Data +public class StuSideReqVo { + + @Schema(description = "试卷号") + private String taskId; + +}