|
@@ -6,10 +6,12 @@ import cn.hutool.core.util.StrUtil;
|
|
|
import cn.hutool.http.HttpStatus;
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.CollectionUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.ObjectUtils;
|
|
|
+import com.baomidou.mybatisplus.core.toolkit.StringUtils;
|
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.Page;
|
|
@@ -17,37 +19,32 @@ import com.github.pagehelper.PageInfo;
|
|
|
import com.zhongzheng.common.core.page.TableDataInfo;
|
|
|
import com.zhongzheng.common.core.redis.RedisCache;
|
|
|
import com.zhongzheng.common.exception.CustomException;
|
|
|
+import com.zhongzheng.common.type.EncryptHandler;
|
|
|
import com.zhongzheng.common.utils.DateUtils;
|
|
|
import com.zhongzheng.common.utils.SecurityUtils;
|
|
|
import com.zhongzheng.common.utils.ServletUtils;
|
|
|
import com.zhongzheng.common.utils.ToolsUtils;
|
|
|
+import com.zhongzheng.common.utils.http.HttpUtils;
|
|
|
import com.zhongzheng.modules.alioss.service.OssService;
|
|
|
import com.zhongzheng.modules.bank.bo.*;
|
|
|
-import com.zhongzheng.modules.bank.domain.Exam;
|
|
|
-import com.zhongzheng.modules.bank.domain.ExamQuestion;
|
|
|
-import com.zhongzheng.modules.bank.domain.Question;
|
|
|
-import com.zhongzheng.modules.bank.domain.QuestionBusiness;
|
|
|
+import com.zhongzheng.modules.bank.domain.*;
|
|
|
import com.zhongzheng.modules.bank.mapper.QuestionMapper;
|
|
|
-import com.zhongzheng.modules.bank.service.IExamQuestionService;
|
|
|
-import com.zhongzheng.modules.bank.service.IExamService;
|
|
|
-import com.zhongzheng.modules.bank.service.IQuestionBusinessService;
|
|
|
-import com.zhongzheng.modules.bank.service.IQuestionService;
|
|
|
+import com.zhongzheng.modules.bank.service.*;
|
|
|
import com.zhongzheng.modules.bank.vo.*;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseBusiness;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseEducationType;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseProjectType;
|
|
|
-import com.zhongzheng.modules.course.domain.CourseSubject;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseBusinessService;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseEducationTypeService;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseProjectTypeService;
|
|
|
-import com.zhongzheng.modules.course.service.ICourseSubjectService;
|
|
|
+import com.zhongzheng.modules.course.domain.*;
|
|
|
+import com.zhongzheng.modules.course.service.*;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamKnowledgeAddBo;
|
|
|
import com.zhongzheng.modules.exam.bo.ExamKnowledgeBusinessAddBo;
|
|
|
import com.zhongzheng.modules.exam.domain.ExamKnowledge;
|
|
|
+import com.zhongzheng.modules.exam.domain.ExamPaper;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamApplyService;
|
|
|
import com.zhongzheng.modules.exam.service.IExamKnowledgeService;
|
|
|
+import com.zhongzheng.modules.exam.service.IExamPaperService;
|
|
|
import com.zhongzheng.modules.goods.bo.*;
|
|
|
import com.zhongzheng.modules.goods.domain.Goods;
|
|
|
+import com.zhongzheng.modules.goods.domain.GoodsAttached;
|
|
|
import com.zhongzheng.modules.goods.domain.GoodsExamTime;
|
|
|
+import com.zhongzheng.modules.goods.service.IGoodsAttachedService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsExamTimeService;
|
|
|
import com.zhongzheng.modules.goods.service.IGoodsService;
|
|
|
import com.zhongzheng.modules.goods.vo.BankGoodsExamVo;
|
|
@@ -77,9 +74,12 @@ import org.w3c.dom.NodeList;
|
|
|
|
|
|
import java.io.IOException;
|
|
|
import java.io.InputStream;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.text.NumberFormat;
|
|
|
import java.util.*;
|
|
|
import java.util.concurrent.TimeUnit;
|
|
|
+import java.util.regex.Matcher;
|
|
|
+import java.util.regex.Pattern;
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
@@ -109,6 +109,9 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
@Autowired
|
|
|
private ICourseSubjectService iCourseSubjectService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private ICourseSubjectProjectService iCourseSubjectProjectService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IExamKnowledgeService iExamKnowledgeService;
|
|
|
|
|
@@ -127,12 +130,30 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
@Autowired
|
|
|
private IUserExamSubscriptionService iUserExamSubscriptionService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IQuestionModuleService iQuestionModuleService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQuestionChapterService iQuestionChapterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQuestionChapterExamService iQuestionChapterExamService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IQuestionModuleChapterService iQuestionModuleChapterService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IGoodsAttachedService iGoodsAttachedService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IUserService iUserService;
|
|
|
|
|
|
@Autowired
|
|
|
private IExamService iExamService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IExamPaperService iExamPaperService;
|
|
|
+
|
|
|
@Autowired
|
|
|
private IGoodsService iGoodsService;
|
|
|
|
|
@@ -142,9 +163,30 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
@Autowired
|
|
|
private OssService ossService;
|
|
|
|
|
|
+ @Autowired
|
|
|
+ private IMajorService iMajorService;
|
|
|
+
|
|
|
+ @Autowired
|
|
|
+ private IMajorProjectService iMajorProjectService;
|
|
|
+
|
|
|
@Value("${aliyun.oss.endpoint}")
|
|
|
private String ossHost;
|
|
|
|
|
|
+ @Value("${oldSys.question}")
|
|
|
+ private String QUESTION;
|
|
|
+
|
|
|
+ @Value("${oldSys.questionDetail}")
|
|
|
+ private String QUESTION_DETAIL;
|
|
|
+
|
|
|
+ @Value("${exam.question}")
|
|
|
+ private String EXAM_QUESTION;
|
|
|
+
|
|
|
+ @Value("${exam.questionDetail}")
|
|
|
+ private String EXAM_QUESTION_DETAIL;
|
|
|
+
|
|
|
+ @Value("${aliyun.oss.endpoint}")
|
|
|
+ private String OSS_PREFIX;
|
|
|
+
|
|
|
|
|
|
@Override
|
|
|
public QuestionVo queryById(Long questionId) {
|
|
@@ -3090,10 +3132,554 @@ public class QuestionServiceImpl extends ServiceImpl<QuestionMapper, Question> i
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void questionImport(String param) {
|
|
|
+ @Transactional
|
|
|
+ public void questionImport() {
|
|
|
+ String tenantId = ServletUtils.getRequest().getHeader("TenantId");
|
|
|
+ HashMap<String, String> map = new HashMap<>();
|
|
|
+ map.put("TenantId", tenantId);
|
|
|
+ String respone = HttpUtils.sendPostJsonHeader(EXAM_QUESTION, "",map);
|
|
|
+ List<ExternalQuestionVo> questionVos = JSONArray.parseArray(respone, ExternalQuestionVo.class);
|
|
|
+ //考前培训
|
|
|
+ CourseEducationType educationType = iCourseEducationTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseEducationType>()
|
|
|
+ .eq(CourseEducationType::getEducationName, "考前培训")
|
|
|
+ .eq(CourseEducationType::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ //施工现场人员
|
|
|
+ CourseProjectType projectType = iCourseProjectTypeService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseProjectType>()
|
|
|
+ .eq(CourseProjectType::getProjectName, "施工现场专业人员")
|
|
|
+ .eq(CourseProjectType::getEducationId, educationType.getId())
|
|
|
+ .eq(CourseProjectType::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ //七大员
|
|
|
+ CourseBusiness business = iCourseBusinessService
|
|
|
+ .getOne(new LambdaQueryWrapper<CourseBusiness>()
|
|
|
+ .eq(CourseBusiness::getBusinessName, "七大员")
|
|
|
+ .eq(CourseBusiness::getProjectId, projectType.getId())
|
|
|
+ .eq(CourseBusiness::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+
|
|
|
+ //专业
|
|
|
+ List<MajorProject> list = iMajorProjectService
|
|
|
+ .list(new LambdaQueryWrapper<MajorProject>()
|
|
|
+ .eq(MajorProject::getProjectId, projectType.getId()));
|
|
|
+ List<Major> majorList = iMajorService.listByIds(list.stream().map(MajorProject::getMajorId).collect(Collectors.toList()));
|
|
|
+
|
|
|
+ //科目
|
|
|
+ List<CourseSubjectProject> list1 = iCourseSubjectProjectService
|
|
|
+ .list(new LambdaQueryWrapper<CourseSubjectProject>()
|
|
|
+ .eq(CourseSubjectProject::getProjectId, projectType.getId()));
|
|
|
+ List<CourseSubject> subjectList = iCourseSubjectService.listByIds(list1.stream().map(CourseSubjectProject::getSubjectId).collect(Collectors.toList()));
|
|
|
+
|
|
|
+
|
|
|
+ //七大员新考题库商品
|
|
|
+ List<ExternalQuestionVo> collect = questionVos.stream().filter(x -> x.getParentId() == 1)
|
|
|
+ .sorted(Comparator.comparing(ExternalQuestionVo::getSortNumber))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ for (ExternalQuestionVo item : collect) {
|
|
|
+ //专业顺序
|
|
|
+
|
|
|
+ //劳务员考核评价大纲及习题集
|
|
|
+ //施工员考核评价大纲及习题集(土建方向)
|
|
|
+ //施工员考核评价大纲及习题集(市政方向)
|
|
|
+ //施工员考核评价大纲及习题集(装饰方向)
|
|
|
+ //施工员考核评价大纲及习题集(设备方向)
|
|
|
+ //机械员考核评价大纲及习题集
|
|
|
+ //材料员考核评价大纲及习题集
|
|
|
+ //标准员考核评价大纲及习题集
|
|
|
+ //质量员考核评价大纲及习题集(土建方向)
|
|
|
+ //质量员考核评价大纲及习题集(市政方向)
|
|
|
+ //质量员考核评价大纲及习题集(装饰方向)
|
|
|
+ //质量员考核评价大纲及习题集(设备方向)
|
|
|
+ //资料员考核评价大纲及习题集
|
|
|
+ Major major = majorList.stream().filter(x -> x.getCategoryName().equals(item.getTopicNoteTypeNum())).findFirst().orElse(null);
|
|
|
+ Long majorId = 0L;
|
|
|
+ if (ObjectUtils.isNotNull(major)){
|
|
|
+ majorId = major.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //科目
|
|
|
+ CourseSubject courseSubject = subjectList.stream().filter(x -> x.getSubjectName().equals(item.getTopicNoteTypeNum())).findFirst().orElse(null);
|
|
|
+ Long subjectId = 0L;
|
|
|
+ if (ObjectUtils.isNotNull(courseSubject)){
|
|
|
+ subjectId = courseSubject.getId();
|
|
|
+ }
|
|
|
+
|
|
|
+ //创建商品
|
|
|
+ Goods goods = new Goods();
|
|
|
+ goods.setGoodsName(item.getName());
|
|
|
+ goods.setYear(2023L);
|
|
|
+ goods.setSupplyId(2L);
|
|
|
+ goods.setCode(ServletUtils.getEncoded("SP"));
|
|
|
+ goods.setGoodsType(2);
|
|
|
+ goods.setEducationTypeId(educationType.getId());
|
|
|
+ goods.setBusinessId(business.getId());
|
|
|
+ goods.setProjectId(projectType.getId().intValue());
|
|
|
+ goods.setStandPrice(new BigDecimal("150.00"));
|
|
|
+ goods.setLowestPrice(new BigDecimal("150.00"));
|
|
|
+ goods.setCreateTime(DateUtils.getNowTime());
|
|
|
+ goods.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ goods.setStatus(1);
|
|
|
+ goods.setGoodsStatus(0);
|
|
|
+ goods.setMajorId(majorId);
|
|
|
+ goods.setSubjectIds(subjectId.toString());
|
|
|
+ iGoodsService.save(goods);
|
|
|
+
|
|
|
+ String upStr1 = "web/Uploads/qdytopic/";
|
|
|
+ //题库
|
|
|
+ List<ExternalQuestionVo> questionVos1 = questionVos.stream()
|
|
|
+ .filter(x -> x.getParentId().equals(item.getMeasureModelId())).sorted(Comparator.comparing(ExternalQuestionVo::getSortNumber)).collect(Collectors.toList());
|
|
|
+ if (CollectionUtils.isNotEmpty(questionVos1)){
|
|
|
+ for (ExternalQuestionVo item1 : questionVos1) {
|
|
|
+ //模块卷
|
|
|
+ QuestionModule module = new QuestionModule();
|
|
|
+ module.setCode(ServletUtils.getEncoded("MJ"));
|
|
|
+ module.setModuleName(item1.getName());
|
|
|
+ module.setPublishStatus(1L);
|
|
|
+ module.setStatus(1);
|
|
|
+ module.setCreateTime(DateUtils.getNowTime());
|
|
|
+ module.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iQuestionModuleService.save(module);
|
|
|
+ //模块卷业务层
|
|
|
+ QuestionBusiness questionBusiness = new QuestionBusiness();
|
|
|
+ questionBusiness.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness.setBusinessId(business.getId());
|
|
|
+ questionBusiness.setProjectId(projectType.getId());
|
|
|
+ questionBusiness.setMajorId(module.getModuleExamId());
|
|
|
+ questionBusiness.setType(4);
|
|
|
+ questionBusiness.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness);
|
|
|
+ //题库模块关联
|
|
|
+ GoodsAttached goodsAttached = new GoodsAttached();
|
|
|
+ goodsAttached.setGoodsId(goods.getGoodsId());
|
|
|
+ goodsAttached.setMajorId(module.getModuleExamId());
|
|
|
+ goodsAttached.setType(1);
|
|
|
+ goodsAttached.setCreateTime(DateUtils.getNowTime());
|
|
|
+ goodsAttached.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ iGoodsAttachedService.save(goodsAttached);
|
|
|
+
|
|
|
+ //章卷
|
|
|
+ List<ExternalQuestionVo> questionVos2 = questionVos.stream()
|
|
|
+ .filter(x -> x.getParentId().equals(item1.getMeasureModelId()))
|
|
|
+ .sorted(Comparator.comparing(ExternalQuestionVo::getSortNumber)).collect(Collectors.toList());
|
|
|
+ for (ExternalQuestionVo item2 : questionVos2) {
|
|
|
+ QuestionChapter questionChapter = new QuestionChapter();
|
|
|
+ questionChapter.setName(item2.getName());
|
|
|
+ questionChapter.setStatus(1);
|
|
|
+ questionChapter.setCreateTime(DateUtils.getNowTime());
|
|
|
+ questionChapter.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ questionChapter.setPublishStatus(1L);
|
|
|
+ questionChapter.setCode(ServletUtils.getEncoded("ZJ"));
|
|
|
+ iQuestionChapterService.save(questionChapter);
|
|
|
+
|
|
|
+ //章卷业务
|
|
|
+ QuestionBusiness questionBusiness1 = new QuestionBusiness();
|
|
|
+ questionBusiness1.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness1.setBusinessId(business.getId());
|
|
|
+ questionBusiness1.setProjectId(projectType.getId());
|
|
|
+ questionBusiness1.setMajorId(questionChapter.getChapterExamId());
|
|
|
+ questionBusiness1.setType(3);
|
|
|
+ questionBusiness1.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness1);
|
|
|
+
|
|
|
+ //模块章卷关联
|
|
|
+ QuestionModuleChapter moduleChapter = new QuestionModuleChapter();
|
|
|
+ moduleChapter.setModuleExamId(module.getModuleExamId());
|
|
|
+ moduleChapter.setChapterExamId(questionChapter.getChapterExamId());
|
|
|
+ moduleChapter.setSort(item2.getSortNumber().longValue());
|
|
|
+ iQuestionModuleChapterService.save(moduleChapter);
|
|
|
+
|
|
|
+ if (ObjectUtils.isNotNull(item2.getIsTopic()) && item2.getIsTopic()){
|
|
|
+ //获取题目内容
|
|
|
+ String topParam = String.format("MeasureModelId=%s",item2.getMeasureModelId());
|
|
|
+ String topRespone = HttpUtils.sendGet(QUESTION_DETAIL, topParam);
|
|
|
+ List<ExternalQuestionDetailVo> questionDetailVos = JSONArray.parseArray(topRespone, ExternalQuestionDetailVo.class);
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(questionDetailVos)){
|
|
|
+ //处理图片
|
|
|
+ handlePhoto(questionDetailVos);
|
|
|
+ //创建试卷
|
|
|
+ Exam exam = new Exam();
|
|
|
+ exam.setCode(ServletUtils.getEncoded("SJ"));
|
|
|
+ exam.setStatus(1);
|
|
|
+ exam.setCreateTime(DateUtils.getNowTime());
|
|
|
+ exam.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ exam.setExamName(item2.getName() + "测试卷");
|
|
|
+ exam.setPublishStatus(1L);
|
|
|
+ exam.setDoType(1);
|
|
|
+ //试卷类型
|
|
|
+ ExamPaper paper = iExamPaperService.getOne(new LambdaQueryWrapper<ExamPaper>()
|
|
|
+ .eq(ExamPaper::getPaperName, "普通练习")
|
|
|
+ .eq(ExamPaper::getStatus, 1)
|
|
|
+ .last("limit 1"));
|
|
|
+ if (ObjectUtils.isNotNull(paper)){
|
|
|
+ exam.setExamPaperId(paper.getPaperId());
|
|
|
+ }
|
|
|
+ iExamService.save(exam);
|
|
|
+ //试卷业务
|
|
|
+ QuestionBusiness questionBusiness2 = new QuestionBusiness();
|
|
|
+ questionBusiness2.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness2.setBusinessId(business.getId());
|
|
|
+ questionBusiness2.setProjectId(projectType.getId());
|
|
|
+ questionBusiness2.setMajorId(exam.getExamId());
|
|
|
+ questionBusiness2.setType(2);
|
|
|
+ questionBusiness2.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness2);
|
|
|
+
|
|
|
+ //章卷关联
|
|
|
+ QuestionChapterExam chapterExam = new QuestionChapterExam();
|
|
|
+ chapterExam.setChapterExamId(questionChapter.getChapterExamId());
|
|
|
+ chapterExam.setExamId(exam.getExamId());
|
|
|
+ chapterExam.setSort(item2.getSortNumber().longValue());
|
|
|
+ iQuestionChapterExamService.save(chapterExam);
|
|
|
+ for (ExternalQuestionDetailVo detailVo : questionDetailVos) {
|
|
|
+ switch (detailVo.getTopicType()){
|
|
|
+ case 1://单选题
|
|
|
+ Question question = new Question();
|
|
|
+ question.setContent(detailVo.getTitle());
|
|
|
+ question.setType(1);
|
|
|
+ question.setStatus(1);
|
|
|
+ question.setCreateTime(DateUtils.getNowTime());
|
|
|
+ question.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ question.setAnalysisContent(detailVo.getDescription());
|
|
|
+ question.setPublishStatus(1);
|
|
|
+ question.setCode(ServletUtils.getEncoded("TM"));
|
|
|
+ question.setCreateBy("(系统)外部题库导入");
|
|
|
+ if (CollectionUtils.isNotEmpty(detailVo.getChildList())){
|
|
|
+ List<QuestionDetailVo> detail = new ArrayList<>();
|
|
|
+ Integer index = 0;
|
|
|
+ for (int i = 0; i < detailVo.getChildList().size(); i++) {
|
|
|
+ ExternalQuestionChildVo childVo = detailVo.getChildList().get(i);
|
|
|
+ QuestionDetailVo questionDetailVo = new QuestionDetailVo();
|
|
|
+ if (childVo.getOptionTitle().contains(upStr1)){
|
|
|
+ questionDetailVo.setImgUrl(getImgUrl(childVo.getOptionTitle()));
|
|
|
+ questionDetailVo.setContent("如图所示");
|
|
|
+ }
|
|
|
+ questionDetailVo.setOptionsId(i +1);
|
|
|
+ if (ObjectUtils.isNotNull(childVo.getIsAnswer()) && childVo.getIsAnswer()){
|
|
|
+ index = i + 1;
|
|
|
+ }
|
|
|
+ detail.add(questionDetailVo);
|
|
|
+ }
|
|
|
+ String s = JSONArray.toJSONString(detail);
|
|
|
+ question.setAnswerQuestion(index.toString());
|
|
|
+ question.setJsonStr(s);
|
|
|
+ }
|
|
|
+ save(question);
|
|
|
+ //题目业务
|
|
|
+ QuestionBusiness questionBusiness3 = new QuestionBusiness();
|
|
|
+ questionBusiness3.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness3.setBusinessId(business.getId());
|
|
|
+ questionBusiness3.setProjectId(projectType.getId());
|
|
|
+ questionBusiness3.setMajorId(question.getQuestionId());
|
|
|
+ questionBusiness3.setType(1);
|
|
|
+ questionBusiness3.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness3);
|
|
|
+
|
|
|
+ //试卷题目关联
|
|
|
+ ExamQuestion examQuestion = new ExamQuestion();
|
|
|
+ examQuestion.setExamId(exam.getExamId());
|
|
|
+ examQuestion.setQuestionId(question.getQuestionId());
|
|
|
+ examQuestion.setSort(detailVo.getSortNumber());
|
|
|
+ examQuestion.setScore(BigDecimal.ZERO);
|
|
|
+ examQuestion.setPartScore(BigDecimal.ZERO);
|
|
|
+ iExamQuestionService.save(examQuestion);
|
|
|
+ break;
|
|
|
+ case 2://多选题
|
|
|
+ Question question1 = new Question();
|
|
|
+ question1.setContent(detailVo.getTitle());
|
|
|
+ question1.setType(2);
|
|
|
+ question1.setStatus(1);
|
|
|
+ question1.setCreateTime(DateUtils.getNowTime());
|
|
|
+ question1.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ question1.setAnalysisContent(detailVo.getDescription());
|
|
|
+ question1.setPublishStatus(1);
|
|
|
+ question1.setCode(ServletUtils.getEncoded("TM"));
|
|
|
+ question1.setCreateBy("(系统)外部题库导入");
|
|
|
+ if (CollectionUtils.isNotEmpty(detailVo.getChildList())){
|
|
|
+ List<QuestionDetailVo> detail = new ArrayList<>();
|
|
|
+ List<String> index = new ArrayList<>();
|
|
|
+ for (int i = 0; i < detailVo.getChildList().size(); i++) {
|
|
|
+ ExternalQuestionChildVo childVo = detailVo.getChildList().get(i);
|
|
|
+ QuestionDetailVo questionDetailVo = new QuestionDetailVo();
|
|
|
+ if (childVo.getOptionTitle().contains(upStr1)){
|
|
|
+ questionDetailVo.setImgUrl(getImgUrl(childVo.getOptionTitle()));
|
|
|
+ questionDetailVo.setContent("如图所示");
|
|
|
+ }
|
|
|
+ questionDetailVo.setOptionsId(i + 1);
|
|
|
+ if (ObjectUtils.isNotNull(childVo.getIsAnswer()) && childVo.getIsAnswer()){
|
|
|
+ Integer x = i + 1;
|
|
|
+ index.add(x +"");
|
|
|
+ }
|
|
|
+ detail.add(questionDetailVo);
|
|
|
+ }
|
|
|
+ String s = JSONArray.toJSONString(detail);
|
|
|
+ question1.setAnswerQuestion(index.stream().collect(Collectors.joining(",")));
|
|
|
+ question1.setJsonStr(s);
|
|
|
+ }
|
|
|
+ save(question1);
|
|
|
+ //题目业务
|
|
|
+ QuestionBusiness questionBusiness4 = new QuestionBusiness();
|
|
|
+ questionBusiness4.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness4.setBusinessId(business.getId());
|
|
|
+ questionBusiness4.setProjectId(projectType.getId());
|
|
|
+ questionBusiness4.setMajorId(question1.getQuestionId());
|
|
|
+ questionBusiness4.setType(1);
|
|
|
+ questionBusiness4.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness4);
|
|
|
+
|
|
|
+ //试卷题目关联
|
|
|
+ ExamQuestion examQuestion1 = new ExamQuestion();
|
|
|
+ examQuestion1.setExamId(exam.getExamId());
|
|
|
+ examQuestion1.setQuestionId(question1.getQuestionId());
|
|
|
+ examQuestion1.setSort(detailVo.getSortNumber());
|
|
|
+ examQuestion1.setScore(BigDecimal.ZERO);
|
|
|
+ examQuestion1.setPartScore(BigDecimal.ZERO);
|
|
|
+ iExamQuestionService.save(examQuestion1);
|
|
|
+ break;
|
|
|
+ case 4://判断题
|
|
|
+ Question question2 = new Question();
|
|
|
+ question2.setContent(detailVo.getTitle());
|
|
|
+ question2.setType(3);
|
|
|
+ question2.setStatus(1);
|
|
|
+ question2.setCreateTime(DateUtils.getNowTime());
|
|
|
+ question2.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ question2.setAnalysisContent(detailVo.getDescription());
|
|
|
+ question2.setPublishStatus(1);
|
|
|
+ question2.setCode(ServletUtils.getEncoded("TM"));
|
|
|
+ question2.setCreateBy("(系统)外部题库导入");
|
|
|
+ if (CollectionUtils.isNotEmpty(detailVo.getChildList())){
|
|
|
+ ExternalQuestionChildVo childVo = detailVo.getChildList().stream().filter(x -> ObjectUtils.isNotNull(x.getIsAnswer()) && x.getIsAnswer()).findFirst().orElse(null);
|
|
|
+ if (ObjectUtils.isNotNull(childVo)){
|
|
|
+ if ("正确".equals(childVo.getOptionTitle())){
|
|
|
+ question2.setAnswerQuestion("1");
|
|
|
+ }else {
|
|
|
+ question2.setAnswerQuestion("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ save(question2);
|
|
|
+ //题目业务
|
|
|
+ QuestionBusiness questionBusiness5 = new QuestionBusiness();
|
|
|
+ questionBusiness5.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness5.setBusinessId(business.getId());
|
|
|
+ questionBusiness5.setProjectId(projectType.getId());
|
|
|
+ questionBusiness5.setMajorId(question2.getQuestionId());
|
|
|
+ questionBusiness5.setType(1);
|
|
|
+ questionBusiness5.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness5);
|
|
|
+
|
|
|
+ //试卷题目关联
|
|
|
+ ExamQuestion examQuestion2 = new ExamQuestion();
|
|
|
+ examQuestion2.setExamId(exam.getExamId());
|
|
|
+ examQuestion2.setQuestionId(question2.getQuestionId());
|
|
|
+ examQuestion2.setSort(detailVo.getSortNumber());
|
|
|
+ examQuestion2.setScore(BigDecimal.ZERO);
|
|
|
+ examQuestion2.setPartScore(BigDecimal.ZERO);
|
|
|
+ iExamQuestionService.save(examQuestion2);
|
|
|
+ break;
|
|
|
+ case 5://案例题
|
|
|
+ Question question3 = new Question();
|
|
|
+ question3.setContent(detailVo.getTitle());
|
|
|
+ question3.setType(4);
|
|
|
+ question3.setStatus(1);
|
|
|
+ question3.setCreateTime(DateUtils.getNowTime());
|
|
|
+ question3.setUpdateTime(DateUtils.getNowTime());
|
|
|
+ question3.setPublishStatus(1);
|
|
|
+ question3.setCode(ServletUtils.getEncoded("TM"));
|
|
|
+ question3.setCreateBy("(系统)外部题库导入");
|
|
|
+ if (CollectionUtils.isNotEmpty(detailVo.getChildTopicLict())){
|
|
|
+ List<QuestionInfoVo> infoVoList = new ArrayList<>();
|
|
|
+ for (ExternalQuestionChildTopicVo topicVo : detailVo.getChildTopicLict()) {
|
|
|
+ switch (topicVo.getTopicType()){
|
|
|
+ case 1://单选
|
|
|
+ QuestionInfoVo infoVo = new QuestionInfoVo();
|
|
|
+ infoVo.setContent(topicVo.getTitle());
|
|
|
+ infoVo.setAnalysisContent(topicVo.getDescription());
|
|
|
+ infoVo.setType(1);
|
|
|
+ if (CollectionUtils.isNotEmpty(topicVo.getChildList())){
|
|
|
+ List<QuestionDetailVo> voList = new ArrayList<>();
|
|
|
+ Integer index = 0;
|
|
|
+ for (int i = 0; i < topicVo.getChildList().size(); i++) {
|
|
|
+ ExternalQuestionChildVo childVo = topicVo.getChildList().get(i);
|
|
|
+ QuestionDetailVo detailVo1 = new QuestionDetailVo();
|
|
|
+ detailVo1.setOptionsId(i + 1);
|
|
|
+ if (childVo.getOptionTitle().contains(upStr1)){
|
|
|
+ detailVo1.setImgUrl(getImgUrl(childVo.getOptionTitle()));
|
|
|
+ detailVo1.setContent("如图所示");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(childVo.getIsAnswer()) && childVo.getIsAnswer()){
|
|
|
+ index = i + 1;
|
|
|
+ }
|
|
|
+ voList.add(detailVo1);
|
|
|
+ }
|
|
|
+ infoVo.setAnswerQuestion(index.toString());
|
|
|
+ infoVo.setOptionsList(voList);
|
|
|
+ }
|
|
|
+ infoVoList.add(infoVo);
|
|
|
+ break;
|
|
|
+ case 2://多选
|
|
|
+ QuestionInfoVo infoVo1 = new QuestionInfoVo();
|
|
|
+ infoVo1.setContent(topicVo.getTitle());
|
|
|
+ infoVo1.setAnalysisContent(topicVo.getDescription());
|
|
|
+ infoVo1.setType(2);
|
|
|
+ if (CollectionUtils.isNotEmpty(topicVo.getChildList())){
|
|
|
+ List<QuestionDetailVo> voList = new ArrayList<>();
|
|
|
+ List<String> indexList = new ArrayList<>();
|
|
|
+ for (int i = 0; i < topicVo.getChildList().size(); i++) {
|
|
|
+ ExternalQuestionChildVo childVo = topicVo.getChildList().get(i);
|
|
|
+ QuestionDetailVo detailVo1 = new QuestionDetailVo();
|
|
|
+ detailVo1.setOptionsId(i + 1);
|
|
|
+ if (childVo.getOptionTitle().contains(upStr1)){
|
|
|
+ detailVo1.setImgUrl(getImgUrl(childVo.getOptionTitle()));
|
|
|
+ detailVo1.setContent("如图所示");
|
|
|
+ }
|
|
|
+ if (ObjectUtils.isNotNull(childVo.getIsAnswer()) && childVo.getIsAnswer()){
|
|
|
+ Integer x = i + 1 ;
|
|
|
+ indexList.add(x+"");
|
|
|
+ }
|
|
|
+ voList.add(detailVo1);
|
|
|
+ }
|
|
|
+ infoVo1.setAnswerQuestion(indexList.stream().collect(Collectors.joining(",")));
|
|
|
+ infoVo1.setOptionsList(voList);
|
|
|
+ }
|
|
|
+ infoVoList.add(infoVo1);
|
|
|
+ break;
|
|
|
+ case 4://判断题
|
|
|
+ QuestionInfoVo infoVo2 = new QuestionInfoVo();
|
|
|
+ infoVo2.setContent(topicVo.getTitle());
|
|
|
+ infoVo2.setAnalysisContent(topicVo.getDescription());
|
|
|
+ infoVo2.setType(3);
|
|
|
+ if (CollectionUtils.isNotEmpty(topicVo.getChildList())){
|
|
|
+ ExternalQuestionChildVo childVo = topicVo.getChildList().stream().filter(x -> ObjectUtils.isNotNull(x.getIsAnswer()) && x.getIsAnswer()).findFirst().orElse(null);
|
|
|
+ if (ObjectUtils.isNotNull(childVo)){
|
|
|
+ if ("正确".equals(childVo.getOptionTitle())){
|
|
|
+ infoVo2.setAnswerQuestion("1");
|
|
|
+ }else {
|
|
|
+ infoVo2.setAnswerQuestion("0");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ infoVoList.add(infoVo2);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ question3.setJsonStr(JSONArray.toJSONString(infoVoList));
|
|
|
+ }
|
|
|
+ save(question3);
|
|
|
+ //题目业务
|
|
|
+ QuestionBusiness questionBusiness6 = new QuestionBusiness();
|
|
|
+ questionBusiness6.setEducationTypeId(educationType.getId());
|
|
|
+ questionBusiness6.setBusinessId(business.getId());
|
|
|
+ questionBusiness6.setProjectId(projectType.getId());
|
|
|
+ questionBusiness6.setMajorId(question3.getQuestionId());
|
|
|
+ questionBusiness6.setType(1);
|
|
|
+ questionBusiness6.setSubjectId(subjectId);
|
|
|
+ iQuestionBusinessService.save(questionBusiness6);
|
|
|
+
|
|
|
+ //试卷题目关联
|
|
|
+ ExamQuestion examQuestion3 = new ExamQuestion();
|
|
|
+ examQuestion3.setExamId(exam.getExamId());
|
|
|
+ examQuestion3.setQuestionId(question3.getQuestionId());
|
|
|
+ examQuestion3.setSort(detailVo.getSortNumber());
|
|
|
+ examQuestion3.setScore(BigDecimal.ZERO);
|
|
|
+ examQuestion3.setPartScore(BigDecimal.ZERO);
|
|
|
+ iExamQuestionService.save(examQuestion3);
|
|
|
+ break;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public String getMeasureList() {
|
|
|
+ return HttpUtils.sendGet(QUESTION, "");
|
|
|
+ }
|
|
|
|
|
|
+ @Override
|
|
|
+ public String getTopicList(String topParam) {
|
|
|
+ return HttpUtils.sendGet(QUESTION_DETAIL, topParam);
|
|
|
}
|
|
|
|
|
|
+ private void handlePhoto(List<ExternalQuestionDetailVo> questionDetailVos) {
|
|
|
+ String prefix = "\\Uploads\\qdytopic\\";
|
|
|
+ String upStr = OSS_PREFIX + "/web/Uploads/qdytopic/";
|
|
|
+ String upStr1 = "web/Uploads/qdytopic/";
|
|
|
+ for (ExternalQuestionDetailVo detailVo : questionDetailVos) {
|
|
|
+ if (StringUtils.isNotBlank(detailVo.getTitle()) && detailVo.getTitle().contains(prefix)){
|
|
|
+ String title = detailVo.getTitle();
|
|
|
+ String replace = title.replace(prefix, upStr);
|
|
|
+ detailVo.setTitle(replace);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(detailVo.getDescription()) && detailVo.getDescription().contains(prefix)){
|
|
|
+ String description = detailVo.getDescription();
|
|
|
+ String replace = description.replace(prefix, upStr);
|
|
|
+ detailVo.setDescription(replace);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(detailVo.getChildList())){
|
|
|
+ List<ExternalQuestionChildVo> childList = detailVo.getChildList();
|
|
|
+ for (ExternalQuestionChildVo childVo : childList) {
|
|
|
+ if (StringUtils.isNotBlank(childVo.getOptionTitle()) && childVo.getOptionTitle().contains(prefix)){
|
|
|
+ String optionTitle = childVo.getOptionTitle();
|
|
|
+ String replace = optionTitle.replace(prefix, upStr1);
|
|
|
+ childVo.setOptionTitle(replace);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(detailVo.getChildTopicLict())){
|
|
|
+ List<ExternalQuestionChildTopicVo> childTopicLict = detailVo.getChildTopicLict();
|
|
|
+ for (ExternalQuestionChildTopicVo childTopicVo : childTopicLict) {
|
|
|
+ if (StringUtils.isNotBlank(childTopicVo.getTitle()) && childTopicVo.getTitle().contains(prefix)){
|
|
|
+ String optionTitle = childTopicVo.getTitle();
|
|
|
+ String replace = optionTitle.replace(prefix, upStr);
|
|
|
+ childTopicVo.setTitle(replace);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (StringUtils.isNotBlank(childTopicVo.getDescription()) && childTopicVo.getDescription().contains(prefix)){
|
|
|
+ String description = childTopicVo.getDescription();
|
|
|
+ String replace = description.replace(prefix, upStr);
|
|
|
+ childTopicVo.setDescription(replace);
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(childTopicVo.getChildList())){
|
|
|
+ List<ExternalQuestionChildVo> childList = childTopicVo.getChildList();
|
|
|
+ for (ExternalQuestionChildVo childVo : childList) {
|
|
|
+ if (StringUtils.isNotBlank(childVo.getOptionTitle()) && childVo.getOptionTitle().contains(prefix)){
|
|
|
+ String optionTitle = childVo.getOptionTitle();
|
|
|
+ String replace = optionTitle.replace(prefix, upStr1);
|
|
|
+ childVo.setOptionTitle(replace);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private String getImgUrl(String img){
|
|
|
+ Matcher m = Pattern.compile("<img.*?src=\"(.*?)\"").matcher(img);
|
|
|
+ String filePath = "";
|
|
|
+ while(m.find())
|
|
|
+ {
|
|
|
+ filePath = m.group(1);
|
|
|
+ }
|
|
|
+ return filePath;
|
|
|
+ }
|
|
|
+
|
|
|
+
|
|
|
private boolean checkNameUnique(Question entity) {
|
|
|
Question info = getOne(new LambdaQueryWrapper<Question>()
|
|
|
.eq(Question::getPrefixName, entity.getPrefixName()).eq(Question::getContent, entity.getContent()).ne(Question::getStatus, -1).last("limit 1"));
|