Accept Merge Request #130: (hyc -> master)

Merge Request: 【新增】mysql本地判分

Created By: @华允传
Accepted By: @华允传
URL: https://g-iswv8783.coding.net/p/education/d/pengchen-exam-java/git/merge/130?initial=true
This commit is contained in:
华允传
2025-06-24 10:35:16 +08:00
committed by Coding
12 changed files with 1989 additions and 57 deletions

View File

@@ -41,6 +41,7 @@ public interface ExamQuestionMapper extends BaseMapperX<ExamQuestion>
default PageResult<ExamQuestion> selectExamQuestionList(QuestionVo questionVo) {
return selectPage(questionVo, new LambdaQueryWrapperX<ExamQuestion>()
.likeIfPresent(ExamQuestion::getQuNum, questionVo.getQuNum())
.likeIfPresent(ExamQuestion::getContent, questionVo.getContent())
.likeIfPresent(ExamQuestion::getQuId,questionVo.getQuId())
.likeIfPresent(ExamQuestion::getKeywords,questionVo.getKeywords())
.likeIfPresent(ExamQuestion::getQuLevel, questionVo.getQuLevel())

View File

@@ -4,16 +4,16 @@
"http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionKeywordMapper">
<resultMap type="ExamQuestionKeyword" id="ExamQuestionKeywordResult">
<result property="keywordId" column="keyword_id" />
<result property="quId" column="qu_id" />
<result property="keyword" column="keyword" />
<result property="scoreRate" column="score_rate" />
</resultMap>
<resultMap type="ExamQuestionKeyword" id="ExamQuestionKeywordResult">
<result property="keywordId" column="keyword_id" />
<result property="quId" column="qu_id" />
<result property="keyword" column="keyword" />
<result property="scoreRate" column="score_rate" />
</resultMap>
<sql id="selectExamQuestionKeywordVo">
select keyword_id, qu_id, keyword, score_rate from exam_question_keyword
</sql>
<sql id="selectExamQuestionKeywordVo">
select keyword_id, qu_id, keyword, score_rate from exam_question_keyword
</sql>
<select id="selectExamQuestionKeywordList" parameterType="ExamQuestionKeyword" resultMap="ExamQuestionKeywordResult">
<include refid="selectExamQuestionKeywordVo"/>

View File

@@ -22,4 +22,4 @@ public interface ConfigMapper extends BaseMapperX<ConfigDO> {
.betweenIfPresent(ConfigDO::getCreateTime, reqVO.getCreateTime()));
}
}
}

View File

