|
@@ -1,5 +1,6 @@
|
|
|
package com.qmth.teachcloud.report.business.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.qmth.teachcloud.common.bean.params.UserSaveParams;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
@@ -13,6 +14,7 @@ import com.qmth.teachcloud.common.service.BasicCourseService;
|
|
|
import com.qmth.teachcloud.common.service.SysOrgService;
|
|
|
import com.qmth.teachcloud.common.service.SysRoleService;
|
|
|
import com.qmth.teachcloud.common.service.SysUserService;
|
|
|
+import com.qmth.teachcloud.report.business.bean.dto.BasicExamCourseDataMd5;
|
|
|
import com.qmth.teachcloud.report.business.bean.dto.printOpen.*;
|
|
|
import com.qmth.teachcloud.report.business.bean.dto.query.TBSchoolClazzDto;
|
|
|
import com.qmth.teachcloud.report.business.bean.dto.query.TBSchoolCollegeDto;
|
|
@@ -20,6 +22,7 @@ import com.qmth.teachcloud.report.business.bean.dto.query.TBSchoolTeacherDto;
|
|
|
import com.qmth.teachcloud.report.business.entity.*;
|
|
|
import com.qmth.teachcloud.report.business.enums.NumberTypeEnum;
|
|
|
import com.qmth.teachcloud.report.business.service.*;
|
|
|
+import org.apache.commons.codec.digest.DigestUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
|
|
@@ -79,80 +82,131 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbPaperDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ public boolean tbPaperDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ boolean repeat = false;
|
|
|
if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
}
|
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
PaperConfig paperConfig = callPrintOpenApiService.callPaperConfig(examId, courseCode);
|
|
|
-
|
|
|
- BigDecimal coefficient = BigDecimal.ZERO;
|
|
|
- if (Objects.nonNull(paperConfig.getCoefficient())) {
|
|
|
- coefficient = BigDecimal.valueOf(Double.parseDouble(String.valueOf(paperConfig.getCoefficient())));
|
|
|
- }
|
|
|
- String paperType = paperConfig.getPaperType();
|
|
|
- List<TBPaper> oldList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
|
|
|
- .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode).eq(TBPaper::getPaperType, paperType));
|
|
|
- Long id;
|
|
|
- if (oldList.size() == 1) {
|
|
|
- id = oldList.get(0).getId();
|
|
|
- } else if (oldList.size() < 1) {
|
|
|
- id = SystemConstant.getDbUuid();
|
|
|
+ // md5 检验
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
+ .eq(TBExamCourse::getSchoolId, schoolId)
|
|
|
+ .eq(TBExamCourse::getExamId, examId)
|
|
|
+ .eq(TBExamCourse::getCourseCode, courseCode));
|
|
|
+ BasicExamCourseDataMd5 md5 = JSON.parseObject(tbExamCourse.getOpenDataMd5(),BasicExamCourseDataMd5.class);
|
|
|
+ String oldMd5 = "";
|
|
|
+ if (Objects.nonNull(md5)) {
|
|
|
+ oldMd5 = md5.getPaperMd5();
|
|
|
} else {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("表数据异常[t_b_paper]");
|
|
|
+ md5 = new BasicExamCourseDataMd5();
|
|
|
}
|
|
|
+ String currentMd5 = this.buildPaperDataMd5(paperConfig);
|
|
|
+ if (!currentMd5.equals(oldMd5)) {
|
|
|
+ // md5 不一致需要重算
|
|
|
+ repeat = true;
|
|
|
+ md5.setPaperMd5(currentMd5);
|
|
|
+ tbExamCourse.setOpenDataMd5(JSON.toJSONString(md5));
|
|
|
+ tbExamCourseService.saveOrUpdate(tbExamCourse);
|
|
|
+
|
|
|
+
|
|
|
+ BigDecimal coefficient = BigDecimal.ZERO;
|
|
|
+ if (Objects.nonNull(paperConfig.getCoefficient())) {
|
|
|
+ coefficient = BigDecimal.valueOf(Double.parseDouble(String.valueOf(paperConfig.getCoefficient())));
|
|
|
+ }
|
|
|
+ String paperType = paperConfig.getPaperType();
|
|
|
+ List<TBPaper> oldList = tbPaperService.list(new QueryWrapper<TBPaper>().lambda()
|
|
|
+ .eq(TBPaper::getExamId, examId).eq(TBPaper::getCourseCode, courseCode).eq(TBPaper::getPaperType, paperType));
|
|
|
+ Long id;
|
|
|
+ if (oldList.size() == 1) {
|
|
|
+ id = oldList.get(0).getId();
|
|
|
+ } else if (oldList.size() < 1) {
|
|
|
+ id = SystemConstant.getDbUuid();
|
|
|
+ } else {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("表数据异常[t_b_paper]");
|
|
|
+ }
|
|
|
|
|
|
- TBPaper tbPaper = new TBPaper();
|
|
|
- tbPaper.setExamId(examId);
|
|
|
- tbPaper.setCourseCode(courseCode);
|
|
|
- tbPaper.setCourseName(courseName);
|
|
|
- tbPaper.setPaperType(paperConfig.getPaperType());
|
|
|
- Long startTime = tbPaper.getStartTime();
|
|
|
- Long endTime = tbPaper.getEndTime();
|
|
|
- if (!SystemConstant.isOneNull(startTime, endTime)) {
|
|
|
- tbPaper.setStartTime(startTime);
|
|
|
- tbPaper.setEndTime(endTime);
|
|
|
+ TBPaper tbPaper = new TBPaper();
|
|
|
+ tbPaper.setExamId(examId);
|
|
|
+ tbPaper.setCourseCode(courseCode);
|
|
|
+ tbPaper.setCourseName(courseName);
|
|
|
+ tbPaper.setPaperType(paperConfig.getPaperType());
|
|
|
+ Long startTime = tbPaper.getStartTime();
|
|
|
+ Long endTime = tbPaper.getEndTime();
|
|
|
+ if (!SystemConstant.isOneNull(startTime, endTime)) {
|
|
|
+ tbPaper.setStartTime(startTime);
|
|
|
+ tbPaper.setEndTime(endTime);
|
|
|
+ }
|
|
|
+ tbPaper.setCoefficient(coefficient);
|
|
|
+ tbPaper.setTotalScore(paperConfig.getTotalScore());
|
|
|
+ tbPaper.setPassScore(paperConfig.getPassScore());
|
|
|
+ tbPaper.setScoreType(paperConfig.getScoreType());
|
|
|
+ tbPaper.setId(id);
|
|
|
+ tbPaperService.saveOrUpdate(tbPaper);
|
|
|
}
|
|
|
- tbPaper.setCoefficient(coefficient);
|
|
|
- tbPaper.setTotalScore(paperConfig.getTotalScore());
|
|
|
- tbPaper.setPassScore(paperConfig.getPassScore());
|
|
|
- tbPaper.setScoreType(paperConfig.getScoreType());
|
|
|
- tbPaper.setId(id);
|
|
|
- tbPaperService.saveOrUpdate(tbPaper);
|
|
|
+ return repeat;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbPaperDimensionDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ public boolean tbPaperDimensionDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ boolean repeat = false;
|
|
|
if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
}
|
|
|
List<PaperDimension> paperDimensionList = callPrintOpenApiService.callPaperDimension(examId, courseCode);
|
|
|
- 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().getDesc());
|
|
|
- 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);
|
|
|
+ // md5 检验
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
+ .eq(TBExamCourse::getSchoolId,schoolId)
|
|
|
+ .eq(TBExamCourse::getExamId,examId)
|
|
|
+ .eq(TBExamCourse::getCourseCode,courseCode));
|
|
|
+ BasicExamCourseDataMd5 md5 = JSON.parseObject(tbExamCourse.getOpenDataMd5(),BasicExamCourseDataMd5.class);
|
|
|
+ String oldMd5 = "";
|
|
|
+ if (Objects.nonNull(md5)){
|
|
|
+ oldMd5 = md5.getDimensionMd5();
|
|
|
+ }
|
|
|
+ String currentMd5 = this.buildDimensionDataMd5(paperDimensionList);
|
|
|
+ if (!currentMd5.equals(oldMd5)) {
|
|
|
+ // md5 不一致需要重算
|
|
|
+ repeat = true;
|
|
|
+ md5.setDimensionMd5(currentMd5);
|
|
|
+ tbExamCourse.setOpenDataMd5(JSON.toJSONString(md5));
|
|
|
+ tbExamCourseService.saveOrUpdate(tbExamCourse);
|
|
|
+ // -- --
|
|
|
+
|
|
|
+ String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
+ List<TBDimension> old = tbDimensionService.list(new QueryWrapper<TBDimension>().lambda().eq(TBDimension::getExamId, examId).eq(TBDimension::getCourseCode, courseCode));
|
|
|
+ if (old != null && old.size() > 0){
|
|
|
+ repeat = this.checkTBDimensionRepeat(old,paperDimensionList);
|
|
|
+ }
|
|
|
+
|
|
|
+ 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().getDesc());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ return repeat;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbPaperStructDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ public boolean tbPaperStructDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ boolean repeat = false;
|
|
|
if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
}
|
|
@@ -165,139 +219,211 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
|
|
|
|
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().getDesc());
|
|
|
- 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());
|
|
|
+ // md5 检验
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
+ .eq(TBExamCourse::getSchoolId,schoolId)
|
|
|
+ .eq(TBExamCourse::getExamId,examId)
|
|
|
+ .eq(TBExamCourse::getCourseCode,courseCode));
|
|
|
+ BasicExamCourseDataMd5 md5 = JSON.parseObject(tbExamCourse.getOpenDataMd5(),BasicExamCourseDataMd5.class);
|
|
|
+ String oldMd5 = "";
|
|
|
+ if (Objects.nonNull(md5)){
|
|
|
+ oldMd5 = md5.getStructMd5();
|
|
|
+ }
|
|
|
+ String currentMd5 = this.buildStructDataMd5(paperStructureList);
|
|
|
+ //因为t_b_paper表是做更新操作的所以当结构数据md5一致,即使是t_b_paper的数据改了,也不影响试卷结构数据所绑定的paper_id 所以不用重新算
|
|
|
+ if (!currentMd5.equals(oldMd5)) {
|
|
|
+ // md5 不一致需要重算
|
|
|
+ repeat = true;
|
|
|
+ md5.setStructMd5(currentMd5);
|
|
|
+ tbExamCourse.setOpenDataMd5(JSON.toJSONString(md5));
|
|
|
+ tbExamCourseService.saveOrUpdate(tbExamCourse);
|
|
|
+ // -- --
|
|
|
+
|
|
|
+ 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().getDesc());
|
|
|
+ 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);
|
|
|
+ // 删除试卷id下所有试卷结构
|
|
|
+ tbPaperStructService.remove(new QueryWrapper<TBPaperStruct>().lambda().eq(TBPaperStruct::getPaperId, paperId));
|
|
|
+ // 新增试卷id下的试卷结构
|
|
|
+ tbPaperStructService.saveBatch(tbPaperStructList);
|
|
|
+ }
|
|
|
+ return repeat;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ public boolean tbPaperModuleDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ boolean repeat = false;
|
|
|
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().getDesc();
|
|
|
-
|
|
|
- // 解析并生成'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(SystemConstant.strNotNull(e.getDefine())?e.getDefine().trim():null);
|
|
|
- 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");
|
|
|
+ // md5 检验
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
+ .eq(TBExamCourse::getSchoolId,schoolId)
|
|
|
+ .eq(TBExamCourse::getExamId,examId)
|
|
|
+ .eq(TBExamCourse::getCourseCode,courseCode));
|
|
|
+ BasicExamCourseDataMd5 md5 = JSON.parseObject(tbExamCourse.getOpenDataMd5(),BasicExamCourseDataMd5.class);
|
|
|
+ String oldMd5 = "";
|
|
|
+ if (Objects.nonNull(md5)){
|
|
|
+ oldMd5 = md5.getModuleMd5();
|
|
|
+ }
|
|
|
+ String currentMd5 = this.buildModuleDataMd5(paperEvaluationList);
|
|
|
+ if (!currentMd5.equals(oldMd5)) {
|
|
|
+ // md5 不一致需要重算
|
|
|
+ repeat = true;
|
|
|
+ md5.setModuleMd5(currentMd5);
|
|
|
+ tbExamCourse.setOpenDataMd5(JSON.toJSONString(md5));
|
|
|
+ tbExamCourseService.saveOrUpdate(tbExamCourse);
|
|
|
+ // -- --
|
|
|
+
|
|
|
+ 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 + "】异常");
|
|
|
}
|
|
|
- return Stream.of(tbModuleConfig);
|
|
|
- }).collect(Collectors.toList());
|
|
|
- tbModuleConfigList.addAll(tbModuleConfigCell);
|
|
|
+ checkDimensionType.put(moduleType, paperEvaluation);
|
|
|
+
|
|
|
+ String interpret = paperEvaluation.getInterpret();
|
|
|
+ String remark = paperEvaluation.getRemark();
|
|
|
+ String formula = paperEvaluation.getFormula().getDesc();
|
|
|
+
|
|
|
+ // 解析并生成'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(SystemConstant.strNotNull(e.getDefine()) ? e.getDefine().trim() : null);
|
|
|
+ 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);
|
|
|
}
|
|
|
- // 删除后新增
|
|
|
- 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);
|
|
|
+ return repeat;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void tbExamStudentScoreDatasourceDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ public boolean tbExamStudentScoreDatasourceDispose(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ boolean repeat = false;
|
|
|
if (tbExamCourseService.verifyExamCourseCantRun(examId, schoolId, courseCode, null)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("课程编号为【" + courseCode + "】的课程不能进行数据更改");
|
|
|
}
|
|
|
String courseName = basicCourseService.findByCourseCode(courseCode, schoolId).getName();
|
|
|
List<ExamStudentScore> examStudentScoreList = callPrintOpenApiService.callExamStudentScore(examId, courseCode);
|
|
|
-
|
|
|
- // 1.创建班级数据
|
|
|
- this.createTBSchoolClazz(examStudentScoreList, schoolId);
|
|
|
- // 2.筛选并创建学校学院表
|
|
|
- this.createCollegeInfo(examStudentScoreList, schoolId);
|
|
|
- // 3.筛选并创建教师
|
|
|
- this.saveTeacherInfo(examStudentScoreList, examId, courseCode, schoolId);
|
|
|
- // 4.创建学生及作答
|
|
|
- this.saveExamStudentScore(examStudentScoreList, examId, courseCode, courseName, schoolId);
|
|
|
+ // md5 检查
|
|
|
+ TBExamCourse tbExamCourse = tbExamCourseService.getOne(new QueryWrapper<TBExamCourse>().lambda()
|
|
|
+ .eq(TBExamCourse::getSchoolId,schoolId)
|
|
|
+ .eq(TBExamCourse::getExamId,examId)
|
|
|
+ .eq(TBExamCourse::getCourseCode,courseCode));
|
|
|
+ BasicExamCourseDataMd5 md5 = JSON.parseObject(tbExamCourse.getOpenDataMd5(),BasicExamCourseDataMd5.class);
|
|
|
+ String oldMd5 = "";
|
|
|
+ if (Objects.nonNull(md5)){
|
|
|
+ oldMd5 = md5.getStudentScoreMd5();
|
|
|
+ }
|
|
|
+ String currentMd5 = this.buildExamStudentDataMd5(examStudentScoreList);
|
|
|
+
|
|
|
+ //因为t_b_paper表是做更新操作的所以当学生数据md5一致,即使是t_b_paper的数据改了,也不影响学生数据所绑定的paper_id 所以不用重新算
|
|
|
+ if (!currentMd5.equals(oldMd5)){
|
|
|
+ // md5 不一致需要重算
|
|
|
+ repeat = true;
|
|
|
+ md5.setStudentScoreMd5(currentMd5);
|
|
|
+ tbExamCourse.setOpenDataMd5(JSON.toJSONString(md5));
|
|
|
+ tbExamCourseService.saveOrUpdate(tbExamCourse);
|
|
|
+ // -- --
|
|
|
+
|
|
|
+ // 1.创建班级数据
|
|
|
+ this.createTBSchoolClazz(examStudentScoreList, schoolId);
|
|
|
+ // 2.筛选并创建学校学院表
|
|
|
+ this.createCollegeInfo(examStudentScoreList, schoolId);
|
|
|
+ // 3.筛选并创建教师
|
|
|
+ this.saveTeacherInfo(examStudentScoreList, examId, courseCode, schoolId);
|
|
|
+ // 4.创建学生及作答
|
|
|
+ this.saveExamStudentScore(examStudentScoreList, examId, courseCode, courseName, schoolId);
|
|
|
+ }
|
|
|
+ return repeat;
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void dataGetAndEdit(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
- this.tbPaperDispose(examId, courseCode, schoolId);
|
|
|
- this.tbPaperDimensionDispose(examId, courseCode, schoolId);
|
|
|
- this.tbPaperStructDispose(examId, courseCode, schoolId);
|
|
|
- this.tbPaperModuleDispose(examId, courseCode, schoolId);
|
|
|
- this.tbExamStudentScoreDatasourceDispose(examId, courseCode, schoolId);
|
|
|
+ public boolean dataGetAndEdit(Long examId, String courseCode, Long schoolId) throws IOException {
|
|
|
+ boolean repeat = false;
|
|
|
+ boolean repeatForPaper = this.tbPaperDispose(examId, courseCode, schoolId);
|
|
|
+ boolean repeatForDimension = this.tbPaperDimensionDispose(examId, courseCode, schoolId);
|
|
|
+ boolean repeatForStruct = this.tbPaperStructDispose(examId, courseCode, schoolId);
|
|
|
+ boolean repeatForModule = this.tbPaperModuleDispose(examId, courseCode, schoolId);
|
|
|
+ boolean repeatForExamStudentScore = this.tbExamStudentScoreDatasourceDispose(examId, courseCode, schoolId);
|
|
|
+ if (repeatForPaper || repeatForDimension || repeatForStruct || repeatForModule || repeatForExamStudentScore){
|
|
|
+ repeat = true;
|
|
|
+ }
|
|
|
+ return repeat;
|
|
|
}
|
|
|
|
|
|
/**
|
|
@@ -635,4 +761,104 @@ public class AnalyzeDataGetAndEditServiceImpl implements AnalyzeDataGetAndEditSe
|
|
|
tbExamRecordService.saveBatch(tbExamRecordList);
|
|
|
tbAnswerService.saveBatch(tbAnswerList);
|
|
|
}
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检验基础试卷有变动需要重新计算
|
|
|
+ *
|
|
|
+ * @param old 旧的试卷
|
|
|
+ * @param current 现在的试卷
|
|
|
+ * @return 1:重算 - 0 :不用
|
|
|
+ */
|
|
|
+ private boolean checkTBPaperRepeat(TBPaper old, PaperConfig current) {
|
|
|
+ String oldStr = old.getPaperType() + old.getScoreType() + old.getCoefficient() + old.getTotalScore() + old.getPassScore();
|
|
|
+ String currentStr = current.getPaperType() + current.getScoreType() + current.getCoefficient() + current.getTotalScore() + current.getPassScore();
|
|
|
+ return !currentStr.equals(oldStr);
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 检验维度点变动的重新计算
|
|
|
+ *
|
|
|
+ * @param old 旧维度
|
|
|
+ * @param current 新维度
|
|
|
+ * @return 1:重算 - 0 :不用
|
|
|
+ */
|
|
|
+ private boolean checkTBDimensionRepeat(List<TBDimension> old, List<PaperDimension> current) {
|
|
|
+ if (old.isEmpty() || current.size() != old.size()) {
|
|
|
+ return false;
|
|
|
+ } else {
|
|
|
+ old = old.stream().sorted(Comparator.comparing(TBDimension::getDimensionType)
|
|
|
+ .thenComparing(TBDimension::getCodePrimary)
|
|
|
+ .thenComparing(TBDimension::getCodeSecond))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ current = current.stream().sorted(Comparator.comparing(PaperDimension::getDimensionType)
|
|
|
+ .thenComparing(PaperDimension::getCodePrimary)
|
|
|
+ .thenComparing(PaperDimension::getCodeSecond))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+
|
|
|
+ List<String> oldStrList = old.stream().flatMap(e -> {
|
|
|
+ String x = e.getDimensionType() + e.getNamePrimary() + e.getCodePrimary() + e.getNameSecond() + e.getCodeSecond() + e.getInterpretation();
|
|
|
+ return Stream.of(x);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ List<String> currentStrList = current.stream().flatMap(e -> {
|
|
|
+ String x = e.getDimensionType() + e.getNamePrimary() + e.getCodePrimary() + e.getNameSecond() + e.getCodeSecond() + e.getInterpretation();
|
|
|
+ return Stream.of(x);
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ return !oldStrList.toString().equals(currentStrList.toString());
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建试卷信息md5
|
|
|
+ * @param paperConfig 试卷配置
|
|
|
+ * @return md5
|
|
|
+ */
|
|
|
+ private String buildPaperDataMd5(PaperConfig paperConfig){
|
|
|
+ return DigestUtils.md5Hex(JSON.toJSONString(paperConfig));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建维度信息md5
|
|
|
+ * @param paperDimensionList 维度信息
|
|
|
+ * @return MD5
|
|
|
+ */
|
|
|
+ private String buildDimensionDataMd5(List<PaperDimension> paperDimensionList){
|
|
|
+ paperDimensionList = paperDimensionList.stream().sorted(Comparator.comparing(PaperDimension::getDimensionType)
|
|
|
+ .thenComparing(PaperDimension::getCodePrimary)
|
|
|
+ .thenComparing(PaperDimension::getCodeSecond))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return DigestUtils.md5Hex(JSON.toJSONString(paperDimensionList));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建结构信息md5
|
|
|
+ * @param paperStructureList 试卷结构信息
|
|
|
+ * @return MD5
|
|
|
+ */
|
|
|
+ private String buildStructDataMd5(List<PaperStructure> paperStructureList){
|
|
|
+ paperStructureList = paperStructureList.stream().sorted(Comparator.comparing(PaperStructure::getNumberType)
|
|
|
+ .thenComparing(PaperStructure::getBigQuestionNumber)
|
|
|
+ .thenComparing(PaperStructure::getSmallQuestionNumber)).collect(Collectors.toList());
|
|
|
+ return DigestUtils.md5Hex(JSON.toJSONString(paperStructureList));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建模块信息MD5
|
|
|
+ * @param paperEvaluationList 试卷模块信息
|
|
|
+ * @return MD5
|
|
|
+ */
|
|
|
+ private String buildModuleDataMd5(List<PaperEvaluation> paperEvaluationList){
|
|
|
+ paperEvaluationList = paperEvaluationList.stream().sorted(Comparator.comparing(PaperEvaluation::getModuleType))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ return DigestUtils.md5Hex(JSON.toJSONString(paperEvaluationList));
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 构建学生成绩数据md5
|
|
|
+ * @param examStudentScoreList 学生成绩数据
|
|
|
+ * @return md5
|
|
|
+ */
|
|
|
+ private String buildExamStudentDataMd5(List<ExamStudentScore> examStudentScoreList){
|
|
|
+ examStudentScoreList = examStudentScoreList.stream().sorted(Comparator.comparing(ExamStudentScore::getStudentCode)).collect(Collectors.toList());
|
|
|
+ return DigestUtils.md5Hex(JSON.toJSONString(examStudentScoreList));
|
|
|
+ }
|
|
|
}
|