【修改】试卷任务,【新增】试题交互,定时试题交互
This commit is contained in:
@@ -7,6 +7,7 @@ import jakarta.annotation.Resource;
|
||||
import lombok.Data;
|
||||
import org.apache.commons.compress.archivers.zip.ZipArchiveEntry;
|
||||
import org.apache.commons.compress.archivers.zip.ZipFile;
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
import org.springframework.stereotype.Service;
|
||||
import org.springframework.web.multipart.MultipartFile;
|
||||
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||
@@ -26,6 +27,7 @@ import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
|
||||
import pc.exam.pp.module.judgement.service.c_programming.JudgementService;
|
||||
import pc.exam.pp.module.judgement.service.choice.JudgementChoiceService;
|
||||
import pc.exam.pp.module.judgement.service.wps_word.JudgementWpsWordService;
|
||||
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
||||
import pc.exam.pp.module.judgement.utils.JudgementCUtils;
|
||||
import pc.exam.pp.module.judgement.utils.multipartFile.CustomMultipartFile;
|
||||
import pc.exam.pp.module.judgement.utils.zipfile.FolderZipper;
|
||||
@@ -66,7 +68,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
StuPaperScoreMapper stuPaperScoreMapper;
|
||||
@Resource
|
||||
JudgementChoiceService judgementChoiceService;
|
||||
|
||||
@Autowired
|
||||
private EndStuMonitorUtils endStuMonitorUtils;
|
||||
@Override
|
||||
public String downloadStudentFile(String fileUrl, String filePath) {
|
||||
try {
|
||||
@@ -157,6 +160,8 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
*/
|
||||
@Override
|
||||
public CommonResult<Double> judgementScore(Long stuId, String paperId) throws Exception {
|
||||
//监控管理 生成选择题文件路径
|
||||
endStuMonitorUtils.endStuMonitor(String.valueOf(stuId), paperId);
|
||||
// 获取平台文件参数
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
double score = 0;
|
||||
@@ -281,8 +286,6 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
System.out.println(judgement+"mysql得分");
|
||||
break;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -304,6 +307,9 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
||||
stuPaperScoreDO.setPaperId(paperId);
|
||||
stuPaperScoreDO.setAllScore(new BigDecimal(score));
|
||||
stuPaperScoreService.insertStuPaperScore(stuPaperScoreDO);
|
||||
|
||||
//更新学生分数
|
||||
endStuMonitorUtils.endStuMonitor(String.valueOf(stuId),paperId,score);
|
||||
// end、删除文件
|
||||
zip_file.delete();
|
||||
folder.delete();
|
||||
|
@@ -17,8 +17,10 @@ import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperParamMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperTaskMapper;
|
||||
import pc.exam.pp.module.exam.dal.mysql.student.StuPaperFileMapper;
|
||||
import pc.exam.pp.module.exam.utils.uuid.IdUtils;
|
||||
import pc.exam.pp.module.infra.service.file.FileService;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileWriter;
|
||||
import java.io.IOException;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -49,12 +51,12 @@ public class EndStuMonitorUtils {
|
||||
String taskId = educationPaper.getTaskId();
|
||||
|
||||
|
||||
String key = "userCache:" + taskId + ":" + stuId;
|
||||
String keychoice = "keychoice:" + taskId + ":" + stuId;
|
||||
StuMonitorQuVo stuMonitorQuVo = JsonUtils.parseObject(stringRedisTemplate.opsForValue().get(keychoice), StuMonitorQuVo.class);
|
||||
String fileurl = null;
|
||||
String fileName = IdUtils.simpleUUID()+".txt";
|
||||
try {
|
||||
String fileName = "StuMonitorQu.txt";
|
||||
|
||||
FileWriter writer = new FileWriter(fileName);
|
||||
writer.write(JsonUtils.toJsonString(stuMonitorQuVo));
|
||||
writer.close();
|
||||
@@ -65,7 +67,7 @@ public class EndStuMonitorUtils {
|
||||
// 1. 生成 JSON 内容
|
||||
String content = JsonUtils.toJsonString(stuMonitorQuVo);
|
||||
|
||||
// 2. 转换为 UTF-8 字节数组(关键修复!)
|
||||
// 2. 转换为 UTF-8 字节数组
|
||||
byte[] bytes = content.getBytes(StandardCharsets.UTF_8);
|
||||
fileurl = fileService.createFile(fileName, path, bytes);
|
||||
System.out.println(fileurl);
|
||||
@@ -94,6 +96,15 @@ public class EndStuMonitorUtils {
|
||||
|
||||
} catch (IOException e) {
|
||||
System.out.println(e);
|
||||
} finally {
|
||||
// 删除临时文件
|
||||
File file = new File(fileName);
|
||||
if (file.exists()) {
|
||||
boolean deleted = file.delete();
|
||||
if (!deleted) {
|
||||
System.out.println("临时文件删除失败: " + fileName);
|
||||
}
|
||||
}
|
||||
}
|
||||
return fileurl;
|
||||
|
||||
|
Reference in New Issue
Block a user