Parcourir la source

3.4.4 update-20250310,sql优化

xiaofei il y a 3 mois
Parent
commit
5620be8872

+ 3 - 2
distributed-print/src/main/java/com/qmth/distributed/print/api/mark/MarkController.java

@@ -77,10 +77,11 @@ public class MarkController extends BaseController {
 
     @RequestMapping(value = "/getStatus", method = RequestMethod.POST)
     public Result status(@RequestParam Long examId, @RequestParam String paperNumber,
-                         @RequestParam QuestionModel questionModel) {
+                         @RequestParam QuestionModel questionModel,
+                         @RequestParam(required = false) Long questionId) {
         validMarkPaperForMark(examId, paperNumber);
         SysUser user = (SysUser) ServletUtil.getRequestUser();
-        return ResultUtil.ok(markService.getStatus(user.getId(), examId, paperNumber, questionModel));
+        return ResultUtil.ok(markService.getStatus(user.getId(), examId, paperNumber, questionModel, questionId));
     }
 
     @RequestMapping(value = "/getTask", method = RequestMethod.POST)

+ 3 - 0
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/dto/mark/mark/MarkStatusDto.java

@@ -1,5 +1,7 @@
 package com.qmth.teachcloud.mark.dto.mark.mark;
 
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
+import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;
 import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.mark.entity.MarkUserQuestion;
 
@@ -39,6 +41,7 @@ public class MarkStatusDto {
     /**
      * 题目ID
      */
+    @JsonSerialize(using = ToStringSerializer.class)
     private Long questionId;
 
     public MarkStatusDto() {

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

@@ -41,8 +41,8 @@ public interface MarkTaskMapper extends BaseMapper<MarkTask> {
     List<MarkTask> listByExamIdAndPaperNumberAndQuestionIdAndUserIdAndClassName(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("questionId") Long questionId, @Param("userId") Long userId, @Param("className") String className);
 
     int countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("questionId") Long questionId, @Param("userId") Long userId, @Param("classNames") List<String> classNames, @Param("statusList") MarkTaskStatus[] statusList);
-    int countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("userId") Long userId, @Param("classNames") List<String> classNames);
-    int countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("userId") Long userId, @Param("classNames") List<String> classNames, @Param("questionId") Long questionId, @Param("statusList") MarkTaskStatus[] statusList);
+    int countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("classNames") List<String> classNames, @Param("questionIds") Long[] questionIds);
+    int countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("userId") Long userId, @Param("classNames") List<String> classNames, @Param("questionIds") Long[] questionIds, @Param("statusList") MarkTaskStatus[] statusList);
 
     IPage<MarkTaskDto> pageMarkTask(@Param("page") Page<Object> page, @Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("questionId") Long questionId, @Param("loginName") String loginName, @Param("status") MarkTaskStatus status, @Param("studentCode") String studentCode, @Param("secretNumber") String secretNumber, @Param("teachClassName") String teachClassName, @Param("subScore") Double subScore);
 

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

@@ -2,6 +2,7 @@ package com.qmth.teachcloud.mark.mapper;
 
 import com.baomidou.mybatisplus.core.metadata.IPage;
 import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
+import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.mark.dto.mark.entrance.MarkEntranceDto;
 import com.qmth.teachcloud.mark.dto.mark.manage.MarkQualityDto;
@@ -39,5 +40,5 @@ public interface MarkUserQuestionMapper extends BaseMapper<MarkUserQuestion> {
 
     List<String > countClassByExamIdAndPaperNumberAndQuestionId(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("questionId") Long questionId);
 
-    String getSubjectiveQuestionNumber(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("userId") Long userId);
+    List<MarkQuestion> listSubjectiveQuestionByUserId(@Param("examId") Long examId, @Param("paperNumber") String paperNumber, @Param("userId") Long userId);
 }

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

