|
@@ -17,10 +17,7 @@ import com.qmth.teachcloud.mark.dto.mark.manage.MarkGroupTotalProgressDto;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.setting.MarkGroupDto;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.setting.MarkGroupSingleDto;
|
|
|
import com.qmth.teachcloud.mark.dto.mark.setting.MarkGroupTaskDto;
|
|
|
-import com.qmth.teachcloud.mark.entity.MarkGroup;
|
|
|
-import com.qmth.teachcloud.mark.entity.MarkPaper;
|
|
|
-import com.qmth.teachcloud.mark.entity.MarkTask;
|
|
|
-import com.qmth.teachcloud.mark.entity.MarkUserGroup;
|
|
|
+import com.qmth.teachcloud.mark.entity.*;
|
|
|
import com.qmth.teachcloud.mark.mapper.MarkGroupMapper;
|
|
|
import com.qmth.teachcloud.mark.service.*;
|
|
|
import org.apache.commons.collections4.CollectionUtils;
|
|
@@ -241,7 +238,76 @@ public class MarkGroupServiceImpl extends ServiceImpl<MarkGroupMapper, MarkGroup
|
|
|
|
|
|
@Transactional
|
|
|
@Override
|
|
|
- public void saveGroupBatch(MarkGroupTaskDto markGroupTaskDto) {
|
|
|
+ public void saveGroup(MarkGroupSingleDto markGroupSingleDto) {
|
|
|
+ Long examId = markGroupSingleDto.getExamId();
|
|
|
+ String paperNumber = markGroupSingleDto.getPaperNumber();
|
|
|
+ MarkGroupDto markGroupDto = markGroupSingleDto.getGroupInfo();
|
|
|
+ MarkGroup markGroup = this.getByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, markGroupDto.getGroupNumber());
|
|
|
+ if (markGroup != null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("数据已存在");
|
|
|
+ }
|
|
|
+ List<MarkQuestion> questions = markGroupDto.getQuestions();
|
|
|
+ // 分组
|
|
|
+ markGroup = new MarkGroup();
|
|
|
+ markGroup.setExamId(examId);
|
|
|
+ markGroup.setPaperNumber(paperNumber);
|
|
|
+ MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, paperNumber);
|
|
|
+ markGroup.setCourseCode(markPaper.getCourseCode());
|
|
|
+ markGroup.setCourseName(markPaper.getCourseName());
|
|
|
+ markGroup.setNumber(markGroupDto.getGroupNumber());
|
|
|
+ markGroup.setPicList(JSON.toJSONString(markGroupDto.getPictureConfigs()));
|
|
|
+ Double totalScore = questions.stream().collect(Collectors.summingDouble(MarkQuestion::getTotalScore));
|
|
|
+ markGroup.setTotalScore(totalScore);
|
|
|
+ if (markGroupDto.getDoubleRate() != null || markGroupDto.getArbitrateThreshold() != null || markGroupDto.getScorePolicy() != null) {
|
|
|
+ if (markGroupDto.getDoubleRate() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("开启双评,双评比例必填");
|
|
|
+ }
|
|
|
+ if (markGroupDto.getArbitrateThreshold() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("开启双评, 仲裁阀值必填");
|
|
|
+ }
|
|
|
+ if (markGroupDto.getScorePolicy() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("开启双评, 合分规则必填");
|
|
|
+ }
|
|
|
+ }
|
|
|
+ markGroup.setDoubleRate(markGroupDto.getDoubleRate());
|
|
|
+ markGroup.setArbitrateThreshold(markGroupDto.getArbitrateThreshold());
|
|
|
+ markGroup.setScorePolicy(markGroupDto.getScorePolicy());
|
|
|
+ markGroup.setTaskCount(0);
|
|
|
+ markGroup.setMarkedCount(0);
|
|
|
+ markGroup.setLeftCount(0);
|
|
|
+ this.save(markGroup);
|
|
|
+
|
|
|
+ // 题目
|
|
|
+ for (MarkQuestion markQuestion : questions) {
|
|
|
+ MarkQuestion question = markQuestionService.getByExamIdAndPaperNumberAndMainNumberAndSubNumberAndObjective(examId, paperNumber, markQuestion.getMainNumber(), markQuestion.getSubNumber(), false);
|
|
|
+ if (question == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("大题号[" + markQuestion.getMainNumber() + "],小题号[" + markQuestion.getSubNumber() + "]数据不存在");
|
|
|
+ } else if (question.getGroupNumber() != null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("大题号[" + markQuestion.getMainNumber() + "],小题号[" + markQuestion.getSubNumber() + "]存在评阅题目");
|
|
|
+ }
|
|
|
+ question.setGroupNumber(markGroupDto.getGroupNumber());
|
|
|
+ markQuestionService.updateById(question);
|
|
|
+ }
|
|
|
+
|
|
|
+ // 评卷员
|
|
|
+ List<MarkUser> markers = markGroupDto.getMarkers();
|
|
|
+ if (CollectionUtils.isEmpty(markers)) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("请选择评卷员");
|
|
|
+ }
|
|
|
+ List<MarkUserGroup> markUserGroupList = markUserGroupService.listByExamIdAndPaperNumberAndGroupNumber(examId, paperNumber, markGroupDto.getGroupNumber());
|
|
|
+ if (CollectionUtils.isNotEmpty(markUserGroupList)) {
|
|
|
+ List<Long> userIds = markUserGroupList.stream().map(MarkUserGroup::getUserId).collect(Collectors.toList());
|
|
|
+ List<MarkUserGroup> markUserGroups = new ArrayList<>();
|
|
|
+ for (MarkUser marker : markGroupDto.getMarkers()) {
|
|
|
+ if (userIds.contains(marker.getUserId())) {
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+ markUserGroups.add(new MarkUserGroup(examId, paperNumber, markGroupDto.getGroupNumber(), marker.getUserId(), markPaper.getMarkMode()));
|
|
|
+ }
|
|
|
+ if (CollectionUtils.isNotEmpty(markUserGroups)) {
|
|
|
+ markUserGroupService.saveBatch(markUserGroups);
|
|
|
+ }
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
@@ -255,7 +321,19 @@ public class MarkGroupServiceImpl extends ServiceImpl<MarkGroupMapper, MarkGroup
|
|
|
if (markGroup == null) {
|
|
|
throw ExceptionResultEnum.ERROR.exception("数据不存在");
|
|
|
}
|
|
|
-
|
|
|
+ if (markGroupDto.getDoubleRate() != null || markGroupDto.getArbitrateThreshold() != null || markGroupDto.getScorePolicy() != null) {
|
|
|
+ if (markGroupDto.getDoubleRate() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("开启双评,双评比例必填");
|
|
|
+ } else if (markGroupDto.getDoubleRate() < markGroup.getDoubleRate()) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("双评比例不能小于原值");
|
|
|
+ }
|
|
|
+ if (markGroupDto.getArbitrateThreshold() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("开启双评,仲裁阀值必填");
|
|
|
+ }
|
|
|
+ if (markGroupDto.getScorePolicy() == null) {
|
|
|
+ throw ExceptionResultEnum.ERROR.exception("开启双评,合分规则必填");
|
|
|
+ }
|
|
|
+ }
|
|
|
markGroup.setDoubleRate(markGroupDto.getDoubleRate());
|
|
|
markGroup.setScorePolicy(markGroupDto.getScorePolicy());
|
|
|
markGroup.setArbitrateThreshold(markGroupDto.getArbitrateThreshold());
|