|
@@ -3,6 +3,7 @@ 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.core.conditions.update.UpdateWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.google.common.collect.Lists;
|
|
|
import com.qmth.distributed.print.business.bean.dto.excel.GradePaperStructDto;
|
|
@@ -14,11 +15,9 @@ import com.qmth.distributed.print.business.bean.result.analyze.GradePaperStructR
|
|
|
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.entity.TBSyncTask;
|
|
|
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.distributed.print.business.service.*;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
import com.qmth.teachcloud.common.entity.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
@@ -33,10 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.math.BigDecimal;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.Comparator;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
+import java.util.*;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -56,17 +52,23 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
private ExamPaperStructureService examPaperStructureService;
|
|
|
@Resource
|
|
|
private ExamTaskService examTaskService;
|
|
|
+ @Resource
|
|
|
+ private TBSyncTaskService tbSyncTaskService;
|
|
|
|
|
|
@Override
|
|
|
- public List<GradePaperStructResult> findGradePaperStructureResultList(String paperNumber, String paperType, SysUser requestUser) {
|
|
|
+ public List<GradePaperStructResult> findGradePaperStructureResultList(String paperNumber, String paperType, boolean useExamCloudStruct, SysUser requestUser) {
|
|
|
Long schoolId = requestUser.getSchoolId();
|
|
|
List<GradePaperStructResult> result = new ArrayList<>();
|
|
|
// 先从分析试卷结构表取
|
|
|
List<GradePaperStructResult> gradeStructDatasource = this.baseMapper.findStructByGradePaper(schoolId, paperNumber, paperType);
|
|
|
- if (gradeStructDatasource != null && gradeStructDatasource.size() > 0) {
|
|
|
+ if (gradeStructDatasource != null && gradeStructDatasource.size() > 0 && !useExamCloudStruct) {
|
|
|
+ // 如果已经设置了试卷结构且没有使用云阅卷试卷结构(没有触发更新试卷结构按钮),查询之前配置好的分析参数-试卷结构
|
|
|
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)
|
|
@@ -75,6 +77,25 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
if (Objects.isNull(examPaperStructure)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("该试卷还没有上传评卷参数设置");
|
|
|
}
|
|
|
+ if (useExamCloudStruct) {
|
|
|
+ // 如果使用云阅卷试卷结构
|
|
|
+ Map<QuestionType, List<Question>> examCloudPaperStructMap = examPaperStructureService.parseExamCloudPaperStruct(examPaperStructure.getId());
|
|
|
+ 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);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
|
|
|
.eq(ExamTask::getSchoolId, schoolId)
|
|
|
.eq(ExamTask::getPaperNumber, paperNumber));
|
|
@@ -84,18 +105,6 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
String courseCode = examTask.getCourseCode();
|
|
|
String courseName = examTask.getCourseName();
|
|
|
|
|
|
- // 客观题
|
|
|
- List<Question> examPaperObjList = new ArrayList<>();
|
|
|
- String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperObj)) {
|
|
|
- examPaperObjList = JSON.parseArray(examPaperObj, Question.class);
|
|
|
- }
|
|
|
- // 主观题
|
|
|
- List<Question> examPaperSubList = new ArrayList<>();
|
|
|
- String examPaperSub = examPaperStructure.getSubjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperSub)) {
|
|
|
- examPaperSubList = JSON.parseArray(examPaperSub, Question.class);
|
|
|
- }
|
|
|
// 按题号排序
|
|
|
examPaperObjList = examPaperObjList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
|
|
|
examPaperSubList = examPaperSubList.stream().sorted(Comparator.comparing(Question::getMainNumber).thenComparing(Question::getSubNumber)).collect(Collectors.toList());
|
|
@@ -137,11 +146,15 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
String paperNumber = gradePaperStructParam.getPaperNumber();
|
|
|
String paperType = gradePaperStructParam.getPaperType();
|
|
|
String paperName = gradePaperStructParam.getPaperName();
|
|
|
+ Boolean useExamCloudStruct = gradePaperStructParam.getUseExamCloudStruct();
|
|
|
+ if (useExamCloudStruct == null){
|
|
|
+ useExamCloudStruct = false;
|
|
|
+ }
|
|
|
List<GradePaperStructDatasource> datasource = gradePaperStructParam.getDatasource();
|
|
|
// 验证批次分析试卷是否在计算
|
|
|
gradeBatchPaperService.checkOperateAuth(schoolId, paperNumber, paperType);
|
|
|
// 检验结构正确性并构建分析试卷结构
|
|
|
- List<GradePaperStruct> gradePaperStructList = this.checkAndBuildGradePaperStruct(datasource, paperNumber, paperType, paperName, requestUser);
|
|
|
+ List<GradePaperStruct> gradePaperStructList = this.checkAndBuildGradePaperStruct(datasource, paperNumber, paperType, paperName, useExamCloudStruct, requestUser);
|
|
|
// 删除旧的试卷结构
|
|
|
this.remove(new QueryWrapper<GradePaperStruct>()
|
|
|
.lambda()
|
|
@@ -149,11 +162,18 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
.eq(GradePaperStruct::getPaperNumber, paperNumber)
|
|
|
.eq(GradePaperStruct::getPaperType, paperType));
|
|
|
this.saveBatch(gradePaperStructList);
|
|
|
+ // 保存成功后如果是用了云阅卷结构的去t_b_sync_task表把该试卷编号的remark清掉
|
|
|
+ if (useExamCloudStruct){
|
|
|
+ UpdateWrapper<TBSyncTask> tbSyncTaskUpdateWrapper = new UpdateWrapper<>();
|
|
|
+ tbSyncTaskUpdateWrapper.lambda().eq(TBSyncTask::getSchoolId,schoolId).eq(TBSyncTask::getRemark,paperNumber);
|
|
|
+ tbSyncTaskUpdateWrapper.lambda().set(TBSyncTask::getRemark,null);
|
|
|
+ tbSyncTaskService.update(tbSyncTaskUpdateWrapper);
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
@Transactional(rollbackFor = Exception.class)
|
|
|
@Override
|
|
|
- public void importGradePaperStruct(MultipartFile file, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException {
|
|
|
+ public void importGradePaperStruct(MultipartFile file, String paperNumber, String paperType, String paperName, Boolean useExamCloudStruct, SysUser requestUser) throws IOException, NoSuchFieldException {
|
|
|
if (Objects.isNull(file)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
}
|
|
@@ -168,6 +188,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
gradePaperStructParam.setPaperNumber(paperNumber);
|
|
|
gradePaperStructParam.setPaperType(paperType);
|
|
|
gradePaperStructParam.setPaperName(paperName);
|
|
|
+ gradePaperStructParam.setUseExamCloudStruct(useExamCloudStruct);
|
|
|
List<GradePaperStructDatasource> gradePaperStructDatasourceList = new ArrayList<>();
|
|
|
|
|
|
if (Objects.nonNull(finalList) && finalList.size() > 0) {
|
|
@@ -196,7 +217,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void exportGradePaperStructTemplate(String paperNumber, String paperType, SysUser requestUser) throws Exception {
|
|
|
+ public void exportGradePaperStructTemplate(String paperNumber, String paperType, boolean useExamCloudStruct, SysUser requestUser) throws Exception {
|
|
|
|
|
|
ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
|
|
|
.eq(ExamTask::getSchoolId, requestUser.getSchoolId())
|
|
@@ -207,7 +228,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
String courseCode = examTask.getCourseCode();
|
|
|
String courseName = examTask.getCourseName();
|
|
|
|
|
|
- List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(paperNumber, paperType, requestUser);
|
|
|
+ List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(paperNumber, paperType, useExamCloudStruct, requestUser);
|
|
|
List<GradePaperStructDto> gradePaperStructDtoList = datasource.stream().flatMap(e -> {
|
|
|
GradePaperStructDto cell = new GradePaperStructDto();
|
|
|
cell.setCourseCode(courseCode);
|
|
@@ -234,16 +255,18 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
/**
|
|
|
* 检验结构正确性并构建分析试卷结构
|
|
|
*
|
|
|
- * @param datasource 数据源
|
|
|
- * @param paperNumber 试卷编号
|
|
|
- * @param paperType 试卷类型
|
|
|
- * @param paperName 试卷名称
|
|
|
- * @param requestUser 请求用户
|
|
|
+ * @param datasource 数据源
|
|
|
+ * @param paperNumber 试卷编号
|
|
|
+ * @param paperType 试卷类型
|
|
|
+ * @param paperName 试卷名称
|
|
|
+ * @param useExamCloudStruct 使用云阅卷结构
|
|
|
+ * @param requestUser 请求用户
|
|
|
* @return 创建好的分析试卷结构
|
|
|
*/
|
|
|
- private List<GradePaperStruct> checkAndBuildGradePaperStruct(List<GradePaperStructDatasource> datasource, String paperNumber, String paperType, String paperName, SysUser requestUser) {
|
|
|
+ private List<GradePaperStruct> checkAndBuildGradePaperStruct(List<GradePaperStructDatasource> datasource, String paperNumber, String paperType, String paperName, Boolean useExamCloudStruct, SysUser requestUser) {
|
|
|
Long schoolId = requestUser.getSchoolId();
|
|
|
Long userId = requestUser.getId();
|
|
|
+
|
|
|
ExamPaperStructure examPaperStructure = examPaperStructureService.getOne(new QueryWrapper<ExamPaperStructure>()
|
|
|
.lambda()
|
|
|
.eq(ExamPaperStructure::getSchoolId, schoolId)
|
|
@@ -252,12 +275,28 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
if (Objects.isNull(examPaperStructure)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("该试卷还没有上传评卷参数设置");
|
|
|
}
|
|
|
-
|
|
|
// 客观题
|
|
|
List<Question> examPaperObjList = new ArrayList<>();
|
|
|
- String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperObj)) {
|
|
|
- examPaperObjList = JSON.parseArray(examPaperObj, Question.class);
|
|
|
+ // 主观题
|
|
|
+ List<Question> examPaperSubList = new ArrayList<>();
|
|
|
+ // 对比信息
|
|
|
+ String comparison = "知学知考";
|
|
|
+ if (useExamCloudStruct != null && useExamCloudStruct) {
|
|
|
+ // 应用云阅卷试卷结构
|
|
|
+ Map<QuestionType, List<Question>> questionTypeListMap = examPaperStructureService.parseExamCloudPaperStruct(examPaperStructure.getId());
|
|
|
+ examPaperObjList = questionTypeListMap.get(QuestionType.OBJECTIVE);
|
|
|
+ examPaperSubList = questionTypeListMap.get(QuestionType.SUBJECTIVE);
|
|
|
+ comparison = "云阅卷";
|
|
|
+ } 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()
|
|
@@ -269,18 +308,10 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
cell.setSubNumber(e.getSmallQuestionNumber());
|
|
|
cell.setTotalScore(e.getFullScore());
|
|
|
return Stream.of(cell);
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
if (!Question.matchTwoQuestionList(examPaperObjList, gradePaperObjList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
- "】的分析试卷结构和 评卷参数试卷结构在【" + QuestionType.OBJECTIVE.getDesc() + "】上不一致");
|
|
|
- }
|
|
|
-
|
|
|
- // 主观题
|
|
|
- List<Question> examPaperSubList = new ArrayList<>();
|
|
|
- String examPaperSub = examPaperStructure.getSubjectiveStructure();
|
|
|
- if (SystemConstant.strNotNull(examPaperSub)) {
|
|
|
- examPaperSubList = JSON.parseArray(examPaperSub, Question.class);
|
|
|
+ "】的分析试卷结构和 [" + comparison + "] 试卷结构在【" + QuestionType.OBJECTIVE.getDesc() + "】上不一致");
|
|
|
}
|
|
|
|
|
|
List<Question> gradePaperSubList = datasource.stream()
|
|
@@ -292,11 +323,10 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
cell.setSubNumber(e.getSmallQuestionNumber());
|
|
|
cell.setTotalScore(e.getFullScore());
|
|
|
return Stream.of(cell);
|
|
|
- })
|
|
|
- .collect(Collectors.toList());
|
|
|
+ }).collect(Collectors.toList());
|
|
|
if (!Question.matchTwoQuestionList(examPaperSubList, gradePaperSubList)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
- "】的分析试卷结构和 评卷参数试卷结构在【" + QuestionType.SUBJECTIVE.getDesc() + "】上不一致");
|
|
|
+ "】的分析试卷结构和 [" + comparison + "] 试卷结构在【" + QuestionType.SUBJECTIVE.getDesc() + "】上不一致");
|
|
|
}
|
|
|
|
|
|
return datasource.stream().flatMap(e -> {
|