From df3245a2dddf182a0ff1533a00f00c1fe2240f76 Mon Sep 17 00:00:00 2001 From: dlaren Date: Thu, 14 Aug 2025 23:13:52 +0800 Subject: [PATCH] =?UTF-8?q?=E3=80=90=E6=96=B0=E5=A2=9E=E3=80=91=20?= =?UTF-8?q?=E4=B8=B4=E6=97=B6ID=EF=BC=8C=E9=98=B2=E6=AD=A2=E8=80=83?= =?UTF-8?q?=E8=AF=95=E6=95=B0=E6=8D=AE=E7=BB=A7=E7=BB=AD=E4=BA=92=E7=9B=B8?= =?UTF-8?q?=E5=B9=B2=E6=89=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- pom.xml | 446 +++++++++--------- .../controller/ExamAppCheckController.java | 24 - .../exam/controller/auto/AutoController.java | 2 +- .../exam/controller/auto/vo/StuInfoVo.java | 3 + .../exam/exam/dal/StuPaperScoreDO.java | 4 + .../exam/exam/mapper/StuPaperScoreMapper.java | 2 +- .../appcheck/ExamAppCheckServiceImpl.java | 3 +- .../AutoForWinEdgeSettingServiceImpl.java | 53 +-- .../AutoForBrowerServiceImpl.java | 51 +- .../service/autoforc/AutoForCServiceImpl.java | 44 +- .../AutoForChoiceServiceImpl.java | 117 ++--- .../autoforfile/AutoForFileServiceImpl.java | 63 +-- .../autoformysql/AutoForMysqlServiceImpl.java | 79 ++-- .../autoforps/AutoForPsServiceImpl.java | 43 +- .../exam/exam/service/ps/PsServiceImpl.java | 21 +- .../stupaperscore/StuPaperScoreService.java | 2 +- .../StuPaperScoreServiceImpl.java | 4 +- .../excel/JudgementForExcelServiceImpl.java | 41 +- .../pptx/JudgementForPptxServiceImpl.java | 41 +- .../wpsword/docx4j/endNote/EndNoteing.java | 4 +- .../word/JudgementForWordServiceImpl.java | 41 +- .../stupaperscore/StuPaperScoreMapper.xml | 18 +- 22 files changed, 477 insertions(+), 629 deletions(-) delete mode 100644 src/main/java/com/example/exam/exam/controller/ExamAppCheckController.java diff --git a/pom.xml b/pom.xml index 9738f8c..2473790 100644 --- a/pom.xml +++ b/pom.xml @@ -1,236 +1,236 @@ + xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" + xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> - 4.0.0 + 4.0.0 - - org.springframework.boot - spring-boot-starter-parent - 3.5.3 - - + + org.springframework.boot + spring-boot-starter-parent + 3.5.3 + + - com.example.exam - exam - 0.0.1-SNAPSHOT - stu - Student end grading + com.example.exam + exam + 0.0.1-SNAPSHOT + stu + Student end grading - - 17 - 1.18.30 - + + 17 + 1.18.30 + - - - org.springframework.boot - spring-boot-starter-data-jpa - - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-websocket - - - org.springframework.boot - spring-boot-devtools - runtime - true - - - com.h2database - h2 - runtime - - - com.mysql - mysql-connector-j - runtime - - - org.projectlombok - lombok - ${lombok.version} - provided - - - org.springframework.boot - spring-boot-starter-test - test - - - org.mybatis.spring.boot - mybatis-spring-boot-starter - 3.0.3 - - - com.baomidou - mybatis-plus-boot-starter - 3.5.5 - - - com.fasterxml.jackson.core - jackson-core - 2.18.2 - provided - - - org.springframework.boot - spring-boot-starter-security - - - - org.apache.xmlbeans - xmlbeans - 5.2.0 - - - net.sf.saxon - Saxon-HE - 12.5 - - - org.apache.commons - commons-compress - 1.26.0 - - - org.apache.commons - commons-lang3 - 3.13.0 - - - com.google.code.gson - gson - 2.10 - - - org.apache.poi - poi - 5.2.3 - + + + org.springframework.boot + spring-boot-starter-data-jpa + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-websocket + + + org.springframework.boot + spring-boot-devtools + runtime + true + + + com.h2database + h2 + runtime + + + com.mysql + mysql-connector-j + runtime + + + org.projectlombok + lombok + ${lombok.version} + provided + + + org.springframework.boot + spring-boot-starter-test + test + + + org.mybatis.spring.boot + mybatis-spring-boot-starter + 3.0.3 + + + com.baomidou + mybatis-plus-boot-starter + 3.5.5 + + + com.fasterxml.jackson.core + jackson-core + 2.18.2 + provided + + + org.springframework.boot + spring-boot-starter-security + + + + org.apache.xmlbeans + xmlbeans + 5.2.0 + + + net.sf.saxon + Saxon-HE + 12.5 + + + org.apache.commons + commons-compress + 1.26.0 + + + org.apache.commons + commons-lang3 + 3.13.0 + + + com.google.code.gson + gson + 2.10 + + + org.apache.poi + poi + 5.2.3 + - - org.apache.poi - poi-ooxml - 5.2.3 - + + org.apache.poi + poi-ooxml + 5.2.3 + - - org.apache.xmlbeans - xmlbeans - 5.2.0 - - - org.apache.poi - poi-ooxml-lite - 5.2.3 - - - org.json - json - 20231013 - - - cn.afterturn - easypoi-base - 4.4.0 - - - org.apache.poi - poi - - - org.apache.poi - poi-ooxml - - - org.apache.poi - ooxml-schemas - - - - - org.docx4j - docx4j-core - 11.5.4 - - - org.docx4j - docx4j-JAXB-MOXy - 11.5.4 - - - - org.docx4j - docx4j-JAXB-Internal - 8.3.9 - - - org.docx4j - docx4j-JAXB-ReferenceImpl - 11.4.9 - + + org.apache.xmlbeans + xmlbeans + 5.2.0 + + + org.apache.poi + poi-ooxml-lite + 5.2.3 + + + org.json + json + 20231013 + + + cn.afterturn + easypoi-base + 4.4.0 + + + org.apache.poi + poi + + + org.apache.poi + poi-ooxml + + + org.apache.poi + ooxml-schemas + + + + + org.docx4j + docx4j-core + 11.5.4 + + + org.docx4j + docx4j-JAXB-MOXy + 11.5.4 + + + + org.docx4j + docx4j-JAXB-Internal + 8.3.9 + + + org.docx4j + docx4j-JAXB-ReferenceImpl + 11.4.9 + - + - - - ${project.artifactId} - - - org.springframework.boot - spring-boot-maven-plugin - 3.5.3 - - - - - com.example.exam.exam.StuApplication - - - - - repackage - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + + + ${project.artifactId} + + + org.springframework.boot + spring-boot-maven-plugin + 3.5.3 + + + + + com.example.exam.exam.StuApplication + + + + + repackage + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/main/java/com/example/exam/exam/controller/ExamAppCheckController.java b/src/main/java/com/example/exam/exam/controller/ExamAppCheckController.java deleted file mode 100644 index b1d8db5..0000000 --- a/src/main/java/com/example/exam/exam/controller/ExamAppCheckController.java +++ /dev/null @@ -1,24 +0,0 @@ -package com.example.exam.exam.controller; - -import com.example.exam.exam.dal.ExamAppCheck; -import com.example.exam.exam.service.appcheck.ExamAppCheckService; -import com.example.exam.exam.utils.Result; -import jakarta.annotation.Resource; -import org.springframework.web.bind.annotation.GetMapping; -import org.springframework.web.bind.annotation.RequestMapping; -import org.springframework.web.bind.annotation.RestController; - -import java.util.List; - -@RestController -@RequestMapping("/exam/app") -public class ExamAppCheckController { - @Resource - ExamAppCheckService examAppCheckService; - - @GetMapping("/getAppCheck") - public Result getAppCheckList(){ - // 使用传入的IP,进行ping,查看是否存在连接,并返回信号的强度 - return Result.success(examAppCheckService.getAppList()); - } -} diff --git a/src/main/java/com/example/exam/exam/controller/auto/AutoController.java b/src/main/java/com/example/exam/exam/controller/auto/AutoController.java index 29de78c..6d9b55a 100644 --- a/src/main/java/com/example/exam/exam/controller/auto/AutoController.java +++ b/src/main/java/com/example/exam/exam/controller/auto/AutoController.java @@ -60,7 +60,7 @@ public class AutoController { @GetMapping("/getStuSource") public Result getStuSource(StuInfoVo stuInfoVo){ BigDecimal source = new BigDecimal(0); - List stuPaperScoreDOList = stuPaperScoreService.findByStuIDAndPaperId(stuInfoVo.getStuId(), stuInfoVo.getPaperId()); + List stuPaperScoreDOList = stuPaperScoreService.findByStuIDAndPaperId(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), stuInfoVo.getTemporaryId()); for (StuPaperScoreDO stuPaperScoreDO : stuPaperScoreDOList){ source = source.add(stuPaperScoreDO.getScore()); } diff --git a/src/main/java/com/example/exam/exam/controller/auto/vo/StuInfoVo.java b/src/main/java/com/example/exam/exam/controller/auto/vo/StuInfoVo.java index 38adfd4..35773c9 100644 --- a/src/main/java/com/example/exam/exam/controller/auto/vo/StuInfoVo.java +++ b/src/main/java/com/example/exam/exam/controller/auto/vo/StuInfoVo.java @@ -31,4 +31,7 @@ public class StuInfoVo { // 学校名称 private String schoolName; + + // 随机ID + private String temporaryId; } diff --git a/src/main/java/com/example/exam/exam/dal/StuPaperScoreDO.java b/src/main/java/com/example/exam/exam/dal/StuPaperScoreDO.java index 9fe03f6..3de4208 100644 --- a/src/main/java/com/example/exam/exam/dal/StuPaperScoreDO.java +++ b/src/main/java/com/example/exam/exam/dal/StuPaperScoreDO.java @@ -36,6 +36,10 @@ public class StuPaperScoreDO{ * 试题ID */ private String quId; + /** + * 临时ID,每次做题都会变 + */ + private String temporaryId; /** * 得分 */ diff --git a/src/main/java/com/example/exam/exam/mapper/StuPaperScoreMapper.java b/src/main/java/com/example/exam/exam/mapper/StuPaperScoreMapper.java index 61fe9d6..c1bb12b 100644 --- a/src/main/java/com/example/exam/exam/mapper/StuPaperScoreMapper.java +++ b/src/main/java/com/example/exam/exam/mapper/StuPaperScoreMapper.java @@ -15,7 +15,7 @@ import java.util.List; @Mapper public interface StuPaperScoreMapper extends BaseMapper { - List findByStuIdAndPaperId(@Param("stuId") Long stuId, @Param("paperId") String paperId); + List findByStuIdAndPaperId(@Param("stuId") Long stuId, @Param("paperId") String paperId, @Param("temporaryId") String temporaryId); // 通过学生ID,试卷ID ,试题ID,查询数据 StuPaperScoreDO findByStuIdAndPaperIdAndQuestionId(@Param("stuId") Long stuId, @Param("paperId") String paperId, @Param("quId") String questionId); diff --git a/src/main/java/com/example/exam/exam/service/appcheck/ExamAppCheckServiceImpl.java b/src/main/java/com/example/exam/exam/service/appcheck/ExamAppCheckServiceImpl.java index 13ede89..032ad85 100644 --- a/src/main/java/com/example/exam/exam/service/appcheck/ExamAppCheckServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/appcheck/ExamAppCheckServiceImpl.java @@ -19,7 +19,6 @@ public class ExamAppCheckServiceImpl implements ExamAppCheckService { @Override public ExamAppCheck getAppList() { - ExamAppCheck appList = examAppCheckMapper.selectById("1"); - return appList; + return examAppCheckMapper.selectById("1"); } } diff --git a/src/main/java/com/example/exam/exam/service/autoForWinEdgeSetting/AutoForWinEdgeSettingServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoForWinEdgeSetting/AutoForWinEdgeSettingServiceImpl.java index 7121e4e..0dcd9d9 100644 --- a/src/main/java/com/example/exam/exam/service/autoForWinEdgeSetting/AutoForWinEdgeSettingServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoForWinEdgeSetting/AutoForWinEdgeSettingServiceImpl.java @@ -40,8 +40,10 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe SystemTenantService systemTenantService; @Autowired private EducationPaperMapper educationPaperMapper; + /** * 自动判题选择题 + * * @param stuInfoVo 学生考试信息 * @return 是否通过 */ @@ -54,13 +56,13 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe String edgeAnswerValue = stuInfoVo.getEdgeAnswerValues(); // 保存ID路径 String filePath = stuInfoVo.getFilePath(); - File file = new File(filePath + "/"+ quId +"@EdgeDummy.json"); + File file = new File(filePath + "/" + quId + "@EdgeDummy.json"); if (!file.exists()) { - LogFileUtils.createFile(filePath + "/"+ quId +"@EdgeDummy.json"); + LogFileUtils.createFile(filePath + "/" + quId + "@EdgeDummy.json"); } Map map = new HashMap<>(); map.put(edgeAnswerKey, edgeAnswerValue); - return writeMapToJson(map, filePath + "/"+ quId +"@EdgeDummy.json"); + return writeMapToJson(map, filePath + "/" + quId + "@EdgeDummy.json"); } @Override @@ -105,7 +107,7 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe } } // 查询哪些文件已经进行获取到学生作答文件了 - for (String str: trueFileQuid) { + for (String str : trueFileQuid) { // 查询到学生文件 Optional fileResult = resultFile.stream().filter(resultFiles -> resultFiles.getName().contains(str)).findFirst(); if (fileResult.isPresent()) { @@ -174,33 +176,20 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe } } judgementStr += "

