|
@@ -1,6 +1,5 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
-import com.alibaba.fastjson.JSON;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
@@ -11,21 +10,20 @@ import com.qmth.distributed.print.business.bean.marking.Question;
|
|
|
import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructDatasource;
|
|
|
import com.qmth.distributed.print.business.bean.params.analyze.GradePaperStructParam;
|
|
|
import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructResult;
|
|
|
-import com.qmth.distributed.print.business.entity.ExamPaperStructure;
|
|
|
import com.qmth.distributed.print.business.entity.ExamTask;
|
|
|
import com.qmth.distributed.print.business.entity.GradePaperStruct;
|
|
|
import com.qmth.distributed.print.business.mapper.GradePaperStructMapper;
|
|
|
-import com.qmth.distributed.print.business.service.ExamPaperStructureService;
|
|
|
import com.qmth.distributed.print.business.service.ExamTaskService;
|
|
|
import com.qmth.distributed.print.business.service.GradeBatchPaperService;
|
|
|
import com.qmth.distributed.print.business.service.GradePaperStructService;
|
|
|
-import com.qmth.teachcloud.common.bean.dto.stmms.ExamCloudPaperStructDto;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.entity.MarkQuestion;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
-import com.qmth.teachcloud.common.enums.QuestionType;
|
|
|
+import com.qmth.teachcloud.common.enums.ObjectiveType;
|
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
+import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
@@ -52,12 +50,10 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
@Resource
|
|
|
private GradeBatchPaperService gradeBatchPaperService;
|
|
|
@Resource
|
|
|
- private ExamPaperStructureService examPaperStructureService;
|
|
|
- @Resource
|
|
|
private ExamTaskService examTaskService;
|
|
|
|
|
|
@Override
|
|
|
- public List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser) {
|
|
|
+ public List<GradePaperStructResult> findGradePaperStructureResultList(Long examId, String paperNumber, String paperType, SysUser requestUser, List<MarkQuestion> markQuestionList) {
|
|
|
Long schoolId = requestUser.getSchoolId();
|
|
|
List<GradePaperStructResult> result = new ArrayList<>();
|
|
|
// 先从分析试卷结构表取
|
|
@@ -66,40 +62,14 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
// 如果已经设置了试卷结构查询之前配置好的分析参数-试卷结构
|
|
|
result = gradeStructDatasource;
|
|
|
} else {
|
|
|
- // 构建客观题结构集合
|
|
|
- List<Question> examPaperObjList = new ArrayList<>();
|
|
|
- // 构建主观题结构集合
|
|
|
- List<Question> examPaperSubList = new ArrayList<>();
|
|
|
- ExamPaperStructure examPaperStructure = examPaperStructureService.getOne(new QueryWrapper<ExamPaperStructure>()
|
|
|
- .lambda()
|
|
|
- .eq(ExamPaperStructure::getSchoolId, schoolId)
|
|
|
- .eq(ExamPaperStructure::getExamId, examId)
|
|
|
- .eq(ExamPaperStructure::getPaperNumber, paperNumber)
|
|
|
- .eq(ExamPaperStructure::getPaperType, paperType));
|
|
|
- if (Objects.isNull(examPaperStructure)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该试卷还没有上传评卷参数设置");
|
|
|
- }
|
|
|
- String cloudInfoJson = examPaperStructure.getCloudInfoJson();
|
|
|
- if (SystemConstant.strNotNull(cloudInfoJson)) {
|
|
|
- // 如果云阅卷同步回来的结构不为空,优先使用云阅卷的
|
|
|
- List<ExamCloudPaperStructDto> examCloudPaperStructDtoList = JSON.parseArray(cloudInfoJson, ExamCloudPaperStructDto.class);
|
|
|
- Map<QuestionType, List<Question>> examCloudPaperStructMap = parseExamCloudPaperStruct(examCloudPaperStructDtoList);
|
|
|
- examPaperObjList = examCloudPaperStructMap.get(QuestionType.OBJECTIVE);
|
|
|
- examPaperSubList = examCloudPaperStructMap.get(QuestionType.SUBJECTIVE);
|
|
|
- } else {
|
|
|
- // 当客观题答案未上传导致云阅卷客观题结构不完整不同步时,使用知学知考试卷结构
|
|
|
- // 客观题
|
|
|
- String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperObj)) {
|
|
|
- examPaperObjList = JSON.parseArray(examPaperObj, Question.class);
|
|
|
- }
|
|
|
- // 主观题
|
|
|
- String examPaperSub = examPaperStructure.getSubjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperSub)) {
|
|
|
- examPaperSubList = JSON.parseArray(examPaperSub, Question.class);
|
|
|
- }
|
|
|
+ if (CollectionUtils.isEmpty(markQuestionList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("知学知考试卷结构不存在");
|
|
|
}
|
|
|
|
|
|
+ // 如果云阅卷同步回来的结构不为空,优先使用云阅卷的
|
|
|
+ Map<ObjectiveType, List<Question>> examCloudPaperStructMap = parseExamCloudPaperStruct(markQuestionList);
|
|
|
+ List<Question> examPaperObjList = examCloudPaperStructMap.get(ObjectiveType.OBJECTIVE);
|
|
|
+ List<Question> examPaperSubList = examCloudPaperStructMap.get(ObjectiveType.SUBJECTIVE);
|
|
|
|
|
|
List<ExamTask> examTaskList = examTaskService.list(new QueryWrapper<ExamTask>().lambda()
|
|
|
.eq(ExamTask::getSchoolId, schoolId)
|
|
@@ -124,7 +94,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
cell.setCourseName(courseName);
|
|
|
cell.setPaperNumber(paperNumber);
|
|
|
cell.setPaperType(paperType);
|
|
|
- cell.setNumberType(QuestionType.OBJECTIVE);
|
|
|
+ cell.setNumberType(ObjectiveType.OBJECTIVE);
|
|
|
cell.setBigTopicName(question.getMainTitle());
|
|
|
cell.setBigQuestionNumber(String.valueOf(question.getMainNumber()));
|
|
|
cell.setSmallQuestionNumber(question.getSubNumber());
|
|
@@ -138,7 +108,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
cell.setCourseName(courseName);
|
|
|
cell.setPaperNumber(paperNumber);
|
|
|
cell.setPaperType(paperType);
|
|
|
- cell.setNumberType(QuestionType.SUBJECTIVE);
|
|
|
+ cell.setNumberType(ObjectiveType.SUBJECTIVE);
|
|
|
cell.setBigTopicName(question.getMainTitle());
|
|
|
cell.setBigQuestionNumber(String.valueOf(question.getMainNumber()));
|
|
|
cell.setSmallQuestionNumber(question.getSubNumber());
|
|
@@ -207,7 +177,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
gradePaperStructDatasource.setBigQuestionNumber(gradePaperStructDto.getBigQuestionNumber());
|
|
|
gradePaperStructDatasource.setSmallQuestionNumber(gradePaperStructDto.getSmallQuestionNumber());
|
|
|
gradePaperStructDatasource.setBigTopicName(gradePaperStructDto.getBigTopicName());
|
|
|
- gradePaperStructDatasource.setNumberType(QuestionType.convertToEnum(gradePaperStructDto.getNumberType()));
|
|
|
+ gradePaperStructDatasource.setNumberType(ObjectiveType.convertToEnum(gradePaperStructDto.getNumberType()));
|
|
|
gradePaperStructDatasource.setFullScore(BigDecimal.valueOf(Double.parseDouble(gradePaperStructDto.getFullScore())));
|
|
|
gradePaperStructDatasource.setKnowledgeDimension(gradePaperStructDto.getKnowledgeDimension());
|
|
|
gradePaperStructDatasource.setAbilityDimension(gradePaperStructDto.getAbilityDimension());
|
|
@@ -221,7 +191,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, @NotNull SysUser requestUser) throws Exception {
|
|
|
+ public void exportGradePaperStructTemplate(Long examId, String paperNumber, String paperType, @NotNull SysUser requestUser, List<MarkQuestion> markQuestionList) throws Exception {
|
|
|
|
|
|
ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
|
|
|
.eq(ExamTask::getSchoolId, requestUser.getSchoolId())
|
|
@@ -232,7 +202,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
String courseCode = examTask.getCourseCode();
|
|
|
String courseName = examTask.getCourseName();
|
|
|
|
|
|
- List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser);
|
|
|
+ List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(examId, paperNumber, paperType, requestUser, markQuestionList);
|
|
|
List<GradePaperStructDto> gradePaperStructDtoList = datasource.stream().flatMap(e -> {
|
|
|
GradePaperStructDto cell = new GradePaperStructDto();
|
|
|
cell.setCourseCode(courseCode);
|
|
@@ -258,43 +228,18 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void updateExamCloudPaperStruct(Long schoolId, String paperNumber, String paperType) {
|
|
|
+ public void updateExamCloudPaperStruct(Long schoolId, String paperNumber, String paperType, List<MarkQuestion> markQuestionList) {
|
|
|
// 更新试卷结构参数的云阅卷试卷结构
|
|
|
- QueryWrapper<ExamPaperStructure> queryWrapper = new QueryWrapper<>();
|
|
|
- queryWrapper.lambda()
|
|
|
- .eq(ExamPaperStructure::getSchoolId, schoolId)
|
|
|
- .eq(ExamPaperStructure::getPaperNumber, paperNumber);
|
|
|
- if (SystemConstant.strNotNull(paperType)) {
|
|
|
- queryWrapper.lambda().eq(ExamPaperStructure::getPaperType, paperType);
|
|
|
- }
|
|
|
-
|
|
|
- List<ExamPaperStructure> examPaperStructureList = examPaperStructureService.list(queryWrapper);
|
|
|
-
|
|
|
- if (examPaperStructureList.size() != 1) {
|
|
|
+ if (CollectionUtils.isEmpty(markQuestionList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("知学知考试卷结构异常");
|
|
|
}
|
|
|
- ExamPaperStructure examPaperStructure = examPaperStructureList.get(0);
|
|
|
- // 云阅卷考试ID
|
|
|
- String examId = String.valueOf(examPaperStructure.getThirdRelateId());
|
|
|
- // 科目代码(课程代码+卷型+课程序号)
|
|
|
- String subjectCode = examPaperStructure.getCourseCode().concat(examPaperStructure.getPaperType()).concat(examPaperStructure.getSequence());
|
|
|
-
|
|
|
- String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
-
|
|
|
// 如果没有客观题 试卷类型传空
|
|
|
paperType = null;
|
|
|
-// if (SystemConstant.strNotNull(examPaperObj)) {
|
|
|
-// List<Question> examPaperObjList = JSON.parseArray(examPaperObj, Question.class);
|
|
|
-// if (examPaperObjList != null && examPaperObjList.size() > 0) {
|
|
|
-// paperType = examPaperStructure.getPaperType();
|
|
|
-// }
|
|
|
-// }
|
|
|
-
|
|
|
// todo 3.3.0待更新
|
|
|
// String cloudInfoJson = cloudMarkingTaskUtils.queryPaperStructure(schoolId, examId, subjectCode, paperType);
|
|
|
// examPaperStructure.setCloudInfoJson(cloudInfoJson);
|
|
|
- examPaperStructure.setStructureChange(false);
|
|
|
- examPaperStructureService.updateById(examPaperStructure);
|
|
|
+// examPaperStructure.setStructureChange(false);
|
|
|
+// examPaperStructureService.updateById(examPaperStructure);
|
|
|
|
|
|
// 更新grade_paper_struct
|
|
|
QueryWrapper<GradePaperStruct> willDeleteQueryWrapper = new QueryWrapper<>();
|
|
@@ -344,98 +289,17 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}).collect(Collectors.toList());
|
|
|
}
|
|
|
|
|
|
- /**
|
|
|
- * 保存教研分析分析中基础配置命题蓝图设置保存时的数据校验
|
|
|
- * <p>
|
|
|
- * 1.优先校验云阅卷试卷结构返回字段
|
|
|
- * 2.如果云阅卷试卷结构返回字段为空,则和知学知考原字段做比较
|
|
|
- * </p>
|
|
|
- *
|
|
|
- * @param datasource 保存的试卷结构数据集
|
|
|
- * @param paperNumber 试卷编号
|
|
|
- * @param paperType 试卷类型
|
|
|
- * @param requestUser 请求用户
|
|
|
- */
|
|
|
- private void checkPaperStructWhenSave(List<GradePaperStructDatasource> datasource, String paperNumber, String paperType, SysUser requestUser) {
|
|
|
- Long schoolId = requestUser.getSchoolId();
|
|
|
- ExamPaperStructure examPaperStructure = examPaperStructureService.getOne(new QueryWrapper<ExamPaperStructure>()
|
|
|
- .lambda()
|
|
|
- .eq(ExamPaperStructure::getSchoolId, schoolId)
|
|
|
- .eq(ExamPaperStructure::getPaperNumber, paperNumber)
|
|
|
- .eq(ExamPaperStructure::getPaperType, paperType));
|
|
|
- if (Objects.isNull(examPaperStructure)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("该试卷还没有上传评卷参数设置");
|
|
|
- }
|
|
|
- //客观题
|
|
|
- List<Question> examPaperObjList = new ArrayList<>();
|
|
|
- // 主观题
|
|
|
- List<Question> examPaperSubList = new ArrayList<>();
|
|
|
- // 对比信息
|
|
|
- String comparison = "知学知考";
|
|
|
- int code = ExceptionResultEnum.ERROR.getCode();
|
|
|
- String cloudInfoJson = examPaperStructure.getCloudInfoJson();
|
|
|
- if (SystemConstant.strNotNull(cloudInfoJson)) {
|
|
|
- // 优先与云阅卷对比
|
|
|
- List<ExamCloudPaperStructDto> examCloudPaperStructDtoList = JSON.parseArray(cloudInfoJson, ExamCloudPaperStructDto.class);
|
|
|
- Map<QuestionType, List<Question>> questionTypeListMap = parseExamCloudPaperStruct(examCloudPaperStructDtoList);
|
|
|
- examPaperObjList = questionTypeListMap.get(QuestionType.OBJECTIVE);
|
|
|
- examPaperSubList = questionTypeListMap.get(QuestionType.SUBJECTIVE);
|
|
|
- comparison = "云阅卷";
|
|
|
- code = ExceptionResultEnum.PAPER_STRUCT_EXCEPTION.getCode();
|
|
|
- } else {
|
|
|
- // 当云阅卷试卷结构同步结果没有时与知学知考对比
|
|
|
- String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperObj)) {
|
|
|
- examPaperObjList = JSON.parseArray(examPaperObj, Question.class);
|
|
|
- }
|
|
|
- String examPaperSub = examPaperStructure.getSubjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperSub)) {
|
|
|
- examPaperSubList = JSON.parseArray(examPaperSub, Question.class);
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- List<Question> gradePaperObjList = datasource.stream()
|
|
|
- .filter(e -> QuestionType.OBJECTIVE.equals(e.getNumberType()))
|
|
|
- .flatMap(e -> {
|
|
|
- Question cell = new Question();
|
|
|
- cell.setMainNumber(Integer.valueOf(e.getBigQuestionNumber()));
|
|
|
- cell.setMainTitle(e.getBigTopicName());
|
|
|
- cell.setSubNumber(e.getSmallQuestionNumber());
|
|
|
- cell.setTotalScore(e.getFullScore());
|
|
|
- return Stream.of(cell);
|
|
|
- }).collect(Collectors.toList());
|
|
|
- if (!Question.matchTwoQuestionList(examPaperObjList, gradePaperObjList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(code, "试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
- "】的分析试卷结构和 [" + comparison + "] 试卷结构在【" + QuestionType.OBJECTIVE.getDesc() + "】上不一致");
|
|
|
- }
|
|
|
-
|
|
|
- List<Question> gradePaperSubList = datasource.stream()
|
|
|
- .filter(e -> QuestionType.SUBJECTIVE.equals(e.getNumberType()))
|
|
|
- .flatMap(e -> {
|
|
|
- Question cell = new Question();
|
|
|
- cell.setMainNumber(Integer.valueOf(e.getBigQuestionNumber()));
|
|
|
- cell.setMainTitle(e.getBigTopicName());
|
|
|
- cell.setSubNumber(e.getSmallQuestionNumber());
|
|
|
- cell.setTotalScore(e.getFullScore());
|
|
|
- return Stream.of(cell);
|
|
|
- }).collect(Collectors.toList());
|
|
|
- if (!Question.matchTwoQuestionList(examPaperSubList, gradePaperSubList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception(code, "试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
- "】的分析试卷结构和 [" + comparison + "] 试卷结构在【" + QuestionType.SUBJECTIVE.getDesc() + "】上不一致");
|
|
|
- }
|
|
|
- }
|
|
|
-
|
|
|
- private Map<QuestionType, List<Question>> parseExamCloudPaperStruct(List<ExamCloudPaperStructDto> examCloudPaperStructDtoList) {
|
|
|
- Map<QuestionType, List<Question>> result = new HashMap<>();
|
|
|
+ private Map<ObjectiveType, List<Question>> parseExamCloudPaperStruct(List<MarkQuestion> markQuestionList) {
|
|
|
+ Map<ObjectiveType, List<Question>> result = new HashMap<>();
|
|
|
List<Question> objList = new ArrayList<>();
|
|
|
List<Question> subList = new ArrayList<>();
|
|
|
- for (ExamCloudPaperStructDto examCloudPaperStructDto : examCloudPaperStructDtoList) {
|
|
|
- boolean objective = examCloudPaperStructDto.getObjective();
|
|
|
- String mainTitle = examCloudPaperStructDto.getMainTitle();
|
|
|
- Integer mainNumber = examCloudPaperStructDto.getMainNumber();
|
|
|
- Integer subNumber = examCloudPaperStructDto.getSubNumber();
|
|
|
- double totalScore = examCloudPaperStructDto.getTotalScore();
|
|
|
- String answer = examCloudPaperStructDto.getAnswer();
|
|
|
+ for (MarkQuestion markQuestion : markQuestionList) {
|
|
|
+ boolean objective = markQuestion.getObjective();
|
|
|
+ String mainTitle = markQuestion.getMainTitle();
|
|
|
+ Integer mainNumber = markQuestion.getMainNumber();
|
|
|
+ Integer subNumber = markQuestion.getSubNumber();
|
|
|
+ double totalScore = markQuestion.getTotalScore();
|
|
|
+ String answer = markQuestion.getAnswer();
|
|
|
|
|
|
Question question = new Question();
|
|
|
question.setMainTitle(mainTitle);
|
|
@@ -449,8 +313,8 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
subList.add(question);
|
|
|
}
|
|
|
}
|
|
|
- result.put(QuestionType.OBJECTIVE, objList);
|
|
|
- result.put(QuestionType.SUBJECTIVE, subList);
|
|
|
+ result.put(ObjectiveType.OBJECTIVE, objList);
|
|
|
+ result.put(ObjectiveType.SUBJECTIVE, subList);
|
|
|
return result;
|
|
|
}
|
|
|
}
|