|
@@ -1,31 +1,35 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import com.alibaba.fastjson.JSON;
|
|
|
+import com.alibaba.fastjson.JSONArray;
|
|
|
+import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.qmth.distributed.print.business.bean.dto.CourseDimensionDto;
|
|
|
import com.qmth.distributed.print.business.bean.dto.CourseDimensionOccupiedDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.report.CourseTargetWebDto;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.report.DimensionDto;
|
|
|
import com.qmth.distributed.print.business.bean.params.CourseTargetParam;
|
|
|
import com.qmth.distributed.print.business.bean.result.CourseDimensionTree;
|
|
|
import com.qmth.distributed.print.business.bean.result.CourseTargetResult;
|
|
|
-import com.qmth.distributed.print.business.entity.CourseDimension;
|
|
|
-import com.qmth.distributed.print.business.entity.CourseTarget;
|
|
|
-import com.qmth.distributed.print.business.entity.TeachCourse;
|
|
|
+import com.qmth.distributed.print.business.bean.result.report.PaperStructDimensionResult;
|
|
|
+import com.qmth.distributed.print.business.entity.*;
|
|
|
+import com.qmth.distributed.print.business.enums.CourseDimensionSourceEnum;
|
|
|
import com.qmth.distributed.print.business.enums.CourseSettingTypeEnum;
|
|
|
import com.qmth.distributed.print.business.mapper.CourseTargetMapper;
|
|
|
-import com.qmth.distributed.print.business.service.CourseDimensionService;
|
|
|
-import com.qmth.distributed.print.business.service.CourseTargetService;
|
|
|
-import com.qmth.distributed.print.business.service.TeachCourseService;
|
|
|
+import com.qmth.distributed.print.business.service.*;
|
|
|
import com.qmth.teachcloud.common.base.BaseEntity;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.util.*;
|
|
|
+import java.util.concurrent.atomic.AtomicInteger;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -46,6 +50,12 @@ public class CourseTargetServiceImpl extends ServiceImpl<CourseTargetMapper, Cou
|
|
|
@Resource
|
|
|
private CourseDimensionService courseDimensionService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ private ExamTaskPaperDataService examTaskPaperDataService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private ExamTaskService examTaskService;
|
|
|
+
|
|
|
@Override
|
|
|
public List<CourseTargetResult> findCourseTargetList(Long teachCourseId) {
|
|
|
TeachCourse teachCourse = teachCourseService.getById(teachCourseId);
|
|
@@ -220,7 +230,8 @@ public class CourseTargetServiceImpl extends ServiceImpl<CourseTargetMapper, Cou
|
|
|
}
|
|
|
}
|
|
|
// 目标描述变了 更新权重设置标识
|
|
|
- if (!courseTarget.getTargetName().equals(db.getTargetName()) || !Objects.equals(courseTarget.getDegreeRequirement(),db.getDegreeRequirement())) {
|
|
|
+ if (!courseTarget.getTargetName().equals(db.getTargetName()) || !Objects.equals(courseTarget.getDegreeRequirement(),
|
|
|
+ db.getDegreeRequirement())) {
|
|
|
teachCourseUpdateWrapper.lambda().set(TeachCourse::getWeightSettingSign, SystemConstant.getDbUuid());
|
|
|
teachCourseService.update(teachCourseUpdateWrapper);
|
|
|
}
|
|
@@ -249,6 +260,103 @@ public class CourseTargetServiceImpl extends ServiceImpl<CourseTargetMapper, Cou
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public List<PaperStructDimensionResult> findTikuPaperStruct(Long examId, String paperNumber) {
|
|
|
+ List<PaperStructDimensionResult> result = new ArrayList<>();
|
|
|
+ ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda().eq(ExamTask::getExamId, examId)
|
|
|
+ .eq(ExamTask::getPaperNumber, paperNumber).last(SystemConstant.LIMIT1));
|
|
|
+ if (Objects.isNull(examTask)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("命题任务不存在");
|
|
|
+ }
|
|
|
+ String courseCode = examTask.getCourseCode();
|
|
|
+ Long userId = examTask.getUserId();
|
|
|
+ TeachCourse teachCourse = teachCourseService.findByExamIdCourseCodeAndUserId(examId, courseCode, userId);
|
|
|
+ List<CourseTarget> courseTargetList = this.list(
|
|
|
+ new QueryWrapper<CourseTarget>().lambda().eq(CourseTarget::getTeachCourseId, teachCourse.getId()));
|
|
|
+ List<CourseDimension> courseDimensionList = courseDimensionService.list(
|
|
|
+ new QueryWrapper<CourseDimension>().lambda().eq(CourseDimension::getTeachCourseId, teachCourse.getId())
|
|
|
+ .eq(CourseDimension::getSource, CourseDimensionSourceEnum.UNION_QUESTION));
|
|
|
+ Map<String, CourseDimension> courseDimensionMap = courseDimensionList.stream()
|
|
|
+ .collect(Collectors.toMap(CourseDimension::getCode, e -> e));
|
|
|
+
|
|
|
+ ExamTaskPaperData examTaskPaperData = examTaskPaperDataService.getOne(
|
|
|
+ new QueryWrapper<ExamTaskPaperData>().lambda().eq(ExamTaskPaperData::getExamId, examId)
|
|
|
+ .eq(ExamTaskPaperData::getPaperNumber, paperNumber).last(SystemConstant.LIMIT1));
|
|
|
+ if (Objects.nonNull(examTaskPaperData)) {
|
|
|
+ String paperStruct = examTaskPaperData.getPaperJson();
|
|
|
+ if (SystemConstant.strNotNull(paperStruct)) {
|
|
|
+ JSONObject paperStructJson = JSONObject.parseObject(paperStruct);
|
|
|
+ JSONArray detailList = paperStructJson.getJSONArray("details");
|
|
|
+ AtomicInteger mainNumberIndex = new AtomicInteger(1);
|
|
|
+
|
|
|
+ for (int d = 0; d < detailList.size(); d++) {
|
|
|
+ int mainNumber = mainNumberIndex.getAndIncrement();
|
|
|
+ JSONObject detail = detailList.getJSONObject(d);
|
|
|
+ JSONArray questionList = detail.getJSONArray("questions");
|
|
|
+ AtomicInteger subNumberIndex = new AtomicInteger(1);
|
|
|
+ for (int q = 0; q < questionList.size(); q++) {
|
|
|
+
|
|
|
+ JSONObject question = questionList.getJSONObject(q);
|
|
|
+ JSONArray subQuestionList = question.getJSONArray("subQuestions");
|
|
|
+ if (CollectionUtils.isNotEmpty(subQuestionList)) {
|
|
|
+ // 包含套题
|
|
|
+ for (int s = 0; s < subQuestionList.size(); s++) {
|
|
|
+ PaperStructDimensionResult subCell = new PaperStructDimensionResult();
|
|
|
+
|
|
|
+ JSONObject subQuestion = subQuestionList.getJSONObject(s);
|
|
|
+ Double score = subQuestion.getDouble("score");
|
|
|
+ String property = subQuestion.getString("property");
|
|
|
+ if (SystemConstant.strNotNull(property)) {
|
|
|
+ List<DimensionDto> dimensionList = JSON.parseArray(property,
|
|
|
+ CourseDimensionDto.class).stream().filter(e -> courseDimensionMap.containsKey(e.getCode())).flatMap(e -> {
|
|
|
+ DimensionDto dimensionDto = new DimensionDto();
|
|
|
+ dimensionDto.setDimensionId(courseDimensionMap.get(e.getCode()).getId());
|
|
|
+ dimensionDto.setDimensionCode(e.getCode());
|
|
|
+ dimensionDto.setDimensionName(e.getName());
|
|
|
+ return Stream.of(dimensionDto);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<CourseTargetWebDto> courseTargetResultList = this.buildByDimensionList(
|
|
|
+ courseTargetList, dimensionList);
|
|
|
+ subCell.setTargetList(courseTargetResultList);
|
|
|
+ }
|
|
|
+ subCell.setMainNumber(mainNumber);
|
|
|
+ subCell.setSubNumber(subNumberIndex.getAndIncrement());
|
|
|
+ subCell.setScore(score);
|
|
|
+ result.add(subCell);
|
|
|
+ }
|
|
|
+
|
|
|
+ } else {
|
|
|
+ // 不包含套题
|
|
|
+ PaperStructDimensionResult cell = new PaperStructDimensionResult();
|
|
|
+ Double score = question.getDouble("score");
|
|
|
+ String property = question.getString("property");
|
|
|
+ if (SystemConstant.strNotNull(property)) {
|
|
|
+ List<DimensionDto> dimensionList = JSON.parseArray(property, CourseDimensionDto.class).stream().filter(e -> courseDimensionMap.containsKey(e.getCode()))
|
|
|
+ .flatMap(e -> {
|
|
|
+ DimensionDto dimensionDto = new DimensionDto();
|
|
|
+ dimensionDto.setDimensionId(courseDimensionMap.get(e.getCode()).getId());
|
|
|
+ dimensionDto.setDimensionCode(e.getCode());
|
|
|
+ dimensionDto.setDimensionName(e.getName());
|
|
|
+ return Stream.of(dimensionDto);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<CourseTargetWebDto> courseTargetResultList = this.buildByDimensionList(
|
|
|
+ courseTargetList, dimensionList);
|
|
|
+ cell.setTargetList(courseTargetResultList);
|
|
|
+ }
|
|
|
+ cell.setMainNumber(mainNumber);
|
|
|
+ cell.setSubNumber(subNumberIndex.getAndIncrement());
|
|
|
+ cell.setScore(score);
|
|
|
+ result.add(cell);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 构建知识点占用情况对象
|
|
|
*
|
|
@@ -270,4 +378,37 @@ public class CourseTargetServiceImpl extends ServiceImpl<CourseTargetMapper, Cou
|
|
|
dto.setStatus(false);
|
|
|
return dto;
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 根据知识点查询对应的课程目标
|
|
|
+ *
|
|
|
+ * @param courseTargetDatasource 课程目标数据源
|
|
|
+ * @param dimensionDtoList 知识点集合
|
|
|
+ * @return 结果
|
|
|
+ */
|
|
|
+ private List<CourseTargetWebDto> buildByDimensionList(List<CourseTarget> courseTargetDatasource,
|
|
|
+ List<DimensionDto> dimensionDtoList) {
|
|
|
+ List<CourseTargetWebDto> result = new ArrayList<>();
|
|
|
+ for (CourseTarget courseTarget : courseTargetDatasource) {
|
|
|
+ Long courseTargetId = courseTarget.getId();
|
|
|
+ String targetName = courseTarget.getTargetName();
|
|
|
+
|
|
|
+ String content = courseTarget.getTargetContent();
|
|
|
+ List<Long> dimensionIdList = JSON.parseArray(content, Long.class);
|
|
|
+ List<DimensionDto> dimensionList = dimensionDtoList.stream().filter(e -> dimensionIdList.contains(e.getDimensionId())).collect(Collectors.toList());
|
|
|
+
|
|
|
+ if (CollectionUtils.isNotEmpty(dimensionList)) {
|
|
|
+ CourseTargetWebDto courseTargetWebDto = new CourseTargetWebDto();
|
|
|
+ courseTargetWebDto.setTargetName(targetName);
|
|
|
+ courseTargetWebDto.setTargetId(courseTargetId);
|
|
|
+ courseTargetWebDto.setDimensionList(dimensionList);
|
|
|
+ result.add(courseTargetWebDto);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (result.size() > 1) {
|
|
|
+ // 一个试题只能存在于一个目标下
|
|
|
+ return new ArrayList<>();
|
|
|
+ }
|
|
|
+ return result;
|
|
|
+ }
|
|
|
}
|