Răsfoiți Sursa

校验阅卷题目和评分题目数量和题型是否一致

wangliang 3 luni în urmă
părinte
comite
fd86169031

+ 47 - 37
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkSubjectiveScoreService.java

@@ -1,37 +1,47 @@
-package com.qmth.teachcloud.mark.service;
-
-import java.util.List;
-import java.util.Set;
-
-import com.github.jeffreyning.mybatisplus.service.IMppService;
-import com.qmth.teachcloud.mark.bean.archivescore.QuestionVo;
-import com.qmth.teachcloud.mark.entity.MarkSubjectiveScore;
-
-/**
- * <p>
- * 主观题得分明细表 服务类
- * </p>
- *
- * @author xf
- * @since 2023-09-22
- */
-public interface MarkSubjectiveScoreService extends IMppService<MarkSubjectiveScore> {
-
-    MarkSubjectiveScore getByStudentIdAndQuestionId(Long studentId, Long questionId);
-
-    Set<Integer> listMainNumberByStudentIdAndUncalculate(Long studentId, boolean uncalculate);
-
-    List<MarkSubjectiveScore> listByStudentIdAndUncalculate(Long studentId, boolean uncalculate);
-
-    void deleteByStudentId(Long studentId);
-
-	List<QuestionVo> getSubjectiveVo(List<Long> studentIds);
-	
-	  List<MarkSubjectiveScore> listByStudentId(Long studentId);
-
-    void updateRejected(Long studentId, Long questionId, boolean rejectd);
-
-    long countByStudentId(Long studentId);
-
-    void deleteByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId);
-}
+package com.qmth.teachcloud.mark.service;
+
+import com.github.jeffreyning.mybatisplus.service.IMppService;
+import com.qmth.teachcloud.mark.bean.archivescore.QuestionVo;
+import com.qmth.teachcloud.mark.entity.MarkSubjectiveScore;
+
+import java.util.List;
+import java.util.Set;
+
+/**
+ * <p>
+ * 主观题得分明细表 服务类
+ * </p>
+ *
+ * @author xf
+ * @since 2023-09-22
+ */
+public interface MarkSubjectiveScoreService extends IMppService<MarkSubjectiveScore> {
+
+    MarkSubjectiveScore getByStudentIdAndQuestionId(Long studentId, Long questionId);
+
+    Set<Integer> listMainNumberByStudentIdAndUncalculate(Long studentId, boolean uncalculate);
+
+    List<MarkSubjectiveScore> listByStudentIdAndUncalculate(Long studentId, boolean uncalculate);
+
+    void deleteByStudentId(Long studentId);
+
+    List<QuestionVo> getSubjectiveVo(List<Long> studentIds);
+
+    List<MarkSubjectiveScore> listByStudentId(Long studentId);
+
+    void updateRejected(Long studentId, Long questionId, boolean rejectd);
+
+    long countByStudentId(Long studentId);
+
+    void deleteByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId);
+
+    /**
+     * 根据学生id和考试id以及试卷编码查询
+     *
+     * @param studentId
+     * @param examId
+     * @param paperNumber
+     * @return
+     */
+    List<MarkSubjectiveScore> listByStudentIdAndExamIdAndPn(Long studentId, Long examId, String paperNumber);
+}

+ 31 - 10
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkServiceImpl.java

@@ -43,6 +43,7 @@ import javax.annotation.Resource;
 import java.math.BigDecimal;
 import java.util.*;
 import java.util.concurrent.ConcurrentHashMap;
+import java.util.function.Function;
 import java.util.stream.Collectors;
 
 @Service
