|
@@ -2,23 +2,21 @@ package com.qmth.teachcloud.report.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.enums.DimensionEnum;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
-import com.qmth.teachcloud.report.business.bean.dto.printOpen.PaperConfig;
|
|
|
-import com.qmth.teachcloud.report.business.bean.dto.printOpen.PaperDimension;
|
|
|
-import com.qmth.teachcloud.report.business.entity.TBPaper;
|
|
|
-import com.qmth.teachcloud.report.business.service.AnalyzeDataGetAndEditService;
|
|
|
-import com.qmth.teachcloud.report.business.service.CallPrintOpenApiService;
|
|
|
-import com.qmth.teachcloud.report.business.service.TBExamCourseService;
|
|
|
-import com.qmth.teachcloud.report.business.service.TBPaperService;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.printOpen.*;
|
|
|
+import com.qmth.teachcloud.report.business.entity.*;
|
|
|
+import com.qmth.teachcloud.report.business.service.*;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
+import java.util.stream.Stream;
|
|
|
|
|
|
/**
|
|
|
* @Description: 分析数据获取和编辑服务实现类
|
|
@@ -36,6 +34,17 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
|
|
|
|
@Resource
|
|
|
private TBPaperService tbPaperService;
|
|
|
+ @Resource
|
|
|
+ private TBDimensionService tbDimensionService;
|
|
|
+ @Resource
|
|
|
+ private TBPaperStructService tbPaperStructService;
|
|
|
+ @Resource
|
|
|
+ private TBModuleProficiencyService tbModuleProficiencyService;
|
|
|
+ @Resource
|
|
|
+ private TBModuleConfigService tbModuleConfigService;
|
|
|
+
|
|
|
+ @Resource
|
|
|
+ private AnalyzeDataCheckService analyzeDataCheckService;
|
|
|
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
@@ -88,20 +97,147 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
}
|
|
|
List<PaperDimension> paperDimensionList = callPrintOpenApiService.callPaperDimension(examId,courseCode);
|
|
|
- // TODO: 2022/6/8 维度新增
|
|
|
-// List<TBDimension> tbDimensionList = paperDimensionList.stream().flatMap(e -> )
|
|
|
+ String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
+
|
|
|
+ List<TBDimension> tbDimensionList = paperDimensionList.stream().flatMap(e -> {
|
|
|
+ TBDimension tbDimension = new TBDimension();
|
|
|
+ tbDimension.setId(SystemConstant.getDbUuid());
|
|
|
+ tbDimension.setExamId(examId);
|
|
|
+ tbDimension.setCourseCode(courseCode);
|
|
|
+ tbDimension.setCourseName(courseName);
|
|
|
+ tbDimension.setDimensionType(e.getDimensionType());
|
|
|
+ tbDimension.setCodePrimary(e.getCodePrimary());
|
|
|
+ tbDimension.setNamePrimary(e.getNamePrimary());
|
|
|
+ tbDimension.setCodeSecond(e.getCodeSecond());
|
|
|
+ tbDimension.setNameSecond(e.getNameSecond());
|
|
|
+ tbDimension.setInterpretation(e.getInterpretation());
|
|
|
+ return Stream.of(tbDimension);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ // 根据课程编号删除已有
|
|
|
+ tbDimensionService.remove(new QueryWrapper<TBDimension>().lambda().eq(TBDimension::getExamId,examId).eq(TBDimension::getCourseCode,courseCode));
|
|
|
+ // 批量新增
|
|
|
+ tbDimensionService.saveBatch(tbDimensionList);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbPaperStructDispose(Long examId, String courseCode, Long schoolId) {
|
|
|
+ public void tbPaperStructDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,null)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
+ }
|
|
|
+ List<TBPaper> tbPaperList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda().eq(TBPaper::getExamId,examId).eq(TBPaper::getCourseCode,courseCode));
|
|
|
+ if (tbPaperList.size() != 1){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到考试id为【" + examId + "】,课程编号为【" + courseCode + "】的唯一试卷");
|
|
|
+ }
|
|
|
+ TBPaper tbPaper = tbPaperList.get(0);
|
|
|
+ Long paperId = tbPaper.getId();
|
|
|
|
|
|
+ List<PaperStructure> paperStructureList = callPrintOpenApiService.callPaperStruct(examId,courseCode);
|
|
|
+
|
|
|
+ List<TBPaperStruct> tbPaperStructList = paperStructureList.stream().flatMap(e -> {
|
|
|
+ TBPaperStruct tbPaperStruct = new TBPaperStruct();
|
|
|
+ tbPaperStruct.setId(SystemConstant.getDbUuid());
|
|
|
+ tbPaperStruct.setPaperId(paperId);
|
|
|
+ tbPaperStruct.setQuestionName(e.getQuestionName());
|
|
|
+ tbPaperStruct.setNumberType(e.getNumberType());
|
|
|
+ tbPaperStruct.setBigQuestionNumber(e.getBigQuestionNumber());
|
|
|
+ tbPaperStruct.setSmallQuestionNumber(e.getSmallQuestionNumber());
|
|
|
+ tbPaperStruct.setQuestionType(e.getBigTopicName());
|
|
|
+ tbPaperStruct.setFullScore(e.getFullScore());
|
|
|
+ tbPaperStruct.setScoreRules(e.getScoreRules());
|
|
|
+ String knowledgeDimension = e.getKnowledgeDimension();
|
|
|
+ String abilityDimension = e.getAbilityDimension();
|
|
|
+ // TODO: 2022/6/9 校验的实现
|
|
|
+ analyzeDataCheckService.checkPaperStructInDimensionDatasource(knowledgeDimension,abilityDimension,examId,courseCode);
|
|
|
+ tbPaperStruct.setKnowledgeDimension(knowledgeDimension);
|
|
|
+ tbPaperStruct.setAbilityDimension(abilityDimension);
|
|
|
+ return Stream.of(tbPaperStruct);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+
|
|
|
+ // 删除试卷id下所有试卷结构
|
|
|
+ tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().eq(TBPaperStruct::getPaperId,paperId));
|
|
|
+ // 新增试卷id下的试卷结构
|
|
|
+ tbPaperStructService.saveBatch(tbPaperStructList);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) {
|
|
|
+ public void tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ if (tbExamCourseService.verifyExamCourseCantRun(examId,schoolId,courseCode,null)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
+ }
|
|
|
+ String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
+ List<PaperEvaluation> paperEvaluationList = callPrintOpenApiService.callPaperModule(examId,courseCode);
|
|
|
+
|
|
|
+ List<TBModuleProficiency> tbModuleProficiencyList = new ArrayList<>();
|
|
|
+ List<TBModuleConfig> tbModuleConfigList = new ArrayList<>();
|
|
|
+ Map<DimensionEnum,PaperEvaluation> checkDimensionType = new HashMap<>();
|
|
|
+ for (PaperEvaluation paperEvaluation : paperEvaluationList) {
|
|
|
+ // 校验大的数据结构
|
|
|
+ DimensionEnum moduleType = paperEvaluation.getModuleType();
|
|
|
+ if (checkDimensionType.containsKey(moduleType)){
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("模块数据存在相同模块类型【" + moduleType + "】异常");
|
|
|
+ }
|
|
|
+ checkDimensionType.put(moduleType,paperEvaluation);
|
|
|
+
|
|
|
+ String interpret = paperEvaluation.getInterpret();
|
|
|
+ String remark = paperEvaluation.getRemark();
|
|
|
+ String formula = paperEvaluation.getFormula();
|
|
|
+
|
|
|
+ // 解析并生成't_b_module_proficiency' 二级维度精熟度
|
|
|
+ List<SecondaryDimensionLevelDefine> secondaryDimensionLevelDefineList = paperEvaluation.getSecondaryDimensionLevelDefineList();
|
|
|
+ List<TBModuleProficiency> tbModuleProficiencyCell = secondaryDimensionLevelDefineList.stream().flatMap(e -> {
|
|
|
+ TBModuleProficiency tbModuleProficiency = new TBModuleProficiency();
|
|
|
+ tbModuleProficiency.setId(SystemConstant.getDbUuid());
|
|
|
+ tbModuleProficiency.setExamId(examId);
|
|
|
+ tbModuleProficiency.setCourseCode(courseCode);
|
|
|
+ tbModuleProficiency.setCourseName(courseName);
|
|
|
+ tbModuleProficiency.setModuleType(moduleType.getDesc());
|
|
|
+ tbModuleProficiency.setInterpret(interpret);
|
|
|
+ tbModuleProficiency.setRemark(remark);
|
|
|
+ tbModuleProficiency.setDefine(e.getDefine().trim());
|
|
|
+ tbModuleProficiency.setLevel(e.getLevel());
|
|
|
+ tbModuleProficiency.setMin(e.getMin());
|
|
|
+ tbModuleProficiency.setMax(e.getMax());
|
|
|
+ tbModuleProficiency.setScope(e.getScope());
|
|
|
+ return Stream.of(tbModuleProficiency);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ tbModuleProficiencyList.addAll(tbModuleProficiencyCell);
|
|
|
+
|
|
|
+ // 解析并生成't_b_module_config' 维度模块等级评价及建议
|
|
|
+ List<ModuleEvaluation> moduleEvaluationList = paperEvaluation.getModuleEvaluationList();
|
|
|
+ List<TBModuleConfig> tbModuleConfigCell = moduleEvaluationList.stream().flatMap(e -> {
|
|
|
+ TBModuleConfig tbModuleConfig = new TBModuleConfig();
|
|
|
+ tbModuleConfig.setId(SystemConstant.getDbUuid());
|
|
|
+ tbModuleConfig.setExamId(examId);
|
|
|
+ tbModuleConfig.setCourseCode(courseCode);
|
|
|
+ tbModuleConfig.setCourseName(courseName);
|
|
|
+ tbModuleConfig.setModuleType(moduleType.getDesc());
|
|
|
+ tbModuleConfig.setFormula(formula);
|
|
|
+ tbModuleConfig.setScope(e.getScope());
|
|
|
+ tbModuleConfig.setLevelCode(e.getLevelCode());
|
|
|
+ tbModuleConfig.setLevelName(e.getLevelName());
|
|
|
+ tbModuleConfig.setResult(e.getResult());
|
|
|
+ tbModuleConfig.setAdvice(e.getAdvice());
|
|
|
+ if (DimensionEnum.KNOWLEDGE.equals(moduleType)) {
|
|
|
+ tbModuleConfig.setAttribute("knowledgeDimension");
|
|
|
+ } else if (DimensionEnum.ABILITY.equals(moduleType)) {
|
|
|
+ tbModuleConfig.setAttribute("abilityDimension");
|
|
|
+ }
|
|
|
+ return Stream.of(tbModuleConfig);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ tbModuleConfigList.addAll(tbModuleConfigCell);
|
|
|
+ }
|
|
|
+ // 删除后新增
|
|
|
+ tbModuleProficiencyService.remove(new QueryWrapper<TBModuleProficiency>().lambda()
|
|
|
+ .eq(TBModuleProficiency::getExamId,examId)
|
|
|
+ .eq(TBModuleProficiency::getCourseCode,courseCode));
|
|
|
+ tbModuleProficiencyService.saveBatch(tbModuleProficiencyList);
|
|
|
|
|
|
+ tbModuleConfigService.remove(new QueryWrapper<TBModuleConfig>().lambda()
|
|
|
+ .eq(TBModuleConfig::getExamId,examId)
|
|
|
+ .eq(TBModuleConfig::getCourseCode,courseCode));
|
|
|
+ tbModuleConfigService.saveBatch(tbModuleConfigList);
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|