|
@@ -1,23 +1,30 @@
|
|
|
package com.qmth.distributed.print.business.service.impl;
|
|
|
|
|
|
+import com.alibaba.fastjson.JSON;
|
|
|
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.qmth.distributed.print.business.bean.marking.ClassMarker;
|
|
|
+import com.qmth.distributed.print.business.bean.marking.EvaluationParameters;
|
|
|
+import com.qmth.distributed.print.business.bean.marking.GroupInfo;
|
|
|
+import com.qmth.distributed.print.business.bean.marking.Marker;
|
|
|
import com.qmth.distributed.print.business.entity.ExamPaperClassMarker;
|
|
|
import com.qmth.distributed.print.business.entity.ExamPaperStructure;
|
|
|
import com.qmth.distributed.print.business.enums.ExamPaperStructureStatusTypeEnum;
|
|
|
import com.qmth.distributed.print.business.mapper.ExamPaperClassMarkerMapper;
|
|
|
import com.qmth.distributed.print.business.service.ExamPaperClassMarkerService;
|
|
|
import com.qmth.distributed.print.business.service.ExamPaperStructureService;
|
|
|
+import com.qmth.distributed.print.business.service.ExamStudentService;
|
|
|
import com.qmth.teachcloud.common.contant.SystemConstant;
|
|
|
+import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
|
|
|
+import org.apache.commons.lang3.StringUtils;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
import org.springframework.transaction.annotation.Transactional;
|
|
|
import org.springframework.util.CollectionUtils;
|
|
|
|
|
|
import javax.annotation.Resource;
|
|
|
-import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
+import java.util.*;
|
|
|
+import java.util.stream.Collectors;
|
|
|
|
|
|
/**
|
|
|
* @Description: 班级和评卷员关系服务实现类
|
|
@@ -28,23 +35,61 @@ public class ExamPaperClassMarkerServiceImpl extends ServiceImpl<ExamPaperClassM
|
|
|
@Resource
|
|
|
ExamPaperStructureService examPaperStructureService;
|
|
|
|
|
|
+ @Resource
|
|
|
+ ExamStudentService examStudentService;
|
|
|
+
|
|
|
@Transactional
|
|
|
@Override
|
|
|
public void saveExamPaperClassInfo(ExamPaperStructure examPaperStructure, Boolean openClassReading, List<ClassMarker> classInfo) {
|
|
|
// 1.删除原有数据
|
|
|
this.deleteExamPaperClassInfo(examPaperStructure.getId());
|
|
|
- if (openClassReading != null && openClassReading && !CollectionUtils.isEmpty(classInfo)) {
|
|
|
- List<ExamPaperClassMarker> list = new ArrayList<>();
|
|
|
- for (ClassMarker classMarker : classInfo) {
|
|
|
- ExamPaperClassMarker examPaperClassMarker = new ExamPaperClassMarker();
|
|
|
- examPaperClassMarker.setId(SystemConstant.getDbUuid());
|
|
|
- examPaperClassMarker.setExamPaperStructureId(examPaperStructure.getId());
|
|
|
- examPaperClassMarker.setMarkerId(Long.valueOf(classMarker.getId()));
|
|
|
- examPaperClassMarker.setLoginName(classMarker.getLoginName());
|
|
|
- examPaperClassMarker.setClassName(classMarker.getClassName());
|
|
|
- list.add(examPaperClassMarker);
|
|
|
+ if (openClassReading != null && openClassReading) {
|
|
|
+ // 校验分组、班级
|
|
|
+ List<String> listUserClass = examStudentService.listUserClass(examPaperStructure.getSchoolId(), examPaperStructure.getExamId(), examPaperStructure.getPaperNumber());
|
|
|
+ if (!CollectionUtils.isEmpty(listUserClass)) {
|
|
|
+ EvaluationParameters evaluationParameters = JSON.parseObject(examPaperStructure.getPaperInfoJson(), EvaluationParameters.class);
|
|
|
+ List<GroupInfo> groupInfos = evaluationParameters.getGroupInfo();
|
|
|
+ Map<Integer, String> groupClassMap = new HashMap<>();
|
|
|
+ for (GroupInfo groupInfo : groupInfos) {
|
|
|
+ Set<String> unbindClassSet = new HashSet<>();
|
|
|
+ Set<String> bindClassSet = new HashSet<>();
|
|
|
+ List<Marker> markerList = groupInfo.getMarkerList();
|
|
|
+ for (Marker marker : markerList) {
|
|
|
+ Optional<ClassMarker> optional = classInfo.stream().filter(m -> StringUtils.isNotBlank(m.getClassName()) && m.getId().equals(marker.getId()) && m.getLoginName().equals(marker.getLoginName())).findFirst();
|
|
|
+ if (optional.isPresent()) {
|
|
|
+ bindClassSet.addAll(new HashSet<>(Arrays.asList(optional.get().getClassName().split(","))));
|
|
|
+ }
|
|
|
+ }
|
|
|
+ for (String s : listUserClass) {
|
|
|
+ if (!bindClassSet.contains(s)) {
|
|
|
+ unbindClassSet.add(s);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (!CollectionUtils.isEmpty(unbindClassSet)) {
|
|
|
+ groupClassMap.put(groupInfo.getGroupNumber(), String.join(",", unbindClassSet));
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ if (!groupClassMap.isEmpty()) {
|
|
|
+ StringJoiner stringJoiner = new StringJoiner(";");
|
|
|
+ for (Map.Entry<Integer, String> entry : groupClassMap.entrySet()) {
|
|
|
+ stringJoiner.add(String.format("班级[%s]在分组[%s]中未被评卷员绑定", entry.getValue(), entry.getKey()));
|
|
|
+ }
|
|
|
+ throw ExceptionResultEnum.ERROR.exception(stringJoiner.toString());
|
|
|
+ }
|
|
|
+
|
|
|
+ List<ExamPaperClassMarker> list = new ArrayList<>();
|
|
|
+ for (ClassMarker classMarker : classInfo) {
|
|
|
+ ExamPaperClassMarker examPaperClassMarker = new ExamPaperClassMarker();
|
|
|
+ examPaperClassMarker.setId(SystemConstant.getDbUuid());
|
|
|
+ examPaperClassMarker.setExamPaperStructureId(examPaperStructure.getId());
|
|
|
+ examPaperClassMarker.setMarkerId(Long.valueOf(classMarker.getId()));
|
|
|
+ examPaperClassMarker.setLoginName(classMarker.getLoginName());
|
|
|
+ examPaperClassMarker.setClassName(classMarker.getClassName());
|
|
|
+ list.add(examPaperClassMarker);
|
|
|
+ }
|
|
|
+ this.saveBatch(list);
|
|
|
}
|
|
|
- this.saveBatch(list);
|
|
|
}
|
|
|
examPaperStructure.setStatus(ExamPaperStructure.parseStatus(examPaperStructure.getStatus(), ExamPaperStructureStatusTypeEnum.MARKER_CLASS.getType(), "save", true));
|
|
|
examPaperStructureService.updateById(examPaperStructure);
|