Răsfoiți Sursa

3.4.4 update-20250306,联调bug修复-主观题复核

xiaofei 3 luni în urmă
părinte
comite
d34fdc50d4

+ 1 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/mapper/MarkTaskMapper.java

@@ -50,5 +50,5 @@ public interface MarkTaskMapper extends BaseMapper<MarkTask> {
 
     Long minQuestionIdByExamIdAndPaperNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("statusList") MarkTaskStatus[] statusList);
 
-    List<MarkTask> listByStudentIdAndUserId(@Param("studentId") Long studentId, @Param("userId") Long userId, @Param("questionId") Long questionId);
+    List<MarkTask> listByStudentIdAndUserId(@Param("studentId") Long studentId, @Param("userId") Long userId);
 }

+ 2 - 3
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkService.java

@@ -15,6 +15,7 @@ import com.qmth.teachcloud.mark.params.MarkResultQuestion;
 import io.lettuce.core.GeoArgs.Sort;
 
 import java.util.List;
+import java.util.Set;
 
 /**
  * <p>
@@ -83,9 +84,7 @@ public interface MarkService {
 
     void clear(Long userId, Long examId, String paperNumber);
 
-    boolean applyTask(MarkTask t, Long userId);
-
-    boolean applyTask(Long examId, String paperNumber, Long studentId, Integer taskNumber, Long userId);
+    boolean applyTask(Long examId, String paperNumber, Long studentId, Integer taskNumber, Long userId, Set<Long> questions);
 
     boolean hasApplied(MarkTask t, Long userId);
 

+ 1 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/MarkTaskService.java

@@ -95,7 +95,7 @@ public interface MarkTaskService extends IService<MarkTask> {
 
     Long minQuestionIdByExamIdAndPaperNumber(Long examId, String paperNumber, MarkTaskStatus...statuses);
 
-    List<MarkTask> listByStudentIdAndUserId(Long studentId, Long userId, Long questionId);
+    List<MarkTask> listByStudentIdAndUserId(Long studentId, Long userId);
 
     List<MarkTask> listByStudentIdAndMarkerId(Long studentId, Long markerId);
 }

+ 17 - 40
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkServiceImpl.java

@@ -223,8 +223,7 @@ public class MarkServiceImpl implements MarkService {
 
     @Override
     public String getGroupKey(MarkQuestion markQuestion) {
-//        return markQuestion.getExamId() + "_" + markQuestion.getPaperNumber() + "_" + markQuestion.getId();
-        return String.valueOf(markQuestion.getId());
+        return getKey(markQuestion.getExamId(), markQuestion.getPaperNumber());
     }
 
     @Override
@@ -344,10 +343,6 @@ public class MarkServiceImpl implements MarkService {
         markUserGroups.forEach(m -> this.updateQuality(m));
     }
 
-    private String getGroupKey(MarkUserQuestion markUserGroup) {
-        return markUserGroup.getExamId() + "_" + markUserGroup.getPaperNumber();
-    }
-
     /**
      * 考生分组判断是否评卷完成,以及后续的统一处理动作
      *
@@ -699,8 +694,7 @@ public class MarkServiceImpl implements MarkService {
 
     @Override
     public void clear(Long userId, Long examId, String paperNumber) {
-        String key = examId + "_" + paperNumber;
-        TaskLock taskLock = TaskLockUtil.getFormalTask(key);
+        TaskLock taskLock = TaskLockUtil.getFormalTask(getKey(examId, paperNumber));
         taskLock.clear(userId);
     }
 
@@ -713,7 +707,7 @@ public class MarkServiceImpl implements MarkService {
     @Override
     public boolean applyStudent(MarkStudent student, Long userId) {
         TaskLock taskLock = TaskLockUtil.getInspectedStudentTask(getKey(student.getExamId(), student.getPaperNumber()));
-        boolean lock = taskLock.add(student.getId(), 1, userId);
+        boolean lock = taskLock.add(student.getId(), 1, userId, new HashSet<>());
         // 上锁失败直接返回
         if (!lock) {
             return false;
@@ -839,12 +833,16 @@ public class MarkServiceImpl implements MarkService {
                 break;
             }
             for (Long studentId : studentIds) {
-                if (this.applyTask(examId, paperNumber, studentId, 1, userId)) {
-                    Long questionId = null;
-                    if (questionModel.equals(QuestionModel.SINGLE)) {
-                        questionId = markTaskService.minQuestionIdByExamIdAndPaperNumber(examId, paperNumber, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED);
-                    }
-                    List<MarkTask> markTaskList = markTaskService.listByStudentIdAndUserId(studentId, userId, questionId);
+                List<MarkTask> markTaskList = markTaskService.listByStudentIdAndUserId(studentId, userId);
+                if (markTaskList.isEmpty()) {
+                    continue;
+                }
+                if (questionModel.equals(QuestionModel.SINGLE)) {
+                    markTaskList = markTaskList.stream().limit(1).collect(Collectors.toList());
+                }
+                // 评阅题目ID集合
+                Set<Long> questions = markTaskList.stream().map(MarkTask::getQuestionId).collect(Collectors.toSet());
+                if (this.applyTask(examId, paperNumber, studentId, 1, userId, questions)) {
                     task = taskService.build(userId, markTaskList);
                 }
             }
@@ -857,30 +855,10 @@ public class MarkServiceImpl implements MarkService {
     }
 
     @Override
-    public boolean applyTask(MarkTask t, Long userId) {
-        // 查询待领取任务时,已经做了多评同一studentId互斥处理
-        String key = String.valueOf(t.getStudentId());
-        TaskLock taskLock = TaskLockUtil.getFormalTask(key);
-        boolean lock = taskLock.add(t.getStudentId(), t.getTaskNumber(), userId);
-        // 上锁失败直接返回
-        if (!lock) {
-            return false;
-        }
-        // 重复校验任务状态
-        if (markTaskService.countByIdAndStatus(t.getId(), t.getStatus()) == 1) {
-            return true;
-        } else {
-            taskLock.remove(t.getStudentId(), t.getTaskNumber(), userId);
-            return false;
-        }
-    }
-
-    @Override
-    public boolean applyTask(Long examId, String paperNumber, Long studentId, Integer taskNumber, Long userId) {
+    public boolean applyTask(Long examId, String paperNumber, Long studentId, Integer taskNumber, Long userId, Set<Long> questions) {
         // 查询待领取任务时,已经做了多评同一studentId互斥处理
-        String key = examId + "_" + paperNumber;
-        TaskLock taskLock = TaskLockUtil.getFormalTask(key);
-        boolean lock = taskLock.add(studentId, taskNumber, userId);
+        TaskLock taskLock = TaskLockUtil.getFormalTask(getKey(examId, paperNumber));
+        boolean lock = taskLock.add(studentId, taskNumber, userId, questions);
         // 上锁失败直接返回
         if (!lock) {
             return false;
@@ -896,8 +874,7 @@ public class MarkServiceImpl implements MarkService {
 
     @Override
     public boolean hasApplied(MarkTask t, Long userId) {
-        String key = t.getExamId() + "_" + t.getPaperNumber();
-        TaskLock taskLock = TaskLockUtil.getFormalTask(key);
+        TaskLock taskLock = TaskLockUtil.getFormalTask(getKey(t.getExamId(), t.getPaperNumber()));
         return taskLock.exist(t.getStudentId(), t.getTaskNumber(), userId);
     }
 

+ 2 - 2
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkTaskServiceImpl.java

@@ -420,8 +420,8 @@ public class MarkTaskServiceImpl extends ServiceImpl<MarkTaskMapper, MarkTask> i
     }
 
     @Override
-    public List<MarkTask> listByStudentIdAndUserId(Long studentId, Long userId, Long questionId) {
-        return baseMapper.listByStudentIdAndUserId(studentId, userId, questionId);
+    public List<MarkTask> listByStudentIdAndUserId(Long studentId, Long userId) {
+        return baseMapper.listByStudentIdAndUserId(studentId, userId);
     }
 
     @Override

+ 1 - 1
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/ScanOmrTaskServiceImpl.java

@@ -814,7 +814,7 @@ public class ScanOmrTaskServiceImpl extends ServiceImpl<ScanOmrTaskMapper, ScanO
     @Override
     public boolean apply(MarkStudent t, Long userId) {
         TaskLock taskLock = TaskLockUtil.getOmrTask(t.getExamId().toString());
-        boolean lock = taskLock.add(t.getId(), 1,userId.toString());
+        boolean lock = taskLock.add(t.getId(), 1,userId.toString(), new HashSet<>());
         // 上锁失败直接返回
         if (!lock) {
             return false;

+ 14 - 7
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/utils/TaskLock.java

@@ -1,5 +1,6 @@
 package com.qmth.teachcloud.mark.utils;
 
+import com.alibaba.fastjson.JSON;
 import com.qmth.teachcloud.common.util.DateDisposeUtils;
 
 import java.util.*;
@@ -16,13 +17,13 @@ public class TaskLock {
     private int count;
 
     public TaskLock() {
-        head = new LockNode(0, 0, 0);
+        head = new LockNode(0, 0, 0, new HashSet<>());
         count = 0;
     }
 
-    public synchronized boolean add(Object id, int number, Object owner) {
+    public synchronized boolean add(Object id, int number, Object owner, Set<Long> questions) {
         if (head.next == null) {
-            head.append(id, number, owner);
+            head.append(id, number, owner, questions);
             count++;
             return true;
         } else {
@@ -42,7 +43,7 @@ public class TaskLock {
                 }
                 // 可以领取
                 else {
-                    node.append(id, number, owner);
+                    node.append(id, number, owner, questions);
                     count++;
                     return true;
                 }
@@ -168,6 +169,7 @@ public class TaskLock {
             map.put("taskId", node.getId());
             map.put("number", node.getNumber());
             map.put("markerId", node.getOwner());
+            map.put("questions", JSON.toJSONString(node.getQuestions()));
             map.put("time", DateDisposeUtils.parseDateToStr(DateDisposeUtils.YYYY_MM_DD_HH_MM_SS, new Date(node.getTime())));
             list.add(map);
             node = node.next;
@@ -184,15 +186,17 @@ public class TaskLock {
         private Object id;
 
         private int number;
+        private Set<Long> questions;
 
         private Object owner;
 
         private long time;
 
-        LockNode(Object id, int number, Object owner) {
+        LockNode(Object id, int number, Object owner, Set<Long> questions) {
             this.id = id;
             this.number = number;
             this.owner = owner;
+            this.questions = questions;
             this.time = System.currentTimeMillis();
         }
 
@@ -219,8 +223,8 @@ public class TaskLock {
             }
         }
 
-        private void append(Object id, int number, Object owner) {
-            LockNode node = new LockNode(id, number, owner);
+        private void append(Object id, int number, Object owner, Set<Long> questions) {
+            LockNode node = new LockNode(id, number, owner, questions);
             this.next = node;
             node.previous = this;
         }
@@ -241,6 +245,9 @@ public class TaskLock {
             return time;
         }
 
+        public Set<Long> getQuestions() {
+            return questions;
+        }
     }
 
 }

+ 3 - 5
teachcloud-mark/src/main/resources/mapper/MarkTaskMapper.xml

@@ -389,6 +389,8 @@
             mark_task mt
         <where>
             mt.student_id = #{studentId}
+            and (mt.user_id is null or mt.user_id =#{userId})
+            and (mt.status='WAITING' or mt.status='REJECTED')
             AND EXISTS( SELECT
                           1
                       FROM
@@ -398,11 +400,7 @@
                         AND mt.paper_Number = muq.paper_number
                         AND mt.question_id = muq.question_id
                         AND muq.user_id = #{userId}
-                        AND muq.enable = true
-                        <if test="questionId != null">
-                            and muq.question_id = #{questionId}
-                        </if>
-                        )
+                        AND muq.enable = true)
             AND NOT EXISTS (
                 SELECT 1 FROM
                     mark_task t