diff --git a/src/main/java/com/example/exam/exam/service/autoforbrower/AutoForBrowerServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoforbrower/AutoForBrowerServiceImpl.java index 0bf5327..ef67f94 100644 --- a/src/main/java/com/example/exam/exam/service/autoforbrower/AutoForBrowerServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoforbrower/AutoForBrowerServiceImpl.java @@ -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 result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst(); Optional results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst(); @@ -105,6 +108,7 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService { stuPaperScoreService.insertStuPaperScore(insertInfo); } break; + } } } } diff --git a/src/main/java/com/example/exam/exam/service/autoforfile/AutoForFileServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoforfile/AutoForFileServiceImpl.java index f0aa0cc..06d2929 100644 --- a/src/main/java/com/example/exam/exam/service/autoforfile/AutoForFileServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoforfile/AutoForFileServiceImpl.java @@ -69,49 +69,52 @@ public class AutoForFileServiceImpl implements AutoForFileService { // 需要根据题号获取试题ID ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuNumber(quNumber); String quId = examQuestion.getQuId(); - // 3、根据题号进行查询试题的相关信息 - Optional result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst(); - Optional results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst(); - EducationPaperScheme educationPaperScheme = result.get(); - EducationPaperQu educationPaperQu = results.get(); - String quScore = educationPaperScheme.getQuScores(); - String judgementStr = "

-----------------------------------------------------------

"; - judgementStr += "

试题序号:" + educationPaperQu.getSort() + "

"; - judgementStr += "

试题编号:" + examQuestion.getQuNum() + "

"; - judgementStr += "

试题分数:" + Double.parseDouble(quScore) + "

"; - judgementStr += "

试题名称:" + name + "

"; - 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 += "

试题得分:" + cpojo.getScore() + "

"; - // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 - // 通过 quId,stuId,paperId 查询 - 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 result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst(); + Optional results = educationPaperQus.stream().filter(quLists -> quLists.getQuId().equals(quId)).findFirst(); + EducationPaperScheme educationPaperScheme = result.get(); + EducationPaperQu educationPaperQu = results.get(); + String quScore = educationPaperScheme.getQuScores(); + String judgementStr = "

-----------------------------------------------------------

"; + judgementStr += "

试题序号:" + educationPaperQu.getSort() + "

"; + judgementStr += "

试题编号:" + examQuestion.getQuNum() + "

"; + judgementStr += "

试题分数:" + Double.parseDouble(quScore) + "

"; + judgementStr += "

试题名称:" + name + "

"; + 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 += "

试题得分:" + cpojo.getScore() + "

"; + // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 + // 通过 quId,stuId,paperId 查询 + 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; } } } diff --git a/src/main/java/com/example/exam/exam/service/autoformysql/AutoForMysqlServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoformysql/AutoForMysqlServiceImpl.java index a3436bd..1330756 100644 --- a/src/main/java/com/example/exam/exam/service/autoformysql/AutoForMysqlServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoformysql/AutoForMysqlServiceImpl.java @@ -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 result = educationPaperSchemeList.stream().filter(quLists -> quLists.getSpName().equals(name)).findFirst(); Optional 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 = "

-----------------------------------------------------------

"; judgementStr += "

试题序号:" + educationPaperQu.getSort() + "

"; judgementStr += "

试题编号:" + examQuestion.getQuNum() + "

"; @@ -106,7 +112,10 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService { stuPaperScoreService.insertStuPaperScore(insertInfo); } System.out.println(judgementStr); + } break; + } + } } }