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

Merge Request: 【修改】删除配置文件定时任务限制,【新增】浏览器考点设置

Created By: @华允传
Accepted By: @华允传
URL: https://g-iswv8783.coding.net/p/education/d/pengchen-exam-java/git/merge/80?initial=true
This commit is contained in:
华允传
2025-05-25 00:20:59 +08:00
committed by Coding
6 changed files with 167 additions and 94 deletions

View File

@@ -207,7 +207,22 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
@Override @Override
public List<String> getKeywords() { public List<String> getKeywords() {
return educationPaperTaskMapper.getKeywords(); List<String> keywords = educationPaperTaskMapper.getKeywords();
// 使用 Set 去重
Set<String> keywordSet = new HashSet<>();
for (String keywordStr : keywords) {
if (keywordStr != null && !keywordStr.trim().isEmpty()) {
String[] split = keywordStr.split(",");
for (String kw : split) {
String trimmed = kw.trim();
if (!trimmed.isEmpty()) {
keywordSet.add(trimmed);
}
}
}
}
return new ArrayList<>(keywordSet);
} }
@Override @Override

View File

@@ -202,34 +202,55 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList(); List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList();
List<SysFileUpload> fileUploads = examQuestion.getFileUploads(); List<SysFileUpload> fileUploads = examQuestion.getFileUploads();
ExamQuestionScore questionScore = examQuestion.getQuestionScores(); ExamQuestionScore questionScore = examQuestion.getQuestionScores();
List<ExamQuestionKeyword> examQuestionKeywords = examQuestion.getQuestionKeywords(); List<ExamQuestionKeyword> examQuestionKeywords = examQuestion.getQuestionKeywords();
if (answerList!=null&&answerList.size()>0){ if (!(("Mysql".equals(examQuestion.getCourseName()))&&("程序设计".equals(examQuestion.getSubjectName())))){
// 获取集合中第一个元素的quId if (answerList!=null&&answerList.size()>0){
String firstQuId = answerList.get(0).getQuId(); //先删除试题的答案
//先删除试题的答案 examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId());
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(firstQuId); //赋值
//赋值 answerList.replaceAll(answer -> {
answerList.replaceAll(answer -> { answer.setAnswerId(IdUtils.simpleUUID());
answer.setAnswerId(IdUtils.simpleUUID()); answer.setQuId(examQuestion.getQuId());
answer.setQuId(firstQuId); return answer;
return answer; });
}); //插入试题答案
//插入试题答案 examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
}
} }
if (fileUploads!=null&&fileUploads.size()>0){ if (fileUploads!=null&&fileUploads.size()>0){
// 获取集合中第一个元素的quId
String firstQuId = fileUploads.get(0).getQuId();
//先删除试题的答案 //先删除试题的答案
sysFileMapper.deleteSysFileByQuesId(firstQuId); sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId());
//赋值 //赋值
fileUploads.replaceAll(fileUpload -> { fileUploads.replaceAll(fileUpload -> {
// 设置文件名(如果文件名为空)
if (!StringUtils.isNotBlank(fileUpload.getFileName())) {
switch (fileUpload.getFileType()) {
case "0":
fileUpload.setFileName("素材");
break;
case "1":
fileUpload.setFileName("原始");
break;
case "2":
fileUpload.setFileName("结果");
break;
default:
fileUpload.setFileName(null);
break;
}
}
if (StringUtils.isNotBlank(fileUpload.getFileName())) {
fileUpload.setFileName(null);
}
// 设置 fileId 和 quId
fileUpload.setFileId(IdUtils.simpleUUID()); fileUpload.setFileId(IdUtils.simpleUUID());
fileUpload.setQuId(firstQuId); fileUpload.setQuId(examQuestion.getQuId());
return fileUpload; return fileUpload;
}); });
//插入试题答案 //插入试题答案
@@ -237,22 +258,20 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
} }
if (questionScore!=null){ if (questionScore!=null){
String firstQuId = questionScore.getQuId();
//先删除试题的判分 //先删除试题的判分
examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(firstQuId); examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
//赋值 //赋值
questionScore.setScoreId(IdUtils.simpleUUID()); questionScore.setScoreId(IdUtils.simpleUUID());
questionScore.setQuId(firstQuId); questionScore.setQuId(examQuestion.getQuId());
examQuestionScoreMapper.insertExamQuestionScore(questionScore); examQuestionScoreMapper.insertExamQuestionScore(questionScore);
} }
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){ if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
String firstQuId = questionScore.getQuId();
//先删除试题的判分 //先删除试题的判分
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(firstQuId); examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
//赋值 //赋值
examQuestionKeywords.replaceAll(examQuestionKeyword -> { examQuestionKeywords.replaceAll(examQuestionKeyword -> {
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID()); examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
examQuestionKeyword.setQuId(firstQuId); examQuestionKeyword.setQuId(examQuestion.getQuId());
return examQuestionKeyword; return examQuestionKeyword;
}); });
examQuestionKeywordMapper.insertExamQuestionKeywordList(examQuestionKeywords); examQuestionKeywordMapper.insertExamQuestionKeywordList(examQuestionKeywords);
@@ -416,14 +435,17 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
for (QuestionExamineDO questionExamineDO : list) { for (QuestionExamineDO questionExamineDO : list) {
String schoolName =questionExamineMapper.selectSchoolName(questionExamineDO.getSource()); String schoolName =questionExamineMapper.selectSchoolName(questionExamineDO.getSource());
ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(questionExamineDO.getQuId()); ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(questionExamineDO.getQuId());
examQuestion.setCreateTeacher(questionExamineDO.getCreateTeacher()); if (examQuestion!=null){
examQuestion.setSchoolName(schoolName); examQuestion.setCreateTeacher(questionExamineDO.getCreateTeacher());
examQuestion.setSource(questionExamineDO.getSource()); examQuestion.setSchoolName(schoolName);
examQuestion.setType(questionExamineDO.getType()); examQuestion.setSource(questionExamineDO.getSource());
examQuestion.setCreateTime(questionExamineDO.getCreateTime()); examQuestion.setType(questionExamineDO.getType());
examQuestion.setUpdateTime(questionExamineDO.getUpdateTime()); examQuestion.setCreateTime(questionExamineDO.getCreateTime());
examQuestion.setUpdater(questionExamineDO.getUpdater()); examQuestion.setUpdateTime(questionExamineDO.getUpdateTime());
examQuestionList.add(examQuestion); examQuestion.setUpdater(questionExamineDO.getUpdater());
examQuestionList.add(examQuestion);
}
} }
} }
PageResult<ExamQuestion> examQuestionPageResult=new PageResult<>(); PageResult<ExamQuestion> examQuestionPageResult=new PageResult<>();

