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())){