@@ -2,18 +2,14 @@ package pc.exam.pp.module.judgement.controller.admin.Browser;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.module.judgement.controller.service.browser.IBrowserServerice;
import java.io.IOException;
@RestController
@RequestMapping("/tool/Browser")
public class BrowserComtroller {
public class BrowserController {
@Autowired
private IBrowserServerice browserServerice;

View File

@@ -1,13 +1,14 @@
package pc.exam.pp.module.judgement.controller.admin.Mysql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.*;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.module.judgement.controller.admin.autoTools.vo.StuPaperReqVo;
import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlLocalService;
import pc.exam.pp.module.judgement.controller.service.mysql.IMysqlServerice;
import java.io.IOException;
import java.math.BigDecimal;
import java.sql.SQLException;
@RestController
@@ -18,8 +19,18 @@ public class MysqlController {
@Autowired
private IMysqlServerice mysqlServerice;
@Autowired
private IMysqlLocalService mysqlLocalService;
/**
* 删除 本地学生的连接和库
* @param tName
* @throws Exception
*/
@GetMapping("/delMysqlConnect")
public void get(@RequestParam("tName") String tName) throws Exception {
mysqlLocalService.delMysqlConnect(tName);
}
/**
* Mysql判分

View File

@@ -50,14 +50,14 @@ public class BrowserServericeImpl implements IBrowserServerice {
List<ExamQuestionAnswer> answerList = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(question.getQuId());
//判断如果类型为1为添加到文件夹的html后缀加 .html
for (ExamQuestionAnswer answer : answerList) {
if ("添加到文件夹".equals(answer.getContentIn())) {
String fileName = answer.getContent();
if (!fileName.endsWith(".html")) {
answer.setContent(fileName + ".html");
}
}
}
// for (ExamQuestionAnswer answer : answerList) {
// if ("添加到文件夹".equals(answer.getContentIn())) {
// String fileName = answer.getContent();
// if (!fileName.endsWith(".html")) {
// answer.setContent(fileName + ".html");
// }
// }
// }

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.judgement.controller.service.mysql;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;
import java.io.File;
import java.io.IOException;
import java.sql.SQLException;
public interface IMysqlLocalService {
SourceAndText Judgement(double sorce, File file, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException;
void delMysqlConnect(String tName);
}

View File

@@ -1,6 +1,7 @@
package pc.exam.pp.module.judgement.controller.service.mysql;
import pc.exam.pp.framework.common.pojo.CommonResult;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
import pc.exam.pp.module.judgement.service.auto_tools.vo.SourceAndText;

View File

@@ -59,7 +59,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
public SourceAndText Judgement(double score, File filepath, ExamQuestion examQuestion, String judgementStr) throws IOException, SQLException {
SourceAndText sourceAndText = new SourceAndText();
double scoreTotal =0.0;
String fileUrl= examQuestionAnswerMapper.selectAnswerFile(examQuestion.getQuId());
String fileUrl= examQuestionAnswerMapper.selectAnswerFile(examQuestion.getQuId());
String path = ZipUtil.downloadStudentFile(fileUrl, "data");
// 4、获取到得是zip文件需要解压
String stuFilePath = ZipUtil.unzipToNamedFolder(path);
@@ -835,11 +835,9 @@ public class MysqlServericeImpl implements IMysqlServerice {
}
private static String compareTables(Set<Map<String, String>> standardSet, Set<Map<String, String>> 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);
@@ -855,45 +853,46 @@ public class MysqlServericeImpl implements IMysqlServerice {
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);
System.out.printf("%02d.【字段】【%s】【名称】【%s】【%s】\n", ++index, fullName, columnName, nameCheck);
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);
judgementStr=mysqlVo1.getText();
MysqlVo mysqlVo2 = compareField(index, fullName, "允许为空", stdCol.get("IS_NULLABLE"), stuCol.get("IS_NULLABLE"),judgementStr);
index=mysqlVo2.getIndex();
yuju=mysqlVo2.getText();
MysqlVo mysqlVo3 = compareField(index, fullName, "扩展", stdCol.get("EXTRA"), stuCol.get("EXTRA"),yuju);
judgementStr=mysqlVo2.getText();
MysqlVo mysqlVo3 = compareField(index, fullName, "扩展", stdCol.get("EXTRA"), stuCol.get("EXTRA"),judgementStr);
index=mysqlVo3.getIndex();
yuju=mysqlVo3.getText();
MysqlVo mysqlVo4 = compareField(index, fullName, "键类型", stdCol.get("COLUMN_KEY"), stuCol.get("COLUMN_KEY"),yuju);
yuju=mysqlVo4.getText();
judgementStr=mysqlVo3.getText();
MysqlVo mysqlVo4 = compareField(index, fullName, "键类型", stdCol.get("COLUMN_KEY"), stuCol.get("COLUMN_KEY"),judgementStr);
judgementStr=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);
judgementStr=mysqlVo1.getText();
MysqlVo mysqlVo2 = printMissing(index, fullName, "允许为空", stdCol.get("IS_NULLABLE"),judgementStr);
index=mysqlVo2.getIndex();
yuju=mysqlVo2.getText();
MysqlVo mysqlVo3 = printMissing(index, fullName, "扩展", stdCol.get("EXTRA"),yuju);
judgementStr=mysqlVo2.getText();
MysqlVo mysqlVo3 = printMissing(index, fullName, "扩展", stdCol.get("EXTRA"),judgementStr);
index=mysqlVo3.getIndex();
yuju=mysqlVo3.getText();
MysqlVo mysqlVo4 = printMissing(index, fullName, "键类型", stdCol.get("COLUMN_KEY"),yuju);
yuju=mysqlVo4.getText();
judgementStr=mysqlVo3.getText();
MysqlVo mysqlVo4 = printMissing(index, fullName, "键类型", stdCol.get("COLUMN_KEY"),judgementStr);
judgementStr=mysqlVo4.getText();
}
}
return yuju;
return judgementStr;
}
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);
System.out.printf("%02d.【字段】【%s】【%s】【%s】【%s】\n", index + 1, fullName, property, stuValue, mark);
appendToFile(answerLogPath, "%02d.【字段】【%s】【%s】【%s】【%s】\n", index + 1, fullName, property, stuValue, mark);
judgementStr = HtmlAppender.appendHtmlLineMysql(judgementStr, "%02d.【字段】【%s】【%s】【%s】【%s】\n", index + 1, fullName, property, stuValue, mark);
mysqlVo.setText(judgementStr);
mysqlVo.setIndex(index + 1);
return mysqlVo;
@@ -901,9 +900,9 @@ public class MysqlServericeImpl implements IMysqlServerice {
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);
System.out.printf("%02d.【字段】【%s】【%s】【%s】【x】\n", index + 1, fullName, property, stdValue);
appendToFile(answerLogPath, "%02d.【字段】【%s】【%s】【%s】【x】\n", index + 1, fullName, property, stdValue);
judgementStr = HtmlAppender.appendHtmlLineMysql(judgementStr, "%02d.【字段】【%s】【%s】【%s】【x】\n", index + 1, fullName, property, stdValue);
mysqlVo.setText(judgementStr);
mysqlVo.setIndex(index + 1);
return mysqlVo;

View File

@@ -2,6 +2,7 @@ package pc.exam.pp.module.judgement.controller.service.mysql;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import pc.exam.pp.module.exam.dal.mysql.paper.EducationPaperMapper;
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
@Service
@@ -13,10 +14,9 @@ public class testServiceImpl implements testservice {
public boolean test() {
String s = endStuMonitorUtils.endStuMonitor("160", "2bf4510550e34d85a852394cea61b455");
endStuMonitorUtils.endStuMonitor("160","2bf4510550e34d85a852394cea61b455",20.0);
// String s = endStuMonitorUtils.endStuMonitor("160", "2bf4510550e34d85a852394cea61b455");
//
// endStuMonitorUtils.endStuMonitor("160","2bf4510550e34d85a852394cea61b455",20.0);
return true;
}

View File

@@ -0,0 +1,16 @@
package pc.exam.pp.module.judgement.controller.service.mysql.vo;
import lombok.Data;
@Data
public class MysqlBooleanVo {
/**
* 是否正确
*/
private boolean flag;
/**
* 文本
*/
private String text;
}