瀏覽代碼

模考接口调整

mingfu 3 周之前
父節點
當前提交
e267579b60

+ 17 - 13
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontTeacherController.java

@@ -61,24 +61,28 @@ public class FrontTeacherController extends BaseController {
     @GetMapping("record/simulated")
     public AjaxResult getRecordSimulated()
     {
-        JSONObject result = new JSONObject();
-        result.put("total", 140);
-        result.put("done", 85);
-        result.put("undone", 3);
-        result.put("unsent", 3);
-        JSONObject data = JSONObject.of("name", "2501", "data", "242");
-        List<JSONObject> list = Lists.newArrayList(data);
-        result.put("list", list);
-        return AjaxResult.success(result);
+        return AjaxResult.success(learnStatService.getSimulatedClassRecord(SecurityUtils.getUserId()));
     }
 
     @ApiOperation("记录-模拟卷班级")
     @GetMapping("record/simulated/{classId}")
-    public AjaxResult getRecordSimulated(@ApiParam("班级id") @PathVariable("classId") Integer classId)
+    public AjaxResult getRecordSimulatedClass(@ApiParam("班级id") @PathVariable("classId") Long classId)
     {
-        JSONObject data = JSONObject.of("seq", "1", "name", "XM", "total", "658", "study", 20, "rate", 39);
-        List<JSONObject> list = Lists.newArrayList(data);
-        return AjaxResult.success(list);
+        return AjaxResult.success(learnStatService.getSimulatedStudentRecord(classId));
+    }
+
+    @ApiOperation("记录-模拟卷科目")
+    @GetMapping("record/simulated/subject/{studentId}")
+    public AjaxResult getRecordSimulatedSubject(@ApiParam("学生ID") @PathVariable("studentId") Long studentId)
+    {
+        return AjaxResult.success(learnStatService.getSimulatedSubjectRecord(studentId));
+    }
+
+    @ApiOperation("记录-模拟卷科目")
+    @GetMapping("record/simulated/knowledge")
+    public AjaxResult getRecordSimulatedKnowledge(@ApiParam("考生ID") @RequestParam("examineeId") Long examineeId)
+    {
+        return AjaxResult.success(studentService.getSimulateStat(examineeId));
     }
 
     @ApiOperation("记录-测试卷")

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

@@ -8,6 +8,7 @@ import com.google.common.collect.Sets;
 import com.ruoyi.common.utils.NumberUtils;
 import com.ruoyi.learn.domain.LearnStudent;
 import com.ruoyi.learn.mapper.LearnAnswerMapper;
+import com.ruoyi.learn.mapper.LearnExamineeMapper;
 import com.ruoyi.learn.service.ILearnStudentService;
 import com.ruoyi.mingxue.mapper.CustomerVideoWatchesMapper;
 import org.springframework.stereotype.Service;
@@ -19,16 +20,30 @@ import java.util.concurrent.atomic.AtomicInteger;
 public class LearnStatService {
     private final CustomerVideoWatchesMapper customerVideoWatchesMapper;
     private final LearnAnswerMapper answerMapper;
+    private final LearnExamineeMapper examineeMapper;
     private final ILearnStudentService learnStudentService;
     private final LearnTeacherService learnTeacherService;
 
-    public LearnStatService(CustomerVideoWatchesMapper customerVideoWatchesMapper, LearnAnswerMapper answerMapper, LearnTeacherService learnTeacherService, ILearnStudentService learnStudentService, LearnTeacherService learnTeacherService1) {
+    public LearnStatService(CustomerVideoWatchesMapper customerVideoWatchesMapper, LearnAnswerMapper answerMapper, LearnTeacherService learnTeacherService, LearnExamineeMapper examineeMapper, ILearnStudentService learnStudentService, LearnTeacherService learnTeacherService1) {
         this.customerVideoWatchesMapper = customerVideoWatchesMapper;
         this.answerMapper = answerMapper;
+        this.examineeMapper = examineeMapper;
         this.learnStudentService = learnStudentService;
         this.learnTeacherService = learnTeacherService1;
     }
 
+    public List<JSONObject> getSimulatedClassRecord(Long teacherId) {
+        return examineeMapper.selectSimulatedStats(teacherId);
+    }
+
+    public List<JSONObject> getSimulatedStudentRecord(Long classId) {
+        return examineeMapper.selectSimulatedStudentStats(classId);
+    }
+
+    public List<JSONObject> getSimulatedSubjectRecord(Long studentId) {
+        return examineeMapper.selectSimulatedStuSubjectStats(studentId);
+    }
+
     public JSONObject getClassRecordKnowledge(Long classId) {
         JSONObject result = new JSONObject();
         Map cond = Dict.create().set("classId", classId);

+ 9 - 5
ie-admin/src/main/java/com/ruoyi/web/service/StudentService.java

@@ -6,6 +6,7 @@ import com.alibaba.fastjson2.util.DateUtils;
 import com.ruoyi.common.annotation.Excel;
 import com.ruoyi.common.core.domain.AjaxResult2;
 import com.ruoyi.common.core.domain.entity.SysUser;
+import com.ruoyi.common.utils.NumberUtils;
 import com.ruoyi.common.utils.SecurityUtils;
 import com.ruoyi.dz.domain.DzSubject;
 import com.ruoyi.dz.service.IDzSubjectService;
@@ -15,10 +16,7 @@ import com.ruoyi.learn.domain.LearnExaminee;
 import com.ruoyi.learn.domain.LearnPaper;
 import com.ruoyi.learn.domain.LearnStudent;
 import com.ruoyi.learn.domain.LearnTestStudent;
-import com.ruoyi.learn.mapper.LearnExamineeMapper;
-import com.ruoyi.learn.mapper.LearnPaperMapper;
-import com.ruoyi.learn.mapper.LearnStudentMapper;
-import com.ruoyi.learn.mapper.LearnTestStudentMapper;
+import com.ruoyi.learn.mapper.*;
 import com.ruoyi.learn.service.ILearnStudentService;
 import com.ruoyi.system.service.ISysUserService;
 import org.apache.commons.compress.utils.Lists;
@@ -37,14 +35,16 @@ public class StudentService {
     private final IDzSubjectService dzSubjectService;
     private final LearnTeacherService learnTeacherService;
     private final LearnExamineeMapper learnExamineeMapper;
+    private final LearnAnswerMapper learnAnswerMapper;
 
-    public StudentService(LearnPaperMapper learnPaperMapper, LearnTestStudentMapper learnTestStudentMapper, ILearnStudentService learnStudentService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService, LearnExamineeMapper learnExamineeMapper) {
+    public StudentService(LearnPaperMapper learnPaperMapper, LearnTestStudentMapper learnTestStudentMapper, ILearnStudentService learnStudentService, IDzSubjectService dzSubjectService, LearnTeacherService learnTeacherService, LearnExamineeMapper learnExamineeMapper, LearnAnswerMapper learnAnswerMapper) {
         this.learnPaperMapper = learnPaperMapper;
         this.learnTestStudentMapper = learnTestStudentMapper;
         this.learnStudentService = learnStudentService;
         this.dzSubjectService = dzSubjectService;
         this.learnTeacherService = learnTeacherService;
         this.learnExamineeMapper = learnExamineeMapper;
+        this.learnAnswerMapper = learnAnswerMapper;
     }
 
     public List<DzSubject> getSubjectList(boolean directed) {
@@ -84,6 +84,10 @@ public class StudentService {
         return learnPaperMapper.selectLearnPaperForStudent(studentId, status);
     }
 
+    public List<JSONObject> getSimulateStat(Long examineeId) {
+        return learnAnswerMapper.selectSimulatedKnowledgeStats(examineeId);
+    }
+
     public List<JSONObject> getSimulateList(Long studentId) {
         LearnExaminee eCond = new LearnExaminee();
         eCond.setStudentId(studentId);

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

@@ -96,7 +96,18 @@ public class LearnExaminee extends BaseEntity
     @Excel(name = "主观题总数")
     private Long subjectiveTotal;
 
-    public void setExamineeId(Long examineeId) 
+    private Long subjectId;
+
+
+    public Long getSubjectId() {
+        return subjectId;
+    }
+
+    public void setSubjectId(Long subjectId) {
+        this.subjectId = subjectId;
+    }
+
+    public void setExamineeId(Long examineeId)
     {
         this.examineeId = examineeId;
     }

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

@@ -5,6 +5,7 @@ import java.util.Map;
 
 import com.alibaba.fastjson2.JSONObject;
 import com.ruoyi.learn.domain.LearnAnswer;
+import org.apache.ibatis.annotations.Param;
 
 /**
  * 答卷答案Mapper接口
@@ -14,6 +15,8 @@ import com.ruoyi.learn.domain.LearnAnswer;
  */
 public interface LearnAnswerMapper 
 {
+    List<JSONObject> selectSimulatedKnowledgeStats(@Param("examineeId") Long examineeId);
+
     JSONObject selectClassKnowledgeHeader(Map cond);
     List<JSONObject> selectClassKnowledgeDetail(Map cond);
 

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

@@ -15,7 +15,11 @@ import org.apache.ibatis.annotations.Param;
  */
 public interface LearnExamineeMapper 
 {
-    public List<JSONObject> selectExamRankingStats(@Param("stuScore") Integer stuScore, @Param("paperIds") Collection<Long> paperIds);
+    public List<JSONObject> selectSimulatedStats(@Param("teacherId") Long teacherId);
+    public List<JSONObject> selectSimulatedStudentStats(@Param("classId") Long classId);
+    public List<JSONObject> selectSimulatedStuSubjectStats(@Param("studentId") Long studentId);
+
+    public List<JSONObject> selectExamRankingStats(@Param("studentId") Integer stuScore, @Param("paperIds") Collection<Long> paperIds);
 
     /**
      * 查询答卷

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

@@ -27,6 +27,16 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         select answer_id, examinee_id, student_id, question_id, seq, knowledge_id, answer, correct, duration, count, state, score_level, score, score_rate, isMark, isNotKnow, create_time, update_time from learn_answer
     </sql>
 
+    <select id="selectSimulatedKnowledgeStats" resultType="com.alibaba.fastjson2.JSONObject">
+        SELECT a.`knowledge_id` `id`, kt.`name`, COUNT(*) `total`, SUM(IF(a.`state` = 1, 1, 0)) `value`, ROUND(SUM(IF(a.`state` = 1, 1, 0)) * 100 / COUNT(*)) rate
+          FROM `learn_examinee` e
+          JOIN `learn_answer` a ON a.`examinee_id` = e.`examinee_id` AND a.`state` &gt; 0
+          JOIN `learn_knowledge_tree` kt ON a.`knowledge_id` = kt.`id`
+         WHERE e.`examinee_id` = #{examineeId}
+         GROUP BY  a.`knowledge_id`, kt.`name`
+         ORDER BY rate DESC
+    </select>
+
     <select id="selectClassKnowledgeHeader" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
         SELECT ROUND(SUM(IF(a.`state` = 1, 1, 0)) * 100 / COUNT(*)) rate
           FROM `learn_answer` a

+ 29 - 0
ie-system/src/main/resources/mapper/learn/LearnExamineeMapper.xml

@@ -58,6 +58,35 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         order by examinee_id desc
     </select>
 
+    <select id="selectSimulatedStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
+        SELECT ls.`class_id` `id`, c.`name`, COUNT(DISTINCT ls.`student_id`) `total`, COUNT(DISTINCT e2.`student_id`) `value`
+          FROM `dz_teacher_class` tc
+          JOIN `learn_student` ls ON ls.`class_id` = tc.`class_id`
+          JOIN `dz_classes` c ON ls.`class_id` = c.`class_id`
+          LEFT JOIN `learn_examinee` e2 ON ls.`student_id` = e2.`student_id` AND e2.`paper_type` = 20
+        WHERE tc.`teacher_id` = #{teacherId}
+        GROUP BY ls.`class_id`, c.`name`
+        ORDER BY `value` DESC
+    </select>
+
+    <select id="selectSimulatedStudentStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
+        SELECT u.`user_id` `id`, u.`nick_name` `name`, COUNT(*) `total`
+          FROM `learn_student` ls
+          JOIN `sys_user` u ON ls.`student_id` = u.`user_id`
+          JOIN `learn_examinee` e2 ON ls.`student_id` = e2.`student_id` AND e2.`paper_type` = 20
+         WHERE ls.`class_id` = #{classId}
+         GROUP BY u.`user_id`, u.`user_name`
+         ORDER BY `total` DESC
+    </select>
+
+    <select id="selectSimulatedStuSubjectStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
+        SELECT e.`examinee_id` `id`, s.`subject_name` `name`, e.`score` `value`, p.`fenshu` `total`
+          FROM `learn_examinee` e
+          JOIN `learn_paper` p ON e.`paper_id` = p.`id`
+          JOIN `dz_subject` s ON p.`subjectId` = s.`subject_id`
+         WHERE e.`student_id` = #{studentId} AND e.`paper_type` = 20
+    </select>
+
     <select id="selectExamRankingStats" parameterType="Map" resultType="com.alibaba.fastjson2.JSONObject">
         SELECT e2.`paper_id`, COUNT(*) totalCount, AVG(e2.`score`) maxScore, AVG(e2.`score`) avgScore, COUNT(IF(e2.`score` &lt; #{stuScore}, 1, 0)) lowCount  FROM `learn_examinee` e2
         WHERE e2.`paper_type` = 20 and e2.paper_id in <foreach item="id" collection="paperIds" open="(" separator="," close=")">#{id}</foreach>