Merge pull request '【修改】完善wps代码' (#3) from hyc into master

Reviewed-on: #3
This commit is contained in:
hyc
2025-09-18 12:09:23 +08:00
7 changed files with 53 additions and 23 deletions

View File

@@ -90,4 +90,8 @@ public class MonitorDO extends BaseDO {
*/ */
private String interactiveTime; private String interactiveTime;
/**
* 使用次数
*/
private String counts;
} }

View File

@@ -72,4 +72,5 @@ public interface MonitorMapper extends BaseMapperX<MonitorDO> {
void deleteByTaskId(String taskId); void deleteByTaskId(String taskId);
Integer selectCountByUserIdAndTaskId(@Param("stuId")Long stuId, @Param("taskId")String taskId);
} }

View File

@@ -240,14 +240,20 @@ public class MonitorServiceImpl implements MonitorService {
if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) { if (StringUtils.isNotBlank(stuMonitorPaperVo.getPaperId())) {
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId()); EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperVo.getPaperId());
String counts = educationPaper.getCounts(); String counts = educationPaper.getCounts();
String countsStu = info.getCounts();
int count = 0; int count = 0;
int countStu = 0;
try { try {
count = Integer.parseInt(counts); count = Integer.parseInt(counts);
countStu = Integer.parseInt(countsStu);
} catch (NumberFormatException | NullPointerException e) { } catch (NumberFormatException | NullPointerException e) {
count = 0; // 默认从 0 开始 count = 0; // 默认从 0 开始
countStu = 0;
} }
count += 1; count += 1;
countStu += 1;
educationPaper.setCounts(String.valueOf(count)); educationPaper.setCounts(String.valueOf(count));
info.setCounts(String.valueOf(countStu));
educationPaperMapper.updateById(educationPaper); educationPaperMapper.updateById(educationPaper);
info.setPaperNum(educationPaper.getNum()); info.setPaperNum(educationPaper.getNum());
} }

View File

@@ -223,6 +223,7 @@ public class EducationPaperPersonServiceImpl implements IEducationPaperPersonSer
info.setTaskName(name); info.setTaskName(name);
info.setTaskType(educationPaperTask.getTaskType()); info.setTaskType(educationPaperTask.getTaskType());
info.setInteractiveTime(null); info.setInteractiveTime(null);
info.setCounts("0");
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info)); stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
monitorMapper.insert(info); monitorMapper.insert(info);
educationPaperPerson.setPersonId(studentId); educationPaperPerson.setPersonId(studentId);

View File

