【修改】监控管理 学生判分结束返回值
This commit is contained in:
@@ -8,7 +8,4 @@ import lombok.Data;
|
|||||||
public class StuMonitorPaperEndVo {
|
public class StuMonitorPaperEndVo {
|
||||||
private String stuId;
|
private String stuId;
|
||||||
private String paperId;
|
private String paperId;
|
||||||
private String score;
|
|
||||||
private String taskId;
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -2,7 +2,6 @@ package pc.exam.pp.module.exam.dal.mysql.paper;
|
|||||||
|
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
|
|
||||||
import org.apache.ibatis.annotations.Mapper;
|
import org.apache.ibatis.annotations.Mapper;
|
||||||
import org.apache.ibatis.annotations.Param;
|
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.mapper.BaseMapperX;
|
||||||
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
import pc.exam.pp.framework.mybatis.core.query.LambdaQueryWrapperX;
|
||||||
import pc.exam.pp.framework.tenant.core.aop.TenantIgnore;
|
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.dto.PaperIdAndNum;
|
||||||
import pc.exam.pp.module.exam.controller.admin.paper.vo.PaperPageVo;
|
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.EducationPaper;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme;
|
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperScheme;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.EducationPaperTask;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 试卷Mapper接口
|
* 试卷Mapper接口
|
||||||
@@ -178,10 +174,12 @@ public interface EducationPaperMapper extends BaseMapperX<EducationPaper>
|
|||||||
|
|
||||||
List<String> selectTaskNumByids(@Param("cannotDeleteTaskIds")List<String> cannotDeleteTaskIds);
|
List<String> selectTaskNumByids(@Param("cannotDeleteTaskIds")List<String> cannotDeleteTaskIds);
|
||||||
|
|
||||||
// //查询所有正在考试的 试卷id
|
// 查询所有正在考试的 试卷id
|
||||||
@TenantIgnore
|
@TenantIgnore
|
||||||
List<String> selectSpecilayCounts(Long loginTenantId);
|
List<String> selectSpecilayCounts(Long loginTenantId);
|
||||||
|
|
||||||
|
//查询学生的考试分数
|
||||||
|
double selctStuScoreByStuIdAndPaperId(@Param("stuId") String stuId
|
||||||
|
, @Param("paperId") String paperId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -10,6 +10,8 @@ import org.springframework.stereotype.Service;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.springframework.validation.annotation.Validated;
|
import org.springframework.validation.annotation.Validated;
|
||||||
|
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.charset.StandardCharsets;
|
||||||
import java.sql.Time;
|
import java.sql.Time;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.temporal.ChronoUnit;
|
import java.time.temporal.ChronoUnit;
|
||||||
@@ -353,57 +355,50 @@ public class MonitorServiceImpl implements MonitorService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void endStuMonitor(StuMonitorPaperEndVo stuMonitorPaperEndVo) {
|
public void endStuMonitor(StuMonitorPaperEndVo stuMonitorPaperEndVo) {
|
||||||
// String key = "userCache:" + stuMonitorPaperEndVo.getTaskId()+":" +stuMonitorPaperEndVo.getStuId();
|
EducationPaper educationPaper = educationPaperMapper.selectEducationPaperByPaperId(stuMonitorPaperEndVo.getPaperId());
|
||||||
// String keychoice = "keychoice:"+stuMonitorPaperEndVo.getTaskId()+":" + stuMonitorPaperEndVo.getStuId();
|
String taskId = educationPaper.getTaskId();
|
||||||
// StuMonitorQuVo stuMonitorQuVo = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(keychoice),StuMonitorQuVo.class);
|
String key = "userCache:" + taskId + ":" + stuMonitorPaperEndVo.getStuId();
|
||||||
//
|
double score =educationPaperMapper.selctStuScoreByStuIdAndPaperId(stuMonitorPaperEndVo.getStuId(),stuMonitorPaperEndVo.getPaperId());
|
||||||
// try {
|
MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
||||||
// String fileName = "StuMonitorQu.txt";
|
info.setRemainingTime(0L);
|
||||||
// FileWriter writer = new FileWriter(fileName);
|
EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(taskId);
|
||||||
// writer.write(JsonUtils.toJsonString(stuMonitorQuVo));
|
EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(taskId);
|
||||||
// writer.close();
|
if ("1".equals(educationPaperParam.getSaveGrades())){
|
||||||
// //上传至
|
info.setScore(String.valueOf(score));
|
||||||
// String stuId = stuMonitorPaperEndVo.getStuId(); // 学生ID
|
}else {
|
||||||
// String paperId = stuMonitorPaperEndVo.getPaperId(); // 试卷ID
|
MonitorDO monitorDO = monitorMapper.selectById(info.getMonitorId());
|
||||||
// String path = ""; // 存储路径(可选)
|
info.setScore(String.valueOf(score));
|
||||||
// // 1. 生成 JSON 内容
|
if (StringUtils.isNotBlank(monitorDO.getScore())) {
|
||||||
// String content = JsonUtils.toJsonString(stuMonitorQuVo);
|
try {
|
||||||
//
|
double oldScore = Double.parseDouble(monitorDO.getScore());
|
||||||
// // 2. 转换为 UTF-8 字节数组(关键修复!)
|
if (score > oldScore) {
|
||||||
// byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
|
info.setScore(String.valueOf(score));
|
||||||
//// String fileurl= fileService.createFile(fileName,path, bytes);
|
} else {
|
||||||
//// System.out.println(fileurl);
|
info.setScore(monitorDO.getScore()); // 保留旧成绩
|
||||||
//
|
}
|
||||||
// } catch (IOException e) {
|
} catch (NumberFormatException e) {
|
||||||
// System.out.println(e);
|
// 如果旧分数格式错误,则直接设置新分数
|
||||||
// }
|
info.setScore(String.valueOf(score));
|
||||||
//
|
}
|
||||||
// MonitorDO info = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(key),MonitorDO.class);
|
} else {
|
||||||
// EducationPaperParam educationPaperParam = educationPaperParamMapper.selectEducationPaperParamByTaskId(stuMonitorPaperEndVo.getTaskId());
|
// 如果没有旧成绩,则直接设置
|
||||||
// EducationPaperTask educationPaperTask = educationPaperTaskMapper.selectEducationPaperTaskByTaskId(stuMonitorPaperEndVo.getTaskId());
|
info.setScore(String.valueOf(score));
|
||||||
// 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()) <Integer.parseInt(stuMonitorPaperEndVo.getScore())){
|
if ("1".equals(educationPaperTask.getTaskType())){
|
||||||
// info.setScore(stuMonitorPaperEndVo.getScore());
|
info.setExamStatus("2");
|
||||||
// }
|
redisTemplate.delete(key);
|
||||||
// }
|
|
||||||
//
|
}else {
|
||||||
//
|
info.setExamStatus("0");
|
||||||
// }
|
stringRedisTemplate.opsForValue().set(key, JsonUtils.toJsonString(info));
|
||||||
// //练习下的任务 结束改为 代考 其他为结束
|
}
|
||||||
// if ("0".equals(educationPaperTask.getTaskType())){
|
|
||||||
// info.setExamStatus("0");
|
monitorMapper.updateById(info);
|
||||||
// }else {
|
|
||||||
// info.setExamStatus("2");
|
|
||||||
// }
|
|
||||||
// //todo 这些都写成方法
|
|
||||||
// redisTemplate.delete(key);
|
|
||||||
// redisTemplate.delete(keychoice);
|
|
||||||
// monitorMapper.updateById(info);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -145,6 +145,11 @@ select task_id from education_paper where paper_id=#{paperId}
|
|||||||
AND em.tenant_id = #{loginTenantId}
|
AND em.tenant_id = #{loginTenantId}
|
||||||
ORDER BY em.paper_num;
|
ORDER BY em.paper_num;
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selctStuScoreByStuIdAndPaperId" resultType="java.lang.Double">
|
||||||
|
SELECT COALESCE(SUM(score), 0.0)
|
||||||
|
FROM exam_stu_paper_score
|
||||||
|
WHERE stu_id = #{stuId} AND paper_id = #{paperId}
|
||||||
|
</select>
|
||||||
|
|
||||||
|
|
||||||
<insert id="insertEducationPaper" parameterType="EducationPaper">
|
<insert id="insertEducationPaper" parameterType="EducationPaper">
|
||||||
|
Reference in New Issue
Block a user