试题得分: " + oneScore + "

"; - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(new BigDecimal(oneScore)); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName("windows网络设置"); - int isTrue = oneScore == 0 ? 1 : oneScore == Double.parseDouble(quScore) ? 0 : 2; - stuPaperScoreDO.setIsTrue(isTrue); - 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(oneScore)); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName("windows网络设置"); - int isTrue = oneScore == 0 ? 1 : oneScore == Double.parseDouble(quScore) ? 0 : 2; - insertInfo.setIsTrue(isTrue); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setTrueScore(new BigDecimal(quScore)); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(new BigDecimal(oneScore)); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName("windows网络设置"); + int isTrue = oneScore == 0 ? 1 : oneScore == Double.parseDouble(quScore) ? 0 : 2; + insertInfo.setIsTrue(isTrue); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setTrueScore(new BigDecimal(quScore)); + stuPaperScoreService.insertStuPaperScore(insertInfo); if (fileInputStream != null) { try { fileInputStream.close(); @@ -215,7 +204,7 @@ public class AutoForWinEdgeSettingServiceImpl implements AutoForWinEdgeSettingSe } } // 没有作答的题目直接0分 - for (String str: noFileQuid) { + for (String str : noFileQuid) { String quId = str; List educationPaperQus = educationPaperQuMapper.selectPaperQuListByPaperId(stuInfoVo.getPaperId()); Optional resultss = educationPaperQus.stream().filter(entry -> entry.getQuId().equals(quId)) 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 ef67f94..1fa7170 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 @@ -34,8 +34,10 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService { StuPaperScoreService stuPaperScoreService; @Resource SystemTenantService systemTenantService; + /** * 自动判题文件处理 + * * @param stuInfoVo 学生考试信息 * @return 是否通过 */ @@ -65,35 +67,22 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService { 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 = judgementBrowerService.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 { + // 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 = judgementBrowerService.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、需要更新学生试题得分 StuPaperScoreDO insertInfo = new StuPaperScoreDO(); insertInfo.setStuId(stuInfoVo.getStuId()); insertInfo.setPaperId(stuInfoVo.getPaperId()); @@ -104,10 +93,10 @@ public class AutoForBrowerServiceImpl implements AutoForBrowerService { insertInfo.setSubjectName(name); insertInfo.setTrueScore(new BigDecimal(quScore)); insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); 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/autoforc/AutoForCServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoforc/AutoForCServiceImpl.java index d9f6dcd..e93a721 100644 --- a/src/main/java/com/example/exam/exam/service/autoforc/AutoForCServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoforc/AutoForCServiceImpl.java @@ -32,8 +32,10 @@ public class AutoForCServiceImpl implements AutoForCService { StuPaperScoreService stuPaperScoreService; @Resource SystemTenantService systemTenantService; + /** * 自动判题C语言 + * * @param stuInfoVo 学生考试信息 * @return 是否通过 */ @@ -56,7 +58,7 @@ public class AutoForCServiceImpl implements AutoForCService { File[] txFileList = txFile.listFiles(); for (File stFile : txFileList) { // 获取试题编号和试题ID - String quNumber = stFile.getName(); + String quNumber = stFile.getName(); // 需要根据题号获取试题ID ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuNumber(quNumber); String quId = examQuestion.getQuId(); @@ -81,33 +83,21 @@ public class AutoForCServiceImpl implements AutoForCService { BigDecimal dangSource = new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP); judgementStr += "

