From df39d937f1d51f507ad1e783a43b38ba19f2af58 Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Mon, 9 Jun 2025 13:52:28 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91?= =?UTF-8?q?=E8=AF=95=E9=A2=98=E5=AE=A1=E6=A0=B8=E6=98=A0=E5=B0=84=E7=9F=A5?= =?UTF-8?q?=E8=AF=86=E7=82=B9=E5=AD=97=E6=AE=B5?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../question/ExamQuestionServiceImpl.java | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java index 6449582c..8e1ff240 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/question/ExamQuestionServiceImpl.java @@ -491,11 +491,36 @@ public class ExamQuestionServiceImpl implements IExamQuestionService PageResult questionExamineDOPageResult = questionExamineMapper.selectPage(questionVo); List list = questionExamineDOPageResult.getList(); List examQuestionList=new ArrayList<>(); + + List examKnowledgePoints = knowledgePointsMapper.selectKnowledgePoints(); + // 构造 ID → 名称映射 + Map idNameMap = examKnowledgePoints.stream() + .collect(Collectors.toMap(ExamKnowledgePoints::getSpId, ExamKnowledgePoints::getSpName)); if (list!=null&&list.size()>0){ for (QuestionExamineDO questionExamineDO : list) { String schoolName =questionExamineMapper.selectSchoolName(questionExamineDO.getSource()); ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(questionExamineDO.getQuId()); + String pointIdStr = examQuestion.getPointNames(); + String chapterIdStr = examQuestion.getChapteridDictText(); if (examQuestion!=null){ + try { + if (pointIdStr != null) { + Long pointId = Long.valueOf(pointIdStr); + if (idNameMap.containsKey(pointId)) { + examQuestion.setPointNamesVo(idNameMap.get(pointId)); + } + } + + if (chapterIdStr != null) { + Long chapterId = Long.valueOf(chapterIdStr); + if (idNameMap.containsKey(chapterId)) { + examQuestion.setChapteridDictTextVo(idNameMap.get(chapterId)); + } + } + } catch (NumberFormatException e) { + // 日志记录或跳过处理 + System.err.println("ID格式错误:" + e.getMessage()); + } examQuestion.setCreateTeacher(questionExamineDO.getCreateTeacher()); examQuestion.setSchoolName(schoolName); examQuestion.setSource(questionExamineDO.getSource()); From 48546ad4c1e5fcbb0ec973e9aacfb77a0614790d Mon Sep 17 00:00:00 2001 From: "YOHO\\20373" <2037305722@qq.com> Date: Mon, 9 Jun 2025 17:45:58 +0800 Subject: [PATCH 2/2] =?UTF-8?q?=E3=80=90=E4=BF=AE=E6=94=B9=E3=80=91mysql?= =?UTF-8?q?=E8=AF=BB=E5=8F=96=E6=96=87=E4=BB=B6=E5=A4=B9=E4=B8=8B=E7=9A=84?= =?UTF-8?q?myd=E6=96=87=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/mysql/MysqlServericeImpl.java | 50 ++++++++++++------- 1 file changed, 31 insertions(+), 19 deletions(-) diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java index 07879445..e0c9d734 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/MysqlServericeImpl.java @@ -91,14 +91,28 @@ public class MysqlServericeImpl implements IMysqlServerice { String filePath = new File(stuFilePath, "answer.txt").getAbsolutePath(); // 结果/answer.txt // String answerPath = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\结果素材\\结果素材\\Teacher\\db\\db_escape.myd"; // 原始 SQL 文件路径 - String answerPath = new File(new File(stuFilePath, "db"), "db_escape.myd").getAbsolutePath(); + File dbDir = new File(stuFilePath, "db"); + String answerPath = null; + if (dbDir.exists() && dbDir.isDirectory()) { + File[] mydFiles = dbDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".myd")); + if (mydFiles != null && mydFiles.length > 0) { + answerPath = mydFiles[0].getAbsolutePath(); // 默认取第一个 .myd 文件 + } + } // String fileStu = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\考试素材\\考试素材\\Student"; String fileStu = filepath.getAbsolutePath(); // String stuAnswerPath = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\考试素材\\考试素材\\Student\\db\\db_escape.myd"; - String stuAnswerPath = new File(new File(fileStu, "db"), "db_escape.myd").getAbsolutePath(); + File stuDbDir = new File(fileStu, "db"); + String stuAnswerPath = null; + if (stuDbDir.exists() && stuDbDir.isDirectory()) { + File[] stuMydFiles = stuDbDir.listFiles((dir, name) -> name.toLowerCase().endsWith(".myd")); + if (stuMydFiles != null && stuMydFiles.length > 0) { + stuAnswerPath = stuMydFiles[0].getAbsolutePath(); // 默认取第一个 .myd 文件 + } + } // 生成随机数据库名,临时使用 databaseName = "db_" + UUID.randomUUID().toString().replace("-", "").substring(0, 8); @@ -623,6 +637,7 @@ public class MysqlServericeImpl implements IMysqlServerice { //考生答案 集合 List> stuResults = new ArrayList<>(); if (extractCallStatements != null && extractCallStatements.size() > 0) { + boolean hasError = false; // 添加标志变量 for (String extractCallStatement : extractCallStatements) { appendToFile(answerLogPath, "测试 call 语句:" + extractCallStatement); @@ -636,7 +651,7 @@ public class MysqlServericeImpl implements IMysqlServerice { } catch (SQLException e) { appendToFile(answerLogPath, "执行标准库 SQL CALL 语句时发生错误: " + e.getMessage()); } - boolean hasError = false; // 添加标志变量 + try (Connection connstu = DriverManager.getConnection(stuDbUrl, user, password); Statement stmtstu = connstu.createStatement()) { @@ -660,23 +675,20 @@ public class MysqlServericeImpl implements IMysqlServerice { hasError = true; // 发生异常,设为 true } - - - // 比较结果(如果发生异常,可以认为比较失败) - boolean flag = !hasError && compareExtractResults(anwerResults, stuResults); - - if (flag) { - //todo 得分 - double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); - scoreTotal+=sr; - } else { - //得分 - double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal); - scoreTotal+=sw; - - } } + // 比较结果(如果发生异常,可以认为比较失败) + boolean flag = !hasError && compareExtractResults(anwerResults, stuResults); + if (flag) { + //todo 得分 + double sr= accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql2,totalKeyScore,score,answerId,scoreTotal); + scoreTotal+=sr; + } else { + //得分 + double sw = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal); + scoreTotal+=sw; + + } } else { appendToFile(answerLogPath, "此存储过程无 CALL 语句"); } @@ -740,7 +752,7 @@ public class MysqlServericeImpl implements IMysqlServerice { } double roundedResult =0.0; - appendToFile(answerLogPath, "共得分:"+scoreTotal); + appendToFile(answerLogPath, "共得分:" + String.format("%.2f", scoreTotal)); folderzip.delete(); deleteFolder(folder); return scoreTotal;