Преглед на файлове

组卷及分发功能基本完成

mingfu преди 20 часа
родител
ревизия
de5c3b145c
променени са 24 файла, в които са добавени 518 реда и са изтрити 360 реда
  1. 105 82
      ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTeacherController.java
  2. 2 2
      ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTestController.java
  3. 5 1
      ie-admin/src/main/java/com/ruoyi/web/service/CommService.java
  4. 175 172
      ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java
  5. 4 22
      ie-admin/src/main/java/com/ruoyi/web/service/PaperService.java
  6. 3 2
      ie-system/src/main/java/com/ruoyi/dz/mapper/DzClassesMapper.java
  7. 1 1
      ie-system/src/main/java/com/ruoyi/ie/mapper/AMarjorPlanMapper.java
  8. 11 0
      ie-system/src/main/java/com/ruoyi/learn/domain/LearnStudent.java
  9. 5 3
      ie-system/src/main/java/com/ruoyi/learn/domain/LearnTest.java
  10. 36 0
      ie-system/src/main/java/com/ruoyi/learn/domain/LearnTestPaper.java
  11. 28 4
      ie-system/src/main/java/com/ruoyi/learn/domain/LearnTestStudent.java
  12. 63 39
      ie-system/src/main/java/com/ruoyi/learn/domain/TestPaperVO.java
  13. 3 3
      ie-system/src/main/java/com/ruoyi/learn/mapper/LearnTestMapper.java
  14. 1 1
      ie-system/src/main/java/com/ruoyi/learn/mapper/LearnTestPaperMapper.java
  15. 3 3
      ie-system/src/main/java/com/ruoyi/learn/service/ILearnTestService.java
  16. 3 3
      ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnTestServiceImpl.java
  17. 15 3
      ie-system/src/main/resources/mapper/dz/DzClassesMapper.xml
  18. 5 2
      ie-system/src/main/resources/mapper/ie/AMarjorPlanMapper.xml
  19. 1 1
      ie-system/src/main/resources/mapper/learn/LearnDirectedKnowledgeMapper.xml
  20. 4 2
      ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml
  21. 10 8
      ie-system/src/main/resources/mapper/learn/LearnStudentMapper.xml
  22. 3 3
      ie-system/src/main/resources/mapper/learn/LearnTestMapper.xml
  23. 19 2
      ie-system/src/main/resources/mapper/learn/LearnTestPaperMapper.xml
  24. 13 1
      ie-system/src/main/resources/mapper/learn/LearnTestStudentMapper.xml

+ 105 - 82
ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTeacherController.java

@@ -3,28 +3,24 @@ package com.ruoyi.web.controller.learn;
 import cn.hutool.core.lang.Dict;
 import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
-import com.google.common.collect.Sets;
 import com.ruoyi.common.annotation.Anonymous;
 import com.ruoyi.common.core.controller.BaseController;
 import com.ruoyi.common.core.domain.AjaxResult;
 import com.ruoyi.common.core.domain.AjaxResult2;
 import com.ruoyi.common.core.domain.entity.SysUser;
-import com.ruoyi.common.core.page.TableDataInfo;
 import com.ruoyi.common.enums.ExamType;
 import com.ruoyi.common.utils.SecurityUtils;
 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.enums.PaperType;
 import com.ruoyi.enums.QuestionType;
-import com.ruoyi.learn.domain.LearnPaper;
-import com.ruoyi.learn.domain.LearnTestPaper;
-import com.ruoyi.learn.domain.TestPaperVO;
+import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.service.ILearnPaperQuestionService;
 import com.ruoyi.learn.service.ILearnPaperService;
 import com.ruoyi.learn.service.ILearnTestPaperService;
 import com.ruoyi.web.service.LearnTeacherService;
