diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java index 768e73f7..bbbcb804 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/controller/admin/question/vo/QuestionVo.java @@ -31,4 +31,6 @@ public class QuestionVo extends PageParam { private String quNum; + private String keywords; + } diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java index 168829df..81166d58 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/EducationPaperTask.java @@ -49,11 +49,11 @@ public class EducationPaperTask extends TenantBaseDO /** 是否为模板 */ //@Excel(name = "是否为模板") - private String isTemplate; + private Integer isTemplate; /** 是否启用(0:启用,1:停用) */ //@Excel(name = "是否启用", readConverterExp = "0=:启用,1:停用") - private String status; + private Integer status; @TableField(exist = false) private String count; diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java index 3c176fa7..cee21b43 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/dataobject/ExamQuestion.java @@ -99,6 +99,8 @@ public class ExamQuestion extends TenantBaseDO { /** 专业分类 */ // @Excel(name = "专业分类") private String specialtyName; + /** 数据库名 */ + private String tname; /** 试题答案 */ // @Excel(name = "试题答案") diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java index eff5b9f5..aaa8812d 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/dal/mysql/question/ExamQuestionMapper.java @@ -42,6 +42,7 @@ public interface ExamQuestionMapper extends BaseMapperX return selectPage(questionVo, new LambdaQueryWrapperX() .likeIfPresent(ExamQuestion::getQuNum, questionVo.getQuNum()) .likeIfPresent(ExamQuestion::getQuId,questionVo.getQuId()) + .likeIfPresent(ExamQuestion::getKeywords,questionVo.getKeywords()) .likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel()) .likeIfPresent(ExamQuestion::getCourseName , questionVo.getCourseName()) .likeIfPresent(ExamQuestion::getPointNames , questionVo.getPointNames()) diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorTaskServiceImpl.java index a6521765..eda08a01 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/monitor/MonitorTaskServiceImpl.java @@ -52,7 +52,7 @@ public class MonitorTaskServiceImpl implements MonitorTaskService{ monitorTaskDO.setTaskType(educationPaperTask.getTaskType()); monitorTaskDO.setTaskName(educationPaperTask.getTaskName()); monitorTaskDO.setTaskNum(educationPaperTask.getTaskNum()); - monitorTaskDO.setStatus(educationPaperTask.getStatus()); + monitorTaskDO.setStatus(String.valueOf(educationPaperTask.getStatus())); monitorTaskDO.setTaskSpecialty(educationPaperTask.getTaskSpecialty()); List educationPapers = educationPaperMapper.selectPaperListByTaskId(educationPaperTask.getTaskId()); diff --git a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java index 51f54b6d..ea328021 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java +++ b/exam-module-exam/exam-module-exam-biz/src/main/java/pc/exam/pp/module/exam/service/paper/EducationPaperTaskServiceImpl.java @@ -323,7 +323,7 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService String timeString = now.format(formatter); educationPaperTask.setTaskName(educationPaperTask.getTaskName()+timeString); - educationPaperTask.setIsTemplate("1"); + educationPaperTask.setIsTemplate(1); educationPaperTaskMapper.insertEducationPaperTask(educationPaperTask); if (options.contains("1")) { diff --git a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml index 190e2a50..418fb58c 100644 --- a/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml +++ b/exam-module-exam/exam-module-exam-biz/src/main/resources/mapper/exam/ExamQuestionMapper.xml @@ -26,6 +26,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" + @@ -50,7 +51,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" select qu_id, qu_bank_id, qu_num,qu_bank_name, chapterId_dict_text,subject_name, qu_level, - content, content_text, analysis,answer, point_names, keywords, manual, create_time, creator, update_time, updater, deleted ,status,audit ,course_name, specialty_name from exam_question + content, content_text, analysis,answer, point_names, keywords, manual, create_time, creator, update_time, updater, deleted ,status,audit ,course_name, specialty_name , tname from exam_question @@ -153,6 +154,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" subject_name, qu_level, answer, + tname, content, content_text, analysis, @@ -179,6 +181,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" #{subjectName}, #{quLevel}, #{answer}, + #{tname}, #{content}, #{contentText}, #{analysis}, @@ -200,14 +203,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" - INSERT INTO exam_question (qu_id, qu_bank_id, qu_num,chapterId_dict_text, subject_name,specialty_name, course_name, qu_level, content, audit, status, content_text, analysis, point_names, keywords, manual) + INSERT INTO exam_question (qu_id, qu_bank_id,tname, qu_num,chapterId_dict_text, subject_name,specialty_name, course_name, qu_level, content, audit, status, content_text, analysis, point_names, keywords, manual) VALUES - (#{item.quId}, #{item.quBankId},#{item.quNum}, #{item.chapteridDictText}, #{item.subjectName}, + (#{item.quId}, #{item.quBankId},#{item.tname},#{item.quNum}, #{item.chapteridDictText}, #{item.subjectName}, #{item.specialtyName}, #{item.courseName}, #{item.quLevel}, #{item.content}, #{item.audit} , #{item.status}, #{item.contentText}, #{item.analysis}, #{item.pointNames}, #{item.keywords}, #{item.manual}) ON DUPLICATE KEY UPDATE + tname== VALUES(tname), chapterId_dict_text = VALUES(chapterId_dict_text), subject_name = VALUES(subject_name), specialty_name = VALUES(specialty_name), @@ -234,6 +238,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" qu_level = #{quLevel}, content = #{content}, answer = #{answer}, + tname = #{tname}, content_text = #{contentText}, analysis = #{analysis}, point_names = #{pointNames}, 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 3760ed08..c2ab1603 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 @@ -11,6 +11,7 @@ import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionKeyword; import pc.exam.pp.module.exam.dal.mysql.question.ExamMysqlKeywordMapper; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionAnswerMapper; import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper; +import pc.exam.pp.module.judgement.controller.service.mysql.vo.MysqlVo; import pc.exam.pp.module.judgement.controller.utils.Mysql.MySQLExporterUtil; import pc.exam.pp.module.judgement.controller.utils.Mysql.SQLComparatorUtil; import pc.exam.pp.module.judgement.controller.utils.Mysql.SqlFileProcessor; @@ -287,8 +288,8 @@ public class MysqlServericeImpl implements IMysqlServerice { table1Columns.add(column); } - appendToFile(answerLogPath, "标准答案建表键值对:"+table1Columns); - judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "标准答案建表键值对:"+table1Columns); +// appendToFile(answerLogPath, "标准答案建表键值对:"+table1Columns); +// judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "标准答案建表键值对:"+table1Columns); } @@ -306,19 +307,27 @@ public class MysqlServericeImpl implements IMysqlServerice { column.put("EXTRA", rsstu.getString("EXTRA")); table2Columns.add(column); } - appendToFile(answerLogPath, "学生答案建表键值对:"+table2Columns); - judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "学生答案建表键值对:"+table2Columns); +// appendToFile(answerLogPath, "学生答案建表键值对:"+table2Columns); +// judgementStr = HtmlAppender.appendHtmlLine(judgementStr, "学生答案建表键值对:"+table2Columns); } } String sql3 = resultStu.get(entry.getKey()); + Matcher matcherStu = pattern.matcher(sql3); + String tableNameStu =""; + if (matcherStu.find()) { + tableNameStu= matcherStu.group(1).replace("`", ""); // 获取表名 + } + String yuju= compareTables(table1Columns, table2Columns, examQuestion.getTname(),tableName, tableNameStu,judgementStr); + judgementStr=yuju; + if (table1Columns.equals(table2Columns)) { // SourceAndText studentScorePojo = accumulateScoreAndLog(examMysqlKeywordList,total,answerLogPath,sql3,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal += studentScorePojo.getScore(); judgementStr = studentScorePojo.getText(); } else { - SourceAndText studentScorePojo= calculateTotalScoreRate(sql2, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); + SourceAndText studentScorePojo= calculateTotalScoreRate(sql3, examMysqlKeywordList,totalKeyScore,score,answerId,scoreTotal,judgementStr); scoreTotal += studentScorePojo.getScore(); judgementStr = studentScorePojo.getText(); } @@ -788,7 +797,8 @@ public class MysqlServericeImpl implements IMysqlServerice { if (equals) { //todo 得分 SourceAndText studentScorePojo = accumulateScoreAndLog(examMysqlKeywordList, total, answerLogPath, sql2, totalKeyScore, score, answerId, scoreTotal,judgementStr); - + scoreTotal += studentScorePojo.getScore(); + judgementStr = studentScorePojo.getText(); } else { SourceAndText studentScorePojo = calculateTotalScoreRate(sql2, examMysqlKeywordList, totalKeyScore, score, answerId, scoreTotal,judgementStr); @@ -824,7 +834,88 @@ public class MysqlServericeImpl implements IMysqlServerice { return sourceAndText; } + private static String compareTables(Set> standardSet, Set> studentSet, String dbTable, String tableName,String tableNameStu,String judgementStr) { + String yuju=""; + int index = 1; + // 判断表名是否一致 + String tableNameCheck = tableName.equalsIgnoreCase(tableNameStu) ? "✔" : "x"; + // 输出 + System.out.printf("%02d.【数据表】【%s】【名称】【%s】【%s】\n", index, dbTable, tableName, tableNameCheck); + appendToFile(answerLogPath, "%02d.【数据表】【%s】【名称】【%s】【%s】\n", index, dbTable, tableName, tableNameCheck); + judgementStr = HtmlAppender.appendHtmlLineMysql(judgementStr, "%02d.【数据表】【%s】【名称】【%s】【%s】\n", index, dbTable, tableName, tableNameCheck); + // 把Set转成Map,方便通过字段名快速取值 + Map> standardMap = convertSetToMap(standardSet); + Map> studentMap = convertSetToMap(studentSet); + + for (String columnName : standardMap.keySet()) { + Map stdCol = standardMap.get(columnName); + Map stuCol = studentMap.get(columnName); + + String fullName = dbTable + "." + columnName; + + String nameCheck = stuCol != null ? "✔" : "x"; + judgementStr = HtmlAppender.appendHtmlLineMysql(judgementStr, "%02d.【字段】【%s】【名称】【%s】【%s】\n", index++, fullName, columnName, nameCheck); + appendToFile(answerLogPath, "%02d.【字段】【%s】【名称】【%s】【%s】\n", index++, fullName, columnName, nameCheck); + + if (stuCol != null) { + MysqlVo mysqlVo1 = compareField(index, fullName, "类型", stdCol.get("COLUMN_TYPE"), stuCol.get("COLUMN_TYPE"),judgementStr); + index=mysqlVo1.getIndex(); + yuju=mysqlVo1.getText(); + MysqlVo mysqlVo2 = compareField(index, fullName, "允许为空", stdCol.get("IS_NULLABLE"), stuCol.get("IS_NULLABLE"),yuju); + index=mysqlVo2.getIndex(); + yuju=mysqlVo2.getText(); + MysqlVo mysqlVo3 = compareField(index, fullName, "扩展", stdCol.get("EXTRA"), stuCol.get("EXTRA"),yuju); + index=mysqlVo3.getIndex(); + yuju=mysqlVo3.getText(); + MysqlVo mysqlVo4 = compareField(index, fullName, "键类型", stdCol.get("COLUMN_KEY"), stuCol.get("COLUMN_KEY"),yuju); + yuju=mysqlVo4.getText(); + } else { + // 缺失字段,直接输出所有属性错误 + MysqlVo mysqlVo1 = printMissing(index, fullName, "类型", stdCol.get("COLUMN_TYPE"),judgementStr); + index=mysqlVo1.getIndex(); + yuju=mysqlVo1.getText(); + MysqlVo mysqlVo2 = printMissing(index, fullName, "允许为空", stdCol.get("IS_NULLABLE"),yuju); + index=mysqlVo2.getIndex(); + yuju=mysqlVo2.getText(); + MysqlVo mysqlVo3 = printMissing(index, fullName, "扩展", stdCol.get("EXTRA"),yuju); + index=mysqlVo3.getIndex(); + yuju=mysqlVo3.getText(); + MysqlVo mysqlVo4 = printMissing(index, fullName, "键类型", stdCol.get("COLUMN_KEY"),yuju); + yuju=mysqlVo4.getText(); + } + } + return yuju; + } + + private static MysqlVo compareField(int index, String fullName, String property, String stdValue, String stuValue, String judgementStr) { + MysqlVo mysqlVo=new MysqlVo(); + String mark = stdValue.equalsIgnoreCase(stuValue) ? "✔" : "x"; + System.out.printf("%02d.【字段】【%s】【%s】【%s】【%s】\n", index, fullName, property, stuValue, mark); + appendToFile(answerLogPath, "%02d.【字段】【%s】【%s】【%s】【%s】\n", index, fullName, property, stuValue, mark); + judgementStr = HtmlAppender.appendHtmlLineMysql(judgementStr, "%02d.【字段】【%s】【%s】【%s】【%s】\n", index, fullName, property, stuValue, mark); + mysqlVo.setText(judgementStr); + mysqlVo.setIndex(index + 1); + return mysqlVo; + } + + private static MysqlVo printMissing(int index, String fullName, String property, String stdValue,String judgementStr) { + MysqlVo mysqlVo=new MysqlVo(); + System.out.printf("%02d.【字段】【%s】【%s】【%s】【x】\n", index, fullName, property, stdValue); + appendToFile(answerLogPath, "%02d.【字段】【%s】【%s】【%s】【x】\n", index, fullName, property, stdValue); + judgementStr = HtmlAppender.appendHtmlLineMysql(judgementStr, "%02d.【字段】【%s】【%s】【%s】【x】\n", index, fullName, property, stdValue); + mysqlVo.setText(judgementStr); + mysqlVo.setIndex(index + 1); + return mysqlVo; + } + + private static Map> convertSetToMap(Set> set) { + Map> map = new LinkedHashMap<>(); + for (Map column : set) { + map.put(column.get("COLUMN_NAME"), column); + } + return map; + } public static void deleteFolder(File folder) { if (folder.isDirectory()) { File[] files = folder.listFiles(); @@ -1448,4 +1539,16 @@ public class MysqlServericeImpl implements IMysqlServerice { e.printStackTrace(); } } + public static void appendToFile(String filePath, String format, Object... args) { + try (BufferedWriter writer = new BufferedWriter(new FileWriter(filePath, true))) { + String timestamp = LocalDateTime.now().format(formatter); + String content = String.format(format, args); + String logLine = String.format("[%s] %s", timestamp, content); + writer.write(logLine); + writer.newLine(); // 可选:添加换行符 + } catch (IOException e) { + e.printStackTrace(); + } + } + } \ No newline at end of file diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/vo/MysqlVo.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/vo/MysqlVo.java new file mode 100644 index 00000000..01b7c76b --- /dev/null +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/controller/service/mysql/vo/MysqlVo.java @@ -0,0 +1,16 @@ +package pc.exam.pp.module.judgement.controller.service.mysql.vo; + +import lombok.Data; + +@Data +public class MysqlVo { + /** + * 序列 + */ + private int index; + + /** + * 文本 + */ + private String text; +} diff --git a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/HtmlAppender.java b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/HtmlAppender.java index 65859f5b..04871dd5 100644 --- a/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/HtmlAppender.java +++ b/exam-module-judgement/exam-module-judgement-biz/src/main/java/pc/exam/pp/module/judgement/utils/HtmlAppender.java @@ -20,6 +20,18 @@ public class HtmlAppender { return result.toString(); } + public static String appendHtmlLineMysql(String originalText, String format, Object... args) { + StringBuilder result = new StringBuilder(originalText == null ? "" : originalText); + + if (format != null && !format.isEmpty()) { + String newLine = String.format(format, args); + result.append("

") + .append(escapeHtml(newLine)) + .append("

\n"); + } + + return result.toString(); + } // 简单HTML转义,防止注入攻击 private static String escapeHtml(String text) { diff --git a/word/试卷.docx b/word/试卷.docx index b4cd5fd0..8d1a642b 100644 Binary files a/word/试卷.docx and b/word/试卷.docx differ