View File

@@ -27,7 +27,7 @@ public class GetPointsController {
return CommonResult.success(examGetPointsService.get_file_point(pointsVo)); return CommonResult.success(examGetPointsService.get_file_point(pointsVo));
} }
/** /**
* 得出MYSQL操作考点 * 文件得出MYSQL操作考点
* @return 得分 * @return 得分
*/ */
@PostMapping("/get_mysql_point") @PostMapping("/get_mysql_point")
@@ -38,12 +38,12 @@ public class GetPointsController {
* 新增MYSQL操作考点 * 新增MYSQL操作考点
* @return 得分 * @return 得分
*/ */
@PostMapping("/set_mysql_point") // @PostMapping("/set_mysql_point")
public CommonResult set_mysql_point(@RequestBody Points points) { // public CommonResult set_mysql_point(@RequestBody Points points) {
return CommonResult.success(examGetPointsService.set_mysql_point(points)); // return CommonResult.success(examGetPointsService.set_mysql_point(points));
} // }
/** /**
* 更新MYSQL操作考点 * 新增/更新MYSQL操作考点
* @return 得分 * @return 得分
*/ */
@PostMapping("/update_mysql_point") @PostMapping("/update_mysql_point")
@@ -56,12 +56,12 @@ public class GetPointsController {
return CommonResult.success(examGetPointsService.getPointById(quId)); return CommonResult.success(examGetPointsService.getPointById(quId));
} }
/** /**
* 得出浏览器操作考点 * 新增修改浏览器操作考点
* @return 得分 * @return 得分
*/ */
@PostMapping("/get_browser_point") @PostMapping("/set_browser_point")
//todo 老师自己设置,不读文件 //todo 老师自己设置,不读文件
public CommonResult get_browser_point(@RequestBody List<ExamQuestionAnswer> examQuestionAnswers) throws IOException { public CommonResult get_browser_point(@RequestBody Points points) {
return CommonResult.success(examGetPointsService.get_browser_point()); return CommonResult.success(examGetPointsService.get_browser_point(points));
} }
} }

View File