试题得分:" + dangSource + "

"; // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 - // 通过 quId,stuId,paperId 查询 - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); score = score.add(new BigDecimal(cpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP)); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(dangSource); - 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(dangSource); - 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); - } + // 直接进行新增,不需要进行更新 + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(dangSource); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName(name); + insertInfo.setTrueScore(new BigDecimal(quScore)); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); break; } } diff --git a/src/main/java/com/example/exam/exam/service/autoforchoice/AutoForChoiceServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoforchoice/AutoForChoiceServiceImpl.java index 0de6f75..1989b73 100644 --- a/src/main/java/com/example/exam/exam/service/autoforchoice/AutoForChoiceServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoforchoice/AutoForChoiceServiceImpl.java @@ -38,8 +38,10 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService { SystemTenantService systemTenantService; @Autowired private EducationPaperMapper educationPaperMapper; + /** * 自动判题选择题 + * * @param stuInfoVo 学生考试信息 * @return 是否通过 */ @@ -138,31 +140,19 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService { judgementStr += "

得分:0

"; isRight = false; } - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(isRight ? new BigDecimal(quScore) : new BigDecimal(0)); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName("选择题"); - stuPaperScoreDO.setIsTrue(isRight ? 0 : 1); - 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(isRight ? new BigDecimal(quScore) : new BigDecimal(0)); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName("选择题"); - insertInfo.setIsTrue(isRight ? 0 : 1); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setTrueScore(new BigDecimal(quScore)); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(isRight ? new BigDecimal(quScore) : new BigDecimal(0)); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName("选择题"); + insertInfo.setIsTrue(isRight ? 0 : 1); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setTrueScore(new BigDecimal(quScore)); + stuPaperScoreService.insertStuPaperScore(insertInfo); } else { // 根据ID查询试题 ExamQuestion examQuestion = examQuestionService.selectExamQuestionByQuId(quId); @@ -182,31 +172,19 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService { judgementStr += "