@@ -55,7 +55,7 @@ public interface MarkService {
 
     MarkSettingDto getSetting(SysUser user, Long examId, String paperNumber);
 
-    List<MarkStatusDto> getStatus(Long userId, Long examId, String paperNumber, QuestionModel questionModel);
+    List<MarkStatusDto> getStatus(Long userId, Long examId, String paperNumber, QuestionModel questionModel, Long questionId);
 
     Task getTask(Long userId, Long examId, String paperNumber, QuestionModel questionModel, Long questionId);
 

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

@@ -56,8 +56,10 @@ public interface MarkTaskService extends IService<MarkTask> {
     void deleteByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId);
 
     int countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(Long examId, String paperNumber, Long questionId, Long userId, List<String> className, MarkTaskStatus... status);
-    int countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(Long examId, String paperNumber, Long userId, List<String> className);
-    int countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(Long examId, String paperNumber, Long userId, List<String> className, Long questionId, MarkTaskStatus...status);
+
+    int countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(Long examId, String paperNumber, List<String> className, Long... questionIds);
+
+    int countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(Long examId, String paperNumber, Long userId, List<String> className, Long[] questionIds, MarkTaskStatus... status);
 
     IPage<Long> listPageHistory(Page<Long> page, Long userId, Long examId, String paperNumber, String secretNumber, Double markerScore);
 
@@ -66,6 +68,7 @@ public interface MarkTaskService extends IService<MarkTask> {
     List<MarkTask> findUnMarkedFilterClass(Page<MarkTask> page, Long examId, String paperNumber, Long userId, Boolean classMark);
 
     int countByIdAndStatus(Long studentId, MarkTaskStatus status);
+
     int countByStatusAndIdIn(List<Long> ids, MarkTaskStatus... status);
 
     List<MarkTask> findByStudentIdAndQuestionIdAndStatus(Long studentId, Long questionId, MarkTaskStatus... status);
@@ -95,7 +98,7 @@ public interface MarkTaskService extends IService<MarkTask> {
 
     List<MarkTask> listByStudentId(Long studentId);
 
-    Long minQuestionIdByExamIdAndPaperNumber(Long examId, String paperNumber, MarkTaskStatus...statuses);
+    Long minQuestionIdByExamIdAndPaperNumber(Long examId, String paperNumber, MarkTaskStatus... statuses);
 
     List<MarkTask> listByStudentIdAndUserId(Long studentId, Long userId);
 

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

@@ -78,7 +78,7 @@ public interface MarkUserQuestionService extends IService<MarkUserQuestion> {
 
     List<String> countClassByExamIdAndPaperNumberAndQuestionId(Long examId, String paperNumber, Long questionId);
 
-    String getSubjectiveQuestionNumber(Long examId, String paperNumber, Long id);
+    List<MarkQuestion> listSubjectiveQuestionByUserId(Long examId, String paperNumber, Long id);
 
     int countByExamIdAndPaperNumberAndAndUserId(Long examId, String paperNumber, Long userId);
 }

+ 22 - 13
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkServiceImpl.java

@@ -681,7 +681,7 @@ public class MarkServiceImpl implements MarkService {
     }
 
     @Override
-    public List<MarkStatusDto> getStatus(Long userId, Long examId, String paperNumber, QuestionModel questionModel) {
+    public List<MarkStatusDto> getStatus(Long userId, Long examId, String paperNumber, QuestionModel questionModel, Long questionId) {
         MarkPaper markPaper = markPaperService.getByExamIdAndPaperNumber(examId, paperNumber);
 
         List<String> classNames = null;
@@ -694,41 +694,49 @@ public class MarkServiceImpl implements MarkService {
         }
 
         List<MarkStatusDto> dtoList = new ArrayList<>();
+        List<MarkUserQuestion> markUserQuestionList = markUserQuestionService.listByExamIdAndPaperNumberAndUserIdAndEnableTure(examId, paperNumber, userId);
         // 评卷方式
         if (QuestionModel.SINGLE.equals(questionModel)) {
-            List<MarkUserQuestion> markUserQuestionList = markUserQuestionService.listByExamIdAndPaperNumberAndUserIdAndEnableTure(examId, paperNumber, userId);
+            if (questionId != null) {
+                markUserQuestionList = markUserQuestionList.stream().filter(m -> m.getQuestionId().equals(questionId)).collect(Collectors.toList());
+            }
             MarkStatusDto dto;
             for (MarkUserQuestion question : markUserQuestionList) {
-                dto = new MarkStatusDto(markQuestionService.getById(question.getId()));
+                dto = new MarkStatusDto(markQuestionService.getById(question.getQuestionId()));
+                Long[] questionIds = new Long[]{question.getQuestionId()};
                 //总数量(考生数)
-                dto.setTotalCount(markTaskService.countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, classNames));
+                dto.setTotalCount(markTaskService.countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(examId, paperNumber, classNames, questionIds));
                 //总评卷数量(考生数)
-//                dto.setMarkedCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, classNames, questionId, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED));
+                dto.setMarkedCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(examId, paperNumber, userId, classNames, questionIds, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED));
                 //个人评卷数量(考生数)
-//                dto.setPersonCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, classNames, questionId, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED,MarkTaskStatus.WAIT_ARBITRATE));
+                dto.setPersonCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(examId, paperNumber, userId, classNames, questionIds, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED,
+                        MarkTaskStatus.WAIT_ARBITRATE));
                 //问题卷数量(任务数)
                 dto.setProblemCount(markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(examId,
                         paperNumber, question.getQuestionId(), null, classNames, MarkTaskStatus.PROBLEM));
                 //待仲裁卷数量(任务数)
                 dto.setArbitrateCount(markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(examId,
                         paperNumber, question.getQuestionId(), null, classNames, MarkTaskStatus.WAIT_ARBITRATE));
+                dto.setLeftCount(dto.getTotalCount() - dto.getPersonCount());
                 dtoList.add(dto);
             }
         } else if (QuestionModel.MULTI.equals(questionModel)) {
             MarkStatusDto dto = new MarkStatusDto();
-
+            List<Long> questionIdList = markUserQuestionList.stream().filter(m -> m.getUserId().equals(userId)).map(MarkUserQuestion::getQuestionId).collect(Collectors.toList());
+            Long[] questionIds = questionIdList.toArray(new Long[0]);
             //待仲裁卷数量
             dto.setArbitrateCount(markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(examId,
                     paperNumber, null, null, classNames, MarkTaskStatus.WAIT_ARBITRATE));
             //总数量
-            dto.setTotalCount(markTaskService.countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, classNames));
+            dto.setTotalCount(markTaskService.countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(examId, paperNumber, classNames, questionIds));
             //总评卷数量(已评)
-//            dto.setMarkedCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, classNames, questionId, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED));
+            dto.setMarkedCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(examId, paperNumber, userId, classNames, questionIds, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED));
             //个人评卷数量
-//            dto.setPersonCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, classNames, questionId, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED, MarkTaskStatus.WAIT_ARBITRATE));
+            dto.setPersonCount(markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(examId, paperNumber, userId, classNames, questionIds, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED,
+                    MarkTaskStatus.WAIT_ARBITRATE));
             //问题卷数量
-//            dto.setProblemCount(markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(examId,
-//                    paperNumber, questionId, null, classNames, MarkTaskStatus.PROBLEM));
+            dto.setProblemCount(markTaskService.countByExamIdAndPaperNumberAndQuestionIdAndUserIdAndAndClassNameStatusIn(examId,
+                    paperNumber, null, null, classNames, MarkTaskStatus.PROBLEM));
             dtoList.add(dto);
         } else {
             throw ExceptionResultEnum.ERROR.exception("参数有误");
@@ -867,12 +875,12 @@ public class MarkServiceImpl implements MarkService {
         if (markUserQuestions.isEmpty()) {
             throw ExceptionResultEnum.ERROR.exception("评卷员未设置评卷题目");
         }
-        Set<Long> questions = markUserQuestions.stream().map(MarkUserQuestion::getQuestionId).collect(Collectors.toSet());
         Task task = null;
         List<Long> studentIds;
         int pageNumber = 1;
         while (task == null) {
             if (questionModel.equals(QuestionModel.SINGLE)) {
+                Set<Long> questions = new HashSet<>(Arrays.asList(questionId));
                 List<MarkTask> list = markTaskService.findUnMarkedFilterClass(new Page<>(pageNumber, 20), examId, paperNumber, userId, markPaper.getClassMark());
                 if (list.isEmpty()) {
                     break;
@@ -884,6 +892,7 @@ public class MarkServiceImpl implements MarkService {
                     }
                 }
             } else if (questionModel.equals(QuestionModel.MULTI)) {
+                Set<Long> questions = markUserQuestions.stream().map(MarkUserQuestion::getQuestionId).collect(Collectors.toSet());
                 studentIds = markStudentService.findUnMarked(new Page<>(pageNumber, 20), examId, paperNumber, userId, markPaper.getClassMark());
                 if (studentIds.isEmpty()) {
                     break;

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

@@ -237,13 +237,13 @@ public class MarkTaskServiceImpl extends ServiceImpl<MarkTaskMapper, MarkTask> i
     }
 
     @Override
-    public int countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(Long examId, String paperNumber, Long userId, List<String> className) {
-        return this.baseMapper.countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, className);
+    public int countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(Long examId, String paperNumber, List<String> className, Long... questionIds) {
+        return this.baseMapper.countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(examId, paperNumber, className, questionIds);
     }
 
     @Override
-    public int countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(Long examId, String paperNumber, Long userId, List<String> className, Long questionId, MarkTaskStatus...status) {
-        return this.baseMapper.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(examId, paperNumber, userId, className, questionId, status);
+    public int countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(Long examId, String paperNumber, Long userId, List<String> className, Long[] questionIds, MarkTaskStatus... status) {
+        return this.baseMapper.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(examId, paperNumber, userId, className, questionIds, status);
     }
 
     @Override

+ 9 - 7
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/service/impl/MarkUserQuestionServiceImpl.java

@@ -10,7 +10,6 @@ import com.qmth.teachcloud.common.bean.dto.mark.MarkUser;
 import com.qmth.teachcloud.common.entity.MarkQuestion;
 import com.qmth.teachcloud.common.entity.SysUser;
 import com.qmth.teachcloud.common.enums.ExceptionResultEnum;
-import com.qmth.teachcloud.common.enums.mark.MarkMode;
 import com.qmth.teachcloud.common.enums.mark.MarkPaperStatus;
 import com.qmth.teachcloud.common.service.SysUserService;
 import com.qmth.teachcloud.common.util.ServletUtil;
@@ -22,7 +21,6 @@ import com.qmth.teachcloud.mark.dto.mark.manage.MarkUserGroupProgressDto;
 import com.qmth.teachcloud.mark.entity.*;
 import com.qmth.teachcloud.mark.enums.LockType;
 import com.qmth.teachcloud.mark.enums.MarkTaskStatus;
-import com.qmth.teachcloud.mark.enums.QuestionModel;
 import com.qmth.teachcloud.mark.lock.LockService;
 import com.qmth.teachcloud.mark.mapper.MarkUserQuestionMapper;
 import com.qmth.teachcloud.mark.service.*;
@@ -83,9 +81,13 @@ public class MarkUserQuestionServiceImpl extends ServiceImpl<MarkUserQuestionMap
                     classNames = markUserClassList.stream().map(MarkUserClass::getClassName).collect(Collectors.toList());
                 }
             }
-            int taskCount = markTaskService.countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName(record.getExamId(), record.getPaperNumber(), sysUser.getId(), classNames);
+
+            List<MarkQuestion> markQuestionList = this.listSubjectiveQuestionByUserId(record.getExamId(), record.getPaperNumber(), sysUser.getId());
+            List<Long> questionIds = markQuestionList.stream().map(MarkQuestion::getId).collect(Collectors.toList());
+
+            int taskCount = markTaskService.countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn(record.getExamId(), record.getPaperNumber(), classNames, questionIds.toArray(new Long[0]));
             record.setTaskCount(taskCount);
-            int markedCount = markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName(record.getExamId(), record.getPaperNumber(), sysUser.getId(), classNames, null, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED);
+            int markedCount = markTaskService.countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn(record.getExamId(), record.getPaperNumber(), sysUser.getId(), classNames, null, MarkTaskStatus.MARKED, MarkTaskStatus.ARBITRATED);
             record.setMarkedCount(markedCount);
 
             record.setLeftCount(taskCount == 0 ? 0 : taskCount - markedCount);
@@ -97,7 +99,7 @@ public class MarkUserQuestionServiceImpl extends ServiceImpl<MarkUserQuestionMap
                 record.setPercent(bigDecimal.doubleValue());
             }
             // 分组题目
-            record.setQuestionNumber(this.getSubjectiveQuestionNumber(record.getExamId(), record.getPaperNumber(), sysUser.getId()));
+            record.setQuestionNumber(markQuestionList.stream().map(m -> m.getMainNumber() + "-" + m.getSubNumber()).collect(Collectors.joining(",")));
         }
 
         return markEntranceDtoIPage;
@@ -385,8 +387,8 @@ public class MarkUserQuestionServiceImpl extends ServiceImpl<MarkUserQuestionMap
     }
 
     @Override
