|
@@ -1,8 +1,9 @@
|
|
|
package com.qmth.distributed.print.api;
|
|
|
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.google.gson.reflect.TypeToken;
|
|
|
import com.qmth.boot.api.constant.ApiConstant;
|
|
|
+import com.qmth.distributed.print.business.bean.dto.CourseWeightDto;
|
|
|
+import com.qmth.distributed.print.business.bean.excel.PaperStructDto;
|
|
|
import com.qmth.distributed.print.business.bean.params.report.PaperStructParams;
|
|
|
import com.qmth.distributed.print.business.bean.result.CourseWeightResult;
|
|
|
import com.qmth.distributed.print.business.bean.result.EditResult;
|
|
@@ -34,6 +35,7 @@ import org.springframework.web.multipart.MultipartFile;
|
|
|
import javax.annotation.Resource;
|
|
|
import javax.validation.Valid;
|
|
|
import java.io.IOException;
|
|
|
+import java.math.BigDecimal;
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
import java.util.Objects;
|
|
@@ -90,16 +92,22 @@ public class TCPaperStructController {
|
|
|
if (bindingResult.hasErrors()) {
|
|
|
return ResultUtil.error(bindingResult.getAllErrors().get(0).getDefaultMessage());
|
|
|
}
|
|
|
- for (PaperStructDimensionResult paperStructDimensionResult : paperStructParams.getPaperStruct()) {
|
|
|
- Objects.requireNonNull(paperStructDimensionResult.getMainNumber(), "大题号为空");
|
|
|
- Objects.requireNonNull(paperStructDimensionResult.getSubNumber(), "小题号为空");
|
|
|
- if (!CollectionUtils.isEmpty(paperStructDimensionResult.getTargetList()) && paperStructDimensionResult.getTargetList().size() > 1) {
|
|
|
- throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
|
|
|
+ CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(paperStructParams.getExamId(), paperStructParams.getCourseCode());
|
|
|
+ for (CourseWeightDto c : courseWeightResult.getSubmitForm()) {
|
|
|
+ for (PaperStructDimensionResult paperStructDimensionResult : paperStructParams.getPaperStruct()) {
|
|
|
+ Objects.requireNonNull(paperStructDimensionResult.getMainNumber(), "大题号为空");
|
|
|
+ Objects.requireNonNull(paperStructDimensionResult.getSubNumber(), "小题号为空");
|
|
|
+ if (!CollectionUtils.isEmpty(paperStructDimensionResult.getTargetList()) && paperStructDimensionResult.getTargetList().size() > 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("一个题只能属于一个目标");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ Double score = paperStructParams.getPaperStruct().stream().filter(s -> Objects.equals(s.getCourseTargetName(), c.getCourseTargetName())).mapToDouble(PaperStructDimensionResult::getScore).sum();
|
|
|
+ if (new BigDecimal(score).compareTo(c.getTotalWeight()) == 1) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("[" + c.getCourseTargetName() + "]知识点小题总分大于该课程目标分,请重新设置");
|
|
|
}
|
|
|
}
|
|
|
SysUser sysUser = (SysUser) ServletUtil.getRequestUser();
|
|
|
TCPaperStruct tcPaperStructDb = tcPaperStructService.queryByExamIdAndCourseCodeAndPaperNumber(paperStructParams.getExamId(), paperStructParams.getCourseCode(), paperStructParams.getPaperNumber());
|
|
|
- CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(paperStructParams.getExamId(), paperStructParams.getCourseCode());
|
|
|
if (Objects.isNull(tcPaperStructDb)) {
|
|
|
MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(paperStructParams.getExamId(), paperStructParams.getPaperNumber());
|
|
|
Objects.requireNonNull(markPaper, "未找到科目信息");
|
|
@@ -112,7 +120,7 @@ public class TCPaperStructController {
|
|
|
tcPaperStructDb.updateInfo(JacksonUtil.parseJson(paperStructParams.getPaperStruct()), sysUser.getId());
|
|
|
if (!tcPaperStructDb.equals(tcPaperStructSource)) {
|
|
|
if (Objects.nonNull(tcPaperStructDb.getDimensionSign()) && tcPaperStructDb.getDimensionSign().longValue() != courseWeightResult.getDimensionSign().longValue()) {
|
|
|
- trBasicInfoService.clearReportData(tcPaperStructDb.getExamId(), tcPaperStructDb.getCourseCode(), tcPaperStructDb.getPaperNumber(), true);
|
|
|
+ trBasicInfoService.clearReportData(tcPaperStructDb.getExamId(), tcPaperStructDb.getCourseCode(), tcPaperStructDb.getPaperNumber(), false);
|
|
|
}
|
|
|
tcPaperStructDb.setDimensionSign(courseWeightResult.getDimensionSign());
|
|
|
tcPaperStructService.updateById(tcPaperStructDb);
|
|
@@ -143,11 +151,31 @@ public class TCPaperStructController {
|
|
|
CourseWeightResult courseWeightResult = trBasicInfoService.findCourseWeightResultRmi(examId, courseCode);
|
|
|
if (Objects.nonNull(tcPaperStruct.getDimensionSign()) && tcPaperStruct.getDimensionSign().longValue() != courseWeightResult.getDimensionSign().longValue()) {
|
|
|
trBasicInfoService.clearReportData(examId, courseCode, paperNumber, true);
|
|
|
- return this.finalScorePaperStructQuery(examId, courseCode, paperNumber);
|
|
|
- } else {
|
|
|
+ paperStructDimensionResultList = new ArrayList<>();
|
|
|
+
|
|
|
if (Objects.nonNull(tcPaperStruct.getPaperStruct())) {
|
|
|
- paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDimensionResult>>() {
|
|
|
+ List<PaperStructDto> paperStructDtoList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDto>>() {
|
|
|
+ }.getType());
|
|
|
+ paperStructDimensionResultList = new ArrayList<>(paperStructDtoList.size());
|
|
|
+ for (PaperStructDto paperStructDto : paperStructDtoList) {
|
|
|
+ paperStructDimensionResultList.add(new PaperStructDimensionResult(paperStructDto.getMainNumber(), paperStructDto.getSubNumber(), paperStructDto.getScore()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return this.finalScorePaperStructQuery(examId, courseCode, paperNumber);
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (Objects.nonNull(tcPaperStruct.getPaperStructDimension())) {
|
|
|
+ paperStructDimensionResultList = GsonUtil.fromJson(tcPaperStruct.getPaperStructDimension(), new TypeToken<List<PaperStructDimensionResult>>() {
|
|
|
+ }.getType());
|
|
|
+ } else if (Objects.nonNull(tcPaperStruct.getPaperStruct())) {
|
|
|
+ List<PaperStructDto> paperStructDtoList = GsonUtil.fromJson(tcPaperStruct.getPaperStruct(), new TypeToken<List<PaperStructDto>>() {
|
|
|
}.getType());
|
|
|
+ paperStructDimensionResultList = new ArrayList<>(paperStructDtoList.size());
|
|
|
+ for (PaperStructDto paperStructDto : paperStructDtoList) {
|
|
|
+ paperStructDimensionResultList.add(new PaperStructDimensionResult(paperStructDto.getMainNumber(), paperStructDto.getSubNumber(), paperStructDto.getScore()));
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ return this.finalScorePaperStructQuery(examId, courseCode, paperNumber);
|
|
|
}
|
|
|
}
|
|
|
}
|