学生答案: 未作答

"; judgementStr += "

正确答案:" + trueAbswerSort + "

"; judgementStr += "

得分:0

"; - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(new BigDecimal(0)); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName("选择题"); - stuPaperScoreDO.setIsTrue(1); - 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(0)); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName("选择题"); - insertInfo.setIsTrue(1); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setTrueScore(new BigDecimal(quScore)); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(new BigDecimal(0)); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName("选择题"); + insertInfo.setIsTrue(1); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setTrueScore(new BigDecimal(quScore)); + stuPaperScoreService.insertStuPaperScore(insertInfo); } } if (fileInputStream != null) { @@ -244,31 +222,19 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService { judgementStr += "

学生答案: 未作答

"; judgementStr += "

正确答案:" + trueAbswerSort + "

"; judgementStr += "

得分:0

"; - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(new BigDecimal(0)); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName("选择题"); - stuPaperScoreDO.setIsTrue(1); - 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(0)); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName("选择题"); - insertInfo.setIsTrue(1); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setTrueScore(new BigDecimal(quScore)); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(new BigDecimal(0)); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName("选择题"); + insertInfo.setIsTrue(1); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setTrueScore(new BigDecimal(quScore)); + stuPaperScoreService.insertStuPaperScore(insertInfo); } } return score; @@ -309,7 +275,6 @@ public class AutoForChoiceServiceImpl implements AutoForChoiceService { } - public static String convertToLetter(int number) { // 判断是否在 1 到 26 的范围内 if (number >= 1 && number <= 26) { 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 06d2929..e720176 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 @@ -40,8 +40,10 @@ public class AutoForFileServiceImpl implements AutoForFileService { StuPaperScoreService stuPaperScoreService; @Resource SystemTenantService systemTenantService; + /** * 自动判题文件处理 + * * @param stuInfoVo 学生考试信息 * @return 是否通过 */ @@ -77,43 +79,30 @@ public class AutoForFileServiceImpl implements AutoForFileService { 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; + 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、需要更新学生试题得分 + 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.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); + 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 1330756..33c1597 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 @@ -34,8 +34,10 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService { StuPaperScoreService stuPaperScoreService; @Resource SystemTenantService systemTenantService; + /** * 自动判题C语言 + * * @param stuInfoVo 学生考试信息 * @return 是否通过 */ @@ -67,53 +69,40 @@ public class AutoForMysqlServiceImpl implements AutoForMysqlService { 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")) { + // 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() + "

"; - judgementStr += "

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

"; - judgementStr += "

试题名称:" + name + "

"; - SourceAndText cpojo = mysqlLocalService.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); - } - System.out.println(judgementStr); + String judgementStr = "

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

"; + judgementStr += "

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

"; + judgementStr += "

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

"; + judgementStr += "

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

"; + judgementStr += "

试题名称:" + name + "

"; + SourceAndText cpojo = mysqlLocalService.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、需要更新学生试题得分 + 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.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(cpojo.getScore() == 0 ? 1 : cpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); + System.out.println(judgementStr); } - break; + break; } } diff --git a/src/main/java/com/example/exam/exam/service/autoforps/AutoForPsServiceImpl.java b/src/main/java/com/example/exam/exam/service/autoforps/AutoForPsServiceImpl.java index dba1f55..280d9af 100644 --- a/src/main/java/com/example/exam/exam/service/autoforps/AutoForPsServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/autoforps/AutoForPsServiceImpl.java @@ -19,7 +19,7 @@ import java.util.List; import java.util.Optional; @Service -public class AutoForPsServiceImpl implements AutoForPsService{ +public class AutoForPsServiceImpl implements AutoForPsService { @Resource PsService psService; @@ -77,33 +77,20 @@ public class AutoForPsServiceImpl implements AutoForPsService{ score = score.add(new BigDecimal(wordpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP)); judgementStr = wordpojo.getText(); judgementStr += "

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

"; - // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 - // 通过 quId,stuId,paperId 查询 - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(new BigDecimal(wordpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP)); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName(name); - stuPaperScoreDO.setIsTrue(wordpojo.getScore() == 0 ? 1 : wordpojo.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(wordpojo.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(wordpojo.getScore() == 0 ? 1 : wordpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + // 4、需要更新学生试题得分 + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(new BigDecimal(wordpojo.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.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(wordpojo.getScore() == 0 ? 1 : wordpojo.getScore() == Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); break; } } diff --git a/src/main/java/com/example/exam/exam/service/ps/PsServiceImpl.java b/src/main/java/com/example/exam/exam/service/ps/PsServiceImpl.java index 543dec3..823f39b 100644 --- a/src/main/java/com/example/exam/exam/service/ps/PsServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/ps/PsServiceImpl.java @@ -27,8 +27,8 @@ import java.util.*; import java.util.stream.Collectors; @Service -public class PsServiceImpl implements PsService{ - static String answerLogPath ; // 文件路径 +public class PsServiceImpl implements PsService { + static String answerLogPath; // 文件路径 @Resource private ExamQuestionAnswerMapper examQuestionAnswerMapper; private static final DateTimeFormatter formatter = @@ -61,11 +61,11 @@ public class PsServiceImpl implements PsService{ String sthJsonPath = path.replaceAll("(?i)\\.psd$", ".json"); Path jsonFilePath = Paths.get(sthJsonPath); - Path jsxPath=null; + Path jsxPath = null; // 执行 Photoshop 脚本 try { - String jsxTargetPath= PsUtil.runTwoPsdsInOneScript(path, jsxTemplatePath, photoshopExe); - jsxPath = Paths.get(jsxTargetPath); + String jsxTargetPath = PsUtil.runTwoPsdsInOneScript(path, jsxTemplatePath, photoshopExe); + jsxPath = Paths.get(jsxTargetPath); appendToFile(answerLogPath, "Photoshop脚本执行完毕"); } catch (Exception e) { @@ -103,7 +103,7 @@ public class PsServiceImpl implements PsService{ sourceAndText.setText(judgementStr); sourceAndText.setScore(0.0); return sourceAndText; - }finally { + } finally { // 检查文件是否存在 if (Files.exists(jsonFilePath)) { try { @@ -141,11 +141,11 @@ public class PsServiceImpl implements PsService{ if (isCorrect) { judgementStr = HtmlAppender.appendHtmlLine(judgementStr, currentPath + "【" + correctValue + "】【✅】"); - appendToFile(answerLogPath, currentPath + "【" + correctValue + "】"+"【√】"); + appendToFile(answerLogPath, currentPath + "【" + correctValue + "】" + "【√】"); result.setScore(result.getScore() + Double.parseDouble(item.getRate())); } else { - judgementStr = HtmlAppender.appendHtmlLine(judgementStr, currentPath + "【" + correctValue + "】"+"【❌】"); - appendToFile(answerLogPath, currentPath + "【" + correctValue + "】"+"【×】"); + judgementStr = HtmlAppender.appendHtmlLine(judgementStr, currentPath + "【" + correctValue + "】" + "【❌】"); + appendToFile(answerLogPath, currentPath + "【" + correctValue + "】" + "【×】"); } result.setText(judgementStr); @@ -220,9 +220,6 @@ public class PsServiceImpl implements PsService{ } - - - /** * 构建答案树形结构 */ diff --git a/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreService.java b/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreService.java index 97ea1f7..5095a89 100644 --- a/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreService.java +++ b/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreService.java @@ -12,7 +12,7 @@ import java.util.List; */ public interface StuPaperScoreService { - List findByStuIDAndPaperId(Long stuId, String paperId); + List findByStuIDAndPaperId(Long stuId, String paperId, String temporaryId); void insertStuPaperScore(StuPaperScoreDO stuPaperScoreDO); diff --git a/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreServiceImpl.java b/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreServiceImpl.java index 8ed7a73..877888f 100644 --- a/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/stupaperscore/StuPaperScoreServiceImpl.java @@ -25,8 +25,8 @@ public class StuPaperScoreServiceImpl implements StuPaperScoreService { private EducationPaperMapper educationPaperMapper; @Override - public List findByStuIDAndPaperId(Long stuId, String paperId) { - return stuPaperScoreMapper.findByStuIdAndPaperId(stuId, paperId); + public List findByStuIDAndPaperId(Long stuId, String paperId, String temporaryId) { + return stuPaperScoreMapper.findByStuIdAndPaperId(stuId, paperId, temporaryId); } @Override diff --git a/src/main/java/com/example/exam/exam/service/wpsexcel/excel/JudgementForExcelServiceImpl.java b/src/main/java/com/example/exam/exam/service/wpsexcel/excel/JudgementForExcelServiceImpl.java index c8d5210..9a4117a 100644 --- a/src/main/java/com/example/exam/exam/service/wpsexcel/excel/JudgementForExcelServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/wpsexcel/excel/JudgementForExcelServiceImpl.java @@ -83,33 +83,20 @@ public class JudgementForExcelServiceImpl implements JudgementForExcelService { judgementStr = excelpojo.getText(); BigDecimal dangSource = new BigDecimal(excelpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP); judgementStr += "

试题得分:" + dangSource + "

"; - // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 - // 通过 quId,stuId,paperId 查询 - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(dangSource); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName(name); - stuPaperScoreDO.setIsTrue(excelpojo.getScore() == 0 ? 1 : excelpojo.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(dangSource); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName(name); - insertInfo.setTrueScore(new BigDecimal(quScore)); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setIsTrue(excelpojo.getScore() == 0 ? 1 : excelpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + // 4、需要新增生试题得分 + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(dangSource); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName(name); + insertInfo.setTrueScore(new BigDecimal(quScore)); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(excelpojo.getScore() == 0 ? 1 : excelpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); break; } } diff --git a/src/main/java/com/example/exam/exam/service/wpspptx/pptx/JudgementForPptxServiceImpl.java b/src/main/java/com/example/exam/exam/service/wpspptx/pptx/JudgementForPptxServiceImpl.java index 346467b..0505c63 100644 --- a/src/main/java/com/example/exam/exam/service/wpspptx/pptx/JudgementForPptxServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/wpspptx/pptx/JudgementForPptxServiceImpl.java @@ -83,33 +83,20 @@ public class JudgementForPptxServiceImpl implements JudgementForPptxService { judgementStr = pptxpojo.getText(); BigDecimal dangSource = new BigDecimal(pptxpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP); judgementStr += "

试题得分:" + dangSource + "

"; - // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 - // 通过 quId,stuId,paperId 查询 - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(dangSource); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName(name); - stuPaperScoreDO.setIsTrue(pptxpojo.getScore() == 0 ? 1 : pptxpojo.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(dangSource); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName(name); - insertInfo.setTrueScore(new BigDecimal(quScore)); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setIsTrue(pptxpojo.getScore() == 0 ? 1 : pptxpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + // 4、需要新增生试题得分 + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(dangSource); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName(name); + insertInfo.setTrueScore(new BigDecimal(quScore)); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(pptxpojo.getScore() == 0 ? 1 : pptxpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); break; } } diff --git a/src/main/java/com/example/exam/exam/service/wpsword/docx4j/endNote/EndNoteing.java b/src/main/java/com/example/exam/exam/service/wpsword/docx4j/endNote/EndNoteing.java index 30970a8..a921697 100644 --- a/src/main/java/com/example/exam/exam/service/wpsword/docx4j/endNote/EndNoteing.java +++ b/src/main/java/com/example/exam/exam/service/wpsword/docx4j/endNote/EndNoteing.java @@ -46,10 +46,9 @@ public class EndNoteing { } - /** * 获取尾注内容 - * "declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' " + * "declare namespace w='http://schemas.openxmlformats.org/wordprocessingml/2006/main' " */ public static String getEndNoteContent(XmlCursor endnoteRefCursor, CTEndnotes endnotes) { if (endnoteRefCursor == null || endnotes == null) return null; @@ -114,5 +113,4 @@ public class EndNoteing { } - } \ No newline at end of file diff --git a/src/main/java/com/example/exam/exam/service/wpsword/word/JudgementForWordServiceImpl.java b/src/main/java/com/example/exam/exam/service/wpsword/word/JudgementForWordServiceImpl.java index 42555dd..fa70a9d 100644 --- a/src/main/java/com/example/exam/exam/service/wpsword/word/JudgementForWordServiceImpl.java +++ b/src/main/java/com/example/exam/exam/service/wpsword/word/JudgementForWordServiceImpl.java @@ -80,33 +80,20 @@ public class JudgementForWordServiceImpl implements JudgementForWordService { judgementStr = wordpojo.getText(); BigDecimal dangSource = new BigDecimal(wordpojo.getScore()).setScale(1, BigDecimal.ROUND_HALF_UP); judgementStr += "

试题得分:" + dangSource + "

"; - // 4、需要更新学生试题得分,首先需要查询试题的数据库是否保存信息 - // 通过 quId,stuId,paperId 查询 - StuPaperScoreDO stuPaperScoreDO = stuPaperScoreService.getStuScoreByPaperIdAndQuid(stuInfoVo.getStuId(), stuInfoVo.getPaperId(), quId); - if (stuPaperScoreDO != null) { - // 说明已经是做过该题,需要更新数据 - stuPaperScoreDO.setScore(dangSource); - stuPaperScoreDO.setContent(judgementStr); - stuPaperScoreDO.setSort(educationPaperQu.getSort()); - stuPaperScoreDO.setSubjectName(name); - stuPaperScoreDO.setIsTrue(wordpojo.getScore() == 0 ? 1 : wordpojo.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(dangSource); - insertInfo.setContent(judgementStr); - insertInfo.setSort(educationPaperQu.getSort()); - insertInfo.setSubjectName(name); - insertInfo.setTrueScore(new BigDecimal(quScore)); - insertInfo.setTenantId(systemTenant.getId()); - insertInfo.setIsTrue(wordpojo.getScore() == 0 ? 1 : wordpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); - stuPaperScoreService.insertStuPaperScore(insertInfo); - } + // 4、需要新增学生试题得分 + StuPaperScoreDO insertInfo = new StuPaperScoreDO(); + insertInfo.setStuId(stuInfoVo.getStuId()); + insertInfo.setPaperId(stuInfoVo.getPaperId()); + insertInfo.setQuId(quId); + insertInfo.setScore(dangSource); + insertInfo.setContent(judgementStr); + insertInfo.setSort(educationPaperQu.getSort()); + insertInfo.setSubjectName(name); + insertInfo.setTrueScore(new BigDecimal(quScore)); + insertInfo.setTenantId(systemTenant.getId()); + insertInfo.setTemporaryId(stuInfoVo.getTemporaryId()); + insertInfo.setIsTrue(wordpojo.getScore() == 0 ? 1 : wordpojo.getScore() >= Double.parseDouble(quScore) ? 0 : 2); + stuPaperScoreService.insertStuPaperScore(insertInfo); break; } } diff --git a/src/main/resources/mapper/stupaperscore/StuPaperScoreMapper.xml b/src/main/resources/mapper/stupaperscore/StuPaperScoreMapper.xml index b8cfda5..0fa729c 100644 --- a/src/main/resources/mapper/stupaperscore/StuPaperScoreMapper.xml +++ b/src/main/resources/mapper/stupaperscore/StuPaperScoreMapper.xml @@ -9,13 +9,25 @@ 文档可见:https://www.iocoder.cn/MyBatis/x-plugins/ --> - DELETE FROM exam_stu_paper_score WHERE stu_id = #{stuId} AND paper_id = #{paperId} + DELETE + FROM exam_stu_paper_score + WHERE stu_id = #{stuId} + AND paper_id = #{paperId}