-    public String getSubjectiveQuestionNumber(Long examId, String paperNumber, Long userId) {
-        return this.baseMapper.getSubjectiveQuestionNumber(examId, paperNumber, userId);
+    public List<MarkQuestion> listSubjectiveQuestionByUserId(Long examId, String paperNumber, Long userId) {
+        return this.baseMapper.listSubjectiveQuestionByUserId(examId, paperNumber, userId);
     }
 
     @Override

+ 10 - 5
teachcloud-mark/src/main/java/com/qmth/teachcloud/mark/utils/TaskLock.java

@@ -2,6 +2,7 @@ package com.qmth.teachcloud.mark.utils;
 
 import com.alibaba.fastjson.JSON;
 import com.qmth.teachcloud.common.util.DateDisposeUtils;
+import org.apache.commons.collections4.CollectionUtils;
 
 import java.util.*;
 
@@ -29,14 +30,14 @@ public class TaskLock {
         } else {
             LockNode node = head.next;
             while (true) {
-                // id+number,只能被一个owner获取
-                if (node.isId(id)) {
+                // id+questions,只能被一个owner获取
+                if (node.isId(id) && node.isEqualQuestions(questions)) {
                     return false;
                 }
                 // id只能被一个owner领取一个number
-                else if (node.isId(id) && node.isOwner(owner)) {
-                    return false;
-                }
+//                else if (node.isId(id) && node.isOwner(owner)) {
+//                    return false;
+//                }
                 // 跳到下一个node
                 else if (node.hasNext()) {
                     node = node.next;
@@ -217,6 +218,10 @@ public class TaskLock {
             return this.id.equals(id);
         }
 
+        private boolean isEqualQuestions(Set<Long> questions) {
+            return CollectionUtils.isEqualCollection(this.questions, questions);
+        }
+
         private boolean isOwner(Object owner) {
             return this.owner.equals(owner);
         }

+ 22 - 33
teachcloud-mark/src/main/resources/mapper/MarkTaskMapper.xml

@@ -282,24 +282,26 @@
             </foreach>))) t  WHERE mt.student_id = t.id)
         </if>
     </select>
-    <select id="countTotalCountByExamIdAndPaperNumberAndUserIdAndAndClassName" resultType="java.lang.Integer">
+    <select id="countTotalCountByExamIdAndPaperNumberAndAndClassNameAndQuestionIdIn" resultType="java.lang.Integer">
+        select count(1) from mark_student ms
+        WHERE
+        ms.exam_id = #{examId}
+        AND ms.paper_number = #{paperNumber}
+        and exists (
         SELECT
-        count(distinct mt.student_id)
+        1
         FROM
         mark_task mt
         WHERE
         mt.exam_id = #{examId}
         AND mt.paper_number = #{paperNumber}
-        AND EXISTS( SELECT
-            1
-                FROM
-            mark_user_question muq
-        WHERE
-            mt.exam_id = muq.exam_id
-            AND mt.paper_number = muq.paper_number
-            AND mt.question_id = muq.question_id
-            AND muq.user_id = #{userId}
-            AND muq.enable = true)
+        AND ms.id = mt.student_id
+        <if test="questionIds != null and questionIds.length > 0 ">
+            AND mt.question_id in
+            <foreach collection="questionIds" item="id" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
+        </if>
         <if test="classNames != null and classNames.size() > 0">
             AND EXISTS( SELECT
             ms.id, ms.exam_id, ms.paper_number, bes.teach_class_name
@@ -322,8 +324,9 @@
             WHERE
             mt.student_id = ms.id)
         </if>
+        )
     </select>
-    <select id="countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassName" resultType="java.lang.Integer">
+    <select id="countMarkedCountByExamIdAndPaperNumberAndUserIdAndAndClassNameAndQuestionIdIn" resultType="java.lang.Integer">
         select count(distinct t.student_id) from (SELECT
         mt.student_id,
         sum(case when mt.marker_score is not null and mt.status in
@@ -337,19 +340,12 @@
         mt.exam_id = #{examId}
         AND mt.paper_number = #{paperNumber}
         AND mt.user_id = #{userId}
-        AND EXISTS( SELECT
-        1
-        FROM
-        mark_user_question muq
-        WHERE
-        mt.exam_id = muq.exam_id
-        AND mt.paper_number = muq.paper_number
-        AND mt.question_id = muq.question_id
-        AND muq.user_id = #{userId}
-        <if test="questionId != null">
-            AND muq.question_id = #{questionId}
+        <if test="questionIds != null and questionIds.length > 0">
+            AND mt.question_id in
+            <foreach collection="questionIds" item="id" open="(" close=")" separator=",">
+                #{id}
+            </foreach>
         </if>
-        AND muq.enable = true)
         <if test="classNames != null and classNames.size() > 0">
             AND EXISTS( SELECT
             ms.id, ms.exam_id, ms.paper_number, bes.teach_class_name
@@ -371,14 +367,7 @@
             </foreach>) bes ON ms.basic_student_id = bes.id
             WHERE
             mt.student_id = ms.id)
-        </if> group by mt.student_id) t where t.markCount = (select count(1)
-                                                        from mark_user_question where exam_id = #{examId}
-                                            AND paper_number = #{paperNumber}
-                                            AND user_id = #{userId}
-                                            <if test="questionId != null">
-                                                AND question_id = #{questionId}
-                                            </if>
-                                            AND enable = true)
+        </if> group by mt.student_id) t
     </select>
     <select id="pageMarkTask" resultType="com.qmth.teachcloud.mark.dto.mark.manage.MarkTaskDto">
         SELECT

+ 2 - 2
teachcloud-mark/src/main/resources/mapper/MarkUserQuestionMapper.xml

@@ -222,9 +222,9 @@
                         AND muc.user_id = muq.user_id
                         AND muq.question_id = #{questionId})
     </select>
-    <select id="getSubjectiveQuestionNumber" resultType="java.lang.String">
+    <select id="listSubjectiveQuestionByUserId" resultType="com.qmth.teachcloud.common.entity.MarkQuestion">
         SELECT
-            GROUP_CONCAT(CONCAT(mq.main_number, '-', mq.sub_number))
+            mq.*
         FROM
             mark_question mq
         WHERE