mingfu 1 kuukausi sitten
vanhempi
commit
a9e838f009

+ 14 - 5
ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTeacherController.java

@@ -10,7 +10,6 @@ import com.ruoyi.dz.domain.DzControl;
 import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.service.IDzControlService;
 import com.ruoyi.dz.service.IDzSubjectService;
-import com.ruoyi.ie.service.IAMarjorPlanService;
 import com.ruoyi.learn.domain.TestPaperVO;
 import com.ruoyi.web.service.LearnTeacherService;
 import io.swagger.annotations.Api;
@@ -127,11 +126,21 @@ public class LearnTeacherController extends BaseController {
     }
 
     @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
-    @PostMapping("/build")
-    @ApiOperation("批量组卷")
-    public AjaxResult batchBuild(@RequestBody TestPaperVO.TestPapersBuildReq req)
+    @PostMapping("/build/auto")
+    @ApiOperation("批量自动组卷")
+    public AjaxResult batchBuildAuto(@RequestBody TestPaperVO.TestPapersBuildAutoReq req)
     {
-        return toAjax(true);
+        req.setBuildType(TestPaperVO.PaperBuildType.Auto);
+        return AjaxResult.success(learnTeacherService.buildPapersAuto(req));
+    }
+
+    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
+    @PostMapping("/build/manual")
+    @ApiOperation("批量手动组卷")
+    public AjaxResult batchBuildManual(@RequestBody TestPaperVO.TestPapersBuildManualReq req)
+    {
+        req.setBuildType(TestPaperVO.PaperBuildType.Manual);
+        return AjaxResult.success(learnTeacherService.buildPapersManual(req));
     }
 
     @PreAuthorize("@ss.hasPermi('learn:test_paper:query')")

+ 4 - 4
ie-admin/src/main/java/com/ruoyi/web/service/ExamService.java

@@ -116,13 +116,13 @@ public class ExamService {
             paperMapper.updateLearnPaper(up);
         }
 
-        PaperService.PaperDef paperDef = new PaperService.PaperDef();
+        TestPaperVO.PaperDef paperDef = new TestPaperVO.PaperDef();
         paperDef.setTotal(15L);
         paperDef.setFillExclude(true);
         paperDef.setKnowIds(Lists.newArrayList(knowledgeId));
-        List<PaperService.TypeDef> typeDefList= Lists.newArrayList();
-        typeDefList.add(new PaperService.TypeDef("单选题", "单选题", 80, 1));
-        typeDefList.add(new PaperService.TypeDef("判断题", "判断题", 10, 2));
+        List<TestPaperVO.TypeDef> typeDefList= Lists.newArrayList();
+        typeDefList.add(new TestPaperVO.TypeDef("单选题", "单选题", 80, 1));
+        typeDefList.add(new TestPaperVO.TypeDef("判断题", "判断题", 10, 2));
         paperDef.setTypes(typeDefList);
         List<LearnPaperQuestion> pqList = paperService.getQuestions(studentId,  paperDef);
 

+ 266 - 2
ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java

@@ -1,34 +1,60 @@
 package com.ruoyi.web.service;
 
 import cn.hutool.core.lang.Dict;
+import com.google.common.collect.Maps;
+import com.google.common.collect.Sets;
+import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.TreeEntity;
+import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.dz.domain.DzClasses;
 import com.ruoyi.dz.mapper.DzClassesMapper;
+import com.ruoyi.enums.PaperType;
+import com.ruoyi.ie.domain.AMarjorPlan;
 import com.ruoyi.ie.mapper.AMarjorPlanMapper;
-import com.ruoyi.learn.domain.LearnKnowledgeTree;
+import com.ruoyi.learn.domain.*;
+import com.ruoyi.learn.mapper.LearnDirectedKnowledgeMapper;
 import com.ruoyi.learn.mapper.LearnKnowledgeTreeMapper;
+import com.ruoyi.learn.mapper.LearnStudentMapper;
+import com.ruoyi.learn.mapper.LearnTestPaperMapper;
 import com.ruoyi.syzy.domain.BBusiWishUniversities;
 import com.ruoyi.syzy.mapper.BBusiWishUniversitiesMapper;
 import lombok.Data;
 import org.apache.commons.compress.utils.Lists;
+import org.apache.commons.lang3.ArrayUtils;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.commons.lang3.tuple.Pair;
 import org.springframework.stereotype.Service;
+import org.springframework.transaction.annotation.Transactional;
+import org.springframework.util.CollectionUtils;
 
+import javax.validation.ValidationException;
+import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
+import java.util.Set;
 import java.util.stream.Collectors;
