diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/vo/StuMonitorPaperEndVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/vo/StuMonitorPaperEndVo.java index 1b4b3ad0..3cc45dd4 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/vo/StuMonitorPaperEndVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/monitor/vo/StuMonitorPaperEndVo.java @@ -8,7 +8,4 @@ import lombok.Data; public class StuMonitorPaperEndVo { private String stuId; private String paperId; - private String score; - private String taskId; - } 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 a6d3ddfa..9ec00bda 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 @@ -2,7 +2,6 @@ package pc.exam.pp.module.exam.dal.mysql.paper; import java.util.List; -import java.util.Map; import org.apache.ibatis.annotations.Mapper; import org.apache.ibatis.annotations.Param; @@ -10,13 +9,10 @@ import pc.exam.pp.framework.common.pojo.PageResult; import pc.exam.pp.framework.mybatis.core.mapper.BaseMapperX; import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX; import pc.exam.pp.framework.tenant.core.aop.TenantIgnore; -import pc.exam.pp.module.exam.controller.admin.paper.dto.EducationPaperStuDto; import pc.exam.pp.module.exam.controller.admin.paper.dto.PaperIdAndNum; import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; -import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperTaskPageVo; import pc.exam.pp.module.exam.dal.dataobject.EducationPaper; import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme; -import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask; /** * 试卷Mapper接口 @@ -178,10 +174,12 @@ public interface EducationPaperMapper extends BaseMapperX List selectTaskNumByids(@Param("cannotDeleteTaskIds")List cannotDeleteTaskIds); - // //查询所有正在考试的 试卷id + // 查询所有正在考试的 试卷id @TenantIgnore List selectSpecilayCounts(Long loginTenantId); - + //查询学生的考试分数 + 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 1aa99513..fd2137a1 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 @@ -10,6 +10,8 @@ import org.springframework.stereotype.Service; import jakarta.annotation.Resource; import org.springframework.validation.annotation.Validated; +import java.io.IOException; +import java.nio.charset.StandardCharsets; import java.sql.Time; import java.time.LocalDateTime; import java.time.temporal.ChronoUnit; @@ -353,57 +355,50 @@ public class MonitorServiceImpl implements MonitorService { @Override public void endStuMonitor(StuMonitorPaperEndVo stuMonitorPaperEndVo) { -// String key = "userCache:" + stuMonitorPaperEndVo.getTaskId()+":" +stuMonitorPaperEndVo.getStuId(); -// String keychoice = "keychoice:"+stuMonitorPaperEndVo.getTaskId()+":" + stuMonitorPaperEndVo.getStuId(); -// StuMonitorQuVo stuMonitorQuVo = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(keychoice),StuMonitorQuVo.class); -// -// try { -// String fileName = "StuMonitorQu.txt"; -// FileWriter writer = new FileWriter(fileName); -// writer.write(JsonUtils.toJsonString(stuMonitorQuVo)); -// writer.close(); -// //上传至 -// String stuId = stuMonitorPaperEndVo.getStuId(); // 学生ID -// String paperId = stuMonitorPaperEndVo.getPaperId(); // 试卷ID -// String path = ""; // 存储路径(可选) -// // 1. 生成 JSON 内容 -// String content = JsonUtils.toJsonString(stuMonitorQuVo); -// -// // 2. 转换为 UTF-8 字节数组(关键修复!) -// byte[] bytes = content.getBytes(StandardCharsets.UTF_8); -//// String fileurl= fileService.createFile(fileName,path, bytes); -//// System.out.println(fileurl); -// -// } catch (IOException e) { -// System.out.println(e); -// } -// -// MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class); -// EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(stuMonitorPaperEndVo.getTaskId()); -// EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(stuMonitorPaperEndVo.getTaskId()); -// if ("1".equals(educationPaperParam.getSaveGrades())){ -// info.setScore(stuMonitorPaperEndVo.getScore()); -// }else { -// MonitorDO monitorDO = monitorMapper.selectById(info.getMonitorId()); -// info.setScore(stuMonitorPaperEndVo.getScore()); -// if (StringUtils.isNotBlank(monitorDO.getScore())) { -// if (Integer.parseInt(monitorDO.getScore()) oldScore) { + info.setScore(String.valueOf(score)); + } else { + info.setScore(monitorDO.getScore()); // 保留旧成绩 + } + } catch (NumberFormatException e) { + // 如果旧分数格式错误,则直接设置新分数 + info.setScore(String.valueOf(score)); + } + } else { + // 如果没有旧成绩,则直接设置 + info.setScore(String.valueOf(score)); + } + + + + } + //考试下的任务 结束改为 结束 其他为待考 + if ("1".equals(educationPaperTask.getTaskType())){ + info.setExamStatus("2"); + redisTemplate.delete(key); + + }else { + info.setExamStatus("0"); + stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); + } + + monitorMapper.updateById(info); } 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 b70d063d..79000ae5 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 @@ -145,6 +145,11 @@ select task_id from education_paper where paper_id=#{paperId} AND em.tenant_id = #{loginTenantId} ORDER BY em.paper_num; +