【修改】删除配置文件定时任务限制,【新增】浏览器考点设置
This commit is contained in:
@@ -207,7 +207,22 @@ public class EducationPaperTaskServiceImpl implements IEducationPaperTaskService
|
||||
|
||||
@Override
|
||||
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
|
||||
|
@@ -202,34 +202,55 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
|
||||
|
||||
|
||||
|
||||
List<ExamQuestionAnswer> answerList = examQuestion.getAnswerList();
|
||||
List<SysFileUpload> fileUploads = examQuestion.getFileUploads();
|
||||
ExamQuestionScore questionScore = examQuestion.getQuestionScores();
|
||||
List<ExamQuestionKeyword> examQuestionKeywords = examQuestion.getQuestionKeywords();
|
||||
if (answerList!=null&&answerList.size()>0){
|
||||
// 获取集合中第一个元素的quId
|
||||
String firstQuId = answerList.get(0).getQuId();
|
||||
//先删除试题的答案
|
||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(firstQuId);
|
||||
//赋值
|
||||
answerList.replaceAll(answer -> {
|
||||
answer.setAnswerId(IdUtils.simpleUUID());
|
||||
answer.setQuId(firstQuId);
|
||||
return answer;
|
||||
});
|
||||
//插入试题答案
|
||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
||||
if (!(("Mysql".equals(examQuestion.getCourseName()))&&("程序设计".equals(examQuestion.getSubjectName())))){
|
||||
if (answerList!=null&&answerList.size()>0){
|
||||
//先删除试题的答案
|
||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(examQuestion.getQuId());
|
||||
//赋值
|
||||
answerList.replaceAll(answer -> {
|
||||
answer.setAnswerId(IdUtils.simpleUUID());
|
||||
answer.setQuId(examQuestion.getQuId());
|
||||
return answer;
|
||||
});
|
||||
//插入试题答案
|
||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(answerList);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
if (fileUploads!=null&&fileUploads.size()>0){
|
||||
// 获取集合中第一个元素的quId
|
||||
String firstQuId = fileUploads.get(0).getQuId();
|
||||
//先删除试题的答案
|
||||
sysFileMapper.deleteSysFileByQuesId(firstQuId);
|
||||
sysFileMapper.deleteSysFileByQuesId(examQuestion.getQuId());
|
||||
//赋值
|
||||
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.setQuId(firstQuId);
|
||||
fileUpload.setQuId(examQuestion.getQuId());
|
||||
return fileUpload;
|
||||
});
|
||||
//插入试题答案
|
||||
@@ -237,22 +258,20 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
|
||||
}
|
||||
if (questionScore!=null){
|
||||
String firstQuId = questionScore.getQuId();
|
||||
//先删除试题的判分
|
||||
examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(firstQuId);
|
||||
examQuestionScoreMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
||||
//赋值
|
||||
questionScore.setScoreId(IdUtils.simpleUUID());
|
||||
questionScore.setQuId(firstQuId);
|
||||
questionScore.setQuId(examQuestion.getQuId());
|
||||
examQuestionScoreMapper.insertExamQuestionScore(questionScore);
|
||||
}
|
||||
if (examQuestionKeywords!=null&&examQuestionKeywords.size()>0){
|
||||
String firstQuId = questionScore.getQuId();
|
||||
//先删除试题的判分
|
||||
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(firstQuId);
|
||||
examQuestionKeywordMapper.deleteExamQuestionScoreByQuesId(examQuestion.getQuId());
|
||||
//赋值
|
||||
examQuestionKeywords.replaceAll(examQuestionKeyword -> {
|
||||
examQuestionKeyword.setKeywordId(IdUtils.simpleUUID());
|
||||
examQuestionKeyword.setQuId(firstQuId);
|
||||
examQuestionKeyword.setQuId(examQuestion.getQuId());
|
||||
return examQuestionKeyword;
|
||||
});
|
||||
examQuestionKeywordMapper.insertExamQuestionKeywordList(examQuestionKeywords);
|
||||
@@ -416,14 +435,17 @@ public class ExamQuestionServiceImpl implements IExamQuestionService
|
||||
for (QuestionExamineDO questionExamineDO : list) {
|
||||
String schoolName =questionExamineMapper.selectSchoolName(questionExamineDO.getSource());
|
||||
ExamQuestion examQuestion = examQuestionMapper.selectExamQuestionByQuId(questionExamineDO.getQuId());
|
||||
examQuestion.setCreateTeacher(questionExamineDO.getCreateTeacher());
|
||||
examQuestion.setSchoolName(schoolName);
|
||||
examQuestion.setSource(questionExamineDO.getSource());
|
||||
examQuestion.setType(questionExamineDO.getType());
|
||||
examQuestion.setCreateTime(questionExamineDO.getCreateTime());
|
||||
examQuestion.setUpdateTime(questionExamineDO.getUpdateTime());
|
||||
examQuestion.setUpdater(questionExamineDO.getUpdater());
|
||||
examQuestionList.add(examQuestion);
|
||||
if (examQuestion!=null){
|
||||
examQuestion.setCreateTeacher(questionExamineDO.getCreateTeacher());
|
||||
examQuestion.setSchoolName(schoolName);
|
||||
examQuestion.setSource(questionExamineDO.getSource());
|
||||
examQuestion.setType(questionExamineDO.getType());
|
||||
examQuestion.setCreateTime(questionExamineDO.getCreateTime());
|
||||
examQuestion.setUpdateTime(questionExamineDO.getUpdateTime());
|
||||
examQuestion.setUpdater(questionExamineDO.getUpdater());
|
||||
examQuestionList.add(examQuestion);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
PageResult<ExamQuestion> examQuestionPageResult=new PageResult<>();
|
||||
|
@@ -27,7 +27,7 @@ public class GetPointsController {
|
||||
return CommonResult.success(examGetPointsService.get_file_point(pointsVo));
|
||||
}
|
||||
/**
|
||||
* 得出MYSQL操作考点
|
||||
* 文件得出MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/get_mysql_point")
|
||||
@@ -38,12 +38,12 @@ public class GetPointsController {
|
||||
* 新增MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/set_mysql_point")
|
||||
public CommonResult set_mysql_point(@RequestBody Points points) {
|
||||
return CommonResult.success(examGetPointsService.set_mysql_point(points));
|
||||
}
|
||||
// @PostMapping("/set_mysql_point")
|
||||
// public CommonResult set_mysql_point(@RequestBody Points points) {
|
||||
// return CommonResult.success(examGetPointsService.set_mysql_point(points));
|
||||
// }
|
||||
/**
|
||||
* 更新MYSQL操作考点
|
||||
* 新增/更新MYSQL操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/update_mysql_point")
|
||||
@@ -56,12 +56,12 @@ public class GetPointsController {
|
||||
return CommonResult.success(examGetPointsService.getPointById(quId));
|
||||
}
|
||||
/**
|
||||
* 得出浏览器操作考点
|
||||
* 新增修改浏览器操作考点
|
||||
* @return 得分
|
||||
*/
|
||||
@PostMapping("/get_browser_point")
|
||||
@PostMapping("/set_browser_point")
|
||||
//todo 老师自己设置,不读文件
|
||||
public CommonResult get_browser_point(@RequestBody List<ExamQuestionAnswer> examQuestionAnswers) throws IOException {
|
||||
return CommonResult.success(examGetPointsService.get_browser_point());
|
||||
public CommonResult get_browser_point(@RequestBody Points points) {
|
||||
return CommonResult.success(examGetPointsService.get_browser_point(points));
|
||||
}
|
||||
}
|
||||
|
@@ -15,9 +15,9 @@ public interface ExamGetPointsService {
|
||||
|
||||
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);
|
||||
|
||||
|
@@ -4,6 +4,7 @@ import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
||||
import jakarta.annotation.Resource;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.apache.commons.collections4.CollectionUtils;
|
||||
import org.apache.ibatis.executor.BatchResult;
|
||||
import org.springframework.stereotype.Service;
|
||||
import pc.exam.pp.module.exam.dal.dataobject.ExamMysqlKeyword;
|
||||
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 排序
|
||||
.collect(Collectors.toList());
|
||||
answerList.addAll(formattedDifferences);
|
||||
// zip_file_sth.delete();
|
||||
// zip_file_answer.delete();
|
||||
// folderStu.delete();
|
||||
// folderAnswer.delete();
|
||||
|
||||
return answerList;
|
||||
answerList.addAll(formattedDifferences);
|
||||
zip_file_sth.delete();
|
||||
zip_file_answer.delete();
|
||||
deleteFolder(folderStu);
|
||||
deleteFolder(folderAnswer);
|
||||
return answerList;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -107,10 +107,23 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
ConfigDO config = configService.getConfigByKey("file_down_path");
|
||||
|
||||
String sthPath = ZipUtil.downloadStudentFile(pointsVo.getAnswerPath(), config.getValue());
|
||||
System.out.println(sthPath);
|
||||
List<String> sqlStatements = readSQLFromFile(sthPath);
|
||||
File zip_file = new File(sthPath);
|
||||
zip_file.delete();
|
||||
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 {
|
||||
|
||||
|
||||
@@ -163,45 +176,67 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
return sqlList;
|
||||
}
|
||||
@Override
|
||||
public List<ExamQuestionAnswer> get_browser_point() {
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean set_mysql_point(Points points) {
|
||||
public boolean get_browser_point(Points points) {
|
||||
try {
|
||||
List<ExamQuestionAnswer> questionAnswerList = points.getQuestionAnswerList();
|
||||
if (CollectionUtils.isEmpty(questionAnswerList)) {
|
||||
String quId = points.getQuId();
|
||||
examQuestionAnswerMapper.deleteExamQuestionAnswerByQuesId(quId);
|
||||
|
||||
// 如果没有新数据就返回
|
||||
if (CollectionUtils.isEmpty(points.getQuestionAnswerList())) {
|
||||
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) {
|
||||
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);
|
||||
}
|
||||
examQuestionAnswer.setAnswerId(IdUtils.simpleUUID());
|
||||
}
|
||||
|
||||
if (!CollectionUtils.isEmpty(allKeywords)) {
|
||||
mysqlKeywordMapper.insertOrUpdate(allKeywords);
|
||||
}
|
||||
|
||||
examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
|
||||
examQuestionAnswerMapper.insertExamQuestionAnswerList(questionAnswerList);
|
||||
return true;
|
||||
} catch (Exception e) {
|
||||
log.error("保存考试点信息失败", e);
|
||||
return false;
|
||||
throw new RuntimeException(e);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// @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
|
||||
public boolean update_mysql_point(Points points) {
|
||||
try {
|
||||
@@ -227,11 +262,12 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
|
||||
// 新的 keyword 收集
|
||||
List<ExamMysqlKeyword> newKeywordList = new ArrayList<>();
|
||||
AtomicInteger counter = new AtomicInteger(0);
|
||||
for (ExamQuestionAnswer answer : questionAnswerList) {
|
||||
String answerId = IdUtils.simpleUUID();
|
||||
answer.setAnswerId(answerId);
|
||||
answer.setQuId(quId); // 以防前端未传
|
||||
|
||||
answer.setSort(String.valueOf(counter.getAndIncrement())); // 设置排序字段(String 类型)
|
||||
List<ExamMysqlKeyword> keywordList = answer.getExamMysqlKeywordList();
|
||||
if (!CollectionUtils.isEmpty(keywordList)) {
|
||||
for (ExamMysqlKeyword keyword : keywordList) {
|
||||
@@ -243,9 +279,9 @@ public class ExamGetPointsServiceImpl implements ExamGetPointsService{
|
||||
}
|
||||
|
||||
// 插入新答案和关键词
|
||||
examQuestionAnswerMapper.insertOrUpdate(questionAnswerList);
|
||||
examQuestionAnswerMapper.insert(questionAnswerList);
|
||||
if (!CollectionUtils.isEmpty(newKeywordList)) {
|
||||
mysqlKeywordMapper.insertOrUpdate(newKeywordList);
|
||||
mysqlKeywordMapper.insert(newKeywordList);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@@ -5,7 +5,6 @@ server:
|
||||
spring:
|
||||
autoconfigure:
|
||||
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.ui.config.AdminServerUiAutoConfiguration # 禁用 Spring Boot Admin 的 Server UI 的自动配置
|
||||
- de.codecentric.boot.admin.client.config.SpringBootAdminClientAutoConfiguration # 禁用 Spring Boot Admin 的 Client 的自动配置
|
||||
@@ -65,9 +64,9 @@ spring:
|
||||
# password: Exam@2024 # OpenGauss 连接的示例
|
||||
slave: # 模拟从库,可根据自己需要修改
|
||||
lazy: true # 开启懒加载,保证启动速度
|
||||
url: jdbc:mysql://127.0.0.1:3306/pc-exam?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
|
||||
username: root
|
||||
password: 123
|
||||
url: jdbc:mysql://rm-bp1a44uap1mm20980mo.mysql.rds.aliyuncs.com:3306/exam-mysql?useSSL=false&serverTimezone=Asia/Shanghai&allowPublicKeyRetrieval=true&rewriteBatchedStatements=true&nullCatalogMeansCurrent=true
|
||||
username: pc_exam
|
||||
password: Pcexam123
|
||||
# tdengine: # IoT 数据库(需要 IoT 物联网再开启噢!)
|
||||
# url: jdbc:TAOS-RS://127.0.0.1:6041/ruoyi_vue_pro
|
||||
# driver-class-name: com.taosdata.jdbc.rs.RestfulDriver
|
||||
@@ -79,10 +78,10 @@ spring:
|
||||
# Redis 配置。Redisson 默认的配置足够使用,一般不需要进行调优
|
||||
data:
|
||||
redis:
|
||||
host: 127.0.0.1 # 地址
|
||||
host: 47.101.60.131 # 地址
|
||||
port: 6379 # 端口
|
||||
database: 15 # 数据库索引
|
||||
password: 250250 # 密码,建议生产环境开启
|
||||
database: 0 # 数据库索引
|
||||
password: sadjklasnfasd # 密码,建议生产环境开启
|
||||
|
||||
--- #################### 定时任务相关配置 ####################
|
||||
|
||||
@@ -124,10 +123,11 @@ rocketmq:
|
||||
spring:
|
||||
# RabbitMQ 配置项,对应 RabbitProperties 配置类
|
||||
rabbitmq:
|
||||
host: 127.0.0.1 # RabbitMQ 服务的地址
|
||||
host: 47.101.60.131 # RabbitMQ 服务的地址
|
||||
port: 5672 # RabbitMQ 服务的端口
|
||||
username: guest # RabbitMQ 服务的账号
|
||||
password: guest # RabbitMQ 服务的密码
|
||||
username: admin # RabbitMQ 服务的账号
|
||||
password: fctBGJYD # RabbitMQ 服务的密码
|
||||
virtualHost: /exam_questions
|
||||
# Kafka 配置项,对应 KafkaProperties 配置类
|
||||
kafka:
|
||||
bootstrap-servers: 127.0.0.1:9092 # 指定 Kafka Broker 地址,可以设置多个,以逗号分隔
|
||||
|
Reference in New Issue
Block a user