+import java.util.stream.Stream;
 
 @Service
 public class LearnTeacherService {
     private final DzClassesMapper dzClassesMapper;
     private final LearnKnowledgeTreeMapper learnKnowledgeTreeMapper;
+    private final LearnStudentMapper learnStudentMapper;
     private final AMarjorPlanMapper marjorPlanMapper;
     private final BBusiWishUniversitiesMapper busiWishUniversitiesMapper;
+    private final LearnDirectedKnowledgeMapper learnDirectedKnowledgeMapper;
+    private final PaperService paperService;
+    private final LearnTestPaperMapper learnTestPaperMapper;
 
-    public LearnTeacherService(DzClassesMapper dzClassesMapper, LearnKnowledgeTreeMapper learnKnowledgeTreeMapper, AMarjorPlanMapper marjorPlanMapper, BBusiWishUniversitiesMapper busiWishUniversitiesMapper) {
+    public LearnTeacherService(DzClassesMapper dzClassesMapper, LearnKnowledgeTreeMapper learnKnowledgeTreeMapper, LearnStudentMapper learnStudentMapper, AMarjorPlanMapper marjorPlanMapper, BBusiWishUniversitiesMapper busiWishUniversitiesMapper, LearnDirectedKnowledgeMapper learnDirectedKnowledgeMapper, PaperService paperService, LearnTestPaperMapper learnTestPaperMapper) {
         this.dzClassesMapper = dzClassesMapper;
         this.learnKnowledgeTreeMapper = learnKnowledgeTreeMapper;
+        this.learnStudentMapper = learnStudentMapper;
         this.marjorPlanMapper = marjorPlanMapper;
         this.busiWishUniversitiesMapper = busiWishUniversitiesMapper;
+        this.learnDirectedKnowledgeMapper = learnDirectedKnowledgeMapper;
+        this.paperService = paperService;
+        this.learnTestPaperMapper = learnTestPaperMapper;
     }
 
     public List<DzClasses> getClasses(Long teacherId)
@@ -45,7 +71,220 @@ public class LearnTeacherService {
                 .set("majorName", t.getMajorName()).set("count", t.getXuefei()).set("total", t.getPlanTotal())).collect(Collectors.toList());
     }
 
+    @Transactional(rollbackFor = Exception.class)
+    public String buildPapersAuto(TestPaperVO.TestPapersBuildAutoReq req) {
+        // 查询 院校,专业组,专业计划范围, 明细一级时只有一个,否则就是批量
+        List<LearnStudent> studentList = learnStudentMapper.selectLearnStudentsByMap(req.toMap());
+        if(CollectionUtils.isEmpty(studentList)) {
+            throw new ValidationException("无可用计划可检查");
+        }
+        Set<Long> planIdSet = Sets.newHashSet();
+        Map<Long, List<LearnStudent>> universityMap = Maps.newHashMap();
+        for(LearnStudent ls : studentList){
+            planIdSet.add(ls.getMajorPlanId());
+            List<LearnStudent> list = universityMap.get(ls.getUniversityId());
+            if(null == list) {
+                list = Lists.newArrayList();
+                universityMap.put(ls.getUniversityId(), list);
+            }
+            list.add(ls);
+        }
+        // 查询已经生成的
+        Map<Long, Map<String, LearnTestPaper>> universityDirectPaperMap = learnTestPaperMapper.selectByBatchAndUniversityIds(req.getBatchId(), universityMap.keySet()).stream()
+                .collect(Collectors.groupingBy(LearnTestPaper::getUniversityId, Collectors.toMap(LearnTestPaper::getDirectKey, a -> a)));
+        if(null == req.getDirectType() || !req.getDirectType()) { // 全量
+            LearnPaper paper = new LearnPaper();
+            paper.setPaperName(req.getTitle());
+            paper.setYear(Calendar.getInstance().get(Calendar.YEAR));
+            paper.setPaperType(PaperType.Test.name());
+            paper.setSubjectId(req.getSubjectId());
+            paper.setDirectKey("");
+            for(Long universityId : universityMap.keySet()) {
+                Map<String, LearnTestPaper> directPaperMap = universityDirectPaperMap.get(universityId);
+                if(null != directPaperMap && directPaperMap.containsKey("")) {
+                    continue;
+                }
+                if(null == paper.getId()) {
+                    Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = paperService.buildPaper(null, paper, req.getPaperDef());
+                    paperService.savePaper(paper, paperResult.getRight());
+                }
+                LearnTestPaper testPaper = new LearnTestPaper();
+                testPaper.setBatchId(req.getBatchId());
+                testPaper.setUniversityId(universityId);
+                testPaper.setDirectKey("");
+                testPaper.setPaperId(paper.getId());
+                learnTestPaperMapper.insertLearnTestPaper(testPaper);
+            }
+            return "";
+        }
+        TestPaperVO.PaperDef paperDef = req.getPaperDef();
+        if(null != req.getPlanIds() && req.getPlanIds().size() == 1) {
+            if(!CollectionUtils.isEmpty(paperDef.getKnowIds())) {
+                throw new ValidationException("批量时不支持自定义知识点");
+            }
+        }
+        Map<Long, Map<String, LearnDirectedKnowledge>> universityDirectedKnowledgeMap = learnDirectedKnowledgeMapper.selectByUniversityIds(universityMap.keySet().toArray(new Long[universityMap.size()])).stream().collect(
+                Collectors.groupingBy(LearnDirectedKnowledge::getUniversityId, Collectors.toMap(LearnDirectedKnowledge::getDirectKey, a -> a)));
+        Map<Long, AMarjorPlan> planMap = marjorPlanMapper.selectAMarjorPlanByIds(planIdSet.toArray(new Long[planIdSet.size()])).stream().collect(Collectors.toMap(AMarjorPlan::getId, a -> a));
+
+        LearnDirectedKnowledge directedKnowledge = null;
+        String directedKey = null;
+
+        for(Long universityId : universityMap.keySet()) {
+            Map<String, LearnDirectedKnowledge> directedKnowledgeMap = universityDirectedKnowledgeMap.get(universityId);
+            for(LearnStudent ls : universityMap.get(universityId)) {
+                AMarjorPlan plan = planMap.get(ls.getMajorPlanId());
+                String groupName = StringUtils.trimToEmpty(plan.getMajorGroup());
+                if(CollectionUtils.isEmpty(paperDef.getKnowIds())) {
+                    if(null != (directedKnowledge = directedKnowledgeMap.get((directedKey = groupName + "_" + plan.getMajorName())))) {
+                        paperDef.setKnowIds(Stream.of(directedKnowledge.getKnowledges().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                    } else if(null != (directedKnowledge = directedKnowledgeMap.get(directedKey = groupName))) {
+                        paperDef.setKnowIds(Stream.of(directedKnowledge.getKnowledges().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                    } else {
+                        throw new ValidationException("院校没有配置定向知识点,生成失败: " + universityId + ":" + groupName + ":" + plan.getMajorName());
+                    }
+                } else if(null != directedKnowledgeMap) {
+                    if(null != (directedKnowledge = directedKnowledgeMap.get((directedKey = groupName + "_" + plan.getMajorName())))) {
+                    } else if(null != (directedKnowledge = directedKnowledgeMap.get(directedKey = groupName))) {
+                    } else {
+                        throw new ValidationException("院校没有配置定向知识点,生成失败" + universityId + ":" + directedKey);
+                    }
+                } else {
+                    throw new ValidationException("院校没有配置定向知识点,生成失败: " + universityId);
+                }
+                Map<String, LearnTestPaper> directPaperMap = universityDirectPaperMap.get(universityId);
+                if(null != directPaperMap && directPaperMap.containsKey(directedKey)) {
+                    continue;
+                }
+                LearnPaper paper = new LearnPaper();
+                paper.setSubjectId(req.getSubjectId());
+                paper.setPaperName(req.getTitle());
+                paper.setYear(plan.getYear());
+                paper.setPaperType(PaperType.Test.name());
+                paper.setDirectKey(directedKey);
+                Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = paperService.buildPaper(null, paper, paperDef);
+                paperService.savePaper(paperResult.getKey(), paperResult.getValue());
+
+                LearnTestPaper testPaper = new LearnTestPaper();
+                testPaper.setBatchId(req.getBatchId());
+                testPaper.setUniversityId(universityId);
+                testPaper.setDirectKey(directedKey);
+                testPaper.setPaperId(paper.getId());
+                learnTestPaperMapper.insertLearnTestPaper(testPaper);
+                directPaperMap.put(directedKey, testPaper);
+            }
+        }
+        return "";
+    }
+
+    @Transactional(rollbackFor = Exception.class)
+    public String buildPapersManual(TestPaperVO.TestPapersBuildManualReq req) {
+        if(null == req.getSubjectId()) {
+            throw new ValidationException("未选择科目");
+        }
+        // 查询 院校,专业组,专业计划范围, 明细一级时只有一个,否则就是批量
+        List<LearnStudent> studentList = learnStudentMapper.selectLearnStudentsByMap(req.toMap());
+        if(CollectionUtils.isEmpty(studentList)) {
+            throw new ValidationException("无可用计划可检查");
+        }
+        Set<Long> planIdSet = Sets.newHashSet();
+        Map<Long, List<LearnStudent>> universityMap = Maps.newHashMap();
+        for(LearnStudent ls : studentList){
+            planIdSet.add(ls.getMajorPlanId());
+            List<LearnStudent> list = universityMap.get(ls.getUniversityId());
+            if(null == list) {
+                list = Lists.newArrayList();
+                universityMap.put(ls.getUniversityId(), list);
+            }
+            list.add(ls);
+        }
+        // 查询已经生成的
+        Map<Long, Map<String, LearnTestPaper>> universityDirectPaperMap = learnTestPaperMapper.selectByBatchAndUniversityIds(req.getBatchId(), universityMap.keySet()).stream()
+                .collect(Collectors.groupingBy(LearnTestPaper::getUniversityId, Collectors.toMap(LearnTestPaper::getDirectKey, a -> a)));
+
+        LearnPaper paper = new LearnPaper();
+        paper.setPaperName(req.getTitle());
+        paper.setYear(Calendar.getInstance().get(Calendar.YEAR));
+        paper.setPaperType(PaperType.Test.name());
+        if(null == req.getDirectType() || !req.getDirectType()) { // 全量
+            paper.setSubjectId(req.getSubjectId());
+            paper.setDirectKey("");
+            for(Long universityId : universityMap.keySet()) {
+                Map<String, LearnTestPaper> directPaperMap = universityDirectPaperMap.get(universityId);
+                if(null != directPaperMap && directPaperMap.containsKey("")) {
+                    continue;
+                }
+                if(null == paper.getId()) {
+                    paperService.savePaper(paper, req.getQuestions());
+                }
+                LearnTestPaper testPaper = new LearnTestPaper();
+                testPaper.setBatchId(req.getBatchId());
+                testPaper.setUniversityId(universityId);
+                testPaper.setDirectKey("");
+                testPaper.setPaperId(paper.getId());
+                testPaper.setConditions("");
+                testPaper.setCreatorId(SecurityUtils.getUserId());
+                learnTestPaperMapper.insertLearnTestPaper(testPaper);
+            }
+            return "";
+        } // 定向
+        // 准备定向数据
+        Map<Long, Map<String, LearnDirectedKnowledge>> universityDirectedKnowledgeMap = learnDirectedKnowledgeMapper.selectByUniversityIds(universityMap.keySet().toArray(new Long[universityMap.size()])).stream().collect(
+                Collectors.groupingBy(LearnDirectedKnowledge::getUniversityId, Collectors.toMap(LearnDirectedKnowledge::getDirectKey, a -> a)));
+        Map<Long, AMarjorPlan> planMap = marjorPlanMapper.selectAMarjorPlanByIds(planIdSet.toArray(new Long[planIdSet.size()])).stream().collect(Collectors.toMap(AMarjorPlan::getId, a -> a));
+
+        String directedKey = null;
+        for(Long universityId : universityMap.keySet()) {
+            Map<String, LearnTestPaper> directPaperMap = universityDirectPaperMap.get(universityId);
+            Map<String, LearnDirectedKnowledge> directedKnowledgeMap = universityDirectedKnowledgeMap.get(universityId);
+            for(LearnStudent ls : universityMap.get(universityId)) { // Group+Name
+                AMarjorPlan plan = planMap.get(ls.getMajorPlanId());
+                String groupName = StringUtils.trimToEmpty(plan.getMajorGroup());
+                if(null != (directedKnowledgeMap.get(directedKey = groupName + "_" + plan.getMajorName()))) {
+                    if(null != directPaperMap.get(directedKey)) {
+                        continue;
+                    }
+                } else if(null != directedKnowledgeMap.get(directedKey = groupName)) {
+                    if(null != directPaperMap.get(directedKey)) {
+                        continue;
+                    }
+                } else {
+                    continue;
+                }
+                if(null == paper.getId()) {
+                    paperService.savePaper(paper, req.getQuestions());
+                }
+                LearnTestPaper testPaper = new LearnTestPaper();
+                testPaper.setBatchId(req.getBatchId());
+                testPaper.setUniversityId(universityId);
+                testPaper.setDirectKey(directedKey);
+                testPaper.setPaperId(paper.getId());
+                learnTestPaperMapper.insertLearnTestPaper(testPaper);
+                directPaperMap.put(directedKey, testPaper);
+            }
+        }
+        return "";
+    }
+
     public List<TreeNode> getKnowledgeTree(Long subjectId, Long[] planIds) {
+        Set<Long> knowledgeIdSet = Sets.newHashSet();
+        if(ArrayUtils.isNotEmpty(planIds)) {
+            List<AMarjorPlan> planList = marjorPlanMapper.selectAMarjorPlanByIds(planIds);
+            AMarjorPlan curr = planList.get(0);
+            LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
+            dkCond.setUniversityId(curr.getUniversityId());
+            dkCond.setYear(curr.getYear());
+            Map<String, LearnDirectedKnowledge> directedKnowledgeMap = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond).stream().collect(Collectors.toMap(LearnDirectedKnowledge::getDirectKey, t -> t));
+            LearnDirectedKnowledge directedKnowledge = null;
+            for(AMarjorPlan plan : planList) {
+                String groupName = StringUtils.trimToEmpty(plan.getMajorGroup());
+                if(null != (directedKnowledge = directedKnowledgeMap.get(groupName + "_" + plan.getMajorName()))) {
+                    knowledgeIdSet.addAll(Stream.of(directedKnowledge.getKnowledges().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                } else if(null != (directedKnowledge = directedKnowledgeMap.get(groupName))) {
+                    knowledgeIdSet.addAll(Stream.of(directedKnowledge.getKnowledges().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                }
+            }
+        }
         LearnKnowledgeTree ktCond = new LearnKnowledgeTree();
         ktCond.setSubjectId(subjectId);
         List<LearnKnowledgeTree> ktList = learnKnowledgeTreeMapper.selectLearnKnowledgeTreeList(ktCond);
@@ -58,6 +297,9 @@ public class LearnTeacherService {
             }
             teMap.get(kt.getPid()).getChildren().add(teMap.get(kt.getId()));
         }
+        for(TreeNode tn : treeNodeList) {
+            tn.setChecked(knowledgeIdSet);
+        }
         return treeNodeList;
     }
 
@@ -65,10 +307,32 @@ public class LearnTeacherService {
     public static class TreeNode {
         private Long id;
         private String name;
+        private Integer status;
         List<TreeNode> children = Lists.newArrayList();
         public TreeNode(Long id, String name) {
             this.id = id;
             this.name = name;
+            this.status = 0;
+        }
+
+        public boolean setChecked(Set<Long> idSet) {
+            boolean checkSelf = idSet.contains(id);
+            if(CollectionUtils.isEmpty(children)) {
+                this.status = checkSelf ? 1 : 0;
+                return true;
+            }
+            int count = 0;
+            for(TreeNode tn : children) {
+                if(checkSelf || idSet.contains(tn.getId())) {
+                    tn.setStatus(1);
+                    count++;
+                }
+            }
+            if(children.size() == count) {
+                this.status = 1;
+                return true;
+            }
+            return false;
         }
     }
 }

+ 9 - 28
ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java

@@ -10,9 +10,7 @@ import com.ruoyi.enums.PaperStatus;
 import com.ruoyi.enums.PaperType;
 import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.mapper.*;
-import lombok.AllArgsConstructor;
 import lombok.Data;
-import lombok.NoArgsConstructor;
 import org.apache.commons.lang3.tuple.Pair;
 import org.springframework.stereotype.Service;
 
@@ -78,9 +76,9 @@ public class PaperService {
         paper.setStatus(PaperStatus.Valid.getVal());
         paper.setDirectKey(directedKnowledge.getDirectKey());
 
-        PaperService.PaperDef paperDef = JSONObject.parseObject(directedKnowledge.getConditions(), PaperDef.class);
+        TestPaperVO.PaperDef paperDef = JSONObject.parseObject(directedKnowledge.getConditions(), TestPaperVO.PaperDef.class);
         paperDef.setKnowIds(Stream.of(directedKnowledge.getKnowledges().split(",")).map(Long::valueOf).collect(Collectors.toList()));
-        paperDef.setTypes(JSONArray.parseArray(directedKnowledge.getQuestionTypes(), TypeDef.class));
+        paperDef.setTypes(JSONArray.parseArray(directedKnowledge.getQuestionTypes(), TestPaperVO.TypeDef.class));
         return buildPaper(null, paper, paperDef);
     }
 
@@ -91,7 +89,7 @@ public class PaperService {
      * @param paperDef
      * @return
      */
-    public Pair<LearnPaper, List<LearnPaperQuestion>> buildPaper(Long studentId, LearnPaper paper, PaperService.PaperDef paperDef) {
+    public Pair<LearnPaper, List<LearnPaperQuestion>> buildPaper(Long studentId, LearnPaper paper, TestPaperVO.PaperDef paperDef) {
         if(null == studentId){
             paperDef.setFillExclude(false);
         }
@@ -123,17 +121,17 @@ public class PaperService {
      * @param paperDef
      * @return
      */
-    public List<LearnPaperQuestion> getQuestions(Long studentId, PaperDef paperDef) {
+    public List<LearnPaperQuestion> getQuestions(Long studentId, TestPaperVO.PaperDef paperDef) {
         // 题型分布定义, 知识点列表, 分值定义
         // 统计知识点+类型的有效数量 TODO 总量可以缓存
         Map<String, KnowTypeAssign> knowTypeAssignMap = Maps.newHashMap();
-        List<String> typeSet = paperDef.getTypes().stream().map(TypeDef::getType).collect(Collectors.toList());
+        List<String> typeSet = paperDef.getTypes().stream().map(TestPaperVO.TypeDef::getType).collect(Collectors.toList());
         Map cond = Maps.newHashMap();
         cond.put("studentId", studentId);
         cond.put("knowIds", paperDef.getKnowIds());
         cond.put("types", typeSet);
         setValue(knowTypeAssignMap, cond, 1); // 填充排除总量
-        if (paperDef.fillExclude) {
+        if (paperDef.getFillExclude()) {
             cond.remove("studentId");
             setValue(knowTypeAssignMap, cond, 2); // 按需填充总量
         }
@@ -161,8 +159,8 @@ public class PaperService {
                     avgKnowTypeCount = 1L;
                 }
                 typeCount = 0;
-                for (TypeDef typeDef : paperDef.getTypes()) {
-                    Long tmpMinKnowTypeCount = assignKnownCount(knowId, typeDef.getType(), knowTypeAssignMap, avgKnowTypeCount, paperDef.fillExclude, assignCount);
+                for (TestPaperVO.TypeDef typeDef : paperDef.getTypes()) {
+                    Long tmpMinKnowTypeCount = assignKnownCount(knowId, typeDef.getType(), knowTypeAssignMap, avgKnowTypeCount, paperDef.getFillExclude(), assignCount);
                     if (tmpMinKnowTypeCount > 0) {
                         minKnowTypeCount = Math.min(minKnowTypeCount, tmpMinKnowTypeCount);
                         knowSet.add(knowId);
@@ -182,7 +180,7 @@ public class PaperService {
         Random random = new Random();
         List<LearnPaperQuestion> pqList = Lists.newArrayList();
         Set<Long> existQuestionIdSet = Sets.newHashSet();
-        for (TypeDef typeDef : paperDef.getTypes()) {
+        for (TestPaperVO.TypeDef typeDef : paperDef.getTypes()) {
             for (Long knowId : paperDef.getKnowIds()) {
                 String key = knowId + "_" + typeDef.getType();
                 KnowTypeAssign ktc = knowTypeAssignMap.get(key);
@@ -312,21 +310,4 @@ public class PaperService {
         Long exclCount; // 排除总数
         Long total; // 全量总数
     }
-
-    @Data
-    @AllArgsConstructor
-    @NoArgsConstructor
-    public static class TypeDef {
-        String title;
-        String type;
-        Integer count;
-        Integer score;
-    }
-    @Data
-    public static class PaperDef {
-        Long total;
-        List<Long> knowIds;
-        Boolean fillExclude; // 不足时是否填充排除的
-        List<TypeDef> types;
-    }
 }

+ 1 - 0
ie-system/src/main/java/com/ruoyi/ie/mapper/AMarjorPlanMapper.java

@@ -14,6 +14,7 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface AMarjorPlanMapper 
 {
+    public List<AMarjorPlan> selectAMarjorPlanByIds(Long[] ids);
     public List<AMarjorPlan>  selectMajorForUniversity(@Param("universityId") Long universityId, @Param("year") Integer year, @Param("batchId") Long batchId);
     /**
      * 查询专业计划要求

+ 12 - 1
ie-system/src/main/java/com/ruoyi/learn/domain/LearnDirectedKnowledge.java

@@ -22,6 +22,9 @@ public class LearnDirectedKnowledge extends BaseEntity
     @Excel(name = "年度")
     private Integer year;
 
+    @Excel(name = "院校ID")
+    private Long universityId;
+
     /** 定向Key */
     @Excel(name = "定向Key")
     private String directKey;
@@ -82,7 +85,15 @@ public class LearnDirectedKnowledge extends BaseEntity
         return year;
     }
 
-    public void setDirectKey(String directKey) 
+    public Long getUniversityId() {
+        return universityId;
+    }
+
+    public void setUniversityId(Long universityId) {
+        this.universityId = universityId;
+    }
+
+    public void setDirectKey(String directKey)
     {
         this.directKey = directKey;
     }

+ 22 - 0
ie-system/src/main/java/com/ruoyi/learn/domain/LearnPaperQuestion.java

@@ -34,6 +34,12 @@ public class LearnPaperQuestion extends BaseEntity
     @Excel(name = "分值")
     private Integer score;
 
+    @Excel(name = "题型")
+    private String type;
+
+    @Excel(name = "难度")
+    private Integer diff;
+
     public void setId(Long id) 
     {
         this.id = id;
@@ -84,6 +90,22 @@ public class LearnPaperQuestion extends BaseEntity
         return score;
     }
 
+    public String getType() {
+        return type;
+    }
+
+    public void setType(String type) {
+        this.type = type;
+    }
+
+    public Integer getDiff() {
+        return diff;
+    }
+
+    public void setDiff(Integer diff) {
+        this.diff = diff;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

+ 23 - 13
ie-system/src/main/java/com/ruoyi/learn/domain/LearnTestPaper.java

@@ -20,7 +20,11 @@ public class LearnTestPaper extends BaseEntity
 
     /** 批次id */
     @Excel(name = "批次id")
-    private Long batchId;
+    private Integer batchId;
+
+    /** 院校id */
+    @Excel(name = "院校id")
+    private Long universityId;
 
     /** 定向key */
     @Excel(name = "定向key")
@@ -32,7 +36,7 @@ public class LearnTestPaper extends BaseEntity
 
     /** 试卷生成条件 */
     @Excel(name = "试卷生成条件")
-    private String condions;
+    private String conditions;
 
     /** 创建人 */
     @Excel(name = "创建人")
@@ -48,17 +52,25 @@ public class LearnTestPaper extends BaseEntity
         return id;
     }
 
-    public void setBatchId(Long batchId) 
+    public void setBatchId(Integer batchId)
     {
         this.batchId = batchId;
     }
 
-    public Long getBatchId() 
+    public Integer getBatchId()
     {
         return batchId;
     }
 
-    public void setDirectKey(String directKey) 
+    public Long getUniversityId() {
+        return universityId;
+    }
+
+    public void setUniversityId(Long universityId) {
+        this.universityId = universityId;
+    }
+
+    public void setDirectKey(String directKey)
     {
         this.directKey = directKey;
     }
@@ -78,17 +90,15 @@ public class LearnTestPaper extends BaseEntity
         return paperId;
     }
 
-    public void setCondions(String condions) 
-    {
-        this.condions = condions;
+    public String getConditions() {
+        return conditions;
     }
 
-    public String getCondions() 
-    {
-        return condions;
+    public void setConditions(String conditions) {
+        this.conditions = conditions;
     }
 
-    public void setCreatorId(Long creatorId) 
+    public void setCreatorId(Long creatorId)
     {
         this.creatorId = creatorId;
     }
@@ -105,7 +115,7 @@ public class LearnTestPaper extends BaseEntity
             .append("batchId", getBatchId())
             .append("directKey", getDirectKey())
             .append("paperId", getPaperId())
-            .append("condions", getCondions())
+            .append("conditions", getConditions())
             .append("creatorId", getCreatorId())
             .append("createTime", getCreateTime())
             .toString();

+ 70 - 14
ie-system/src/main/java/com/ruoyi/learn/domain/TestPaperVO.java

@@ -1,38 +1,75 @@
 package com.ruoyi.learn.domain;
 
+import com.google.common.collect.Maps;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
+import lombok.AllArgsConstructor;
 import lombok.Data;
+import lombok.NoArgsConstructor;
 
 import java.util.List;
 import java.util.Map;
 
 public class TestPaperVO {
-    enum PaperBuildType {
+    public static enum PaperBuildType {
         Manual, Auto
     }
 
-    @ApiModel("批量组卷请求")
+    @ApiModel("基本组卷请求")
     @Data
     public static class TestPapersBuildReq {
-        @ApiModelProperty("班级")
-        List<Long> classIds;
-        @ApiModelProperty("考生类型")
-        List<String> examTypes;
-        @ApiModelProperty("组卷类型")
+        @ApiModelProperty("名称")
+        String title;
+        @ApiModelProperty("总分")
+        Integer total;
+
+        @ApiModelProperty("批次")
+        Integer batchId;
+        @ApiModelProperty("省份")
+        String location;
+        @ApiModelProperty("组卷方式")
         PaperBuildType buildType;
-        @ApiModelProperty("定向类型 null是全部")
+        @ApiModelProperty("是否定向")
         Boolean directType;
+
+        @ApiModelProperty("科目")
+        Long subjectId;
+
+        @ApiModelProperty("考生类型")
+        List<String> examTypes;
+        @ApiModelProperty("班级")
+        List<Long> classIds;
         @ApiModelProperty("院校")
         List<Long> universityIds;
         @ApiModelProperty("专业组(单院校有效)")
         List<String> groups;
-        @ApiModelProperty("科目")
-        List<Integer> subjectIds;
-        @ApiModelProperty("知识点")
-        List<Long> knowledgeIds;
-        @ApiModelProperty("题型要求")
-        Map<String, Integer> questionTypeNum;
+        @ApiModelProperty("专业组(单专业组有效)")
+        List<Long> planIds;
+
+        public Map<String, Object> toMap() {
+            Map<String, Object> map = Maps.newHashMap();
+            map.put("batchId", batchId);
+            map.put("location", location);
+            map.put("examTypes", examTypes);
+            map.put("classIds", classIds);
+            map.put("universityIds", universityIds);
+            map.put("groups", groups);
+            map.put("planIds", planIds);
+            return map;
+        }
+    }
+
+    @ApiModel("手动组卷请求")
+    @Data
+    public static class TestPapersBuildManualReq extends TestPapersBuildReq {
+        @ApiModelProperty("试题列表")
+        List<LearnPaperQuestion> questions;
+    }
+    @ApiModel("智能组卷请求")
+    @Data
+    public static class TestPapersBuildAutoReq extends TestPapersBuildReq {
+        @ApiModelProperty("试卷要求")
+        PaperDef paperDef;
     }
 
     @ApiModel("批量查询请求")
@@ -86,4 +123,23 @@ public class TestPaperVO {
         @ApiModelProperty("学生")
         List<Long> studentIds;
     }
+
+
+    @Data
+    public static class PaperDef {
+        Long total;
+        List<Long> knowIds;
+        Boolean fillExclude; // 不足时是否填充排除的
+        List<TestPaperVO.TypeDef> types;
+    }
+
+    @Data
+    @AllArgsConstructor
+    @NoArgsConstructor
+    public static class TypeDef {
+        String title;
+        String type;
+        Integer count;
+        Integer score;
+    }
 }

+ 2 - 0
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnDirectedKnowledgeMapper.java

@@ -11,6 +11,8 @@ import com.ruoyi.learn.domain.LearnDirectedKnowledge;
  */
 public interface LearnDirectedKnowledgeMapper 
 {
+    public List<LearnDirectedKnowledge> selectByUniversityIds(Long[] universityIds);
+
     /**
      * 查询定向知识点关系
      * 

+ 4 - 0
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnStudentMapper.java

@@ -1,6 +1,8 @@
 package com.ruoyi.learn.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.ruoyi.learn.domain.LearnStudent;
 
 /**
@@ -11,6 +13,8 @@ import com.ruoyi.learn.domain.LearnStudent;
  */
 public interface LearnStudentMapper 
 {
+    public List<LearnStudent> selectLearnStudentsByMap(Map cond);
+
     /**
      * 查询学生
      * 

+ 4 - 0
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnTestPaperMapper.java

@@ -1,7 +1,9 @@
 package com.ruoyi.learn.mapper;
 
+import java.util.Collection;
 import java.util.List;
 import com.ruoyi.learn.domain.LearnTestPaper;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 批次测试卷Mapper接口
@@ -11,6 +13,8 @@ import com.ruoyi.learn.domain.LearnTestPaper;
  */
 public interface LearnTestPaperMapper 
 {
+    public List<LearnTestPaper> selectByBatchAndUniversityIds(@Param("batchId") Integer batchId, @Param("universityIds") Collection<Long> universityIds);
+
     /**
      * 查询批次测试卷
      * 

+ 5 - 0
ie-system/src/main/resources/mapper/ie/AMarjorPlanMapper.xml

@@ -107,6 +107,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <select id="selectAMarjorPlanByIds" parameterType="Long" resultMap="AMarjorPlanResult">
+        <include refid="selectAMarjorPlanVo"/>
+        where id in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
+    </select>
+
     <select id="selectMajorCodesByIds" parameterType="String" resultType="String">
         SELECT distinct m1.code majorCode
         FROM `a_marjor_plan` p

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

@@ -7,6 +7,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="LearnDirectedKnowledge" id="LearnDirectedKnowledgeResult">
         <result property="id"    column="id"    />
         <result property="year"    column="year"    />
+        <result property="universityId"    column="university_id"    />
         <result property="directKey"    column="direct_key"    />
         <result property="enrollFormula"    column="enrollFormula"    />
         <result property="cultural"    column="cultural"    />
@@ -20,13 +21,14 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLearnDirectedKnowledgeVo">
-        select id, year, direct_key, enrollFormula, cultural, professional, subjects, question_types, knowledges, locations, examineeTypes, conditions from learn_directed_knowledge
+        select id, year, university_id, direct_key, enrollFormula, cultural, professional, subjects, question_types, knowledges, locations, examineeTypes, conditions from learn_directed_knowledge
     </sql>
 
     <select id="selectLearnDirectedKnowledgeList" parameterType="LearnDirectedKnowledge" resultMap="LearnDirectedKnowledgeResult">
         <include refid="selectLearnDirectedKnowledgeVo"/>
         <where>  
             <if test="year != null "> and year = #{year}</if>
+            <if test="universityId != null  and universityId != ''"> and university_id = #{universityId}</if>
             <if test="directKey != null  and directKey != ''"> and direct_key = #{directKey}</if>
             <if test="enrollFormula != null  and enrollFormula != ''"> and enrollFormula = #{enrollFormula}</if>
             <if test="cultural != null  and cultural != ''"> and cultural = #{cultural}</if>
@@ -45,10 +47,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where id = #{id}
     </select>
 
+    <select id="selectByUniversityIds" parameterType="Long" resultMap="LearnDirectedKnowledgeResult">
+        <include refid="selectLearnDirectedKnowledgeVo"/>
+        where id in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
+    </select>
+
     <insert id="insertLearnDirectedKnowledge" parameterType="LearnDirectedKnowledge" useGeneratedKeys="true" keyProperty="id">
         insert into learn_directed_knowledge
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="year != null">year,</if>
+            <if test="universityId != null">university_id,</if>
             <if test="directKey != null">direct_key,</if>
             <if test="enrollFormula != null">enrollFormula,</if>
             <if test="cultural != null">cultural,</if>
@@ -62,6 +70,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="year != null">#{year},</if>
+            <if test="universityId != null">#{universityId},</if>
             <if test="directKey != null">#{directKey},</if>
             <if test="enrollFormula != null">#{enrollFormula},</if>
             <if test="cultural != null">#{cultural},</if>
@@ -79,6 +88,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update learn_directed_knowledge
         <trim prefix="SET" suffixOverrides=",">
             <if test="year != null">year = #{year},</if>
+            <if test="universityId != null">university_id = #{universityId},</if>
             <if test="directKey != null">direct_key = #{directKey},</if>
             <if test="enrollFormula != null">enrollFormula = #{enrollFormula},</if>
             <if test="cultural != null">cultural = #{cultural},</if>

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

@@ -9,11 +9,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="classId"    column="class_id"    />
         <result property="campusId"    column="campus_id"    />
         <result property="universityId"    column="university_id"    />
+        <result property="majorGroup"    column="major_group"    />
         <result property="majorPlanId"    column="major_plan_id"    />
     </resultMap>
 
     <sql id="selectLearnStudentVo">
-        select student_id, class_id, campus_id, university_id, major_plan_id from learn_student
+        select student_id, class_id, campus_id, university_id, major_group,major_plan_id from learn_student
     </sql>
 
     <select id="selectLearnStudentList" parameterType="LearnStudent" resultMap="LearnStudentResult">
@@ -22,6 +23,20 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="directKey != null  and directKey != ''"> and direct_key = #{directKey}</if>
         </where>
     </select>
+
+    <select id="selectLearnStudentsByMap" parameterType="map" resultMap="LearnStudentResult">
+        SELECT distinct ls.`university_id`, ls.`major_group`, ls.`major_plan_id`
+        FROM `learn_student` ls
+        LEFT JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id` AND ts.`batch_id` = #{batchId}
+        JOIN `sys_user` u ON ls.`student_id` = u.`user_id`
+        <where> ts.`id` IS NULL and u.`location` = #{location}
+            <if test="examTypes != null  and examTypes.size() > 0"> AND u.`exam_type` in <foreach item="id" collection="examTypes" open="(" separator="," close=")">#{id}</foreach></if>
+            <if test="classIds != null  and classIds.size() > 0"> AND ls.`class_id` IN <foreach item="id" collection="classIds" open="(" separator="," close=")">#{id}</foreach></if>
+            <if test="universityIds != null  and universityIds.size() > 0"> AND ls.`university_id` IN <foreach item="id" collection="universityIds" open="(" separator="," close=")">#{id}</foreach></if>
+            <if test="groups != null  and groups.size() > 0"> AND ls.`major_group` IN <foreach item="id" collection="groups" open="(" separator="," close=")">#{id}</foreach></if>
+            <if test="planIds != null  and planIds.size() > 0"> AND ls.`major_plan_id` IN <foreach item="id" collection="planIds" open="(" separator="," close=")">#{id}</foreach></if>
+        </where>
+    </select>
     
     <select id="selectLearnStudentByStudentId" parameterType="Long" resultMap="LearnStudentResult">
         <include refid="selectLearnStudentVo"/>
@@ -35,6 +50,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="classId != null">class_id,</if>
             <if test="campusId != null">campus_id,</if>
             <if test="universityId != null">university_id,</if>
+            <if test="majorGroup != null">major_group,</if>
             <if test="majorPlanId != null">major_plan_id,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
@@ -42,6 +58,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="classId != null">#{classId},</if>
             <if test="campusId != null">#{campusId},</if>
             <if test="universityId != null">#{universityId},</if>
+            <if test="majorGroup != null">#{majorGroup},</if>
             <if test="majorPlanId != null">#{majorPlanId},</if>
          </trim>
     </insert>
@@ -52,6 +69,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="classId != null">class_id = #{classId},</if>
             <if test="campusId != null">campus_id = #{campusId},</if>
             <if test="universityId != null">university_id = #{universityId},</if>
+            <if test="majorGroup != null">major_group = #{majorGroup},</if>
             <if test="majorPlanId != null">major_plan_id = #{majorPlanId},</if>
         </trim>
         where student_id = #{studentId}

+ 20 - 10
ie-system/src/main/resources/mapper/learn/LearnTestPaperMapper.xml

@@ -7,28 +7,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <resultMap type="LearnTestPaper" id="LearnTestPaperResult">
         <result property="id"    column="id"    />
         <result property="batchId"    column="batch_id"    />
+        <result property="universityId"    column="university_id"    />
         <result property="directKey"    column="direct_key"    />
         <result property="paperId"    column="paper_id"    />
-        <result property="condions"    column="condions"    />
+        <result property="conditions"    column="conditions"    />
         <result property="creatorId"    column="creator_id"    />
         <result property="createTime"    column="create_time"    />
     </resultMap>
 
     <sql id="selectLearnTestPaperVo">
-        select id, batch_id, direct_key, paper_id, condions, creator_id, create_time from learn_test_paper
+        select id, batch_id, university_id, direct_key, paper_id, conditions, creator_id, create_time from learn_test_paper
     </sql>
 
     <select id="selectLearnTestPaperList" parameterType="LearnTestPaper" resultMap="LearnTestPaperResult">
         <include refid="selectLearnTestPaperVo"/>
         <where>  
             <if test="batchId != null "> and batch_id = #{batchId}</if>
+            <if test="universityId != null "> and university_id = #{universityId}</if>
             <if test="directKey != null  and directKey != ''"> and direct_key = #{directKey}</if>
             <if test="paperId != null "> and paper_id = #{paperId}</if>
-            <if test="condions != null  and condions != ''"> and condions = #{condions}</if>
+            <if test="conditions != null  and conditions != ''"> and conditions = #{conditions}</if>
             <if test="creatorId != null "> and creator_id = #{creatorId}</if>
         </where>
     </select>
-    
+
+    <select id="selectByBatchAndUniversityIds" resultMap="LearnTestPaperResult">
+        <include refid="selectLearnTestPaperVo"/>
+        where batch_id = #{batchId} and university_id in <foreach item="id" collection="universityIds" open="(" separator="," close=")">#{id}</foreach>
+    </select>
+
     <select id="selectLearnTestPaperById" parameterType="String" resultMap="LearnTestPaperResult">
         <include refid="selectLearnTestPaperVo"/>
         where id = #{id}
@@ -38,17 +45,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         insert into learn_test_paper
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="batchId != null">batch_id,</if>
-            <if test="directKey != null and directKey != ''">direct_key,</if>
+            <if test="universityId != null">university_id,</if>
+            <if test="directKey != null ">direct_key,</if>
             <if test="paperId != null">paper_id,</if>
-            <if test="condions != null and condions != ''">condions,</if>
+            <if test="conditions != null">conditions,</if>
             <if test="creatorId != null">creator_id,</if>
             <if test="createTime != null">create_time,</if>
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="batchId != null">#{batchId},</if>
-            <if test="directKey != null and directKey != ''">#{directKey},</if>
+            <if test="universityId != null">#{universityId},</if>
+            <if test="directKey != null">#{directKey},</if>
             <if test="paperId != null">#{paperId},</if>
-            <if test="condions != null and condions != ''">#{condions},</if>
+            <if test="conditions != null">#{conditions},</if>
             <if test="creatorId != null">#{creatorId},</if>
             <if test="createTime != null">#{createTime},</if>
          </trim>
@@ -58,9 +67,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         update learn_test_paper
         <trim prefix="SET" suffixOverrides=",">
             <if test="batchId != null">batch_id = #{batchId},</if>
-            <if test="directKey != null and directKey != ''">direct_key = #{directKey},</if>
+            <if test="universityId != null">university_id = #{universityId},</if>
+            <if test="directKey != null">direct_key = #{directKey},</if>
             <if test="paperId != null">paper_id = #{paperId},</if>
-            <if test="condions != null and condions != ''">condions = #{condions},</if>
+            <if test="conditions != null">conditions = #{conditions},</if>
             <if test="creatorId != null">creator_id = #{creatorId},</if>
             <if test="createTime != null">create_time = #{createTime},</if>
         </trim>

+ 13 - 0
ie-system/src/main/resources/mapper/learn/LearnTestStudentMapper.xml

@@ -20,6 +20,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select id, batch_id, student_id, direct_key, paper_id, class_id, examinee_id, status, create_time from learn_test_student
     </sql>
 
+    <select id="selectDirectedStudentList" parameterType="LearnTestStudent" resultMap="LearnTestStudentResult">
+        <include refid="selectLearnTestStudentVo"/>
+        <where>
+            <if test="batchId != null "> and batch_id = #{batchId}</if>
+            <if test="studentId != null "> and student_id = #{studentId}</if>
+            <if test="directKey != null  and directKey != ''"> and direct_key = #{directKey}</if>
+            <if test="paperId != null "> and paper_id = #{paperId}</if>
+            <if test="classId != null "> and class_id = #{classId}</if>
+            <if test="examineeId != null "> and examinee_id = #{examineeId}</if>
+            <if test="status != null "> and status = #{status}</if>
+        </where>
+    </select>
+
     <select id="selectLearnTestStudentList" parameterType="LearnTestStudent" resultMap="LearnTestStudentResult">
         <include refid="selectLearnTestStudentVo"/>
         <where>