【修改】删除文件,wps判分log文件地址修改,mysql结果文件随题下载
This commit is contained in:
@@ -75,4 +75,6 @@ public interface ExamQuestionAnswerMapper extends BaseMapperX<ExamQuestionAnswe
|
|||||||
List<String> selectExamQuestionAnswerIdByQuId(String quId);
|
List<String> selectExamQuestionAnswerIdByQuId(String quId);
|
||||||
|
|
||||||
|
|
||||||
|
String selectAnswerFile(String quId);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@@ -92,6 +92,9 @@
|
|||||||
<select id="selectExamQuestionAnswerIdByQuId" resultType="java.lang.String">
|
<select id="selectExamQuestionAnswerIdByQuId" resultType="java.lang.String">
|
||||||
select answer_id from exam_question_answer where qu_id =#{quId}
|
select answer_id from exam_question_answer where qu_id =#{quId}
|
||||||
</select>
|
</select>
|
||||||
|
<select id="selectAnswerFile" resultType="java.lang.String">
|
||||||
|
select url from sys_file where qu_id =#{quId} and file_type ='2'
|
||||||
|
</select>
|
||||||
<insert id="insertExamQuestionAnswerList">
|
<insert id="insertExamQuestionAnswerList">
|
||||||
insert into exam_question_answer
|
insert into exam_question_answer
|
||||||
(answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort)
|
(answer_id, qu_id, is_right, image, content,contentIn,score_rate,sort)
|
||||||
|
@@ -3,6 +3,7 @@ package pc.exam.pp.module.judgement.controller.service.mysql;
|
|||||||
import jakarta.annotation.Resource;
|
import jakarta.annotation.Resource;
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
|
import pc.exam.pp.framework.common.pojo.CommonResult;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamMysqlKeyword;
|
import pc.exam.pp.module.exam.dal.dataobject.ExamMysqlKeyword;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestion;
|
||||||
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
|
||||||
@@ -13,6 +14,7 @@ import pc.exam.pp.module.exam.dal.mysql.question.ExamQuestionMapper;
|
|||||||
import pc.exam.pp.module.judgement.controller.utils.Mysql.MySQLExporterUtil;
|
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.SQLComparatorUtil;
|
||||||
import pc.exam.pp.module.judgement.controller.utils.Mysql.SqlFileProcessor;
|
import pc.exam.pp.module.judgement.controller.utils.Mysql.SqlFileProcessor;
|
||||||
|
import pc.exam.pp.module.judgement.controller.utils.zip.ZipUtil;
|
||||||
import pc.exam.pp.module.judgement.domain.SqlExecutionResult;
|
import pc.exam.pp.module.judgement.domain.SqlExecutionResult;
|
||||||
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
import pc.exam.pp.module.judgement.utils.EndStuMonitorUtils;
|
||||||
|
|
||||||
@@ -47,6 +49,19 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double Judgement(double score,File filepath, ExamQuestion examQuestion) throws IOException, SQLException {
|
public double Judgement(double score,File filepath, ExamQuestion examQuestion) throws IOException, SQLException {
|
||||||
|
|
||||||
|
String fileUrl= examQuestionAnswerMapper.selectAnswerFile(examQuestion.getQuId());
|
||||||
|
String path = ZipUtil.downloadStudentFile(fileUrl, "data");
|
||||||
|
// 4、获取到得是zip文件,需要解压
|
||||||
|
String stuFilePath = ZipUtil.unzipToNamedFolder(path);
|
||||||
|
File folderzip = new File(path);
|
||||||
|
File folder = new File(stuFilePath);
|
||||||
|
// 5、解压之后得文件获取文件夹和文件
|
||||||
|
String stu_files = null;
|
||||||
|
|
||||||
|
// 5.2、查询试题ID
|
||||||
|
|
||||||
|
|
||||||
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(examQuestion.getQuId());
|
List<ExamQuestionAnswer> examQuestionAnswers = examQuestionAnswerMapper.selectExamQuestionAnswerByQuId(examQuestion.getQuId());
|
||||||
String totalKeyScore ="0";
|
String totalKeyScore ="0";
|
||||||
if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){
|
if (examQuestionAnswers!=null&&examQuestionAnswers.size()>0){
|
||||||
@@ -63,16 +78,16 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
|||||||
// 文件路径
|
// 文件路径
|
||||||
|
|
||||||
// String file = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\结果素材\\结果素材\\Teacher";
|
// String file = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\结果素材\\结果素材\\Teacher";
|
||||||
String file = new File(filepath, "结果").getAbsolutePath();
|
// String file = new File(filepath, "结果").getAbsolutePath();
|
||||||
// String filePath = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\结果素材\\结果素材\\Teacher\\answer.txt"; // 答案文件路径
|
// String filePath = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\结果素材\\结果素材\\Teacher\\answer.txt"; // 答案文件路径
|
||||||
String filePath = new File(file, "answer.txt").getAbsolutePath(); // 结果/answer.txt
|
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 = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\结果素材\\结果素材\\Teacher\\db\\db_escape.myd"; // 原始 SQL 文件路径
|
||||||
String answerPath = new File(new File(file, "db"), "db_escape.myd").getAbsolutePath();
|
String answerPath = new File(new File(stuFilePath, "db"), "db_escape.myd").getAbsolutePath();
|
||||||
|
|
||||||
|
|
||||||
// String fileStu = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\考试素材\\考试素材\\Student";
|
// String fileStu = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\考试素材\\考试素材\\Student";
|
||||||
String fileStu = new File(filepath, "素材").getAbsolutePath();
|
String fileStu = filepath.getAbsolutePath();
|
||||||
|
|
||||||
// String stuAnswerPath = "D:\\Desktop\\202504211120_mysql\\71\\MYS_010_122\\考试素材\\考试素材\\Student\\db\\db_escape.myd";
|
// 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();
|
String stuAnswerPath = new File(new File(fileStu, "db"), "db_escape.myd").getAbsolutePath();
|
||||||
@@ -121,7 +136,7 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
|||||||
if (sqlFileExecuted && sqlFileExecutedstu) {
|
if (sqlFileExecuted && sqlFileExecutedstu) {
|
||||||
|
|
||||||
|
|
||||||
Map<String, String> result = readFilesAsMap(file);
|
Map<String, String> result = readFilesAsMap(stuFilePath);
|
||||||
Map<String, String> resultStu = readFilesAsMap(fileStu);
|
Map<String, String> resultStu = readFilesAsMap(fileStu);
|
||||||
try (Connection conn = DriverManager.getConnection(stuDbUrl, user, password);
|
try (Connection conn = DriverManager.getConnection(stuDbUrl, user, password);
|
||||||
Statement stmt = conn.createStatement()) {
|
Statement stmt = conn.createStatement()) {
|
||||||
@@ -695,11 +710,23 @@ public class MysqlServericeImpl implements IMysqlServerice {
|
|||||||
System.out.println("无效的 totalKeyScore 值:" + totalKeyScore);
|
System.out.println("无效的 totalKeyScore 值:" + totalKeyScore);
|
||||||
}
|
}
|
||||||
appendToFile(answerLogPath, "共得分:"+roundedResult);
|
appendToFile(answerLogPath, "共得分:"+roundedResult);
|
||||||
|
folderzip.delete();
|
||||||
|
deleteFolder(folder);
|
||||||
return roundedResult;
|
return roundedResult;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public static void deleteFolder(File folder) {
|
||||||
|
if (folder.isDirectory()) {
|
||||||
|
File[] files = folder.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
deleteFolder(file); // 递归删除所有子文件/文件夹
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
folder.delete(); // 删除空文件夹或文件
|
||||||
|
}
|
||||||
|
|
||||||
private static void accumulateScoreAndLog(List<ExamMysqlKeyword> examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score) {
|
private static void accumulateScoreAndLog(List<ExamMysqlKeyword> examMysqlKeywordList, AtomicInteger total, String answerLogPath, String sql2, String totalKeyScore, double score) {
|
||||||
AtomicInteger singleTotal = new AtomicInteger(); // 单独累加 scoreRateStr 的总和
|
AtomicInteger singleTotal = new AtomicInteger(); // 单独累加 scoreRateStr 的总和
|
||||||
|
@@ -272,10 +272,10 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
|||||||
}
|
}
|
||||||
// wps 类型存在多级文文件夹,需要个性化设置
|
// wps 类型存在多级文文件夹,需要个性化设置
|
||||||
if (one_file.getName().split("\\.")[0].equals("WPS文字")) {
|
if (one_file.getName().split("\\.")[0].equals("WPS文字")) {
|
||||||
double wps_word_score = judgementWpsWordService.judgementWpsWord(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
double wps_word_score = judgementWpsWordService.judgementWpsWord(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
||||||
score += wps_word_score;
|
score += wps_word_score;
|
||||||
System.out.println(wps_word_score+"wps_word得分");
|
System.out.println(wps_word_score+"wps_word得分");
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
if (one_file.getName().split("\\.")[0].equals("WPS演示")) {
|
if (one_file.getName().split("\\.")[0].equals("WPS演示")) {
|
||||||
double wps_pptx_score = judgementWpsPptxService.judgementWpsPptx(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
double wps_pptx_score = judgementWpsPptxService.judgementWpsPptx(15.0, one_file.getPath(), file_one.getPath(), examQuestion);
|
||||||
@@ -333,11 +333,23 @@ public class AutoToolsServiceImpl implements AutoToolsService{
|
|||||||
// 更新学生分数
|
// 更新学生分数
|
||||||
// endStuMonitorUtils.endStuMonitor(String.valueOf(stuId),paperId,score);
|
// endStuMonitorUtils.endStuMonitor(String.valueOf(stuId),paperId,score);
|
||||||
// end、删除文件
|
// end、删除文件
|
||||||
|
System.out.println(stuFilePath);
|
||||||
zip_file.delete();
|
zip_file.delete();
|
||||||
folder.delete();
|
// folder.delete();
|
||||||
|
deleteFolder(folder);
|
||||||
return CommonResult.success(score);
|
return CommonResult.success(score);
|
||||||
}
|
}
|
||||||
|
public static void deleteFolder(File folder) {
|
||||||
|
if (folder.isDirectory()) {
|
||||||
|
File[] files = folder.listFiles();
|
||||||
|
if (files != null) {
|
||||||
|
for (File file : files) {
|
||||||
|
deleteFolder(file); // 递归删除所有子文件/文件夹
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
folder.delete(); // 删除空文件夹或文件
|
||||||
|
}
|
||||||
/**
|
/**
|
||||||
* 读取学生选择题答案
|
* 读取学生选择题答案
|
||||||
* @param filePath 文件路径
|
* @param filePath 文件路径
|
||||||
|
@@ -57,7 +57,12 @@ public class JudgementWpsExcelServiceImpl implements JudgementWpsExcelService {
|
|||||||
@Override
|
@Override
|
||||||
public double judgementWpsXlsx(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception {
|
public double judgementWpsXlsx(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception {
|
||||||
// 1创建log文件txt,用于记录
|
// 1创建log文件txt,用于记录
|
||||||
LogFileUtils.createFile(pathC + "/WPS_Xlsx判分过程.txt");
|
File pathCDir = new File(pathC);
|
||||||
|
File parentDir = pathCDir.getParentFile();
|
||||||
|
|
||||||
|
// 拼接同级目录下的目标文件路径
|
||||||
|
String targetFilePath = new File(parentDir, "WPS_Xlsx判分过程.txt").getPath();
|
||||||
|
LogFileUtils.createFile(targetFilePath);
|
||||||
LogFileUtils.writeLine("✅ 开始WPS_Xlsx判分");
|
LogFileUtils.writeLine("✅ 开始WPS_Xlsx判分");
|
||||||
double wpsXlsxScore = 0;
|
double wpsXlsxScore = 0;
|
||||||
List<XlsxInfoVo> margins = WpsExcelUtils.wpsExcel(path);
|
List<XlsxInfoVo> margins = WpsExcelUtils.wpsExcel(path);
|
||||||
|
@@ -59,8 +59,15 @@ public class JudgementWpsPptxServiceImpl implements JudgementWpsPptxService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public double judgementWpsPptx(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception {
|
public double judgementWpsPptx(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception {
|
||||||
|
|
||||||
|
// 创建log文件txt,用于记录
|
||||||
|
File pathCDir = new File(pathC);
|
||||||
|
File parentDir = pathCDir.getParentFile();
|
||||||
|
|
||||||
|
// 拼接同级目录下的目标文件路径
|
||||||
|
String targetFilePath = new File(parentDir, "WPS_Pptx判分过程.txt").getPath();
|
||||||
// 1创建log文件txt,用于记录
|
// 1创建log文件txt,用于记录
|
||||||
LogFileUtils.createFile(pathC + "/WPS_Pptx判分过程.txt");
|
LogFileUtils.createFile(targetFilePath);
|
||||||
LogFileUtils.writeLine("✅ 开始WPS_Pptx判分");
|
LogFileUtils.writeLine("✅ 开始WPS_Pptx判分");
|
||||||
double wpsPptScore = 0;
|
double wpsPptScore = 0;
|
||||||
// 2、pptx文件读取并返回考点及说明信息
|
// 2、pptx文件读取并返回考点及说明信息
|
||||||
|
@@ -57,7 +57,12 @@ public class JudgementWpsWordServiceImpl implements JudgementWpsWordService {
|
|||||||
@Override
|
@Override
|
||||||
public double judgementWpsWord(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception {
|
public double judgementWpsWord(double sorce, String pathC, String path, ExamQuestion examQuestion) throws Exception {
|
||||||
// 创建log文件txt,用于记录
|
// 创建log文件txt,用于记录
|
||||||
LogFileUtils.createFile(pathC + "/WPS_Word判分过程.txt");
|
File pathCDir = new File(pathC);
|
||||||
|
File parentDir = pathCDir.getParentFile();
|
||||||
|
|
||||||
|
// 拼接同级目录下的目标文件路径
|
||||||
|
String targetFilePath = new File(parentDir, "WPS_Word判分过程.txt").getPath();
|
||||||
|
LogFileUtils.createFile(targetFilePath);
|
||||||
LogFileUtils.writeLine("✅ 开始WPS_Word判分");
|
LogFileUtils.writeLine("✅ 开始WPS_Word判分");
|
||||||
double wps_word_sorce = 0;
|
double wps_word_sorce = 0;
|
||||||
// 1、查询Word考点tree
|
// 1、查询Word考点tree
|
||||||
|
Reference in New Issue
Block a user