|
@@ -3,7 +3,6 @@ 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;
|
|
@@ -15,15 +14,20 @@ 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.*;
|
|
|
+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.SysUser;
|
|
|
import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
import com.qmth.teachcloud.common.enums.QuestionType;
|
|
|
+import com.qmth.teachcloud.common.sync.CloudMarkingTaskUtils;
|
|
|
import com.qmth.teachcloud.common.util.ExcelUtil;
|
|
|
import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
+import org.jetbrains.annotations.NotNull;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.LinkedMultiValueMap;
|
|
@@ -53,16 +57,16 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
@Resource
|
|
|
private ExamTaskService examTaskService;
|
|
|
@Resource
|
|
|
- private TBSyncTaskService tbSyncTaskService;
|
|
|
+ private CloudMarkingTaskUtils cloudMarkingTaskUtils;
|
|
|
|
|
|
@Override
|
|
|
- public List<GradePaperStructResult> findGradePaperStructureResultList(String paperNumber, String paperType, boolean useExamCloudStruct, SysUser requestUser) {
|
|
|
+ public List<GradePaperStructResult> findGradePaperStructureResultList(String paperNumber, String paperType, 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 && !useExamCloudStruct) {
|
|
|
- // 如果已经设置了试卷结构且没有使用云阅卷试卷结构(没有触发更新试卷结构按钮),查询之前配置好的分析参数-试卷结构
|
|
|
+ if (gradeStructDatasource != null && gradeStructDatasource.size() > 0) {
|
|
|
+ // 如果已经设置了试卷结构查询之前配置好的分析参数-试卷结构
|
|
|
result = gradeStructDatasource;
|
|
|
} else {
|
|
|
// 构建客观题结构集合
|
|
@@ -77,13 +81,15 @@ 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());
|
|
|
+ String cloudInfoJson = examPaperStructure.getCloudInfoJson();
|
|
|
+ if (SystemConstant.strNotNull(cloudInfoJson)) {
|
|
|
+ // 如果云阅卷同步回来的结构不为空,优先使用云阅卷的
|
|
|
+ List<ExamCloudPaperStructDto> examCloudPaperStructDtoList = JSON.parseArray(cloudInfoJson, ExamCloudPaperStructDto.class);
|
|
|
+ Map<QuestionType, List<Question>> examCloudPaperStructMap = examPaperStructureService.parseExamCloudPaperStruct(examCloudPaperStructDtoList);
|
|
|
examPaperObjList = examCloudPaperStructMap.get(QuestionType.OBJECTIVE);
|
|
|
examPaperSubList = examCloudPaperStructMap.get(QuestionType.SUBJECTIVE);
|
|
|
} else {
|
|
|
- // 如果老师还没设置过分析参数则从评卷参数中把试卷结构取出来
|
|
|
+ // 当客观题答案未上传导致云阅卷客观题结构不完整不同步时,使用知学知考试卷结构
|
|
|
// 客观题
|
|
|
String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
if (SystemConstant.strNotNull(examPaperObj)) {
|
|
@@ -146,15 +152,11 @@ 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, useExamCloudStruct, requestUser);
|
|
|
+ List<GradePaperStruct> gradePaperStructList = this.checkAndBuildGradePaperStruct(datasource, paperNumber, paperType, paperName, requestUser);
|
|
|
// 删除旧的试卷结构
|
|
|
this.remove(new QueryWrapper<GradePaperStruct>()
|
|
|
.lambda()
|
|
@@ -162,22 +164,14 @@ 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, Boolean useExamCloudStruct, SysUser requestUser) throws IOException, NoSuchFieldException {
|
|
|
+ public void importGradePaperStruct(MultipartFile file, String paperNumber, String paperType, String paperName, SysUser requestUser) throws IOException, NoSuchFieldException {
|
|
|
if (Objects.isNull(file)) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("找不到附件");
|
|
|
}
|
|
|
-
|
|
|
List<LinkedMultiValueMap<Integer, Object>> finalList = ExcelUtil.excelReader(file.getInputStream(), Lists.newArrayList(GradePaperStructDto.class), (finalExcelList, finalColumnNameList, finalExcelErrorList) -> {
|
|
|
if (finalExcelErrorList.size() > 0) {
|
|
|
throw ExceptionResultEnum.ERROR.exception(JSONObject.toJSONString(finalExcelErrorList));
|
|
@@ -188,7 +182,6 @@ 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) {
|
|
@@ -217,7 +210,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public void exportGradePaperStructTemplate(String paperNumber, String paperType, boolean useExamCloudStruct, SysUser requestUser) throws Exception {
|
|
|
+ public void exportGradePaperStructTemplate(String paperNumber, String paperType, @NotNull SysUser requestUser) throws Exception {
|
|
|
|
|
|
ExamTask examTask = examTaskService.getOne(new QueryWrapper<ExamTask>().lambda()
|
|
|
.eq(ExamTask::getSchoolId, requestUser.getSchoolId())
|
|
@@ -228,7 +221,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
String courseCode = examTask.getCourseCode();
|
|
|
String courseName = examTask.getCourseName();
|
|
|
|
|
|
- List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(paperNumber, paperType, useExamCloudStruct, requestUser);
|
|
|
+ List<GradePaperStructResult> datasource = this.findGradePaperStructureResultList(paperNumber, paperType, requestUser);
|
|
|
List<GradePaperStructDto> gradePaperStructDtoList = datasource.stream().flatMap(e -> {
|
|
|
GradePaperStructDto cell = new GradePaperStructDto();
|
|
|
cell.setCourseCode(courseCode);
|
|
@@ -252,18 +245,45 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
return this.baseMapper.findBySchoolIdAndPaperNumberAndPaperType(schoolId, paperNumber, paperType);
|
|
|
}
|
|
|
|
|
|
+ @Transactional(rollbackFor = Exception.class)
|
|
|
+ @Override
|
|
|
+ public void updateExamCloudPaperStruct(Long schoolId, String paperNumber) {
|
|
|
+ // 更新试卷结构参数的云阅卷试卷结构
|
|
|
+ List<ExamPaperStructure> examPaperStructureList = examPaperStructureService.list(new QueryWrapper<ExamPaperStructure>()
|
|
|
+ .lambda()
|
|
|
+ .eq(ExamPaperStructure::getSchoolId,schoolId)
|
|
|
+ .eq(ExamPaperStructure::getPaperNumber,paperNumber));
|
|
|
+ if (examPaperStructureList.size() != 1){
|
|
|
+ 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 cloudInfoJson = cloudMarkingTaskUtils.queryPaperStructure(schoolId, examId, subjectCode, examPaperStructure.getPaperType());
|
|
|
+ examPaperStructure.setCloudInfoJson(cloudInfoJson);
|
|
|
+ examPaperStructure.setStructureChange(false);
|
|
|
+ examPaperStructureService.updateById(examPaperStructure);
|
|
|
+
|
|
|
+ // 更新grade_paper_struct
|
|
|
+ this.remove(new QueryWrapper<GradePaperStruct>()
|
|
|
+ .lambda()
|
|
|
+ .eq(GradePaperStruct::getSchoolId,schoolId)
|
|
|
+ .eq(GradePaperStruct::getPaperNumber,paperNumber));
|
|
|
+ }
|
|
|
+
|
|
|
/**
|
|
|
* 检验结构正确性并构建分析试卷结构
|
|
|
*
|
|
|
- * @param datasource 数据源
|
|
|
- * @param paperNumber 试卷编号
|
|
|
- * @param paperType 试卷类型
|
|
|
- * @param paperName 试卷名称
|
|
|
- * @param useExamCloudStruct 使用云阅卷结构
|
|
|
- * @param requestUser 请求用户
|
|
|
+ * @param datasource 数据源
|
|
|
+ * @param paperNumber 试卷编号
|
|
|
+ * @param paperType 试卷类型
|
|
|
+ * @param paperName 试卷名称
|
|
|
+ * @param requestUser 请求用户
|
|
|
* @return 创建好的分析试卷结构
|
|
|
*/
|
|
|
- private List<GradePaperStruct> checkAndBuildGradePaperStruct(List<GradePaperStructDatasource> datasource, String paperNumber, String paperType, String paperName, Boolean useExamCloudStruct, SysUser requestUser) {
|
|
|
+ private List<GradePaperStruct> checkAndBuildGradePaperStruct(List<GradePaperStructDatasource> datasource, String paperNumber, String paperType, String paperName, SysUser requestUser) {
|
|
|
Long schoolId = requestUser.getSchoolId();
|
|
|
Long userId = requestUser.getId();
|
|
|
|
|
@@ -281,14 +301,18 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
List<Question> examPaperSubList = new ArrayList<>();
|
|
|
// 对比信息
|
|
|
String comparison = "知学知考";
|
|
|
- if (useExamCloudStruct != null && useExamCloudStruct) {
|
|
|
- // 应用云阅卷试卷结构
|
|
|
- Map<QuestionType, List<Question>> questionTypeListMap = examPaperStructureService.parseExamCloudPaperStruct(examPaperStructure.getId());
|
|
|
+ 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 = examPaperStructureService.parseExamCloudPaperStruct(examCloudPaperStructDtoList);
|
|
|
examPaperObjList = questionTypeListMap.get(QuestionType.OBJECTIVE);
|
|
|
examPaperSubList = questionTypeListMap.get(QuestionType.SUBJECTIVE);
|
|
|
comparison = "云阅卷";
|
|
|
+ code = SystemConstant.PAPER_STRUCT_EXCEPTION_CODE;
|
|
|
} else {
|
|
|
- // 应用知学知考试卷结构
|
|
|
+ // 当云阅卷试卷结构同步结果没有时与知学知考对比
|
|
|
String examPaperObj = examPaperStructure.getObjectiveStructure();
|
|
|
if (SystemConstant.strNotNull(examPaperObj)) {
|
|
|
examPaperObjList = JSON.parseArray(examPaperObj, Question.class);
|
|
@@ -310,7 +334,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
return Stream.of(cell);
|
|
|
}).collect(Collectors.toList());
|
|
|
if (!Question.matchTwoQuestionList(examPaperObjList, gradePaperObjList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(code,"试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
"】的分析试卷结构和 [" + comparison + "] 试卷结构在【" + QuestionType.OBJECTIVE.getDesc() + "】上不一致");
|
|
|
}
|
|
|
|
|
@@ -325,7 +349,7 @@ public class GradePaperStructServiceImpl extends ServiceImpl<GradePaperStructMap
|
|
|
return Stream.of(cell);
|
|
|
}).collect(Collectors.toList());
|
|
|
if (!Question.matchTwoQuestionList(examPaperSubList, gradePaperSubList)) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(code,"试卷编号为【" + paperNumber + "】,试卷类型为【" + paperType +
|
|
|
"】的分析试卷结构和 [" + comparison + "] 试卷结构在【" + QuestionType.SUBJECTIVE.getDesc() + "】上不一致");
|
|
|
}
|
|
|
|