@@ -365,24 +366,44 @@ public class MarkServiceImpl implements MarkService {
     @Transactional
     public void checkStudentSubjective(Long studentId, Long examId, String paperNumber, Integer version) {
         try {
-            long unBindMarkerQuestionCount = markQuestionService.countUnBindMarkerByExamIdAndPaperNumberAndObjective(examId, paperNumber, false);
-            long questionCount = markQuestionService.countByExamIdAndPaperNumberAndObjective(examId, paperNumber, false);
-            long subjectiveScoreCount = markSubjectiveScoreService.countByStudentId(studentId);
-            // 主观题数大于0,主观题全部绑定了评卷员,考生小题分数数量等于主观题数量
-            // todo 校验mark_subjective_score中的question_id是否一样
-            if (questionCount > 0) {
+            List<MarkQuestion> markQuestionList = markQuestionService.listByExamIdAndPaperNumberAndObjective(examId, paperNumber, false);
+            List<MarkSubjectiveScore> markSubjectiveScoreList = markSubjectiveScoreService.listByStudentIdAndExamIdAndPn(studentId, examId, paperNumber);
+            //校验阅卷题目和评分题目数量和题型是否一致
+            if (CollectionUtils.isNotEmpty(markQuestionList) && CollectionUtils.isNotEmpty(markSubjectiveScoreList)
+                    && this.megreQuestion(markQuestionList, markSubjectiveScoreList)) {
                 scoreCalculate(studentId, version);
             }
-//            else {//否则更新该学生主观题状态为未阅卷
-////                markStudentService.updateSubjectiveStatusAndScore(studentId, SubjectiveStatus.UNMARK, null, null);
-//                markStudentService.updateSubjectiveScoreByVersion(studentId, SubjectiveStatus.UNMARK, null, null, version);
-//            }
         } catch (Exception e) {
             log.error(SystemConstant.LOG_ERROR, e);
             throw ExceptionResultEnum.ERROR.exception(e.getMessage());
         }
     }
 
+    /**
+     * 题型匹配
+     *
+     * @param markQuestionList
+     * @param markSubjectiveScoreList
+     * @return
+     */
+    protected boolean megreQuestion(List<MarkQuestion> markQuestionList, List<MarkSubjectiveScore> markSubjectiveScoreList) {
+        boolean calculate = true;
+        Map<String, MarkQuestion> markQuestionMap = markQuestionList.stream().collect(Collectors.toMap(k -> k.getMainNumber() + "-" + k.getSubNumber(), Function.identity(), (dto1, dto2) -> dto1));
+        Map<String, MarkSubjectiveScore> markSubjectiveScoreMap = markSubjectiveScoreList.stream().collect(Collectors.toMap(k -> k.getMainNumber() + "-" + k.getSubNumber(), Function.identity(), (dto1, dto2) -> dto1));
+        if (markQuestionMap.size() != markSubjectiveScoreMap.size()) {
+            calculate = false;
+        }
+        if (calculate) {
+            for (Map.Entry<String, MarkQuestion> entry : markQuestionMap.entrySet()) {
+                if (!markSubjectiveScoreMap.containsKey(entry.getKey())) {
+                    calculate = false;
+                    break;
+                }
+            }
+        }
+        return calculate;
+    }
+
     @Override
     public void buildMarkTask(MarkPaper markPaper) {
         try {

+ 122 - 103
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkSubjectiveScoreServiceImpl.java

@@ -1,103 +1,122 @@
-package com.qmth.teachcloud.mark.service.impl;
-
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
-import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
-import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
-import com.qmth.teachcloud.mark.bean.archivescore.QuestionVo;
-import com.qmth.teachcloud.mark.entity.MarkSubjectiveScore;
-import com.qmth.teachcloud.mark.mapper.MarkSubjectiveScoreMapper;
-import com.qmth.teachcloud.mark.service.MarkSubjectiveScoreService;
-import org.apache.commons.collections4.CollectionUtils;
-import org.springframework.stereotype.Service;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-/**
- * <p>
- * 主观题得分明细表 服务实现类
- * </p>
- *
- * @author xf
- * @since 2023-09-22
- */
-@Service
-public class MarkSubjectiveScoreServiceImpl extends MppServiceImpl<MarkSubjectiveScoreMapper, MarkSubjectiveScore> implements MarkSubjectiveScoreService {
-    @Override
-    public MarkSubjectiveScore getByStudentIdAndQuestionId(Long studentId, Long questionId) {
-        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
-                .eq(MarkSubjectiveScore::getQuestionId, questionId);
-        return this.getOne(queryWrapper);
-    }
-
-    @Override
-    public Set<Integer> listMainNumberByStudentIdAndUncalculate(Long studentId, boolean uncalculate) {
-        Set<Integer> mainNumbers = new HashSet<Integer>();
-        List<MarkSubjectiveScore> list = this.listByStudentIdAndUncalculate(studentId, uncalculate);
-        for (MarkSubjectiveScore subjectiveScore : list) {
-            mainNumbers.add(subjectiveScore.getMainNumber());
-        }
-        return mainNumbers;
-    }
-
-    @Override
-    public List<MarkSubjectiveScore> listByStudentIdAndUncalculate(Long studentId, boolean uncalculate) {
-        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
-                .orderByAsc(MarkSubjectiveScore::getMainNumber)
-                .orderByAsc(MarkSubjectiveScore::getSubNumber);
-        return this.list(queryWrapper);
-    }
-
-    @Override
-    public void deleteByStudentId(Long studentId) {
-        UpdateWrapper<MarkSubjectiveScore> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId);
-        this.remove(updateWrapper);
-    }
-
-    @Override
-    public List<QuestionVo> getSubjectiveVo(List<Long> studentIds) {
-        if (CollectionUtils.isEmpty(studentIds)) {
-            return null;
-        }
-        return this.baseMapper.getSubjectiveVo(studentIds);
-    }
-
-    @Override
-    public List<MarkSubjectiveScore> listByStudentId(Long studentId) {
-        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
-                .orderByAsc(MarkSubjectiveScore::getMainNumber)
-                .orderByAsc(MarkSubjectiveScore::getSubNumber);
-        return this.list(queryWrapper);
-    }
-
-    @Override
-    public void updateRejected(Long studentId, Long questionId, boolean rejectd) {
-        UpdateWrapper<MarkSubjectiveScore> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().set(MarkSubjectiveScore::getRejected, rejectd)
-                .eq(MarkSubjectiveScore::getStudentId, studentId)
-                .eq(MarkSubjectiveScore::getQuestionId, questionId);
-        this.update(updateWrapper);
-    }
-
-    @Override
-    public long countByStudentId(Long studentId) {
-        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
-        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId);
-        return this.count(queryWrapper);
-    }
-
-    @Override
-    public void deleteByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId) {
-        UpdateWrapper<MarkSubjectiveScore> updateWrapper = new UpdateWrapper<>();
-        updateWrapper.lambda().eq(MarkSubjectiveScore::getExamId, examId)
-                .eq(MarkSubjectiveScore::getPaperNumber, paperNumber)
-                .eq(MarkSubjectiveScore::getQuestionId, questionId);
-        this.remove(updateWrapper);
-    }
-
-}
+package com.qmth.teachcloud.mark.service.impl;
+
+import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
+import com.baomidou.mybatisplus.core.conditions.update.UpdateWrapper;
+import com.github.jeffreyning.mybatisplus.service.MppServiceImpl;
+import com.qmth.teachcloud.mark.bean.archivescore.QuestionVo;
+import com.qmth.teachcloud.mark.entity.MarkSubjectiveScore;
+import com.qmth.teachcloud.mark.mapper.MarkSubjectiveScoreMapper;
+import com.qmth.teachcloud.mark.service.MarkSubjectiveScoreService;
+import org.apache.commons.collections4.CollectionUtils;
+import org.springframework.stereotype.Service;
+
+import java.util.HashSet;
+import java.util.List;
+import java.util.Set;
+
+/**
+ * <p>
+ * 主观题得分明细表 服务实现类
+ * </p>
+ *
+ * @author xf
+ * @since 2023-09-22
+ */
+@Service
+public class MarkSubjectiveScoreServiceImpl extends MppServiceImpl<MarkSubjectiveScoreMapper, MarkSubjectiveScore> implements MarkSubjectiveScoreService {
+
+    @Override
+    public MarkSubjectiveScore getByStudentIdAndQuestionId(Long studentId, Long questionId) {
+        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
+                .eq(MarkSubjectiveScore::getQuestionId, questionId);
+        return this.getOne(queryWrapper);
+    }
+
+    @Override
+    public Set<Integer> listMainNumberByStudentIdAndUncalculate(Long studentId, boolean uncalculate) {
+        Set<Integer> mainNumbers = new HashSet<Integer>();
+        List<MarkSubjectiveScore> list = this.listByStudentIdAndUncalculate(studentId, uncalculate);
+        for (MarkSubjectiveScore subjectiveScore : list) {
+            mainNumbers.add(subjectiveScore.getMainNumber());
+        }
+        return mainNumbers;
+    }
+
+    @Override
+    public List<MarkSubjectiveScore> listByStudentIdAndUncalculate(Long studentId, boolean uncalculate) {
+        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
+                .orderByAsc(MarkSubjectiveScore::getMainNumber)
+                .orderByAsc(MarkSubjectiveScore::getSubNumber);
+        return this.list(queryWrapper);
+    }
+
+    @Override
+    public void deleteByStudentId(Long studentId) {
+        UpdateWrapper<MarkSubjectiveScore> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId);
+        this.remove(updateWrapper);
+    }
+
+    @Override
+    public List<QuestionVo> getSubjectiveVo(List<Long> studentIds) {
+        if (CollectionUtils.isEmpty(studentIds)) {
+            return null;
+        }
+        return this.baseMapper.getSubjectiveVo(studentIds);
+    }
+
+    @Override
+    public List<MarkSubjectiveScore> listByStudentId(Long studentId) {
+        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
+                .orderByAsc(MarkSubjectiveScore::getMainNumber)
+                .orderByAsc(MarkSubjectiveScore::getSubNumber);
+        return this.list(queryWrapper);
+    }
+
+    @Override
+    public void updateRejected(Long studentId, Long questionId, boolean rejectd) {
+        UpdateWrapper<MarkSubjectiveScore> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().set(MarkSubjectiveScore::getRejected, rejectd)
+                .eq(MarkSubjectiveScore::getStudentId, studentId)
+                .eq(MarkSubjectiveScore::getQuestionId, questionId);
+        this.update(updateWrapper);
+    }
+
+    @Override
+    public long countByStudentId(Long studentId) {
+        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId);
+        return this.count(queryWrapper);
+    }
+
+    @Override
+    public void deleteByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId) {
+        UpdateWrapper<MarkSubjectiveScore> updateWrapper = new UpdateWrapper<>();
+        updateWrapper.lambda().eq(MarkSubjectiveScore::getExamId, examId)
+                .eq(MarkSubjectiveScore::getPaperNumber, paperNumber)
+                .eq(MarkSubjectiveScore::getQuestionId, questionId);
+        this.remove(updateWrapper);
+    }
+
+    /**
+     * 根据学生id和考试id以及试卷编码查询
+     *
+     * @param studentId
+     * @param examId
+     * @param paperNumber
+     * @return
+     */
+    @Override
+    public List<MarkSubjectiveScore> listByStudentIdAndExamIdAndPn(Long studentId, Long examId, String paperNumber) {
+        QueryWrapper<MarkSubjectiveScore> queryWrapper = new QueryWrapper<>();
+        queryWrapper.lambda().eq(MarkSubjectiveScore::getStudentId, studentId)
+                .eq(MarkSubjectiveScore::getExamId, examId)
+                .eq(MarkSubjectiveScore::getPaperNumber, paperNumber)
+                .orderByAsc(MarkSubjectiveScore::getMainNumber)
+                .orderByAsc(MarkSubjectiveScore::getSubNumber);
+        return this.list(queryWrapper);
+    }
+}