+import com.ruoyi.web.service.PaperService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -43,17 +39,17 @@ public class LearnTeacherController extends BaseController {
     private final IDzControlService dzControlService;
     private final IDzSubjectService dzSubjectService;
     private final LearnTeacherService learnTeacherService;
-    private final ILearnPaperService paperService;
+    private final PaperService paperService;
+    private final ILearnPaperService learnPaperService;
     private final ILearnTestPaperService testPaperService;
-    private final ILearnPaperQuestionService paperQuestionService;
 
-    public LearnTeacherController(IDzControlService dzControlService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService, ILearnPaperService paperService, ILearnTestPaperService testPaperService, ILearnPaperQuestionService paperQuestionService) {
+    public LearnTeacherController(IDzControlService dzControlService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService, PaperService paperService, ILearnPaperService learnPaperService, ILearnTestPaperService testPaperService) {
         this.dzControlService = dzControlService;
         this.dzSubjectService = dzSubjectService;
         this.learnTeacherService = learnTeacherService;
         this.paperService = paperService;
+        this.learnPaperService = learnPaperService;
         this.testPaperService = testPaperService;
-        this.paperQuestionService = paperQuestionService;
     }
 
 
@@ -95,7 +91,7 @@ public class LearnTeacherController extends BaseController {
                                  @ApiParam("专业计划ID") @RequestParam(required = false) Long majorPlanId)
     {
         Set<Long> knowledgeIdSet = null;
-        if("FullHand".equals(buildType)) {
+        if("ExactHand".equals(buildType)) {
             knowledgeIdSet = learnTeacherService.getKnowledgeIdSet(majorPlanId);
         }
         return AjaxResult.success(learnTeacherService.getKnowledgeTree(null, subjectId, knowledgeIdSet, null));
@@ -103,16 +99,104 @@ public class LearnTeacherController extends BaseController {
 
     @GetMapping(value = "classStatistic")
     @ApiOperation("班级生成统计")
-    public AjaxResult classStatistic(@ApiParam("类型 ExactIntelligent/FullIntelligent/ExactHand/FullHand") @RequestParam String buildType,
-                                     @ApiParam("批次ID") @RequestParam Long batchId,
-                                     @ApiParam("考生类型") @RequestParam(required = false) ExamType examType,
-                                     @ApiParam("科目") @RequestParam(required = false) Long subjectId,
-                                     @ApiParam("计划专业") @RequestParam(required = false) Long planId)
+    public AjaxResult classStatistic(TestPaperVO.TestPaperBuildReq req)
     {
-        return AjaxResult.success(learnTeacherService.getClassesBuildStats(buildType, SecurityUtils.getUserId(), batchId, examType, subjectId, planId));
+        return AjaxResult.success(learnTeacherService.getClassesBuildStats(req, SecurityUtils.getUserId()));
     }
 
 
+    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
+    @GetMapping("build/getBuiltPaper")
+    @ApiOperation("获取已组卷详情")
+    public AjaxResult getBuiltPaper(String buildType, Integer batchId, String examType, Long subjectId) {
+        LearnTestPaper cond = new LearnTestPaper();
+        cond.setBatchId(batchId);
+        cond.setBuildType(buildType);
+        cond.setSubjectId(subjectId);
+        cond.setExamType(examType);
+        List<LearnTestPaper> testPaperList = testPaperService.selectLearnTestPaperList(cond);
+        if (CollectionUtils.isEmpty(testPaperList)) {
+            return AjaxResult.success(new JSONObject());
+        }
+        LearnTestPaper learnTestPaper = testPaperList.get(0);
+        if(null == learnTestPaper || null == learnTestPaper.getPaperId()){
+            return AjaxResult.success(new JSONObject());
+        }
+        PaperVO paperVO = paperService.loadPaper(learnTestPaper.getPaperId());
+        JSONObject root = JSONObject.from(paperVO);
+        root.remove("id");
+        root.put("paperId", learnTestPaper.getPaperId());
+        return AjaxResult.success(root);
+    }
+
+
+    @GetMapping("/questionTypes")
+    @ApiOperation("题型列表")
+    public AjaxResult questionTypes(@ApiParam("科目ID") Long subjectId, @RequestParam(required = false) @ApiParam("知识点") Collection<Long> knowledgeIds)
+    {
+        List<Dict> dictList = learnTeacherService.getQuestionTypes(subjectId, knowledgeIds).stream().map(t -> {
+            QuestionType qt = QuestionType.of(t.getQtpye());
+            return Dict.create().set("dictLabel", qt.getTitle()).set("dictValue", qt.getVal());
+        }).sorted(new Comparator<Dict>() {
+            @Override
+            public int compare(Dict o1, Dict o2) {
+                return o1.getInt("dictValue").compareTo(o2.getInt("dictValue"));
+            }
+        }).collect(Collectors.toList());
+        return AjaxResult.success(dictList);
+    }
+
+    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
+    @PostMapping("/build/exactIntelligent")
+    @ApiOperation("定向智能")
+    public AjaxResult buildExactIntelligent(@RequestBody TestPaperVO.TestPaperBuildReq req)
+    {
+        req.setBuildType("ExactIntelligent");
+        req.setDirectType(true);
+        req.setSubjectId(11L);
+        return AjaxResult.success(learnTeacherService.buildPapersDirect(req));
+    }
+
+    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
+    @PostMapping("/build/fullIntelligent")
+    @ApiOperation("全量智能")
+    public AjaxResult buildFullIntelligent(@RequestBody TestPaperVO.TestPaperBuildReq req)
+    {
+        req.setBuildType("FullIntelligent");
+        req.setDirectType(false);
+        if(null == req.getSubjectId()) {
+            AjaxResult.error("未选择科目");
+        }
+        return AjaxResult.success(learnTeacherService.buildPapersFull(req));
+    }
+
+    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
+    @PostMapping("/build/exactHand")
+    @ApiOperation("定向手动")
+    public AjaxResult buildExactHand(@RequestBody TestPaperVO.TestPaperBuildReq req)
+    {
+        req.setBuildType("ExactHand");
+        req.setDirectType(true);
+        req.setSubjectId(11L);
+        if(null == req.getMajorPlanId()) {
+            AjaxResult.error("未选择计划");
+        }
+        return AjaxResult.success(learnTeacherService.buildPapersDirect(req));
+    }
+
+    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
+    @PostMapping("/build/fullHand")
+    @ApiOperation("全量手动")
+    public AjaxResult buildFullHand(@RequestBody TestPaperVO.TestPaperBuildReq req)
+    {
+        req.setBuildType("FullHand");
+        req.setDirectType(false);
+        if(null == req.getSubjectId()) {
+            AjaxResult.error("未选择科目");
+        }
+        return AjaxResult.success(learnTeacherService.buildPapersFull(req));
+    }
+
     @GetMapping("/universities")
     @ApiOperation("院校列表")
     public AjaxResult universities(@ApiParam("批次ID") Long batchId)
@@ -122,11 +206,11 @@ public class LearnTeacherController extends BaseController {
 
     @GetMapping("/majors")
     @ApiOperation("专业列表")
-    public AjaxResult majors(@ApiParam("批次ID") Long batchId, @RequestParam(required = false) @ApiParam("院校列表") Long universityId)
+    public AjaxResult majors(@ApiParam("批次ID") Long batchId, @RequestParam @ApiParam("院校列表") Long universityId, @RequestParam @ApiParam("考生类型") ExamType examType)
     {
         SysUser sysUser = SecurityUtils.getLoginUser().getUser();
-        DzControl control = dzControlService.selectDzControl(sysUser.getLocation(), sysUser.getExamType());
-        return AjaxResult.success(learnTeacherService.selectMajorList(universityId, control.getPlanYear(), batchId));
+        DzControl control = dzControlService.selectDzControl(sysUser.getLocation(), examType);
+        return AjaxResult.success(learnTeacherService.selectMajorList(universityId, control.getPlanYear(), batchId, examType.name()));
     }
 
 
@@ -171,57 +255,6 @@ public class LearnTeacherController extends BaseController {
         return AjaxResult.success(learnTeacherService.getStudents(batchId, getUserId()));
     }
 
-    @GetMapping("/questionTypes")
-    @ApiOperation("题型列表")
-    public AjaxResult questionTypes(@ApiParam("科目ID") Long subjectId, @RequestParam(required = false) @ApiParam("知识点") Collection<Long> knowledgeIds)
-    {
-        List<Dict> dictList = learnTeacherService.getQuestionTypes(subjectId, knowledgeIds).stream().map(t -> {
-            QuestionType qt = QuestionType.of(t.getQtpye());
-            return Dict.create().set("dictLabel", qt.getTitle()).set("dictValue", qt.getVal());
-        }).sorted(new Comparator<Dict>() {
-            @Override
-            public int compare(Dict o1, Dict o2) {
-                return o1.getInt("dictValue").compareTo(o2.getInt("dictValue"));
-            }
-        }).collect(Collectors.toList());
-        return AjaxResult.success(dictList);
-    }
-
-    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
-    @PostMapping("/build/exactIntelligent")
-    @ApiOperation("定向智能")
-    public AjaxResult buildExactIntelligent(@RequestBody TestPaperVO.TestPapersAutoReq req)
-    {
-        req.setBuildType("ExactIntelligent");
-        return AjaxResult.success(learnTeacherService.buildPapersAuto(req));
-    }
-
-    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
-    @PostMapping("/build/fullIntelligent")
-    @ApiOperation("全量智能")
-    public AjaxResult buildFullIntelligent(@RequestBody TestPaperVO.TestPapersAutoReq req)
-    {
-        req.setBuildType("ExactIntelligent");
-        return AjaxResult.success(learnTeacherService.buildPapersAuto(req));
-    }
-
-    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
-    @PostMapping("/build/exactHand")
-    @ApiOperation("定向手动")
-    public AjaxResult buildExactHand(@RequestBody TestPaperVO.TestPapersHandReq req)
-    {
-        return AjaxResult.success(learnTeacherService.buildPapersManual(req));
-    }
-
-    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
-    @PostMapping("/build/fullHand")
-    @ApiOperation("全量手动")
-    public AjaxResult buildFullHand(@RequestBody TestPaperVO.TestPapersHandReq req)
-    {
-        return AjaxResult.success(learnTeacherService.buildPapersManual(req));
-    }
-
-
     @ApiOperation("04 取试卷列表")
     @GetMapping(value = "papers")
     public AjaxResult papers(@ApiParam("批次") @RequestParam(required = false) Integer batchId) {
@@ -232,18 +265,8 @@ public class LearnTeacherController extends BaseController {
         List<LearnPaper> paperList = Lists.newArrayList();
         for(LearnTestPaper tp : testPaperList) {
             JSONObject root = JSONObject.from(tp);
-            paperList.add(paperService.selectLearnPaperById(tp.getPaperId()));
+            paperList.add(learnPaperService.selectLearnPaperById(tp.getPaperId()));
         }
         return AjaxResult.success(paperList);
     }
-
-    @PreAuthorize("@ss.hasPermi('learn:test_paper:add')")
-    @ApiOperation("04 取试卷详情")
-    @GetMapping(value = "paper")
-    public AjaxResult loadPaper(@ApiParam("考卷类型PaperType") PaperType type, @ApiParam("考卷标识") Long id) {
-        LearnPaper paper = paperService.selectLearnPaperById(id);
-        JSONObject root = JSONObject.from(paper);
-        root.put("questions", paperQuestionService.selectLearnPaperQuestionById(id));
-        return AjaxResult.success(root);
-    }
 }

+ 2 - 2
ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTestController.java

@@ -68,7 +68,7 @@ public class LearnTestController extends BaseController
      */
     @PreAuthorize("@ss.hasPermi('learn:test:query')")
     @GetMapping(value = "/{batchId}")
-    public AjaxResult getInfo(@PathVariable("batchId") String batchId)
+    public AjaxResult getInfo(@PathVariable("batchId") Integer batchId)
     {
         return success(learnTestService.selectLearnTestByBatchId(batchId));
     }
@@ -105,7 +105,7 @@ public class LearnTestController extends BaseController
     @Log(title = "试卷批次", businessType = BusinessType.DELETE)
 	@DeleteMapping("/{batchIds}")
     @ApiOperation("删除")
-    public AjaxResult remove(@PathVariable String[] batchIds)
+    public AjaxResult remove(@PathVariable Integer[] batchIds)
     {
         return toAjax(learnTestService.deleteLearnTestByBatchIds(batchIds));
     }

+ 5 - 1
ie-admin/src/main/java/com/ruoyi/web/service/CommService.java

@@ -101,9 +101,13 @@ public class CommService {
             parent.getChildren().add(node);
         }
         if(!CollectionUtils.isEmpty(knowledgeIdSet)) {
+            List<LearnTeacherService.TreeNode> rootList = Lists.newArrayList();
             for(LearnTeacherService.TreeNode tn : treeNodeList) {
-                tn.setChecked(knowledgeIdSet);
+                if(knowledgeIdSet.contains(tn.getId()) || tn.getChildren().stream().filter(t -> knowledgeIdSet.contains(t.getId())).count() > 0L) {
+                    rootList.add(tn);
+                }
             }
+            return rootList;
         }
         return treeNodeList;
     }

+ 175 - 172
ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java

@@ -5,18 +5,24 @@ import com.alibaba.fastjson2.JSONObject;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
 import com.google.common.collect.Sets;
+import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.entity.SysUser;
 import com.ruoyi.common.enums.ExamType;
 import com.ruoyi.common.enums.SubjectType;
 import com.ruoyi.common.utils.NumberUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.dz.domain.DzClasses;
+import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.mapper.DzClassesMapper;
+import com.ruoyi.dz.service.IDzSubjectService;
+import com.ruoyi.enums.ExamineeStatus;
+import com.ruoyi.enums.PaperStatus;
 import com.ruoyi.enums.PaperType;
 import com.ruoyi.ie.domain.AMarjorPlan;
 import com.ruoyi.ie.mapper.AMarjorPlanMapper;
 import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.mapper.*;
+import com.ruoyi.learn.service.ILearnTestService;
 import com.ruoyi.syzy.domain.BBusiWishUniversities;
 import com.ruoyi.syzy.mapper.BBusiWishUniversitiesMapper;
 import lombok.Data;
@@ -45,8 +51,11 @@ public class LearnTeacherService {
     private final LearnTestPaperMapper learnTestPaperMapper;
     private final LearnQuestionsMapper learnQuestionsMapper;
     private final LearnKnowledgeCourseMapper learnKnowledgeCourseMapper;
+    private final LearnTestStudentMapper learnTestStudentMapper;
+    private final IDzSubjectService dzSubjectService;
+    private final ILearnTestService learnTestService;
 
-    public LearnTeacherService(DzClassesMapper dzClassesMapper, LearnKnowledgeTreeMapper learnKnowledgeTreeMapper, LearnStudentMapper learnStudentMapper, AMarjorPlanMapper marjorPlanMapper, BBusiWishUniversitiesMapper busiWishUniversitiesMapper, LearnDirectedKnowledgeMapper learnDirectedKnowledgeMapper, PaperService paperService, CommService commService, LearnTestPaperMapper learnTestPaperMapper, LearnQuestionsMapper learnQuestionsMapper, LearnKnowledgeCourseMapper learnKnowledgeCourseMapper) {
+    public LearnTeacherService(DzClassesMapper dzClassesMapper, LearnKnowledgeTreeMapper learnKnowledgeTreeMapper, LearnStudentMapper learnStudentMapper, AMarjorPlanMapper marjorPlanMapper, BBusiWishUniversitiesMapper busiWishUniversitiesMapper, LearnDirectedKnowledgeMapper learnDirectedKnowledgeMapper, PaperService paperService, CommService commService, LearnTestPaperMapper learnTestPaperMapper, LearnQuestionsMapper learnQuestionsMapper, LearnKnowledgeCourseMapper learnKnowledgeCourseMapper, LearnTestStudentMapper learnTestStudentMapper, IDzSubjectService dzSubjectService, ILearnTestService learnTestService) {
         this.dzClassesMapper = dzClassesMapper;
         this.learnKnowledgeTreeMapper = learnKnowledgeTreeMapper;
         this.learnStudentMapper = learnStudentMapper;
@@ -58,19 +67,27 @@ public class LearnTeacherService {
         this.learnTestPaperMapper = learnTestPaperMapper;
         this.learnQuestionsMapper = learnQuestionsMapper;
         this.learnKnowledgeCourseMapper = learnKnowledgeCourseMapper;
+        this.learnTestStudentMapper = learnTestStudentMapper;
+        this.dzSubjectService = dzSubjectService;
+        this.learnTestService = learnTestService;
     }
 
     public List<LearnQuestions> getQuestionTypes(Long subjectId, Collection<Long> knowledgeIds) {
         return learnQuestionsMapper.statQuestionTypes(subjectId, knowledgeIds);
     }
 
-    public List<JSONObject> getClassesBuildStats(String buildType, Long teacherId, Long batchId, ExamType examType, Long subjectId, Long planId) {
+    public List<JSONObject> getClassesBuildStats(TestPaperVO.TestPaperBuildReq req, Long teacherId) {
+        req.setTeacherId(teacherId);
+        String buildType = req.getBuildType();
+        if(buildType.startsWith("Exact")) {
+            req.setSubjectId(11L);
+        }
         if("ExactIntelligent".equals(buildType)){
-            return dzClassesMapper.selectClassesDirectedBuildStats(buildType, teacherId, batchId, subjectId, null);
+            return dzClassesMapper.selectClassesDirectedBuildStats(req.toMap());
         } else if("ExactHand".equals(buildType)){
-            return dzClassesMapper.selectClassesDirectedBuildStats(buildType, teacherId, batchId, subjectId, planId);
+            return dzClassesMapper.selectClassesDirectedBuildStats(req.toMap());
         }
-        return dzClassesMapper.selectClassesBuildStats(buildType, teacherId, batchId, subjectId, examType.name());
+        return dzClassesMapper.selectClassesBuildStats(req.toMap());
     }
 
     public List<DzClasses> getClasses(Long teacherId)
@@ -86,212 +103,198 @@ public class LearnTeacherService {
         return busiWishUniversitiesMapper.selectUniversityListForTeacher(teacherId, batchId);
     }
 
-    public List<Dict> selectMajorList(Long universityId, Integer year, Long batchId) {
+    public List<Dict> selectMajorList(Long universityId, Integer year, Long batchId, String examType) {
         // TODO 由于未区分考生类型,好些会重复,暂取最小计划,使用这个去匹配相关的类型
-        return marjorPlanMapper.selectMajorForUniversity(universityId, year, batchId).stream().map(t -> Dict.create().set("id", t.getId()).set("majorGroup", t.getMajorGroup())
+        return marjorPlanMapper.selectMajorForUniversity(universityId, year, "ExactHand", batchId, 11L, examType).stream().map(t -> Dict.create().set("id", t.getId()).set("majorGroup", t.getMajorGroup())
                 .set("majorName", t.getMajorName()).set("count", t.getXuefei()).set("total", t.getPlanTotal())).collect(Collectors.toList());
     }
 
+    public String buildDirectKey(LearnDirectedKnowledge dk) {
+        return dk.getUniversityId() + "_" + dk.getExamineeTypes() + "_" + StringUtils.trimToEmpty(dk.getDirectKey());
+    }
+    public String buildDirectKey(LearnStudent dk) {
+        return dk.getUniversityId() + "_" + dk.getExamType() + "_" + StringUtils.trimToEmpty(dk.getDirectKey());
+    }
+
     @Transactional(rollbackFor = Exception.class)
-    public String buildPapersAuto(TestPaperVO.TestPapersAutoReq req) {
-        if(null != req) {
-            return "";
-        }
-        // 查询 院校,专业组,专业计划范围, 明细一级时只有一个,否则就是批量
+    public String buildPapersDirect(TestPaperVO.TestPaperBuildReq 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);
+            throw new ValidationException("无学生可发布");
         }
+        // 定向手动是精准到一个计划,定向自动是对应一组计划
+        Map<Long, Map<String, List<LearnStudent>>> universityDirectStudentMap = studentList.stream()
+                .collect(Collectors.groupingBy(LearnStudent::getUniversityId, Collectors.groupingBy(this::buildDirectKey, Collectors.toList())));
         // 查询已经生成的
-        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("");
-            paper.setFenshu(0);
-            for(Long universityId : universityMap.keySet()) {
+        Map<Long, Map<String, LearnTestPaper>> universityDirectPaperMap = learnTestPaperMapper.selectByBatchAndUniversityIds(req.getBuildType(), req.getBatchId(), req.getSubjectId(), universityDirectStudentMap.keySet()).stream()
+                .collect(Collectors.groupingBy(LearnTestPaper::getUniversityId, Collectors.toMap(t -> StringUtils.trimToEmpty(t.getDirectKey()), a -> a)));
+        // 补充发卷
+        if("ExactHand".equals(req.getBuildType())) { // 肯定只有一个计划
+            for(Long universityId : universityDirectStudentMap.keySet()) {
+                Map<String, List<LearnStudent>> directedStudentsMap = universityDirectStudentMap.get(universityId);
                 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);
+                buildPapersDirect(req, universityId, req.getExamType(), null, directedStudentsMap, directPaperMap);
             }
-            return "";
-        }
-        TestPaperVO.PaperDef paperDef = req.getPaperDef();
-        if(null != req.getPlanIds() && req.getPlanIds().size() == 1) {
-            if(!CollectionUtils.isEmpty(paperDef.getKnowIds())) {
-                throw new ValidationException("批量时不支持自定义知识点");
+        } else {
+            // directKey = universityId_examType_directKey
+            Map<Long, Map<String, LearnDirectedKnowledge>> universityDirectedKnowledgeMap = learnDirectedKnowledgeMapper.selectByUniversityIds(universityDirectStudentMap.keySet().toArray(new Long[universityDirectStudentMap.size()])).stream().collect(
+                    Collectors.groupingBy(LearnDirectedKnowledge::getUniversityId, Collectors.toMap(this::buildDirectKey, a -> a)));
+            for(Long universityId : universityDirectedKnowledgeMap.keySet()) {
+                Map<String, LearnDirectedKnowledge> directedKnowledgeMap = universityDirectedKnowledgeMap.get(universityId);
+                Map<String, List<LearnStudent>> directedStudentsMap = universityDirectStudentMap.get(universityId);
+                Map<String, LearnTestPaper> directPaperMap = universityDirectPaperMap.get(universityId);
+                if(null == directedKnowledgeMap) {
+                    throw new ValidationException("院校无定向定义");
+                }
+                buildPapersDirect(req, universityId, req.getExamType(), directedKnowledgeMap, directedStudentsMap, directPaperMap);
             }
         }
-        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;
+        return "";
+    }
 
-        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;
-                }
+    private void buildPapersDirect(TestPaperVO.TestPaperBuildReq req, Long universityId, String examType, Map<String, LearnDirectedKnowledge> directedKnowledgeMap, Map<String, List<LearnStudent>> directedStudentsMap, Map<String, LearnTestPaper> directPaperMap) {
+        if(null == directPaperMap) {
+            directPaperMap = Maps.newHashMap();
+        }
+        DzSubject dzSubject = dzSubjectService.selectDzSubjectBySubjectId(req.getSubjectId());
+        LearnTest learnTest = learnTestService.selectLearnTestByBatchId(req.getBatchId());
+        for(String directedKey : directedStudentsMap.keySet()) {
+            LearnTestPaper learnTestPaper;
+            if(null == (learnTestPaper = directPaperMap.get(directedKey))) {
                 LearnPaper paper = new LearnPaper();
                 paper.setSubjectId(req.getSubjectId());
-                paper.setPaperName(req.getTitle());
-                paper.setYear(plan.getYear());
+                String paperName = StringUtils.isBlank(req.getName()) ? learnTest.getName() + "_" + dzSubject.getSubjectName() + "_" + directedKey : req.getName();
+                paper.setPaperName(paperName.length() > 254 ? paperName.substring(0, 254) : paperName);
+                paper.setYear(Calendar.getInstance().get(Calendar.YEAR)); // TODO  年度
                 paper.setPaperType(PaperType.Test.name());
                 paper.setDirectKey(directedKey);
                 paper.setFenshu(0);
-                Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = paperService.buildPaper(null, paper, paperDef);
-                paperService.savePaper(paperResult.getKey(), paperResult.getValue());
-
+                if(null == directedKnowledgeMap) {
+                    List<LearnPaperQuestion> pqList = Lists.newArrayList();
+                    for (LearnPaperQuestion q : req.getQuestions()) {
+                        LearnPaperQuestion pq = new LearnPaperQuestion();
+                        pq.setQuestionId(q.getId()); // 没传questionId?
+                        pq.setSeq(pqList.size() + 1);
+                        pq.setKnowledgeId(q.getKnowledgeId());
+                        pq.setScore(null == q.getScore() ? 1.0 : q.getScore());
+                        pqList.add(pq);
+                    }
+                    paperService.savePaper(paper, pqList);
+                } else {
+                    LearnDirectedKnowledge directedKnowledge = directedKnowledgeMap.get(directedKey);
+                    TestPaperVO.PaperDef paperDef = req.getPaperDef();
+                    examType = directedKnowledge.getExamineeTypes();
+                    paperDef.setKnowIds(Stream.of(directedKnowledge.getKnowledges().split(",")).map(t -> Long.parseLong(t.trim())).collect(Collectors.toList()));
+                    if (CollectionUtils.isEmpty(paperDef.getTypes())) {
+                        paperDef.setTypes(getQuestionTypes(null, paperDef.getKnowIds()).stream().map(t -> {
+                            TestPaperVO.TypeDef typeDef = new TestPaperVO.TypeDef();
+                            typeDef.setType(t.getQtpye());
+                            typeDef.setScore(1);
+                            typeDef.setTitle(t.getQtpye());
+                            return typeDef;
+                        }).collect(Collectors.toList()));
+                    }
+                    if(paperDef.getTotal().equals(0L)) { // TODO  总数怎么定?
+                        paperDef.setTotal(15L);
+                    }
+                    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.setBuildType(req.getBuildType());
                 testPaper.setUniversityId(universityId);
+                testPaper.setExamType(examType);
+                testPaper.setBatchId(req.getBatchId());
+                testPaper.setSubjectId(req.getSubjectId());
                 testPaper.setDirectKey(directedKey);
                 testPaper.setPaperId(paper.getId());
+                testPaper.setConditions(JSONObject.toJSONString(req));
+                testPaper.setCreatorId(SecurityUtils.getUserId());
                 learnTestPaperMapper.insertLearnTestPaper(testPaper);
                 directPaperMap.put(directedKey, testPaper);
+                learnTestPaper = testPaper;
+            }
+            for(LearnStudent student : directedStudentsMap.get(directedKey)) {
+                LearnTestStudent lts = new LearnTestStudent();
+                lts.setBatchId(req.getBatchId());
+                lts.setStudentId(student.getStudentId());
+                lts.setBuildType(req.getBuildType());
+                lts.setSubjectId(req.getSubjectId());
+                lts.setDirectKey(directedKey);
+                lts.setPaperId(learnTestPaper.getPaperId());
+                lts.setClassId(student.getClassId());
+                lts.setStatus(ExamineeStatus.Sign.getVal());
+                learnTestStudentMapper.insertLearnTestStudent(lts);
             }
         }
-        return "";
     }
 
     @Transactional(rollbackFor = Exception.class)
-    public String buildPapersManual(TestPaperVO.TestPapersHandReq req) {
-        if(null != req) {
-            return "";
-        }
-        if(null == req.getSubjectId()) {
-            throw new ValidationException("未选择科目");
-        }
-        // 查询 院校,专业组,专业计划范围, 明细一级时只有一个,否则就是批量
+    public String buildPapersFull(TestPaperVO.TestPaperBuildReq 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);
+            throw new ValidationException("无学生可发布");
         }
+        DzSubject dzSubject = dzSubjectService.selectDzSubjectBySubjectId(req.getSubjectId());
+        LearnTest learnTest = learnTestService.selectLearnTestByBatchId(req.getBatchId());
         // 查询已经生成的
-        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()) { // 全量
+        List<LearnTestPaper> learnTestPaperList = learnTestPaperMapper.selectByBatchAndUniversityIds(req.getBuildType(), req.getBatchId(), req.getSubjectId(),null);
+        LearnTestPaper learnTestPaper;
+        if(CollectionUtils.isEmpty(learnTestPaperList)) {
+            LearnPaper paper = new LearnPaper();
             paper.setSubjectId(req.getSubjectId());
+            String paperName = StringUtils.isBlank(req.getName()) ? learnTest.getName() + "_" + dzSubject.getSubjectName() : req.getName();
+            paper.setPaperName(paperName.length() > 254 ? paperName.substring(0, 254) : paperName);
+            paper.setYear(Calendar.getInstance().get(Calendar.YEAR)); // TODO  年度
+            paper.setPaperType(PaperType.Test.name());
             paper.setDirectKey("");
+            paper.setStatus(PaperStatus.Valid.getVal());
+            paper.setRelateId(req.getBatchId().longValue());
             paper.setFenshu(0);
-            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());
+            if("FullHand".equals(req.getBuildType())) {
+                List<LearnPaperQuestion> pqList = Lists.newArrayList();
+                Double fenScore = 0.0;
+                for (LearnPaperQuestion q : req.getQuestions()) {
+                    LearnPaperQuestion pq = new LearnPaperQuestion();
+                    pq.setQuestionId(q.getId()); // 没传questionId?
+                    pq.setSeq(pqList.size() + 1);
+                    pq.setKnowledgeId(q.getKnowledgeId());
+                    pq.setScore(null == q.getScore() ? 1.0 : q.getScore());
+                    fenScore += q.getScore();
+                    pqList.add(pq);
                 }
-                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);
+                paper.setFenshu((int) Math.round(fenScore));
+                paperService.savePaper(paper, pqList);
+            } else {
+                Pair<LearnPaper, List<LearnPaperQuestion>> paperResult = paperService.buildPaper(null, paper, req.getPaperDef());
+                paperService.savePaper(paperResult.getKey(), paperResult.getValue());
             }
+            LearnTestPaper testPaper = new LearnTestPaper();
+            testPaper.setBuildType(req.getBuildType());
+            testPaper.setBatchId(req.getBatchId());
+            testPaper.setExamType(req.getExamType());
+            testPaper.setSubjectId(req.getSubjectId());
+            testPaper.setDirectKey("");
+            testPaper.setPaperId(paper.getId());
+            testPaper.setConditions(JSONObject.toJSONString(req));
+            testPaper.setCreatorId(SecurityUtils.getUserId());
+            learnTestPaperMapper.insertLearnTestPaper(testPaper);
+            learnTestPaper = testPaper;
+        } else {
+            learnTestPaper = learnTestPaperList.get(0);
+        }
+        for(LearnStudent student : studentList) {
+            LearnTestStudent lts = new LearnTestStudent();
+            lts.setBatchId(req.getBatchId());
+            lts.setStudentId(student.getStudentId());
+            lts.setBuildType(req.getBuildType());
+            lts.setSubjectId(req.getSubjectId());
+            lts.setDirectKey("");
+            lts.setPaperId(learnTestPaper.getPaperId());
+            lts.setClassId(student.getClassId());
+            lts.setStatus(ExamineeStatus.Sign.getVal());
+            learnTestStudentMapper.insertLearnTestStudent(lts);
         }
         return "";
     }

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

@@ -402,25 +402,6 @@ public class PaperService {
         return 0;
     }
 
-    /**
-     * 原版本,新的是2
-     * @param directedKnowledge
-     * @return
-     */
-    public Pair<LearnPaper, List<LearnPaperQuestion>> buildSimulatedPaper(LearnDirectedKnowledge directedKnowledge) {
-        LearnPaper paper = new LearnPaper();
-        paper.setPaperType(PaperType.Simulated.name());
-        paper.setRelateId(directedKnowledge.getId()); // 定向ID
-        paper.setYear(directedKnowledge.getYear());
-        paper.setStatus(PaperStatus.Valid.getVal());
-        paper.setDirectKey(directedKnowledge.getDirectKey());
-
-        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(), TestPaperVO.TypeDef.class));
-        return buildPaper(null, paper, paperDef);
-    }
-
     public Pair<LearnPaper, List<LearnPaperQuestion>> buildPaper2(Long studentId, LearnPaper paper, TestPaperVO.PaperDef2 paperDef) {
         paperDef.setFillExclude(null != studentId);
         List<LearnPaperQuestion> pqList = getQuestions2(studentId, paperDef);
@@ -450,6 +431,7 @@ public class PaperService {
      */
     public LearnPaper savePaper(LearnPaper paper, List<LearnPaperQuestion> pqList) {
         paper.setNumber(pqList.size());
+        paper.setFenshu((int) Math.round(pqList.stream().mapToDouble(LearnPaperQuestion::getScore).sum()));
         paperMapper.insertLearnPaper(paper);
         Long paperId = paper.getId();
         pqList.stream().forEach(t -> t.setPaperId(paperId));
@@ -828,13 +810,13 @@ public class PaperService {
                     continue;
                 }
                 Long avgKnowTypeCount = Math.min(minKnowTypeCount, lackTotal / knowCount / typeCount);
-                if(avgKnowTypeCount == 0 && lackTotal > 0) {
+                if(avgKnowTypeCount == 0L && lackTotal > 0L) {
                     avgKnowTypeCount = 1L;
                 }
                 typeCount = 0;
                 for (TestPaperVO.TypeDef typeDef : paperDef.getTypes()) {
                     Long tmpMinKnowTypeCount = assignKnownCount(knowId, typeDef.getType(), knowTypeAssignMap, avgKnowTypeCount, paperDef.getFillExclude(), assignCount);
-                    if (tmpMinKnowTypeCount > 0) {
+                    if (tmpMinKnowTypeCount > 0L) {
                         minKnowTypeCount = Math.min(minKnowTypeCount, tmpMinKnowTypeCount);
                         knowSet.add(knowId);
                         typeCount++;
@@ -843,7 +825,7 @@ public class PaperService {
                 knowTypesMap.put(knowId, typeCount);
             }
             lackTotal = paperDef.getTotal() - assignCount.get();
-            if (lackTotal <= 0 || knowSet.isEmpty()) {
+            if (lackTotal <= 0L || knowSet.isEmpty()) {
                 break;
             }
         } while (true);

+ 3 - 2
ie-system/src/main/java/com/ruoyi/dz/mapper/DzClassesMapper.java

@@ -2,6 +2,7 @@ package com.ruoyi.dz.mapper;
 
 import java.util.Collection;
 import java.util.List;
+import java.util.Map;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.dz.domain.DzClasses;
@@ -15,8 +16,8 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface DzClassesMapper
 {
-    List<JSONObject> selectClassesDirectedBuildStats(@Param("buildType") String buildType, @Param("teacherId") Long teacherId, @Param("batchId") Long batchId, @Param("subjectId") Long subjectId, @Param("planId") Long planId);
-    List<JSONObject> selectClassesBuildStats(@Param("buildType") String buildType, @Param("teacherId") Long teacherId, @Param("batchId") Long batchId, @Param("subjectId") Long subjectId, @Param("examType") String examType);
+    List<JSONObject> selectClassesDirectedBuildStats(Map cond);
+    List<JSONObject> selectClassesBuildStats(Map cond);
 
     public List<DzClasses> selectClassesByIds(@Param("ids") Collection<Long> ids);
     public List<DzClasses> selectClassesForTeacher(@Param("teacherId") Long teacherId);

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

@@ -15,7 +15,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);
+    public List<AMarjorPlan>  selectMajorForUniversity(@Param("universityId") Long universityId, @Param("year") Integer year, @Param("buildType") String buildType, @Param("batchId") Long batchId, @Param("subjectId") Long subjectId, @Param("examType") String examType);
     /**
      * 查询专业计划要求
      * 

+ 11 - 0
ie-system/src/main/java/com/ruoyi/learn/domain/LearnStudent.java

@@ -42,6 +42,9 @@ public class LearnStudent extends BaseEntity
     private Long majorPlanId;
 
 
+    @Excel(name = "考生类型")
+    private String examType;
+
     private String studentName;
     private String paperId;
     private Integer status;
@@ -126,6 +129,14 @@ public class LearnStudent extends BaseEntity
         this.status = status;
     }
 
+    public String getExamType() {
+        return examType;
+    }
+
+    public void setExamType(String examType) {
+        this.examType = examType;
+    }
+
     public String getModules() {
         return modules;
     }

+ 5 - 3
ie-system/src/main/java/com/ruoyi/learn/domain/LearnTest.java

@@ -4,6 +4,7 @@ import org.apache.commons.lang3.builder.ToStringBuilder;
 import org.apache.commons.lang3.builder.ToStringStyle;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.BaseEntity;
+import org.springframework.data.annotation.Id;
 
 /**
  * 试卷批次对象 learn_test
@@ -16,7 +17,8 @@ public class LearnTest extends BaseEntity
     private static final long serialVersionUID = 1L;
 
     /** 考卷批次 */
-    private Long batchId;
+    @Id
+    private Integer batchId;
 
     /** 批次名称 */
     @Excel(name = "批次名称")
@@ -30,11 +32,11 @@ public class LearnTest extends BaseEntity
     @Excel(name = "创建人")
     private Long creatorId;
 
-    public Long getBatchId() {
+    public Integer getBatchId() {
         return batchId;
     }
 
-    public void setBatchId(Long batchId) {
+    public void setBatchId(Integer batchId) {
         this.batchId = batchId;
     }
 

+ 36 - 0
ie-system/src/main/java/com/ruoyi/learn/domain/LearnTestPaper.java

@@ -22,6 +22,18 @@ public class LearnTestPaper extends BaseEntity
     @Excel(name = "批次id")
     private Integer batchId;
 
+    /** 生成类型 */
+    @Excel(name = "生成类型")
+    private String buildType;
+
+    /** 科目ID */
+    @Excel(name = "科目ID")
+    private Long subjectId;
+
+    /** 考生类型 */
+    @Excel(name = "考生类型")
+    private String examType;
+
     /** 院校id */
     @Excel(name = "院校id")
     private Long universityId;
@@ -62,6 +74,30 @@ public class LearnTestPaper extends BaseEntity
         return batchId;
     }
 
+    public String getBuildType() {
+        return buildType;
+    }
+
+    public void setBuildType(String buildType) {
+        this.buildType = buildType;
+    }
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public String getExamType() {
+        return examType;
+    }
+
+    public void setExamType(String examType) {
+        this.examType = examType;
+    }
+
     public Long getUniversityId() {
         return universityId;
     }

+ 28 - 4
ie-system/src/main/java/com/ruoyi/learn/domain/LearnTestStudent.java

@@ -20,12 +20,20 @@ public class LearnTestStudent extends BaseEntity
 
     /** 批次id */
     @Excel(name = "批次id")
-    private Long batchId;
+    private Integer batchId;
 
     /** 学生id */
     @Excel(name = "学生id")
     private Long studentId;
 
+    /** 组卷类型 */
+    @Excel(name = "组卷类型")
+    private String buildType;
+
+    /** 科目ID */
+    @Excel(name = "科目ID")
+    private Long subjectId;
+
     /** 定向标识学生可能有多个 */
     @Excel(name = "定向标识学生可能有多个")
     private String directKey;
@@ -58,12 +66,12 @@ public class LearnTestStudent 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;
     }
@@ -78,7 +86,23 @@ public class LearnTestStudent extends BaseEntity
         return studentId;
     }
 
-    public void setDirectKey(String directKey) 
+    public String getBuildType() {
+        return buildType;
+    }
+
+    public void setBuildType(String buildType) {
+        this.buildType = buildType;
+    }
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public void setDirectKey(String directKey)
     {
         this.directKey = directKey;
     }

+ 63 - 39
ie-system/src/main/java/com/ruoyi/learn/domain/TestPaperVO.java

@@ -2,8 +2,10 @@ package com.ruoyi.learn.domain;
 
 import com.alibaba.fastjson2.JSONArray;
 import com.alibaba.fastjson2.JSONObject;
+import com.fasterxml.jackson.annotation.JsonIgnore;
 import com.google.common.collect.Lists;
 import com.google.common.collect.Maps;
+import com.ruoyi.common.enums.SubjectType;
 import com.ruoyi.enums.QuestionType;
 import io.swagger.annotations.ApiModel;
 import io.swagger.annotations.ApiModelProperty;
@@ -22,62 +24,84 @@ import java.util.stream.Stream;
 public class TestPaperVO {
     @ApiModel("基本组卷请求")
     @Data
-    public static class TestPapersBuildReq {
-        @ApiModelProperty("名称")
-        String title;
-        @ApiModelProperty("总分")
-        Integer total;
+    public static class TestPaperBuildReq {
+        @ApiModelProperty("是否定向")
+        Boolean directType;
 
-        @ApiModelProperty("批次")
-        Integer batchId;
-        @ApiModelProperty("省份")
-        String location;
+        // 所有
         @ApiModelProperty("组卷方式")
         String buildType;
-        @ApiModelProperty("是否定向")
-        Boolean directType;
+        @ApiModelProperty("批次")
+        Integer batchId;
+        @ApiModelProperty("班级")
+        List<Long> classIds;
 
+        // 全量智能+全量手动
+        @ApiModelProperty("考生类型")
+        String examType;
         @ApiModelProperty("科目")
         Long subjectId;
 
-        @ApiModelProperty("考生类型")
-        List<String> examTypes;
-        @ApiModelProperty("班级")
-        List<Long> classIds;
+        // 全量智能
         @ApiModelProperty("院校")
-        List<Long> universityIds;
-        @ApiModelProperty("专业组(单院校有效)")
-        List<String> groups;
-        @ApiModelProperty("专业组(单专业组有效)")
-        List<Long> planIds;
+        List<Long> knowledgeIds;
+        List<TypeDef2> types;
+
+        // 定向手动+全量手动
+        @ApiModelProperty("名称")
+        String name;
+        @ApiModelProperty("试题列表")
+        List<LearnPaperQuestion> questions;
+        // 定向手动
+        @ApiModelProperty("定向院校")
+        Long universityId;
+        @ApiModelProperty("定向专业组")
+        String majorGroup;
+        @ApiModelProperty("定向计划")
+        Long majorPlanId;
+
+        @JsonIgnore
+        Long teacherId;
+
+        public TestPaperVO.PaperDef getPaperDef() {
+            TestPaperVO.PaperDef paperDef = new TestPaperVO.PaperDef();
+            paperDef.setFillExclude(false);
+            paperDef.setKnowIds(knowledgeIds);
+            Long total = 0L;
+            if(CollectionUtils.isNotEmpty(types)) {
+                List<TestPaperVO.TypeDef> typeDefList = Lists.newArrayList();
+                for(TypeDef2 typeDef2 : types) {
+                    total += typeDef2.getCount();
+                    TestPaperVO.TypeDef typeDef = new TestPaperVO.TypeDef();
+                    BeanUtils.copyProperties(typeDef2, typeDef);
+                    typeDef.setType(typeDef.getTitle());
+                    if(null == typeDef.getScore()) {
+                        typeDef.setScore(1);
+                    }
+                    typeDefList.add(typeDef);
+                }
+                paperDef.setTypes(typeDefList);
+            }
+            paperDef.setTotal(total);
+            return paperDef;
+        }
 
         public Map<String, Object> toMap() {
             Map<String, Object> map = Maps.newHashMap();
+            map.put("directed", directType);
+            map.put("subjectId", subjectId);
+            map.put("buildType", buildType);
             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);
+            map.put("examType", examType);
+            map.put("universityId", universityId);
+            map.put("majorGroup", majorGroup);
+            map.put("majorPlanId", majorPlanId);
+            map.put("teacherId", teacherId);
             return map;
         }
     }
 
-    @ApiModel("手动")
-    @Data
-    public static class TestPapersHandReq extends TestPapersBuildReq {
-        @ApiModelProperty("试题列表")
-        List<LearnPaperQuestion> questions;
-    }
-
-    @ApiModel("智能")
-    @Data
-    public static class TestPapersAutoReq extends TestPapersBuildReq {
-        @ApiModelProperty("试卷要求")
-        PaperDef paperDef;
-    }
-
     @Data
     public static class PaperDef {
         Long total;

+ 3 - 3
ie-system/src/main/java/com/ruoyi/learn/mapper/LearnTestMapper.java

@@ -17,7 +17,7 @@ public interface LearnTestMapper
      * @param batchId 试卷批次主键
      * @return 试卷批次
      */
-    public LearnTest selectLearnTestByBatchId(String batchId);
+    public LearnTest selectLearnTestByBatchId(Integer batchId);
 
     /**
      * 查询试卷批次列表
@@ -49,7 +49,7 @@ public interface LearnTestMapper
      * @param batchId 试卷批次主键
      * @return 结果
      */
-    public int deleteLearnTestByBatchId(String batchId);
+    public int deleteLearnTestByBatchId(Integer batchId);
 
     /**
      * 批量删除试卷批次
@@ -57,5 +57,5 @@ public interface LearnTestMapper
      * @param batchIds 需要删除的数据主键集合
      * @return 结果
      */
-    public int deleteLearnTestByBatchIds(String[] batchIds);
+    public int deleteLearnTestByBatchIds(Integer[] batchIds);
 }

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

@@ -13,7 +13,7 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface LearnTestPaperMapper 
 {
-    public List<LearnTestPaper> selectByBatchAndUniversityIds(@Param("batchId") Integer batchId, @Param("universityIds") Collection<Long> universityIds);
+    public List<LearnTestPaper> selectByBatchAndUniversityIds(@Param("buildType") String buildType, @Param("batchId") Integer batchId, @Param("subjectId") Long subjectId, @Param("universityIds") Collection<Long> universityIds);
 
     /**
      * 查询批次测试卷

+ 3 - 3
ie-system/src/main/java/com/ruoyi/learn/service/ILearnTestService.java

@@ -17,7 +17,7 @@ public interface ILearnTestService
      * @param batchId 试卷批次主键
      * @return 试卷批次
      */
-    public LearnTest selectLearnTestByBatchId(String batchId);
+    public LearnTest selectLearnTestByBatchId(Integer batchId);
 
     /**
      * 查询试卷批次列表
@@ -49,7 +49,7 @@ public interface ILearnTestService
      * @param batchIds 需要删除的试卷批次主键集合
      * @return 结果
      */
-    public int deleteLearnTestByBatchIds(String[] batchIds);
+    public int deleteLearnTestByBatchIds(Integer[] batchIds);
 
     /**
      * 删除试卷批次信息
@@ -57,5 +57,5 @@ public interface ILearnTestService
      * @param batchId 试卷批次主键
      * @return 结果
      */
-    public int deleteLearnTestByBatchId(String batchId);
+    public int deleteLearnTestByBatchId(Integer batchId);
 }

+ 3 - 3
ie-system/src/main/java/com/ruoyi/learn/service/impl/LearnTestServiceImpl.java

@@ -27,7 +27,7 @@ public class LearnTestServiceImpl implements ILearnTestService
      * @return 试卷批次
      */
     @Override
-    public LearnTest selectLearnTestByBatchId(String batchId)
+    public LearnTest selectLearnTestByBatchId(Integer batchId)
     {
         return learnTestMapper.selectLearnTestByBatchId(batchId);
     }
@@ -76,7 +76,7 @@ public class LearnTestServiceImpl implements ILearnTestService
      * @return 结果
      */
     @Override
-    public int deleteLearnTestByBatchIds(String[] batchIds)
+    public int deleteLearnTestByBatchIds(Integer[] batchIds)
     {
         return learnTestMapper.deleteLearnTestByBatchIds(batchIds);
     }
@@ -88,7 +88,7 @@ public class LearnTestServiceImpl implements ILearnTestService
      * @return 结果
      */
     @Override
-    public int deleteLearnTestByBatchId(String batchId)
+    public int deleteLearnTestByBatchId(Integer batchId)
     {
         return learnTestMapper.deleteLearnTestByBatchId(batchId);
     }

+ 15 - 3
ie-system/src/main/resources/mapper/dz/DzClassesMapper.xml

@@ -35,10 +35,17 @@
                SUM(IF(ls.`major_plan_id` IS not NULL and ts.`student_id` IS NOT NULL and ts.`status` != 4 , 1, 0)) unfinish,
                sum(if(ls.`major_plan_id` IS NOT NULL and ts.`student_id` is not null AND ts.`status` = 4 , 1, 0)) send
         FROM `dz_teacher_class` tc
-        join `learn_student` ls on tc.`class_id` = ls.`class_id` <if test="planId != null"> and ls.`major_plan_id` = #{planId}</if>
+        join `learn_student` ls on tc.`class_id` = ls.`class_id`
         join `dz_classes` c on ls.`class_id` = c.`class_id`
+        JOIN `sys_user` u ON ls.`student_id` = u.`user_id`
         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}
-        where tc.`teacher_id` = #{teacherId}
+        <where>tc.`teacher_id` = #{teacherId}
+            <if test="buildType != null and buildType = 'ExactIntelligent'"> AND ls.`university_id` is not null</if>
+            <if test="universityId != null"> AND ls.`university_id` = #{universityId}</if>
+            <if test="majorGroup != null"> AND ls.`major_group` = #{majorGroup}</if>
+            <if test="majorPlanId != null"> AND ls.`major_plan_id` = #{majorPlanId}</if>
+            <if test="examType != null  and examType != ''"> AND u.`exam_type` = #{examType}</if>
+        </where>
         group by c.`class_id`, c.`name`
     </select>
 
@@ -52,7 +59,12 @@
          JOIN sys_user u ON ls.`student_id` = u.`user_id` AND u.`exam_type` = #{examType}
          join `dz_classes` c on ls.`class_id` = c.`class_id`
          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}
-        where tc.`teacher_id` = #{teacherId}
+        <where>tc.`teacher_id` = #{teacherId}
+            <if test="universityId != null"> AND ls.`university_id` = #{universityId}</if>
+            <if test="majorGroup != null"> AND ls.`major_group` = #{majorGroup}</if>
+            <if test="majorPlanId != null"> AND ls.`major_plan_id` = #{majorPlanId}</if>
+            <if test="examType != null  and examType != ''"> AND u.`exam_type` = #{examType}</if>
+        </where>
         group by c.`class_id`, c.`name`
     </select>
 

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

@@ -41,9 +41,12 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     <select id="selectMajorForUniversity" parameterType="Map" resultMap="AMarjorPlanResult">
         SELECT MIN(mp.id) id, mp.`majorGroup`, mp.`majorName`, COUNT(DISTINCT sl.`student_id`) planTotal, COUNT(DISTINCT ts.`id`) xuefei
           FROM `learn_student` sl
-          LEFT JOIN `learn_test_student` ts ON ts.`batch_id` = #{batchId} and ts.`student_id` = sl.`student_id`
+          LEFT JOIN `learn_test_student` ts ON ts.`batch_id` = #{batchId} and ts.build_type = #{buildType} and ts.subject_id = #{subjectId} and ts.`student_id` = sl.`student_id`
           JOIN `a_marjor_plan` mp ON sl.`major_plan_id` = mp.`id`
-         WHERE sl.`university_id` = #{universityId} and mp.year = #{year}
+          JOIN `sys_user` u ON sl.`student_id` = u.`user_id`
+         <where>sl.class_id is not null and sl.`university_id` = #{universityId} and mp.year = #{year}
+             <if test="examType != null  and examType != ''">  AND u.`exam_type` = #{examType}</if>
+         </where>
          GROUP BY mp.`majorGroup`, mp.`majorName`
          ORDER BY mp.`majorGroup`, mp.`majorName`
     </select>

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

@@ -52,7 +52,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="selectByUniversityIds" parameterType="Long" resultMap="LearnDirectedKnowledgeResult">
         <include refid="selectLearnDirectedKnowledgeVo"/>
-        where id in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
+        where university_id in <foreach item="id" collection="array" open="(" separator="," close=")">#{id}</foreach>
     </select>
 
     <insert id="insertLearnDirectedKnowledge" parameterType="LearnDirectedKnowledge" useGeneratedKeys="true" keyProperty="id">

+ 4 - 2
ie-system/src/main/resources/mapper/learn/LearnQuestionsMapper.xml

@@ -356,8 +356,10 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <select id="statQuestionTypes" resultMap="LearnQuestionsResult">
         SELECT q.`qtpye`, COUNT(*) number FROM `learn_questions` q
-         WHERE q.`subjectId` = #{subjectId}
-           <if test="null != knowledgeIds"> AND q.`knowledgeId` IN <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">#{id}</foreach></if>
+        <where>
+            <if test="null != subjectId"> AND q.`subjectId` = #{subjectId}</if>
+            <if test="null != knowledgeIds"> AND q.`knowledgeId` IN <foreach item="id" collection="knowledgeIds" open="(" separator="," close=")">#{id}</foreach></if>
+        </where>
          GROUP BY q.`qtpye`
     </select>
 

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

@@ -26,17 +26,19 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
-    <select id="selectLearnStudentsByMap" parameterType="map" resultMap="LearnStudentResult">
-        SELECT distinct ls.`university_id`, ls.`major_group`, ls.`major_plan_id`
+    <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
         FROM `learn_student` ls
-        LEFT JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id` AND ts.`batch_id` = #{batchId}
+        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}
         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>
+        <where> ts.`id` IS NULL
+            <choose><when test="directed and universityId != null"> AND ls.`university_id` = #{universityId}</when>
+                <when test="directed and universityId == null"> AND ls.`university_id` is not null</when></choose>
             <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>
+            <if test="universityId != null"> AND ls.`university_id` = #{universityId}</if>
+            <if test="majorGroup != null"> AND ls.`major_group` = #{majorGroup}</if>
+            <if test="majorPlanId != null"> AND ls.`major_plan_id` = #{majorPlanId}</if>
+            <if test="examType != null  and examType != ''"> AND u.`exam_type` = #{examType}</if>
         </where>
     </select>
 

+ 3 - 3
ie-system/src/main/resources/mapper/learn/LearnTestMapper.xml

@@ -25,7 +25,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by batch_id desc
     </select>
     
-    <select id="selectLearnTestByBatchId" parameterType="String" resultMap="LearnTestResult">
+    <select id="selectLearnTestByBatchId" parameterType="Integer" resultMap="LearnTestResult">
         <include refid="selectLearnTestVo"/>
         where batch_id = #{batchId}
     </select>
@@ -56,11 +56,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         where batch_id = #{batchId}
     </update>
 
-    <delete id="deleteLearnTestByBatchId" parameterType="String">
+    <delete id="deleteLearnTestByBatchId" parameterType="Integer">
         delete from learn_test where batch_id = #{batchId}
     </delete>
 
-    <delete id="deleteLearnTestByBatchIds" parameterType="String">
+    <delete id="deleteLearnTestByBatchIds" parameterType="Integer">
         delete from learn_test where batch_id in 
         <foreach item="batchId" collection="array" open="(" separator="," close=")">
             #{batchId}

+ 19 - 2
ie-system/src/main/resources/mapper/learn/LearnTestPaperMapper.xml

@@ -7,6 +7,9 @@ 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="buildType"    column="build_type"    />
+        <result property="subjectId"    column="subject_id"    />
+        <result property="examType"    column="exam_type"    />
         <result property="universityId"    column="university_id"    />
         <result property="directKey"    column="direct_key"    />
         <result property="paperId"    column="paper_id"    />
@@ -16,13 +19,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLearnTestPaperVo">
-        select id, batch_id, university_id, direct_key, paper_id, conditions, creator_id, create_time from learn_test_paper
+        select id, batch_id, build_type, subject_id, exam_type, 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="buildType != null "> and build_type = #{buildType}</if>
+            <if test="subjectId != null "> and subject_id = #{subjectId}</if>
+            <if test="examType != null "> and exam_type = #{examType}</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>
@@ -33,7 +39,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
 
     <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>
+        <where> batch_id = #{batchId} and build_type = #{buildType} and subject_id = #{subjectId}
+         <if test="null != universityIds">and university_id in <foreach item="id" collection="universityIds" open="(" separator="," close=")">#{id}</foreach></if>
+        </where>
     </select>
 
     <select id="selectLearnTestPaperById" parameterType="String" resultMap="LearnTestPaperResult">
@@ -45,6 +53,9 @@ 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="buildType != null">build_type,</if>
+            <if test="subjectId != null">subject_id,</if>
+            <if test="examType != null">exam_type,</if>
             <if test="universityId != null">university_id,</if>
             <if test="directKey != null ">direct_key,</if>
             <if test="paperId != null">paper_id,</if>
@@ -54,6 +65,9 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
          </trim>
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="batchId != null">#{batchId},</if>
+            <if test="buildType != null">#{buildType},</if>
+            <if test="subjectId != null">#{subjectId},</if>
+            <if test="examType != null">#{examType},</if>
             <if test="universityId != null">#{universityId},</if>
             <if test="directKey != null">#{directKey},</if>
             <if test="paperId != null">#{paperId},</if>
@@ -67,6 +81,9 @@ 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="buildType != null">build_type = #{buildType},</if>
+            <if test="subjectId != null">subject_id = #{subjectId},</if>
+            <if test="examType != null">exam_type = #{examType},</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>

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

@@ -8,6 +8,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <result property="id"    column="id"    />
         <result property="batchId"    column="batch_id"    />
         <result property="studentId"    column="student_id"    />
+        <result property="buildType"    column="build_type"    />
+        <result property="subjectId"    column="subject_id"    />
         <result property="directKey"    column="direct_key"    />
         <result property="paperId"    column="paper_id"    />
         <result property="classId"    column="class_id"    />
@@ -17,7 +19,7 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
     </resultMap>
 
     <sql id="selectLearnTestStudentVo">
-        select id, batch_id, student_id, direct_key, paper_id, class_id, examinee_id, status, create_time from learn_test_student
+        select id, batch_id, student_id, build_type, subject_id, direct_key, paper_id, class_id, examinee_id, status, create_time from learn_test_student
     </sql>
 
     <select id="selectDirectedStudentList" parameterType="LearnTestStudent" resultMap="LearnTestStudentResult">
@@ -25,6 +27,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>
             <if test="batchId != null "> and batch_id = #{batchId}</if>
             <if test="studentId != null "> and student_id = #{studentId}</if>
+            <if test="buildType != null "> and build_type = #{buildType}</if>
+            <if test="subjectId != null "> and subject_id = #{subjectId}</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>
@@ -43,6 +47,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <where>  
             <if test="batchId != null "> and batch_id = #{batchId}</if>
             <if test="studentId != null "> and student_id = #{studentId}</if>
+            <if test="buildType != null "> and build_type = #{buildType}</if>
+            <if test="subjectId != null "> and subject_id = #{subjectId}</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>
@@ -61,6 +67,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="(" suffix=")" suffixOverrides=",">
             <if test="batchId != null">batch_id,</if>
             <if test="studentId != null">student_id,</if>
+            <if test="buildType != null">build_type,</if>
+            <if test="subjectId != null">subject_id,</if>
             <if test="directKey != null and directKey != ''">direct_key,</if>
             <if test="paperId != null">paper_id,</if>
             <if test="classId != null">class_id,</if>
@@ -71,6 +79,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="values (" suffix=")" suffixOverrides=",">
             <if test="batchId != null">#{batchId},</if>
             <if test="studentId != null">#{studentId},</if>
+            <if test="buildType != null">#{buildType},</if>
+            <if test="subjectId != null">#{subjectId},</if>
             <if test="directKey != null and directKey != ''">#{directKey},</if>
             <if test="paperId != null">#{paperId},</if>
             <if test="classId != null">#{classId},</if>
@@ -85,6 +95,8 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         <trim prefix="SET" suffixOverrides=",">
             <if test="batchId != null">batch_id = #{batchId},</if>
             <if test="studentId != null">student_id = #{studentId},</if>
+            <if test="buildType != null">build_type = #{buildType},</if>
+            <if test="subjectId != null">subject_id = #{subjectId},</if>
             <if test="directKey != null and directKey != ''">direct_key = #{directKey},</if>
             <if test="paperId != null">paper_id = #{paperId},</if>
             <if test="classId != null">class_id = #{classId},</if>