From 8086e2a1236cd8a6211da97b87c1ef058c590de6 Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Thu, 22 May 2025 14:25:05 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E7=9B=91?= =?UTF-8?q?=E6=8E=A7=E7=AE=A1=E7=90=86=E6=97=B6=E9=97=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/monitor/MonitorServiceImpl.java | 24 +++++++++++++++---- .../judgement/utils/EndStuMonitorUtils.java | 1 + 2 files changed, 20 insertions(+), 5 deletions(-) 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 1bfe9dde..6f03d2d9 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 @@ -3,6 +3,7 @@ package pc.exam.pp.module.exam.service.monitor; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; import com.alibaba.excel.util.StringUtils; +import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.data.redis.core.RedisTemplate; import org.springframework.data.redis.core.StringRedisTemplate; @@ -310,10 +311,15 @@ public class MonitorServiceImpl implements MonitorService { monitorDO.setExamStatus(status); monitorMapper.updateById(monitorDO); MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class); - + EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); + Time examTime = educationPaperParam.getExamTime(); if (info==null){ - MonitorDO monitorDO1=new MonitorDO(); + MonitorDO monitorDO1 = monitorMapper.selectOne( + new QueryWrapper() + .eq("stu_id", stuId) + .eq("task_id", taskId) + ); PersonRepDto personRepDto = educationPaperPersonMapper.selectUserById(stuId); String name= educationPaperTaskMapper.selectEducationPaperTaskNameByid(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); @@ -322,17 +328,25 @@ public class MonitorServiceImpl implements MonitorService { monitorDO1.setTaskType(educationPaperTask.getTaskType()); monitorDO1.setExamStatus(status); monitorDO1.setPaperNum(""); + monitorDO1.setIp(""); monitorDO1.setStuId(stuId); monitorDO1.setUsername(personRepDto.getUsername()); monitorDO1.setNickname(personRepDto.getNickname()); - EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); - Time examTime = educationPaperParam.getExamTime(); + //如果开启了 时长限制 或者考场 if ("0".equals(educationPaperParam.getIsTime())||"0".equals(educationPaperParam.getIsSession())){ monitorDO1.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay()); } stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(monitorDO1)); + monitorMapper.updateById(monitorDO1); }else { + //如果开启了 时长限制 或者考场 + if ("0".equals(educationPaperParam.getIsTime())||"0".equals(educationPaperParam.getIsSession())){ + info.setRemainingTime((long) examTime.toLocalTime().toSecondOfDay()); + } + info.setScore("0"); + info.setPaperNum(""); + info.setIp(""); info.setExamStatus(status); stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); } @@ -351,7 +365,7 @@ public class MonitorServiceImpl implements MonitorService { String taskId = monitorDO.getTaskId(); String stuId = monitorDO.getStuId(); String key = "userCache:" + taskId+":" +stuId; - + monitorDO.setRemainingTime(0L); if ("0".equals(monitorDO.getTaskType())){ monitorDO.setExamStatus("0"); stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(monitorDO)); diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java index f60c341b..0491e66f 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/EndStuMonitorUtils.java @@ -117,6 +117,7 @@ public class EndStuMonitorUtils { String key = "userCache:" + taskId + ":" + stuId; MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class); + info.setRemainingTime(0L); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId); if ("1".equals(educationPaperParam.getSaveGrades())){