Explorar o código

组卷限制到当前班级,卷生成慢调整

mingfu hai 2 semanas
pai
achega
dc8fd33516

+ 8 - 3
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -26,6 +26,7 @@ import org.apache.commons.lang3.tuple.Pair;
 import org.springframework.stereotype.Service;
 
 import java.util.*;
+import java.util.concurrent.ThreadLocalRandom;
 import java.util.concurrent.atomic.AtomicLong;
 import java.util.function.Function;
 import java.util.regex.Matcher;
@@ -560,7 +561,7 @@ public class PaperService {
         List<KnowTypeAssign> knowTypeAssignList = Lists.newArrayList(knowTypeAssignMap.values());
         List<LearnPaperQuestion> pqList = Lists.newArrayList();
         Set<String> existQuestionSet = Sets.newHashSet();
-        Random random = new Random();
+        Random random = ThreadLocalRandom.current();
         Map<String, List<LearnQuestions>> typeQuestionMap = Maps.newHashMap();
         LearnQuestions qCond = new LearnQuestions();
         do {
@@ -585,7 +586,11 @@ public class PaperService {
                     addRandomList(knowTypeAssign.getKnowId(), QuestionType.of(knowTypeAssign.getType()), questions, random, total.longValue(), 1L, 1.0, existQuestionSet, 1, pqList);
                     if(oldSize != pqList.size()) {
                         knowTypeAssign.exclAssign++;
+                    } else {
+                        knowTypeAssignList.remove(idx);
                     }
+                } else {
+                    knowTypeAssignList.remove(idx);
                 }
             } else {
                 knowTypeAssignList.remove(idx);
@@ -909,7 +914,7 @@ public class PaperService {
     public List<LearnPaperQuestion> getQuestions(Long studentId, TestPaperVO.PaperDef paperDef, Map<String, KnowTypeAssign> knowTypeAssignMap) {
         // 知识点已经分配,准备题型分配
         LearnQuestions qCond = new LearnQuestions();
-        Random random = new Random();
+        Random random = ThreadLocalRandom.current();
         List<LearnPaperQuestion> pqList = Lists.newArrayList();
         Set<String> existQuestionSet = Sets.newHashSet();
         int total = paperDef.getTotal().intValue();
@@ -957,7 +962,7 @@ public class PaperService {
     public List<LearnPaperQuestion> getQuestions2(Long studentId, Integer total, Integer seqId, Collection<Long> knownIds, String isSubType, List<TestPaperVO.TypeDef2> types, Map<String, KnowTypeAssign> knowTypeAssignMap, Set<String> existQuestionSet) {
         // 知识点已经分配,准备题型分配
         LearnQuestions qCond = new LearnQuestions();
-        Random random = new Random();
+        Random random = ThreadLocalRandom.current();
         List<LearnPaperQuestion> pqList = Lists.newArrayList();
         for (TestPaperVO.TypeDef2 typeDef : types) {
             String typeTitle = typeDef.getType().getTitle();

+ 1 - 1
ie-system/src/main/resources/mapper/learn/LearnStudentMapper.xml

@@ -30,7 +30,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectLearnStudentsByMap" parameterType="map" resultMap="LearnStudentResult"> <!-- 排除本批次已经生成的 -->
       SELECT ls.`student_id`, ls.`university_id`, ls.`major_group`, ls.`major_plan_id`, ls.`direct_key`, u.exam_type examType, ls.campus_id, ls.class_id, ls.school_id
         FROM `learn_student` ls
-        LEFT JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id` AND ts.`batch_id` = #{batchId} and ts.build_type = #{buildType} and ts.subject_id = #{subjectId}
+        LEFT JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id` AND ts.`batch_id` = #{batchId} and ts.build_type = #{buildType} and ts.subject_id = #{subjectId} and ts.class_id = ls.class_id
         JOIN `sys_user` u ON ls.`student_id` = u.`user_id`
         <where> ts.`id` IS NULL
             <choose><when test="directed and universityId != null"> AND ls.`university_id` = #{universityId}</when>