Jelajahi Sumber

试卷作业接口

mingfu 1 bulan lalu
induk
melakukan
c27fbe6cc5

+ 21 - 4
ie-admin/src/main/java/com/ruoyi/web/controller/front/FrontStudentController.java

@@ -15,14 +15,13 @@ import com.ruoyi.ie.domain.AEnrollUniversity;
 import com.ruoyi.ie.domain.AMarjorPlan;
 import com.ruoyi.ie.service.IAEnrollUniversityService;
 import com.ruoyi.ie.service.IAMarjorPlanService;
-import com.ruoyi.learn.domain.LearnDirectedKnowledge;
-import com.ruoyi.learn.domain.LearnPlan;
-import com.ruoyi.learn.domain.LearnPlanStudy;
+import com.ruoyi.learn.domain.*;
 import com.ruoyi.learn.service.ILearnDirectedKnowledgeService;
 import com.ruoyi.learn.service.ILearnPlanService;
 import com.ruoyi.learn.service.ILearnPlanStudyService;
 import com.ruoyi.sy.service.ISyMajorService;
 import com.ruoyi.system.service.ISysUserService;
+import com.ruoyi.web.service.StudentService;
 import io.swagger.annotations.Api;
 import io.swagger.annotations.ApiOperation;
 import io.swagger.annotations.ApiParam;
