2 Revize d7e9efa72d ... 305b34ce9b

Autor SHA1 Zpráva Datum
  mingfu 305b34ce9b Merge branch 'master' of http://49.234.186.218:9000/root/ieplus před 4 dny
  mingfu 55e514efd6 组卷记录调整 před 4 dny

+ 16 - 11
ie-admin/src/main/java/com/ruoyi/web/controller/learn/LearnTeacherController.java

@@ -15,6 +15,7 @@ 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.PaperBuildStatus;
 import com.ruoyi.enums.QuestionType;
 import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.service.ILearnPaperQuestionService;
@@ -109,13 +110,8 @@ public class LearnTeacherController extends BaseController {
     @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);
+    public AjaxResult getBuiltPaper(TestPaperVO.TestPaperBuildReq req) {
+        List<LearnTestPaper> testPaperList = learnTeacherService.getBuiltTestPaper(req);
         if (CollectionUtils.isEmpty(testPaperList)) {
             return AjaxResult.success(Collections.emptyList());
         }
@@ -136,21 +132,30 @@ public class LearnTeacherController extends BaseController {
     public TableDataInfo getPaperClassRecords(TestPaperVO.TestPaperBuildReq req)
     {
         startPage();
-        return getDataTable(learnTeacherService.getPaperClassRecords(req, SecurityUtils.getUserId()));
+        List<JSONObject> list = learnTeacherService.getPaperClassRecords(req, SecurityUtils.getUserId());
+        list.stream().forEach(o -> {
+            o.put("buildType", req.getBuildType());
+        });
+        return getDataTable(list);
     }
 
     @GetMapping("/getPaperStudentRecords")
     @ApiOperation("班级详情")
     public AjaxResult getPaperStudentRecords(TestPaperVO.TestPaperBuildReq req)
     {
-        return AjaxResult.success(learnTeacherService.getPaperStudentRecords(req));
+        List<JSONObject> list = learnTeacherService.getPaperStudentRecords(req);
+        list.stream().forEach(o -> {
+            Integer state = o.getInteger("state");
+            o.put("state", PaperBuildStatus.of(state).getTitle());
+        });
+        return AjaxResult.success(list);
     }
 
     @GetMapping("/getPaperStudentDetail")
     @ApiOperation("学生详情")
-    public AjaxResult getPaperStudentDetail(@ApiParam("学生ID") Long studentId)
+    public AjaxResult getPaperStudentDetail(@ApiParam("考卷ID") Long examineeId)
     {
-        return AjaxResult.success(learnTeacherService.getPaperStudentDetail(studentId));
+        return AjaxResult.success(learnTeacherService.getPaperStudentDetail(examineeId));
     }
 
     @PostMapping("/postUnfinishAlarm")

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

@@ -67,7 +67,7 @@ public class LearnStatService {
 
     public List<JSONObject> getRecordKnowledge(Long studentId) {
         LearnStudent learnStudent = learnStudentService.selectLearnStudentByStudentId(studentId);
-        Set<Long> knowledgeIdSet = null != learnStudent ? learnTeacherService.getKnowledgeIdSet(learnStudent.getMajorPlanId()) : Sets.newHashSet();
+        Set<Long> knowledgeIdSet = null != learnStudent ? learnTeacherService.getKnowledgeIdSet(learnStudent.getMajorPlanId()) : Sets.newHashSet(0L);
         knowledgeIdSet.add(0L);
         List<JSONObject> list = answerMapper.selectKnowledgeStats(Dict.create().set("studentId", studentId).set("knowIds", knowledgeIdSet));
         list.forEach(o -> {

+ 21 - 3
ie-admin/src/main/java/com/ruoyi/web/service/LearnTeacherService.java

@@ -30,6 +30,7 @@ import lombok.Data;
 import org.apache.commons.lang3.ArrayUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.apache.commons.lang3.tuple.Pair;
+import org.springframework.beans.BeanUtils;
 import org.springframework.stereotype.Service;
 import org.springframework.transaction.annotation.Transactional;
 import org.springframework.util.CollectionUtils;
@@ -111,15 +112,32 @@ public class LearnTeacherService {
         return dzClassesMapper.getPaperStudentRecords(req.toMap());
     }
 
-    public List<JSONObject> getPaperStudentDetail(Long studentId) {
-        List<JSONObject> list = learnAnswerMapper.selectKnowledgeStats(Dict.create().set("studentId", studentId).set("knowIds", Sets.newHashSet()));
+    public List<JSONObject> getPaperStudentDetail(Long examineeId) {
+        List<JSONObject> list = learnAnswerMapper.selectPaperKnowledgeStats(Dict.create().set("examineeId", examineeId));
         list.forEach(o -> {
             CommonUtils.normalRate(o);
-            o.put("directed", "1".equals(o.get("directed")));
         });
         return list;
     }
 
+    public List<LearnTestPaper> getBuiltTestPaper(TestPaperVO.TestPaperBuildReq req) {
+        LearnTestPaper cond = new LearnTestPaper();
+        BeanUtils.copyProperties(req, cond);
+        if(null != req.getMajorPlanId()) {
+            AMarjorPlan plan = marjorPlanMapper.selectAMarjorPlanById(req.getMajorPlanId());
+            LearnDirectedKnowledge dkCond = new LearnDirectedKnowledge();
+            dkCond.setUniversityId(plan.getUniversityId());
+            dkCond.setYear(plan.getYear());
+            SysUser sysUser = SecurityUtils.getLoginUser().getUser();
+            dkCond.setLocations(sysUser.getLocation());
+            dkCond.setExamineeTypes(sysUser.getExamType().name());
+            Map<String, LearnDirectedKnowledge> directedKnowledgeMap = learnDirectedKnowledgeMapper.selectLearnDirectedKnowledgeList(dkCond).stream().collect(Collectors.toMap(LearnDirectedKnowledge::getDirectKey, t -> t));
+            LearnDirectedKnowledge directedKnowledge = getBestLearnDirectedKnowledge(plan, directedKnowledgeMap);
+            cond.setDirectKey(buildDirectKey(directedKnowledge));
+        }
+        return learnTestPaperMapper.selectLearnTestPaperList(cond);
+    }
+
     public List<DzClasses> getClasses(Long teacherId)
     {
         return dzClassesMapper.selectClassesForTeacher(teacherId);

+ 1 - 1
ie-system/src/main/java/com/ruoyi/enums/PaperBuildStatus.java

@@ -10,7 +10,7 @@ import java.util.Map;
 @AllArgsConstructor
 @Getter
 public enum PaperBuildStatus {
-    Init(10, "未定向"), Build(20, "未组卷"), Exam(30, "未完成"), Finish(40, "已完成");
+    Init(10, "未定向未组卷"), Build(20, "定向未组卷"), Exam(30, "组卷未完成"), Finish(40, "组卷已完成");
 
     private final Integer val;
     private final String title;

+ 2 - 0
ie-system/src/main/java/com/ruoyi/learn/domain/TestPaperVO.java

@@ -16,6 +16,7 @@ import org.apache.commons.collections4.CollectionUtils;
 import org.apache.commons.lang3.StringUtils;
 import org.springframework.beans.BeanUtils;
 
+import java.util.Calendar;
 import java.util.List;
 import java.util.Map;
 import java.util.stream.Collectors;
@@ -101,6 +102,7 @@ public class TestPaperVO {
             map.put("majorPlanId", majorPlanId);
             map.put("teacherId", teacherId);
             map.put("classId", classId);
+            map.put("year", Calendar.getInstance().get(Calendar.YEAR));
             return map;
         }
     }

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

@@ -21,6 +21,7 @@ public interface LearnAnswerMapper
     List<JSONObject> selectClassKnowledgeDetail(Map cond);
 
     List<JSONObject> selectKnowledgeStats(Map cond);
+    List<JSONObject> selectPaperKnowledgeStats(Map cond);
 
     List<JSONObject> selectClassQuestionStats(Map cond);
     JSONObject selectQuestionStatsHeader(Map cond);

+ 12 - 6
ie-system/src/main/resources/mapper/dz/DzClassesMapper.xml

@@ -30,7 +30,7 @@
     </resultMap>
 
     <select id="selectClassesDirectedBuildStats" resultType="com.alibaba.fastjson2.JSONObject">
-        SELECT c.`class_id` classId, c.`name` className, count(*) `total`, SUM(if(ls.`major_plan_id` IS NULL, 1, 0)) unexact,
+        SELECT c.`class_id` classId, c.`name` className, lt.`batch_id` batchId, lt.`name` batchName, count(*) `total`, SUM(if(ls.`major_plan_id` IS NULL, 1, 0)) unexact,
                SUM(IF(ls.`major_plan_id` IS not NULL and ts.`student_id` IS NULL, 1, 0)) unsend,
                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
@@ -38,6 +38,7 @@
         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`
+        join `learn_test` lt on lt.`year` = #{year} <if test="batchId != null"> and lt.`batch_id` =  #{batchId} </if>
         LEFT JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id`
             <if test="batchId != null"> and ts.`batch_id` =  #{batchId} </if>
             <if test="buildType != null"> AND ts.`build_type` = #{buildType} </if>
@@ -50,11 +51,12 @@
             <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`
+        group by c.`class_id`, c.`name`, lt.`batch_id`, lt.`name`
+        order by c.`class_id`, c.`name`, lt.`batch_id`, lt.`name`
     </select>
 
     <select id="selectClassesBuildStats" resultType="com.alibaba.fastjson2.JSONObject">
-        SELECT c.`class_id` classId, c.`name` className, count(*) `total`,
+        SELECT c.`class_id` classId, c.`name` className, lt.`batch_id` batchId, lt.`name` batchName, count(*) `total`,
                SUM(IF(ts.`student_id` IS NULL, 1, 0)) unsend,
                SUM(IF(ts.`student_id` IS NOT NULL and ts.`status` != 4 , 1, 0)) unfinish,
                sum(if(ts.`student_id` is not null AND ts.`status` = 4 , 1, 0)) send
@@ -62,32 +64,36 @@
          join `learn_student` ls on tc.`class_id` = ls.`class_id`
          JOIN sys_user u ON ls.`student_id` = u.`user_id`
          join `dz_classes` c on ls.`class_id` = c.`class_id`
+         join `learn_test` lt on lt.`year` = #{year} <if test="batchId != null"> and lt.`batch_id` =  #{batchId} </if>
          LEFT JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id`
             <if test="batchId != null"> and ts.`batch_id` =  #{batchId} </if>
             <if test="buildType != null"> AND ts.`build_type` = #{buildType} </if>
             <if test="subjectId != null"> and ts.`subject_id` = #{subjectId} </if>
         <where>tc.`teacher_id` = #{teacherId}
+            <if test="classId != null"> AND ls.`class_id` = #{classId}</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`
+        group by c.`class_id`, c.`name`, lt.`batch_id`, lt.`name`
+        order by c.`class_id`, c.`name`, lt.`batch_id`, lt.`name`
     </select>
 
     <select id="getPaperStudentRecords" resultType="com.alibaba.fastjson2.JSONObject">
-        SELECT ls.`student_id` studentId, u.`nick_name` studentName, u.`phonenumber` mobile, ts.`batch_id` batchId, ts.`subject_id` subjectId, ts.`paper_id` paperId, lp.`paperName`, lp.`fenshu` total, le.`score`, le.`score_rate` rate,
+        SELECT ts.examinee_id examineeId, ls.`student_id` studentId, u.`nick_name` studentName, dc.`name` className, u.`phonenumber` mobile, ts.`batch_id` batchId, ts.`subject_id` subjectId, ts.`paper_id` paperId, lp.`paperName`, lp.`fenshu` total, le.`score`, le.`score_rate` rate,
               lt.`name` batchName, ds.`subject_name` subjectName,
               CASE WHEN ls.`major_plan_id` IS NULL AND #{buildType} IN ('ExactHand', 'ExactIntelligent') THEN '10' WHEN ts.`student_id` IS NULL THEN '20' WHEN ts.`status` != 4 THEN '30' ELSE '40' END state
         FROM `learn_student` ls
         JOIN `sys_user` u ON ls.`student_id` = u.`user_id`
         JOIN `learn_test_student` ts ON ts.`student_id` = ls.`student_id`
+        JOIN `dz_classes` dc on dc.`class_id` = ls.`class_id`
         JOIN `dz_subject` ds on ds.`subject_id` = ts.`subject_id`
         join `learn_test` lt on lt.`batch_id` = ts.`batch_id`
         <if test="batchId != null"> and ts.`batch_id` =  #{batchId} </if>
         <if test="buildType != null"> AND ts.`build_type` = #{buildType} </if>
         <if test="subjectId != null"> and ts.`subject_id` = #{subjectId} </if>
-        LEFT JOIN `learn_examinee` le ON le.`paper_id` = ts.`paper_id` AND le.`student_id` = ts.`student_id`
+        LEFT JOIN `learn_examinee` le ON le.examinee_id = ts.examinee_id
         LEFT JOIN `learn_paper` lp ON ts.`paper_id` = lp.`id`
         <where> ls.`class_id` = #{classId}
             <if test="universityId != null"> AND ls.`university_id` = #{universityId}</if>

+ 10 - 0
ie-system/src/main/resources/mapper/learn/LearnAnswerMapper.xml

@@ -66,6 +66,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by directed desc, rate desc, a.`knowledge_id`
     </select>
 
+    <select id="selectPaperKnowledgeStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
+        SELECT a.`knowledge_id` knowledgeId , kt.`name` knowledgeName
+        , COUNT(*) num, SUM(IF(a.`state` = 1, 1, 0)) correct, round(SUM(IF(a.`state` = 1, 1, 0)) * 100 / COUNT(*), 1) rate
+        FROM `learn_answer` a
+        JOIN `learn_knowledge_tree` kt ON a.`knowledge_id` = kt.`id`
+        WHERE a.`examinee_id` = #{examineeId} and a.`state` > 0
+        GROUP BY a.`knowledge_id`
+        order by rate desc, a.`knowledge_id`
+    </select>
+
     <select id="selectClassQuestionStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
         SELECT ls.`student_id` id, u.`nick_name` `name`, COUNT(*) total , COUNT(DISTINCT DATE(a.create_time)) `time`, SUM(IF(a.`state` = 1, 1, 0)) `value`, ROUND(SUM(IF(a.`state` = 1, 1, 0)) * 100 / COUNT(*), 1) rate
           FROM `learn_answer` a