From 8430fde91d5fab41fb26e0d5392339988489a7e5 Mon Sep 17 00:00:00 2001 From: huababa1 <2037205722@qq.com> Date: Fri, 1 Aug 2025 17:28:53 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91mysql?= =?UTF-8?q?=E3=80=81=E6=96=87=E4=BB=B6=E5=A4=84=E7=90=86=E3=80=81=E6=B5=8F?= =?UTF-8?q?=E8=A7=88=E5=99=A8=E5=88=A4=E5=88=86=E8=B7=AF=E5=BE=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../AutoForBrowerServiceImpl.java | 4 + .../autoforfile/AutoForFileServiceImpl.java | 87 ++++++++++--------- .../autoformysql/AutoForMysqlServiceImpl.java | 9 ++ 3 files changed, 58 insertions(+), 42 deletions(-) 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; + } + } } }