@@ -51,9 +50,10 @@ public class FrontStudentController extends BaseController {
     private final ILearnPlanStudyService learnPlanStudyService;
     private final IAMarjorPlanService marjorPlanService;
     private final ILearnDirectedKnowledgeService learnDirectedKnowledgeService;
+    private final StudentService studentService;
 
     public FrontStudentController(IDzControlService dzControlService, IAEnrollUniversityService universityService, ISyMajorService syMajorService, ISysUserService sysUserService,
-                                  ILearnPlanService learnPlanService, ILearnPlanStudyService learnPlanStudyService, IAMarjorPlanService marjorPlanService, ILearnDirectedKnowledgeService learnDirectedKnowledgeService) {
+                                  ILearnPlanService learnPlanService, ILearnPlanStudyService learnPlanStudyService, IAMarjorPlanService marjorPlanService, ILearnDirectedKnowledgeService learnDirectedKnowledgeService, StudentService studentService) {
         this.dzControlService = dzControlService;
         this.universityService = universityService;
         this.syMajorService = syMajorService;
@@ -62,6 +62,23 @@ public class FrontStudentController extends BaseController {
         this.learnPlanStudyService = learnPlanStudyService;
         this.marjorPlanService = marjorPlanService;
         this.learnDirectedKnowledgeService = learnDirectedKnowledgeService;
+        this.studentService = studentService;
+    }
+
+    @ApiOperation("试卷作业统计")
+    @GetMapping("paperStats")
+    public AjaxResult paperStats()
+    {
+        return AjaxResult.success(studentService.selectStatsForStudent(SecurityUtils.getUserId()));
+    }
+
+    @ApiOperation("试卷作业列表")
+    @GetMapping("papers")
+    public TableDataInfo papers(@ApiParam("status=1未做3正做4完成") Integer status)
+    {
+        startPage();
+        List<LearnPaper> list = studentService.selectLearnPaperForStudent(SecurityUtils.getUserId(), status);
+        return getDataTable(list);
     }
 
     @ApiOperation("01 计划院校列表")

+ 43 - 0
ie-admin/src/main/java/com/ruoyi/web/service/StudentService.java

@@ -0,0 +1,43 @@
+package com.ruoyi.web.service;
+
+import cn.hutool.core.lang.Dict;
+import com.ruoyi.enums.ExamineeStatus;
+import com.ruoyi.learn.domain.LearnPaper;
+import com.ruoyi.learn.domain.LearnTestStudent;
+import com.ruoyi.learn.mapper.LearnPaperMapper;
+import com.ruoyi.learn.mapper.LearnTestStudentMapper;
+import org.apache.commons.compress.utils.Lists;
+import org.springframework.stereotype.Service;
+
+import java.util.List;
+
+@Service
+public class StudentService {
+    private final LearnPaperMapper learnPaperMapper;
+    private final LearnTestStudentMapper learnTestStudentMapper;
+
+    public StudentService(LearnPaperMapper learnPaperMapper, LearnTestStudentMapper learnTestStudentMapper) {
+        this.learnPaperMapper = learnPaperMapper;
+        this.learnTestStudentMapper = learnTestStudentMapper;
+    }
+
+    public List<Dict> selectStatsForStudent(Long studentId) {
+        Integer undone = 0, done = 0;
+        for(LearnTestStudent ts : learnTestStudentMapper.selectStatsForStudent(studentId)) {
+            if(ExamineeStatus.Init.getVal().equals(ts.getStatus()) || ExamineeStatus.Exam.getVal().equals(ts.getStatus())) {
+                undone += ts.getCount();
+            } else {
+                done += ts.getCount();
+            }
+        }
+        List<Dict> list = Lists.newArrayList();
+        list.add(Dict.create().set("全部", undone + done));
+        list.add(Dict.create().set("未完成", undone));
+        list.add(Dict.create().set("已完成", done));
+        return list;
+    }
+
+    public List<LearnPaper> selectLearnPaperForStudent(Long studentId, Integer status) {
+        return learnPaperMapper.selectLearnPaperForStudent(studentId, status);
+    }
+}

+ 13 - 3
ie-system/src/main/java/com/ruoyi/learn/domain/LearnTestStudent.java

@@ -44,7 +44,9 @@ public class LearnTestStudent extends BaseEntity
 
     /** 状态 */
     @Excel(name = "状态")
-    private Long status;
+    private Integer status;
+
+    private Integer count;
 
     public void setId(String id) 
     {
@@ -116,16 +118,24 @@ public class LearnTestStudent extends BaseEntity
         return examineeId;
     }
 
-    public void setStatus(Long status) 
+    public void setStatus(Integer status)
     {
         this.status = status;
     }
 
-    public Long getStatus() 
+    public Integer getStatus()
     {
         return status;
     }
 
+    public Integer getCount() {
+        return count;
+    }
+
+    public void setCount(Integer count) {
+        this.count = count;
+    }
+
     @Override
     public String toString() {
         return new ToStringBuilder(this,ToStringStyle.MULTI_LINE_STYLE)

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

@@ -2,6 +2,8 @@ package com.ruoyi.learn.mapper;
 
 import java.util.List;
 import com.ruoyi.learn.domain.LearnPaper;
+import org.apache.ibatis.annotations.Param;
+import org.springframework.web.bind.annotation.RequestParam;
 
 /**
  * 试卷Mapper接口
@@ -11,6 +13,8 @@ import com.ruoyi.learn.domain.LearnPaper;
  */
 public interface LearnPaperMapper 
 {
+    public List<LearnPaper> selectLearnPaperForStudent(@Param("studentId") Long studentId, @Param("status") Integer status);
+
     /**
      * 查询试卷
      * 

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

@@ -1,6 +1,8 @@
 package com.ruoyi.learn.mapper;
 
 import java.util.List;
+import java.util.Map;
+
 import com.ruoyi.learn.domain.LearnTestStudent;
 
 /**
@@ -11,6 +13,8 @@ import com.ruoyi.learn.domain.LearnTestStudent;
  */
 public interface LearnTestStudentMapper 
 {
+    List<LearnTestStudent> selectStatsForStudent(Long studentId);
+
     /**
      * 查询测试学生
      * 

+ 9 - 0
ie-system/src/main/resources/mapper/learn/LearnPaperMapper.xml

@@ -47,6 +47,15 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
             <if test="createTime != null "> and createTime = #{createTime}</if>
         </where>
     </select>
+
+    <select id="selectLearnPaperForStudent" resultMap="LearnPaperResult">
+        SELECT p.*
+          FROM `learn_test_student` ts JOIN `learn_paper` p on ts.paper_id = p.id
+        <where> ts.student_id = #{studentId}
+            <if test="status != null "> and ts.status = #{status}</if>
+        </where>
+
+    </select>
     
     <select id="selectLearnPaperById" parameterType="Long" resultMap="LearnPaperResult">
         <include refid="selectLearnPaperVo"/>

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

@@ -33,6 +33,11 @@ PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
         </where>
     </select>
 
+
+    <select id="selectStatsForStudent" parameterType="Long" resultMap="LearnTestStudentResult">
+        SELECT ts.status, COUNT(*) count FROM learn_test_student ts WHERE ts.`student_id` = #{studentId}
+    </select>
+
     <select id="selectLearnTestStudentList" parameterType="LearnTestStudent" resultMap="LearnTestStudentResult">
         <include refid="selectLearnTestStudentVo"/>
         <where>