|
@@ -4247,6 +4247,54 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return new HashMap<>();
|
|
return new HashMap<>();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ //题目业务层次
|
|
|
|
|
+ QuestionBusinessImportVo importVo = JSON.parseObject(param, QuestionBusinessImportVo.class);
|
|
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService
|
|
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseEducationType>()
|
|
|
|
|
+ .eq(CourseEducationType::getEducationName, importVo.getEducationName())
|
|
|
|
|
+ .eq(CourseEducationType::getStatus, 1)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ CourseProjectType projectType = iCourseProjectTypeService.getOne(new LambdaUpdateWrapper<CourseProjectType>()
|
|
|
|
|
+ .eq(CourseProjectType::getEducationId, educationType.getId())
|
|
|
|
|
+ .eq(CourseProjectType::getProjectName, importVo.getProjectName())
|
|
|
|
|
+ .eq(CourseProjectType::getStatus, 1)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ CourseBusiness business = iCourseBusinessService.getOne(new LambdaUpdateWrapper<CourseBusiness>()
|
|
|
|
|
+ .eq(CourseBusiness::getProjectId, projectType.getId())
|
|
|
|
|
+ .eq(CourseBusiness::getBusinessName, importVo.getBusinessName())
|
|
|
|
|
+ .eq(CourseBusiness::getStatus, 1)
|
|
|
|
|
+ .last("limit 1"));
|
|
|
|
|
+ CourseSubject courseSubject = iCourseSubjectService.getOneByName(importVo.getSubjectName(),projectType.getId());
|
|
|
|
|
+
|
|
|
|
|
+ //试卷类型
|
|
|
|
|
+ ExamPaper paper = iExamPaperService.getOne(new LambdaUpdateWrapper<ExamPaper>().eq(ExamPaper::getPaperName, "普通练习").eq(ExamPaper::getStatus, 1).last("limit 1"));
|
|
|
|
|
+
|
|
|
|
|
+ //创建试卷
|
|
|
|
|
+ Exam exam = new Exam();
|
|
|
|
|
+ exam.setCode(ServletUtils.getEncoded("SJ"));
|
|
|
|
|
+ exam.setExamName(importVo.getExamName());
|
|
|
|
|
+ exam.setCreateTime(DateUtils.getNowTime());
|
|
|
|
|
+ exam.setUpdateTime(DateUtils.getNowTime());
|
|
|
|
|
+ exam.setStatus(1);
|
|
|
|
|
+ exam.setExamPaperId(paper.getPaperId());
|
|
|
|
|
+ exam.setYear(2025l);
|
|
|
|
|
+ exam.setPublishStatus(1l);
|
|
|
|
|
+ exam.setPrefixName("安管题库");
|
|
|
|
|
+ iExamService.save(exam);
|
|
|
|
|
+
|
|
|
|
|
+
|
|
|
|
|
+ //试卷业务层次
|
|
|
|
|
+ QuestionBusiness examBus = new QuestionBusiness();
|
|
|
|
|
+ examBus.setEducationTypeId(educationType.getId());
|
|
|
|
|
+ examBus.setProjectId(projectType.getId());
|
|
|
|
|
+ examBus.setBusinessId(business.getId());
|
|
|
|
|
+ examBus.setSubjectId(courseSubject.getId());
|
|
|
|
|
+ examBus.setMajorId(exam.getExamId());
|
|
|
|
|
+ examBus.setType(2);
|
|
|
|
|
+ iQuestionBusinessService.save(examBus);
|
|
|
|
|
+
|
|
|
|
|
+ //排序
|
|
|
|
|
+ Integer b = 1;
|
|
|
for (int i = 0; i < questionList2.size(); i++) {
|
|
for (int i = 0; i < questionList2.size(); i++) {
|
|
|
QuestionImportV4 questionImportV4 = questionList2.get(i);
|
|
QuestionImportV4 questionImportV4 = questionList2.get(i);
|
|
|
Integer a = 0;
|
|
Integer a = 0;
|
|
@@ -4261,9 +4309,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV = questionList2.subList(i, i + a);
|
|
List<QuestionImportV4> questionImportV = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
//第一个是内容
|
|
|
QuestionImportV4 v4 = questionImportV.get(0);
|
|
QuestionImportV4 v4 = questionImportV.get(0);
|
|
|
- question.setContent(v4.getQuestionName());
|
|
|
|
|
|
|
+ question.setContent(questionImage(v4.getQuestionName()));
|
|
|
question.setType(1);
|
|
question.setType(1);
|
|
|
- question.setAnswerQuestion(v4.getDescribe());
|
|
|
|
|
|
|
+ question.setAnalysisContent(v4.getDescribe());
|
|
|
question.setCode(ServletUtils.getEncoded("TM"));
|
|
question.setCode(ServletUtils.getEncoded("TM"));
|
|
|
//正确选项
|
|
//正确选项
|
|
|
Integer index = 0;
|
|
Integer index = 0;
|
|
@@ -4286,9 +4334,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV1 = questionList2.subList(i, i + a);
|
|
List<QuestionImportV4> questionImportV1 = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
//第一个是内容
|
|
|
QuestionImportV4 v41 = questionImportV1.get(0);
|
|
QuestionImportV4 v41 = questionImportV1.get(0);
|
|
|
- question.setContent(v41.getQuestionName());
|
|
|
|
|
|
|
+ question.setContent(questionImage(v41.getQuestionName()));
|
|
|
question.setType(2);
|
|
question.setType(2);
|
|
|
- question.setAnswerQuestion(v41.getDescribe());
|
|
|
|
|
|
|
+ question.setAnalysisContent(v41.getDescribe());
|
|
|
//正确选项
|
|
//正确选项
|
|
|
List<Integer> index1 = new ArrayList<>();
|
|
List<Integer> index1 = new ArrayList<>();
|
|
|
//转换单选选项
|
|
//转换单选选项
|
|
@@ -4310,9 +4358,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV2 = questionList2.subList(i, i + a);
|
|
List<QuestionImportV4> questionImportV2 = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
//第一个是内容
|
|
|
QuestionImportV4 v42 = questionImportV2.get(0);
|
|
QuestionImportV4 v42 = questionImportV2.get(0);
|
|
|
- question.setContent(v42.getQuestionName());
|
|
|
|
|
|
|
+ question.setContent(questionImage(v42.getQuestionName()));
|
|
|
question.setType(3);
|
|
question.setType(3);
|
|
|
- question.setAnswerQuestion(v42.getDescribe());
|
|
|
|
|
|
|
+ question.setAnalysisContent(v42.getDescribe());
|
|
|
//正确选项
|
|
//正确选项
|
|
|
Integer index2 = 0;
|
|
Integer index2 = 0;
|
|
|
//转换单选选项
|
|
//转换单选选项
|
|
@@ -4328,9 +4376,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV3 = questionList2.subList(i, i + a);
|
|
List<QuestionImportV4> questionImportV3 = questionList2.subList(i, i + a);
|
|
|
//第一个是内容
|
|
//第一个是内容
|
|
|
QuestionImportV4 v42 = questionImportV3.get(0);
|
|
QuestionImportV4 v42 = questionImportV3.get(0);
|
|
|
- question.setContent(v42.getQuestionName());
|
|
|
|
|
|
|
+ question.setContent(questionImage(v42.getQuestionName()));
|
|
|
question.setType(4);
|
|
question.setType(4);
|
|
|
- question.setAnswerQuestion(v42.getDescribe());
|
|
|
|
|
|
|
+ question.setAnalysisContent(v42.getDescribe());
|
|
|
//截取案例题小题
|
|
//截取案例题小题
|
|
|
List<QuestionImportV4> vv = new ArrayList<>();
|
|
List<QuestionImportV4> vv = new ArrayList<>();
|
|
|
for (int i1 = i+1; i1 < questionList2.size(); i1++) {
|
|
for (int i1 = i+1; i1 < questionList2.size(); i1++) {
|
|
@@ -4352,7 +4400,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV5 = vv.subList(i1, i1 + y);
|
|
List<QuestionImportV4> questionImportV5 = vv.subList(i1, i1 + y);
|
|
|
QuestionImportV4 questionImportV42 = questionImportV5.get(0);
|
|
QuestionImportV4 questionImportV42 = questionImportV5.get(0);
|
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
|
- questionInfoVo.setContent(questionImportV42.getQuestionName());
|
|
|
|
|
|
|
+ questionInfoVo.setContent(questionImage(questionImportV42.getQuestionName()));
|
|
|
questionInfoVo.setType(1);
|
|
questionInfoVo.setType(1);
|
|
|
//正确选项
|
|
//正确选项
|
|
|
Integer index = 0;
|
|
Integer index = 0;
|
|
@@ -4378,7 +4426,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV6 = vv.subList(i1, i1 + y);
|
|
List<QuestionImportV4> questionImportV6 = vv.subList(i1, i1 + y);
|
|
|
QuestionImportV4 questionImportV42 = questionImportV6.get(0);
|
|
QuestionImportV4 questionImportV42 = questionImportV6.get(0);
|
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
|
- questionInfoVo.setContent(questionImportV42.getQuestionName());
|
|
|
|
|
|
|
+ questionInfoVo.setContent(questionImage(questionImportV42.getQuestionName()));
|
|
|
questionInfoVo.setType(2);
|
|
questionInfoVo.setType(2);
|
|
|
//正确选项
|
|
//正确选项
|
|
|
List<Integer> index = new ArrayList<>();
|
|
List<Integer> index = new ArrayList<>();
|
|
@@ -4404,7 +4452,7 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
List<QuestionImportV4> questionImportV7 = vv.subList(i1, i1 + y);
|
|
List<QuestionImportV4> questionImportV7 = vv.subList(i1, i1 + y);
|
|
|
QuestionImportV4 questionImportV42 = questionImportV7.get(0);
|
|
QuestionImportV4 questionImportV42 = questionImportV7.get(0);
|
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
QuestionInfoVo questionInfoVo = new QuestionInfoVo();
|
|
|
- questionInfoVo.setContent(questionImportV42.getQuestionName());
|
|
|
|
|
|
|
+ questionInfoVo.setContent(questionImage(questionImportV42.getQuestionName()));
|
|
|
questionInfoVo.setType(3);
|
|
questionInfoVo.setType(3);
|
|
|
//正确选项
|
|
//正确选项
|
|
|
Integer index2 = 0;
|
|
Integer index2 = 0;
|
|
@@ -4427,24 +4475,6 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
question.setCreateTime(DateUtils.getNowTime());
|
|
question.setCreateTime(DateUtils.getNowTime());
|
|
|
question.setUpdateTime(DateUtils.getNowTime());
|
|
question.setUpdateTime(DateUtils.getNowTime());
|
|
|
save(question);
|
|
save(question);
|
|
|
- //题目业务层次
|
|
|
|
|
- QuestionBusinessImportVo importVo = JSON.parseObject(param, QuestionBusinessImportVo.class);
|
|
|
|
|
- CourseEducationType educationType = iCourseEducationTypeService
|
|
|
|
|
- .getOne(new LambdaQueryWrapper<CourseEducationType>()
|
|
|
|
|
- .eq(CourseEducationType::getEducationName, importVo.getEducationName())
|
|
|
|
|
- .eq(CourseEducationType::getStatus, 1)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- CourseProjectType projectType = iCourseProjectTypeService.getOne(new LambdaUpdateWrapper<CourseProjectType>()
|
|
|
|
|
- .eq(CourseProjectType::getEducationId, educationType.getId())
|
|
|
|
|
- .eq(CourseProjectType::getProjectName, importVo.getProjectName())
|
|
|
|
|
- .eq(CourseProjectType::getStatus, 1)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- CourseBusiness business = iCourseBusinessService.getOne(new LambdaUpdateWrapper<CourseBusiness>()
|
|
|
|
|
- .eq(CourseBusiness::getProjectId, projectType.getId())
|
|
|
|
|
- .eq(CourseBusiness::getBusinessName, importVo.getBusinessName())
|
|
|
|
|
- .eq(CourseBusiness::getStatus, 1)
|
|
|
|
|
- .last("limit 1"));
|
|
|
|
|
- CourseSubject courseSubject = iCourseSubjectService.getOneByName(importVo.getSubjectName(),projectType.getId());
|
|
|
|
|
QuestionBusiness business1 = new QuestionBusiness();
|
|
QuestionBusiness business1 = new QuestionBusiness();
|
|
|
business1.setEducationTypeId(educationType.getId());
|
|
business1.setEducationTypeId(educationType.getId());
|
|
|
business1.setProjectId(projectType.getId());
|
|
business1.setProjectId(projectType.getId());
|
|
@@ -4454,6 +4484,16 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
business1.setType(1);
|
|
business1.setType(1);
|
|
|
iQuestionBusinessService.save(business1);
|
|
iQuestionBusinessService.save(business1);
|
|
|
|
|
|
|
|
|
|
+
|
|
|
|
|
+ //试卷题库关联关系
|
|
|
|
|
+ ExamQuestion examQuestion = new ExamQuestion();
|
|
|
|
|
+ examQuestion.setExamId(exam.getExamId());
|
|
|
|
|
+ examQuestion.setQuestionId(question.getQuestionId());
|
|
|
|
|
+ examQuestion.setSort(b);
|
|
|
|
|
+ iExamQuestionService.save(examQuestion);
|
|
|
|
|
+
|
|
|
|
|
+ //重置排序
|
|
|
|
|
+ b = b+1;
|
|
|
//重置索引
|
|
//重置索引
|
|
|
i = i+a-1;
|
|
i = i+a-1;
|
|
|
}
|
|
}
|
|
@@ -4461,6 +4501,43 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
return Collections.emptyMap();
|
|
return Collections.emptyMap();
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ private String questionImage(String question){
|
|
|
|
|
+ //图片转换
|
|
|
|
|
+ Pattern pattern = Pattern.compile("src='(.*?)'");
|
|
|
|
|
+ Matcher matcher = pattern.matcher(question);
|
|
|
|
|
+ if (matcher.find()) {
|
|
|
|
|
+ String imagePath = matcher.group(1);
|
|
|
|
|
+ //下载图片
|
|
|
|
|
+ String ossPath = "";
|
|
|
|
|
+ //上传oss图片
|
|
|
|
|
+ try {
|
|
|
|
|
+ URL url = new URL(imagePath);
|
|
|
|
|
+ HttpURLConnection connection = (HttpURLConnection) url.openConnection();
|
|
|
|
|
+ connection.setRequestMethod("GET");
|
|
|
|
|
+ connection.setConnectTimeout(5000);
|
|
|
|
|
+ connection.setReadTimeout(5000);
|
|
|
|
|
+
|
|
|
|
|
+ // 检查响应码
|
|
|
|
|
+ int responseCode = connection.getResponseCode();
|
|
|
|
|
+ if (responseCode == HttpURLConnection.HTTP_OK) {
|
|
|
|
|
+ try (InputStream inputStream = connection.getInputStream()) {
|
|
|
|
|
+ String s = ossService.uploadInputStream(inputStream,6);
|
|
|
|
|
+ ossPath = ossHost + "/" + s;
|
|
|
|
|
+
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ connection.disconnect();
|
|
|
|
|
+ if (StringUtils.isNotBlank(ossPath)){
|
|
|
|
|
+ String updatedHtml = question.replaceAll("src='.*?'", "src='" +ossPath+ "'");
|
|
|
|
|
+ return updatedHtml;
|
|
|
|
|
+ }
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ throw new CustomException("oss图片上传失败");
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+ return question;
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
@Override
|
|
@Override
|
|
|
public Map<String, Object> importImage(List<QuestionImageVo> questionList2) {
|
|
public Map<String, Object> importImage(List<QuestionImageVo> questionList2) {
|
|
|
if (CollectionUtils.isEmpty(questionList2)){
|
|
if (CollectionUtils.isEmpty(questionList2)){
|