【修改】mysql、文件处理、浏览器判分路径

This commit is contained in:
huababa1
2025-08-01 17:28:53 +08:00
parent fe00f061b5
commit 8430fde91d
3 changed files with 58 additions and 42 deletions

View File

@@ -62,6 +62,9 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService {
// 需要根据题号获取试题ID
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuNumber(quNumber);
String quId = examQuestion.getQuId();
File[] wjFiles = stFile.listFiles();
for (File wjFile : wjFiles) {
// 3、根据题号进行查询试题的相关信息
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
@@ -105,6 +108,7 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService {
stuPaperScoreService.insertStuPaperScore(insertInfo);
}
break;
}
}
}
}

View File

@@ -69,49 +69,52 @@ public class AutoForFileServiceImpl implements AutoForFileService {
// 需要根据题号获取试题ID
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuNumber(quNumber);
String quId = examQuestion.getQuId();
// 3、根据题号进行查询试题的相关信息
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
EducationPaperScheme educationPaperScheme = result.get();
EducationPaperQu educationPaperQu = results.get();
String quScore = educationPaperScheme.getQuScores();
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称" + name + "</p>";
SourceAndText cpojo = fileServerice.Judgement(Double.parseDouble(quScore), stFile, examQuestion, judgementStr);
score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = cpojo.getText();
judgementStr += "<p>试题得分:" + cpojo.getScore() + "</p>";
// 4、需要更新学生试题得分首先需要查询试题的数据库是否保存信息
// 通过 quIdstuIdpaperId 查询
StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId);
if (stuPaperScoreDO != null) {
// 说明已经是做过该题,需要更新数据
stuPaperScoreDO.setScore(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
stuPaperScoreDO.setContent(judgementStr);
stuPaperScoreDO.setSort(educationPaperQu.getSort());
stuPaperScoreDO.setSubjectName(name);
stuPaperScoreDO.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2);
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
stuPaperScoreDO.setTenantId(systemTenant.getId());
stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
} else {
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());
insertInfo.setQuId(quId);
insertInfo.setScore(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
insertInfo.setContent(judgementStr);
insertInfo.setSort(educationPaperQu.getSort());
insertInfo.setSubjectName(name);
insertInfo.setTrueScore(new BigDecimal(quScore));
insertInfo.setTenantId(systemTenant.getId());
insertInfo.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2);
stuPaperScoreService.insertStuPaperScore(insertInfo);
File[] wjFiles = stFile.listFiles();
for (File wjFile : wjFiles) {
// 3、根据题号进行查询试题的相关信息
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
EducationPaperScheme educationPaperScheme = result.get();
EducationPaperQu educationPaperQu = results.get();
String quScore = educationPaperScheme.getQuScores();
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号" + examQuestion.getQuNum() + "</p>";
judgementStr += "<p>试题分数:" + Double.parseDouble(quScore) + "</p>";
judgementStr += "<p>试题名称:" + name + "</p>";
SourceAndText cpojo = fileServerice.Judgement(Double.parseDouble(quScore), stFile, examQuestion, judgementStr);
score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
judgementStr = cpojo.getText();
judgementStr += "<p>试题得分:" + cpojo.getScore() + "</p>";
// 4、需要更新学生试题得分首先需要查询试题的数据库是否保存信息
// 通过 quIdstuIdpaperId 查询
StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId);
if (stuPaperScoreDO != null) {
// 说明已经是做过该题,需要更新数据
stuPaperScoreDO.setScore(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
stuPaperScoreDO.setContent(judgementStr);
stuPaperScoreDO.setSort(educationPaperQu.getSort());
stuPaperScoreDO.setSubjectName(name);
stuPaperScoreDO.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2);
stuPaperScoreDO.setTrueScore(new BigDecimal(quScore));
stuPaperScoreDO.setTenantId(systemTenant.getId());
stuPaperScoreService.updateStuPaperScore(stuPaperScoreDO);
} else {
StuPaperScoreDO insertInfo = new StuPaperScoreDO();
insertInfo.setStuId(stuInfoVo.getStuId());
insertInfo.setPaperId(stuInfoVo.getPaperId());
insertInfo.setQuId(quId);
insertInfo.setScore(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP));
insertInfo.setContent(judgementStr);
insertInfo.setSort(educationPaperQu.getSort());
insertInfo.setSubjectName(name);
insertInfo.setTrueScore(new BigDecimal(quScore));
insertInfo.setTenantId(systemTenant.getId());
insertInfo.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2);
stuPaperScoreService.insertStuPaperScore(insertInfo);
}
break;
}
break;
}
}
}

View File

@@ -63,12 +63,18 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService {
// 需要根据题号获取试题ID
ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuNumber(quNumber);
String quId = examQuestion.getQuId();
File[] wjFiles = stFile.listFiles();
for (File wjFile : wjFiles) {
// 3、根据题号进行查询试题的相关信息
Optional<EducationPaperScheme> result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst();
Optional<EducationPaperQu> results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst();
EducationPaperScheme educationPaperScheme = result.get();
EducationPaperQu educationPaperQu = results.get();
String quScore = educationPaperScheme.getQuScores();
if (wjFile.getName().contains(".sql")) {
String judgementStr = "<p>-----------------------------------------------------------</p>";
judgementStr += "<p>试题序号:" + educationPaperQu.getSort() + "</p>";
judgementStr += "<p>试题编号:" + examQuestion.getQuNum() + "</p>";
@@ -106,7 +112,10 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService {
stuPaperScoreService.insertStuPaperScore(insertInfo);
}
System.out.println(judgementStr);
}
break;
}
}
}
}