【修改】 监控管理中学生分数不一致的问题

This commit is contained in:
dlaren
2025-08-19 15:20:40 +08:00
parent 59ae05442c
commit b25e354303
17 changed files with 235 additions and 203 deletions

View File

@@ -71,7 +71,7 @@ public class FileController {
public CommonResult<String> uploadStuFile(StuFileUploadReqVO uploadReqVO) throws Exception {
MultipartFile file = uploadReqVO.getFile();
String path = uploadReqVO.getPath();
return success(fileService.createStuFile(uploadReqVO.getStuId(), uploadReqVO.getPaperId(), file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
return success(fileService.createStuFile(uploadReqVO.getStuId(), uploadReqVO.getPaperId(), uploadReqVO.getTemporaryId(), file.getOriginalFilename(), path, IoUtil.readBytes(file.getInputStream())));
}
@GetMapping("/{configId}/get/**")

View File

@@ -22,4 +22,7 @@ public class StuFileUploadReqVO {
@Schema(description = "试卷ID")
private String paperId;
@Schema(description = "临时ID每次做题都会变")
private String temporaryId;
}

View File

@@ -36,10 +36,11 @@ public interface FileService {
*
* @param name 文件名称
* @param path 文件路径
* @param temporaryId 临时ID
* @param content 文件内容
* @return 文件路径
*/
String createStuFile(Long stuId, String paperId, String name, String path, byte[] content);
String createStuFile(Long stuId, String paperId, String temporaryId, String name, String path, byte[] content);
/**
* 创建文件

View File

@@ -78,7 +78,7 @@ public class FileServiceImpl implements FileService {
@Override
@SneakyThrows
public String createStuFile(Long stuId, String paperId, String name, String path, byte[] content) {
public String createStuFile(Long stuId, String paperId, String temporaryId, String name, String path, byte[] content) {
// 计算默认的 path 名
String type = FileTypeUtils.getMineType(content, name);
if (StrUtil.isEmpty(path)) {
@@ -88,7 +88,6 @@ public class FileServiceImpl implements FileService {
if (StrUtil.isEmpty(name)) {
name = path;
}
// 上传到文件存储器
FileClient client = fileConfigService.getMasterFileClient();
Assert.notNull(client, "客户端(master) 不能为空");
@@ -105,19 +104,22 @@ public class FileServiceImpl implements FileService {
fileMapper.insert(file);
// 需要更新学生表
// 1、先查询学生试卷 是否已经存在数据
List<StuPaperFileDO> stuPaperFileDOList = stuPaperFileService.findByStuIDAndPaperId(stuId, paperId);
List<StuPaperFileDO> stuPaperFileDOList = stuPaperFileService.findByStuIDAndPaperId(stuId, paperId, temporaryId);
StuPaperFileDO stuPaperFileDO = null;
// 如果查询出来数据得话,需要进行替换
for (StuPaperFileDO fileUrl : stuPaperFileDOList) {
if (fileUrl.getType() == 0) {
stuPaperFileDO = fileUrl;
}
}
// 如果没有查询到,需要新增
if (stuPaperFileDO == null) {
// 说明没有上传过,需要新增进去
StuPaperFileDO stuPaperFile = new StuPaperFileDO();
stuPaperFile.setPaperId(paperId);
stuPaperFile.setStuId(stuId);
stuPaperFile.setUrl(url);
stuPaperFile.setTemporaryId(temporaryId);
stuPaperFile.setType(0);
stuPaperFileService.insertStuPaperFile(stuPaperFile);
} else {