|
@@ -2,6 +2,7 @@ package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
+import com.google.gson.reflect.TypeToken;
|
|
|
import com.qmth.boot.api.exception.ApiException;
|
|
|
import com.qmth.boot.tools.excel.ExcelReader;
|
|
|
import com.qmth.boot.tools.excel.enums.ExcelType;
|
|
@@ -12,14 +13,13 @@ import com.qmth.distributed.print.business.entity.TCPaperStruct;
|
|
|
import com.qmth.distributed.print.business.mapper.TCPaperStructMapper;
|
|
|
import com.qmth.distributed.print.business.service.*;
|
|
|
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.FieldUniqueEnum;
|
|
|
-import com.qmth.teachcloud.common.util.JacksonUtil;
|
|
|
-import com.qmth.teachcloud.common.util.RedisUtil;
|
|
|
-import com.qmth.teachcloud.common.util.ResultUtil;
|
|
|
-import com.qmth.teachcloud.common.util.ServletUtil;
|
|
|
+import com.qmth.teachcloud.common.util.*;
|
|
|
import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
|
+import com.qmth.teachcloud.mark.service.MarkQuestionService;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
|
@@ -32,6 +32,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.io.IOException;
|
|
|
import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* <p>
|
|
@@ -63,6 +64,9 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
|
|
|
@Resource
|
|
|
CourseTargetService courseTargetService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ MarkQuestionService markQuestionService;
|
|
|
+
|
|
|
/**
|
|
|
* 根据考试id/课程编码/试卷编码查询数据库数据
|
|
|
*
|
|
@@ -200,12 +204,14 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
|
|
|
StringJoiner successData = new StringJoiner("");
|
|
|
List<PaperStructDimensionResult> paperStructDimensionResultList = courseTargetService.findTikuPaperStruct(examId, paperNumber);
|
|
|
if (!CollectionUtils.isEmpty(paperStructDimensionResultList)) {
|
|
|
- for (PaperStructDimensionResult paperStructDimensionResult : paperStructDimensionResultList) {
|
|
|
- Objects.requireNonNull(paperStructDimensionResult.getMainNumber(), "大题号为空");
|
|
|
- Objects.requireNonNull(paperStructDimensionResult.getSubNumber(), "小题号为空");
|
|
|
- if (!CollectionUtils.isEmpty(paperStructDimensionResult.getTargetList()) && paperStructDimensionResult.getTargetList().size() > 1) {
|
|
|
+ List<String> paperStructList = new ArrayList<>(paperStructDimensionResultList.size()), paperStructDbList = new ArrayList<>(paperStructDimensionResultList.size());
|
|
|
+ for (PaperStructDimensionResult p : paperStructDimensionResultList) {
|
|
|
+ Objects.requireNonNull(p.getMainNumber(), "大题号为空");
|
|
|
+ Objects.requireNonNull(p.getSubNumber(), "小题号为空");
|
|
|
+ if (!CollectionUtils.isEmpty(p.getTargetList()) && p.getTargetList().size() > 1) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
|
|
|
}
|
|
|
+ paperStructList.add(p.getMainNumber() + "_" + p.getSubNumber() + "_" + p.getScore());
|
|
|
}
|
|
|
successData.add("共同步").add(paperStructDimensionResultList.size() + "").add("条数据");
|
|
|
TCPaperStruct tcPaperStructDb = tcPaperStructService.getOne(new QueryWrapper<TCPaperStruct>().lambda().eq(TCPaperStruct::getExamId, examId).eq(TCPaperStruct::getCourseCode, courseCode).eq(TCPaperStruct::getPaperNumber, paperNumber));
|
|
@@ -215,19 +221,43 @@ public class TCPaperStructServiceImpl extends ServiceImpl<TCPaperStructMapper, T
|
|
|
BeanUtils.copyProperties(tcPaperStructDb, tcPaperStruct);
|
|
|
tcPaperStruct.setPaperStructDimension(JacksonUtil.parseJson(paperStructDimensionResultList));
|
|
|
|
|
|
- if (!tcPaperStruct.equals(tcPaperStructDb)) {
|
|
|
+ if (Objects.nonNull(tcPaperStructDb.getPaperStruct())) {
|
|
|
+ List<PaperStructDto> paperStructDtoList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDto>>() {
|
|
|
+ }.getType());
|
|
|
+ paperStructDbList = paperStructDtoList.stream().map(e -> e.getMainNumber() + "_" + e.getSubNumber() + "_" + e.getScore()).collect(Collectors.toList());
|
|
|
+ } else {
|
|
|
+ List<MarkQuestion> markQuestionList = markQuestionService.listQuestionByExamIdAndPaperNumberAndPaperType(examId, paperNumber, null);
|
|
|
+ if (CollectionUtils.isEmpty(markQuestionList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到试卷结构");
|
|
|
+ }
|
|
|
+ paperStructDbList = markQuestionList.stream().map(e -> e.getMainNumber() + "_" + e.getSubNumber() + "_" + e.getTotalScore()).collect(Collectors.toList());
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(paperStructDbList) && !CollectionUtils.isEmpty(paperStructList) && !CollectionUtils.isEqualCollection(paperStructDbList, paperStructList)) {
|
|
|
+ Collections.sort(paperStructDbList);
|
|
|
+ Collections.sort(paperStructList);
|
|
|
+
|
|
|
tcFinalScoreService.remove(examId, courseCode, paperNumber);
|
|
|
trBasicInfoService.clearReportData(examId, courseCode, paperNumber, false);
|
|
|
+ tcPaperStruct.setPaperStruct(null);
|
|
|
}
|
|
|
- tcPaperStruct.setPaperStruct(null);
|
|
|
tcPaperStruct.updateInfo(sysUser.getId());
|
|
|
} else {
|
|
|
tcPaperStructService.remove(examId, courseCode, paperNumber);
|
|
|
MarkPaper markPaper = printCommonService.getMarkPaper(examId, paperNumber);
|
|
|
CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
|
|
|
tcPaperStruct = new TCPaperStruct(examId, courseCode, markPaper.getCourseName(), paperNumber, JacksonUtil.parseJson(paperStructDimensionResultList), sysUser.getId(), courseWeightResult.getDimensionSign());
|
|
|
- tcFinalScoreService.remove(examId, courseCode, paperNumber);
|
|
|
- trBasicInfoService.clearReportData(examId, courseCode, paperNumber, false);
|
|
|
+ List<MarkQuestion> markQuestionList = markQuestionService.listQuestionByExamIdAndPaperNumberAndPaperType(examId, paperNumber, null);
|
|
|
+ if (CollectionUtils.isEmpty(markQuestionList)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("未找到试卷结构");
|
|
|
+ }
|
|
|
+ paperStructDbList = markQuestionList.stream().map(e -> e.getMainNumber() + "_" + e.getSubNumber() + "_" + e.getTotalScore()).collect(Collectors.toList());
|
|
|
+ if (!CollectionUtils.isEmpty(paperStructDbList) && !CollectionUtils.isEmpty(paperStructList) && !CollectionUtils.isEqualCollection(paperStructDbList, paperStructList)) {
|
|
|
+ Collections.sort(paperStructDbList);
|
|
|
+ Collections.sort(paperStructList);
|
|
|
+
|
|
|
+ tcFinalScoreService.remove(examId, courseCode, paperNumber);
|
|
|
+ trBasicInfoService.clearReportData(examId, courseCode, paperNumber, false);
|
|
|
+ }
|
|
|
}
|
|
|
tcPaperStructService.saveOrUpdate(tcPaperStruct);
|
|
|
}
|