@@ -15,9 +15,9 @@ public interface ExamGetPointsService {
List<String> get_mysql_point(PointsVo pointsVo) throws IOException; List<String> get_mysql_point(PointsVo pointsVo) throws IOException;
List<ExamQuestionAnswer> get_browser_point(); boolean get_browser_point(Points points);
boolean set_mysql_point(Points points); // boolean set_mysql_point(Points points);
boolean update_mysql_point(Points points); boolean update_mysql_point(Points points);

View File

@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import jakarta.annotation.Resource; import jakarta.annotation.Resource;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.collections4.CollectionUtils;
import org.apache.ibatis.executor.BatchResult;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
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.ExamQuestionAnswer; import pc.exam.pp.module.exam.dal.dataobject.ExamQuestionAnswer;
@@ -90,13 +91,12 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
}) })
.sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序 .sorted(Comparator.comparingInt(answer -> Integer.parseInt(answer.getSort()))) // 按 sort 排序
.collect(Collectors.toList()); .collect(Collectors.toList());
answerList.addAll(formattedDifferences); answerList.addAll(formattedDifferences);
// zip_file_sth.delete(); zip_file_sth.delete();
// zip_file_answer.delete(); zip_file_answer.delete();
// folderStu.delete(); deleteFolder(folderStu);
// folderAnswer.delete(); deleteFolder(folderAnswer);
return answerList;
return answerList;
} }
@Override @Override
@@ -107,10 +107,23 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
ConfigDO config = configService.getConfigByKey("file_down_path"); ConfigDO config = configService.getConfigByKey("file_down_path");
String sthPath = ZipUtil.downloadStudentFile(pointsVo.getAnswerPath(), config.getValue()); String sthPath = ZipUtil.downloadStudentFile(pointsVo.getAnswerPath(), config.getValue());
System.out.println(sthPath);
List<String> sqlStatements = readSQLFromFile(sthPath); List<String> sqlStatements = readSQLFromFile(sthPath);
File zip_file = new File(sthPath);
zip_file.delete();
return sqlStatements; return sqlStatements;
} }
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 List<String> readSQLFromFile(String filePath) throws IOException { private static List<String> readSQLFromFile(String filePath) throws IOException {
@@ -163,45 +176,67 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
return sqlList; return sqlList;
} }
@Override @Override
public List<ExamQuestionAnswer> get_browser_point() { public boolean get_browser_point(Points points) {
return null;
}
@Override
public boolean set_mysql_point(Points points) {
try { try {
List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList(); String quId = points.getQuId();
if (CollectionUtils.isEmpty(questionAnswerList)) { examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(quId);
// 如果没有新数据就返回
if (CollectionUtils.isEmpty(points.getQuestionAnswerList())) {
return true; return true;
} }
List<ExamMysqlKeyword> allKeywords = new ArrayList<>(); //设置sort
AtomicInteger sortCounter = new AtomicInteger(1);
points.getQuestionAnswerList().forEach(answer -> {
answer.setSort(String.valueOf(sortCounter.getAndIncrement()));
});
List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) { for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) {
String answerId = IdUtils.simpleUUID(); examQuestionAnswer.setAnswerId(IdUtils.simpleUUID());
examQuestionAnswer.setAnswerId(answerId);
examQuestionAnswer.setQuId(points.getQuId());
List<ExamMysqlKeyword> keywordList = examQuestionAnswer.getExamMysqlKeywordList();
if (!CollectionUtils.isEmpty(keywordList)) {
for (ExamMysqlKeyword keyword : keywordList) {
keyword.setAnswerId(answerId);
keyword.setKeywordId(IdUtils.simpleUUID());
}
allKeywords.addAll(keywordList);
}
} }
examQuestionAnswerMapper.insertExamQuestionAnswerList(questionAnswerList);
if (!CollectionUtils.isEmpty(allKeywords)) {
mysqlKeywordMapper.insertOrUpdate(allKeywords);
}
examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
return true; return true;
} catch (Exception e) { } catch (Exception e) {
log.error("保存考试点信息失败", e); throw new RuntimeException(e);
return false;
} }
} }
// @Override
// public boolean set_mysql_point(Points points) {
// try {
// List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
// if (CollectionUtils.isEmpty(questionAnswerList)) {
// return true;
// }
// List<ExamMysqlKeyword> allKeywords = new ArrayList<>();
//
// for (ExamQuestionAnswer examQuestionAnswer : questionAnswerList) {
// String answerId = IdUtils.simpleUUID();
// examQuestionAnswer.setAnswerId(answerId);
// examQuestionAnswer.setQuId(points.getQuId());
// List<ExamMysqlKeyword> keywordList = examQuestionAnswer.getExamMysqlKeywordList();
// if (!CollectionUtils.isEmpty(keywordList)) {
// for (ExamMysqlKeyword keyword : keywordList) {
// keyword.setAnswerId(answerId);
// keyword.setKeywordId(IdUtils.simpleUUID());
// }
// allKeywords.addAll(keywordList);
// }
// }
//
// if (!CollectionUtils.isEmpty(allKeywords)) {
// mysqlKeywordMapper.insertOrUpdate(allKeywords);
// }
//
// examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
// return true;
// } catch (Exception e) {
// log.error("保存考试点信息失败", e);
// return false;
// }
// }
@Override @Override
public boolean update_mysql_point(Points points) { public boolean update_mysql_point(Points points) {
try { try {
@@ -227,11 +262,12 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
// 新的 keyword 收集 // 新的 keyword 收集
List<ExamMysqlKeyword> newKeywordList = new ArrayList<>(); List<ExamMysqlKeyword> newKeywordList = new ArrayList<>();
AtomicInteger counter = new AtomicInteger(0);
for (ExamQuestionAnswer answer : questionAnswerList) { for (ExamQuestionAnswer answer : questionAnswerList) {
String answerId = IdUtils.simpleUUID(); String answerId = IdUtils.simpleUUID();
answer.setAnswerId(answerId); answer.setAnswerId(answerId);
answer.setQuId(quId); // 以防前端未传 answer.setQuId(quId); // 以防前端未传
answer.setSort(String.valueOf(counter.getAndIncrement())); // 设置排序字段String 类型)
List<ExamMysqlKeyword> keywordList = answer.getExamMysqlKeywordList(); List<ExamMysqlKeyword> keywordList = answer.getExamMysqlKeywordList();
if (!CollectionUtils.isEmpty(keywordList)) { if (!CollectionUtils.isEmpty(keywordList)) {
for (ExamMysqlKeyword keyword : keywordList) { for (ExamMysqlKeyword keyword : keywordList) {
@@ -243,9 +279,9 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
} }
// 插入新答案和关键词 // 插入新答案和关键词
examQuestionAnswerMapper.insertOrUpdate(questionAnswerList); examQuestionAnswerMapper.insert(questionAnswerList);
if (!CollectionUtils.isEmpty(newKeywordList)) { if (!CollectionUtils.isEmpty(newKeywordList)) {
mysqlKeywordMapper.insertOrUpdate(newKeywordList); mysqlKeywordMapper.insert(newKeywordList);
} }
return true; return true;

View File

@@ -5,7 +5,6 @@ server:
spring: spring:
autoconfigure: autoconfigure:
exclude: exclude:
- org.springframework.boot.autoconfigure.quartz.QuartzAutoConfiguration # 默认 local 环境,不开启 Quartz 的自动配置
- de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置 - de.codecentric.boot.admin.server.config.AdminServerAutoConfiguration # 禁用 Spring Boot Admin 的 Server 的自动配置
- de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置 - de.codecentric.boot.admin.server.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置 - de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
@@ -65,9 +64,9 @@ spring:
# password: Exam@2024 # OpenGauss 连接的示例 # password: Exam@2024 # OpenGauss 连接的示例
slave: # 模拟从库,可根据自己需要修改 slave: # 模拟从库,可根据自己需要修改
lazy: true # 开启懒加载,保证启动速度 lazy: true # 开启懒加载,保证启动速度
url: jdbc:mysql://127.0.0.1:3306/pc-exam?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true url: jdbc:mysql://rm-bp1a44uap1mm20980mo.mysql.rds.aliyuncs.com:3306/exam-mysql?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
username: root username: pc_exam
password: 123 password: Pcexam123
# tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!) # tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!)
# url: jdbc:TAOS-RS://127.0.0.1:6041/ruoyi_vue_pro # url: jdbc:TAOS-RS://127.0.0.1:6041/ruoyi_vue_pro
# driver-class-name: com.taosdata.jdbc.rs.RestfulDriver # driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
@@ -79,10 +78,10 @@ spring:
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优 # Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
data: data:
redis: redis:
host: 127.0.0.1 # 地址 host: 47.101.60.131 # 地址
port: 6379 # 端口 port: 6379 # 端口
database: 15 # 数据库索引 database: 0 # 数据库索引
password: 250250 # 密码,建议生产环境开启 password: sadjklasnfasd # 密码,建议生产环境开启
--- #################### 定时任务相关配置 #################### --- #################### 定时任务相关配置 ####################
@@ -124,10 +123,11 @@ rocketmq:
spring: spring:
# RabbitMQ 配置项,对应 RabbitProperties 配置类 # RabbitMQ 配置项,对应 RabbitProperties 配置类
rabbitmq: rabbitmq:
host: 127.0.0.1 # RabbitMQ 服务的地址 host: 47.101.60.131 # RabbitMQ 服务的地址
port: 5672 # RabbitMQ 服务的端口 port: 5672 # RabbitMQ 服务的端口
username: guest # RabbitMQ 服务的账号 username: admin # RabbitMQ 服务的账号
password: guest # RabbitMQ 服务的密码 password: fctBGJYD # RabbitMQ 服务的密码
virtualHost: /exam_questions
# Kafka 配置项,对应 KafkaProperties 配置类 # Kafka 配置项,对应 KafkaProperties 配置类
kafka: kafka:
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔 bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