From e716f414a8480945c466f7d14ae3b74756d87c0a Mon Sep 17 00:00:00 2001 From: huababa1 <2037205722@qq.com> Date: Thu, 18 Sep 2025 12:08:28 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91=E8=AF=95?= =?UTF-8?q?=E5=8D=B7=E4=BB=BB=E5=8A=A1=E7=9A=84=E4=BD=BF=E7=94=A8=E6=AC=A1?= =?UTF-8?q?=E6=95=B0=E5=AD=A6=E7=94=9F=E5=92=8C=E7=AE=A1=E7=90=86=E7=AB=AF?= =?UTF-8?q?=E5=88=86=E5=BC=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../dal/dataobject/monitor/MonitorDO.java | 4 +++ .../exam/dal/mysql/monitor/MonitorMapper.java | 1 + .../service/monitor/MonitorServiceImpl.java | 6 ++++ .../EducationPaperPersonServiceImpl.java | 1 + .../paper/EducationPaperServiceImpl.java | 7 +++- .../paper/EducationPaperTaskServiceImpl.java | 35 ++++++++++--------- .../mapper/monitor/MonitorMapper.xml | 22 +++++++++--- 7 files changed, 53 insertions(+), 23 deletions(-) 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 70f6cdf7..1f0a73b2 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 @@ -90,4 +90,8 @@ public class MonitorDO extends BaseDO { */ private String interactiveTime; + /** + * 使用次数 + */ + private String counts; } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java index 81edd2ba..7b8c6e3e 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/monitor/MonitorMapper.java @@ -72,4 +72,5 @@ public interface MonitorMapper extends BaseMapperX { void deleteByTaskId(String taskId); + Integer selectCountByUserIdAndTaskId(@Param("stuId")Long stuId, @Param("taskId")String taskId); } \ No newline at end of file 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 2fd8c8ed..bc62a3cb 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 @@ -240,14 +240,20 @@ public class MonitorServiceImpl implements MonitorService { if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) { EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId()); String counts = educationPaper.getCounts(); + String countsStu = info.getCounts(); int count = 0; + int countStu = 0; try { count = Integer.parseInt(counts); + countStu = Integer.parseInt(countsStu); } catch (NumberFormatException | NullPointerException e) { count = 0; // 默认从 0 开始 + countStu = 0; } count += 1; + countStu += 1; educationPaper.setCounts(String.valueOf(count)); + info.setCounts(String.valueOf(countStu)); educationPaperMapper.updateById(educationPaper); info.setPaperNum(educationPaper.getNum()); } 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 5ee32726..c69a90c4 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 @@ -223,6 +223,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer info.setTaskName(name); info.setTaskType(educationPaperTask.getTaskType()); info.setInteractiveTime(null); + info.setCounts("0"); stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); monitorMapper.insert(info); educationPaperPerson.setPersonId(studentId); 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 b91ad596..de454388 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 @@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper; import cn.afterturn.easypoi.word.WordExportUtil; +import jakarta.annotation.Resource; import jakarta.servlet.http.HttpServletResponse; import org.apache.poi.util.Units; import org.apache.poi.xwpf.usermodel.*; @@ -27,6 +28,7 @@ import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo; import pc.exam.pp.module.exam.controller.admin.paper.vo.SchemeInfo; import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; import pc.exam.pp.module.exam.dal.dataobject.*; +import pc.exam.pp.module.exam.dal.mysql.monitor.MonitorMapper; import pc.exam.pp.module.exam.dal.mysql.paper.*; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionFileMapper; @@ -73,6 +75,8 @@ public class EducationPaperServiceImpl implements IEducationPaperService private ExamQuestionMapper examQuestionMapper; @Autowired private ExamQuestionFileMapper sysFileMapper; + @Resource + private MonitorMapper monitorMapper; /** * 查询试卷 * @@ -339,10 +343,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService EducationPaperStuDto educationPaperStuDto=new EducationPaperStuDto(); // EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(educationPaper.getTaskId()); +// Integer counts= monitorMapper.selectCountByUserIdAndTaskId(loginUserId,educationPaper.getTaskId()); educationPaperStuDto.setPaperId(educationPaper.getPaperId()); educationPaperStuDto.setNum(educationPaper.getNum()); educationPaperStuDto.setTaskId(educationPaper.getTaskId()); - educationPaperStuDto.setCounts(educationPaper.getCounts()); +// educationPaperStuDto.setCounts(counts); educationPaperStuDto.setRollUp(educationPaper.getRollUp()); educationPaperStuDto.setIsAb(educationPaper.getIsAb()); // educationPaperStuDto.setEducationPaperParam(educationPaperParam); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index 5e067dd1..3d0b913e 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -629,21 +629,22 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService if ("0".equals(taskType)) { for (EducationPaperTask paperTask : list) { String taskId = paperTask.getTaskId(); - int count = 0; - List educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId()); - if (educationPapers != null && educationPapers.size() > 0) { - for (EducationPaper educationPaper : educationPapers) { - try { - count += Integer.parseInt(educationPaper.getCounts()); - } catch (NumberFormatException e) { - // 可选:记录异常或忽略非法数字 - System.err.println("无效的 counts 值: " + educationPaper.getCounts()); - } - - } - } - paperTask.setCount(String.valueOf(count)); - +// int count = 0; +// List educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId()); +// if (educationPapers != null && educationPapers.size() > 0) { +//// for (EducationPaper educationPaper : educationPapers) { +//// try { +//// count += Integer.parseInt(educationPaper.getCounts()); +//// } catch (NumberFormatException e) { +//// // 可选:记录异常或忽略非法数字 +//// System.err.println("无效的 counts 值: " + educationPaper.getCounts()); +//// } +//// +//// } +// +// } + Integer counts= monitorMapper.selectCountByUserIdAndTaskId(stuId,taskId); + paperTask.setCount(counts.toString()); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); //最高成绩 @@ -653,14 +654,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService if (StringUtils.isNotBlank(score)) { paperTask.setScore(score); } else { - paperTask.setScore("0.0"); + paperTask.setScore("0"); } } else { String score = monitorMapper.selectByStuIdAndTaskIdNew(stuId, taskId); if (StringUtils.isNotBlank(score)) { paperTask.setScore(score); } else { - paperTask.setScore("0.0"); + paperTask.setScore("0"); } } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml index 1370f06a..25c99fc0 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/monitor/MonitorMapper.xml @@ -28,28 +28,32 @@ select score from exam_monitor where stu_id = #{stuId} - and task_id = #{taskId} + and task_id = #{taskId} + and deleted = '0' + and exam_status = '0' ORDER BY score DESC LIMIT 1 +