@@ -2,6 +2,7 @@ package pc.exam.pp.module.exam.service.paper;
import cn.afterturn.easypoi.word.WordExportUtil; import cn.afterturn.easypoi.word.WordExportUtil;
import jakarta.annotation.Resource;
import jakarta.servlet.http.HttpServletResponse; import jakarta.servlet.http.HttpServletResponse;
import org.apache.poi.util.Units; import org.apache.poi.util.Units;
import org.apache.poi.xwpf.usermodel.*; 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.SchemeInfo;
import pc.exam.pp.module.exam.controller.admin.paper.vo.StuInfoPaper; 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.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.paper.*;
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionFileMapper; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionFileMapper;
@@ -73,6 +75,8 @@ public class EducationPaperServiceImpl implements IEducationPaperService
private ExamQuestionMapper examQuestionMapper; private ExamQuestionMapper examQuestionMapper;
@Autowired @Autowired
private ExamQuestionFileMapper sysFileMapper; private ExamQuestionFileMapper sysFileMapper;
@Resource
private MonitorMapper monitorMapper;
/** /**
* 查询试卷 * 查询试卷
* *
@@ -339,10 +343,11 @@ public class EducationPaperServiceImpl implements IEducationPaperService
EducationPaperStuDto educationPaperStuDto=new EducationPaperStuDto(); EducationPaperStuDto educationPaperStuDto=new EducationPaperStuDto();
// EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(educationPaper.getTaskId()); // EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(educationPaper.getTaskId());
// Integer counts= monitorMapper.selectCountByUserIdAndTaskId(loginUserId,educationPaper.getTaskId());
educationPaperStuDto.setPaperId(educationPaper.getPaperId()); educationPaperStuDto.setPaperId(educationPaper.getPaperId());
educationPaperStuDto.setNum(educationPaper.getNum()); educationPaperStuDto.setNum(educationPaper.getNum());
educationPaperStuDto.setTaskId(educationPaper.getTaskId()); educationPaperStuDto.setTaskId(educationPaper.getTaskId());
educationPaperStuDto.setCounts(educationPaper.getCounts()); // educationPaperStuDto.setCounts(counts);
educationPaperStuDto.setRollUp(educationPaper.getRollUp()); educationPaperStuDto.setRollUp(educationPaper.getRollUp());
educationPaperStuDto.setIsAb(educationPaper.getIsAb()); educationPaperStuDto.setIsAb(educationPaper.getIsAb());
// educationPaperStuDto.setEducationPaperParam(educationPaperParam); // educationPaperStuDto.setEducationPaperParam(educationPaperParam);

View File

@@ -629,21 +629,22 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
if ("0".equals(taskType)) { if ("0".equals(taskType)) {
for (EducationPaperTask paperTask : list) { for (EducationPaperTask paperTask : list) {
String taskId = paperTask.getTaskId(); String taskId = paperTask.getTaskId();
int count = 0; // int count = 0;
List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId()); // List<EducationPaper> educationPapers = educationPaperMapper.selectPaperListByTaskId(paperTask.getTaskId());
if (educationPapers != null && educationPapers.size() > 0) { // if (educationPapers != null && educationPapers.size() > 0) {
for (EducationPaper educationPaper : educationPapers) { //// for (EducationPaper educationPaper : educationPapers) {
try { //// try {
count += Integer.parseInt(educationPaper.getCounts()); //// count += Integer.parseInt(educationPaper.getCounts());
} catch (NumberFormatException e) { //// } catch (NumberFormatException e) {
// 可选:记录异常或忽略非法数字 //// // 可选:记录异常或忽略非法数字
System.err.println("无效的 counts 值: " + educationPaper.getCounts()); //// System.err.println("无效的 counts 值: " + educationPaper.getCounts());
} //// }
////
} //// }
} //
paperTask.setCount(String.valueOf(count)); // }
Integer counts= monitorMapper.selectCountByUserIdAndTaskId(stuId,taskId);
paperTask.setCount(counts.toString());
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId); EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
//最高成绩 //最高成绩
@@ -653,14 +654,14 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
if (StringUtils.isNotBlank(score)) { if (StringUtils.isNotBlank(score)) {
paperTask.setScore(score); paperTask.setScore(score);
} else { } else {
paperTask.setScore("0.0"); paperTask.setScore("0");
} }
} else { } else {
String score = monitorMapper.selectByStuIdAndTaskIdNew(stuId, taskId); String score = monitorMapper.selectByStuIdAndTaskIdNew(stuId, taskId);
if (StringUtils.isNotBlank(score)) { if (StringUtils.isNotBlank(score)) {
paperTask.setScore(score); paperTask.setScore(score);
} else { } else {
paperTask.setScore("0.0"); paperTask.setScore("0");
} }
} }

View File

@@ -29,6 +29,8 @@
from exam_monitor from exam_monitor
where stu_id = #{stuId} 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 ORDER BY score DESC LIMIT 1
</select> </select>
<select id="selectByStuIdAndTaskIdNew" resultType="java.lang.String"> <select id="selectByStuIdAndTaskIdNew" resultType="java.lang.String">
@@ -36,6 +38,8 @@
from exam_monitor from exam_monitor
where stu_id = #{stuId} where stu_id = #{stuId}
and task_id = #{taskId} and task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
ORDER BY create_time DESC LIMIT 1 ORDER BY create_time DESC LIMIT 1
</select> </select>
<select id="selectByStuIdAndTaskId" resultType="java.lang.String"> <select id="selectByStuIdAndTaskId" resultType="java.lang.String">
@@ -63,6 +67,14 @@
WHERE ets.tenant_id = #{loginTenantId} WHERE ets.tenant_id = #{loginTenantId}
</select> </select>
<select id="selectCountByUserIdAndTaskId" resultType="java.lang.Integer">
select sum(counts)
from exam_monitor
where stu_id =#{stuId}
and task_id = #{taskId}
and deleted = '0'
and exam_status = '0'
</select>
</mapper> </mapper>