Sfoglia il codice sorgente

Merge remote-tracking branch 'cloud-schoolapi/ywx'

tags/正式版本
王宁 2 anni fa
parent
commit
96a04092a8

+ 2
- 0
sexam/src/main/java/com/xhkjedu/sexam/SexamApplication.java Vedi File

@@ -3,11 +3,13 @@ package com.xhkjedu.sexam;
3 3
 import org.springframework.boot.SpringApplication;
4 4
 import org.springframework.boot.autoconfigure.SpringBootApplication;
5 5
 import org.springframework.cloud.netflix.eureka.EnableEurekaClient;
6
+import org.springframework.scheduling.annotation.EnableAsync;
6 7
 import tk.mybatis.spring.annotation.MapperScan;
7 8
 
8 9
 @SpringBootApplication
9 10
 @EnableEurekaClient
10 11
 @MapperScan(basePackages = {"com.xhkjedu.sexam.mapper"})
12
+@EnableAsync
11 13
 public class SexamApplication {
12 14
 
13 15
     public static void main(String[] args) {

+ 143
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperCorrectTeacherController.java Vedi File

@@ -0,0 +1,143 @@
1
+package com.xhkjedu.sexam.controller.paper;
2
+
3
+import com.github.pagehelper.PageHelper;
4
+import com.github.pagehelper.PageInfo;
5
+import com.xhkjedu.sexam.model.exam.ESubject;
6
+import com.xhkjedu.sexam.model.paper.EPaperCorrectquestion;
7
+import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
8
+import com.xhkjedu.sexam.service.paper.EPaperCorrectTeacherService;
9
+import com.xhkjedu.sexam.vo.paper.EPTeacherVo;
10
+import com.xhkjedu.utils.N_Utils;
11
+import com.xhkjedu.utils.PageUtil;
12
+import com.xhkjedu.vo.PageResult;
13
+import com.xhkjedu.vo.ResultVo;
14
+import org.springframework.web.bind.annotation.PostMapping;
15
+import org.springframework.web.bind.annotation.RequestBody;
16
+import org.springframework.web.bind.annotation.RequestMapping;
17
+import org.springframework.web.bind.annotation.RestController;
18
+
19
+import javax.annotation.Resource;
20
+import java.util.List;
21
+import java.util.Map;
22
+
23
+/**
24
+ * @author ywx
25
+ * @classname EPaperCorrectTeacherController
26
+ * @description 教师阅卷
27
+ * @date 2022/7/27 11:24
28
+ **/
29
+@RestController
30
+@RequestMapping("/ept")
31
+public class EPaperCorrectTeacherController {
32
+    @Resource
33
+    private EPaperCorrectTeacherService correctTeacherService;
34
+
35
+    /**
36
+     * 待阅卷列表
37
+     *
38
+     * @return com.xhkjedu.vo.ResultVo
39
+     * @Param [vo]
40
+     * @Author ywx
41
+     * @Date 2022/7/27 14:07
42
+     **/
43
+    @PostMapping("/list_pending")
44
+    public ResultVo listPending(@RequestBody ESubject vo) {
45
+        Integer teacherid = vo.getTeacherid();
46
+        N_Utils.validation(new Object[]{teacherid, "教师id", 1});
47
+        List<Map> list = correctTeacherService.listPending(teacherid);
48
+        return new ResultVo(0, "获取成功", list);
49
+    }
50
+
51
+    /**
52
+     * 已阅卷列表
53
+     *
54
+     * @return com.xhkjedu.vo.ResultVo
55
+     * @Param [vo]
56
+     * @Author ywx
57
+     * @Date 2022/7/27 14:18
58
+     **/
59
+    @PostMapping("/list_marked")
60
+    public ResultVo listMarked(@RequestBody ESubject vo) {
61
+        Integer teacherid = vo.getTeacherid();
62
+        Integer page = vo.getPage();
63
+        Integer pageSize = vo.getPageSize();
64
+        N_Utils.validation(new Object[]{teacherid, "教师id", 1, page, "页码", 1, pageSize, "显示条数", 1});
65
+        PageHelper.startPage(page, pageSize);
66
+        List<Map> list = correctTeacherService.listMarked(teacherid);
67
+        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
68
+        return new ResultVo(0, "获取成功", pageResult);
69
+    }
70
+
71
+    /**
72
+     * 随机获取待批试题
73
+     *
74
+     * @return com.xhkjedu.vo.ResultVo
75
+     * @Param [vo]
76
+     * @Author ywx
77
+     * @Date 2022/7/27 16:21
78
+     **/
79
+    @PostMapping("/get_cq")
80
+    public ResultVo getCorrectQuestion(@RequestBody EPTeacherVo vo) {
81
+        Integer epid = vo.getEpid();
82
+        Integer teacherid = vo.getTeacherid();
83
+        String qorders = vo.getQorders();
84
+        N_Utils.validation(new Object[]{epid, "试卷id", 1, teacherid, "教师id", 1, qorders, "页码", 2});
85
+        return correctTeacherService.getCorrectQuestion(epid, teacherid, qorders, vo.getClassids());
86
+    }
87
+
88
+    /**
89
+     * 获取上一份批阅试题
90
+     *
91
+     * @return com.xhkjedu.vo.ResultVo
92
+     * @Param [vo]
93
+     * @Author ywx
94
+     * @Date 2022/7/27 16:33
95
+     **/
96
+    @PostMapping("/get_pre")
97
+    public ResultVo getPreQuestion(@RequestBody EPTeacherVo vo) {
98
+        Integer epid = vo.getEpid();
99
+        Integer teacherid = vo.getTeacherid();
100
+        N_Utils.validation(new Object[]{epid, "试卷id", 1, teacherid, "教师id", 1});
101
+        return correctTeacherService.getPreQuestion(epid, teacherid);
102
+    }
103
+
104
+    /**
105
+     * 阅卷记录
106
+     *
107
+     * @return com.xhkjedu.vo.ResultVo
108
+     * @Param [vo]
109
+     * @Author ywx
110
+     * @Date 2022/7/27 16:41
111
+     **/
112
+    @PostMapping("/list_jl")
113
+    public ResultVo listRecord(@RequestBody EPaperCorrectquestion vo) {
114
+        Integer epid = vo.getEpid();
115
+        Integer teacherid = vo.getTeacherid();
116
+        Integer qorder = vo.getQorder();
117
+        Integer page = vo.getPage();
118
+        Integer pageSize = vo.getPageSize();
119
+        N_Utils.validation(new Object[]{epid, "试卷id", 1, teacherid, "教师id", 1, qorder, "试题排序", 1
120
+                , page, "页码", 1, pageSize, "显示条数", 1});
121
+        PageHelper.startPage(page, pageSize);
122
+        List<Map> list = correctTeacherService.listRecord(epid, teacherid, qorder);
123
+        PageResult pageResult = PageUtil.getPageResult(new PageInfo<>(list));
124
+        return new ResultVo(0, "获取成功", pageResult);
125
+    }
126
+
127
+    /**
128
+     * 批阅试题
129
+     *
130
+     * @return com.xhkjedu.vo.ResultVo
131
+     * @Param [vo]
132
+     * @Author ywx
133
+     * @Date 2022/7/28 15:30
134
+     **/
135
+    @PostMapping("/correct")
136
+    public ResultVo correctQuestion(@RequestBody EPaperStudentQuestion vo) {
137
+        Integer epsid = vo.getEpsid();
138
+        Integer epsqid = vo.getEpsqid();
139
+        Integer checkid = vo.getCheckid();
140
+        N_Utils.validation(new Object[]{epsid, "试卷学生id", 1, epsqid, "试卷学生试题id", 1, checkid, "批阅人", 1});
141
+        return correctTeacherService.correctQuestion(vo);
142
+    }
143
+}

+ 42
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paper/EPaperCorrectTeacherMapper.java Vedi File

@@ -0,0 +1,42 @@
1
+package com.xhkjedu.sexam.mapper.paper;
2
+
3
+import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
4
+import com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+public interface EPaperCorrectTeacherMapper {
11
+    //待阅卷列表
12
+    List<Map> listPending(@Param("teacherid") Integer teacherid);
13
+
14
+    //已阅卷列表
15
+    List<Map> listMarked(@Param("teacherid") Integer teacherid);
16
+
17
+    //随机获取一条待批阅试题
18
+    EPaperSQuestionVo getCorrectQuestion(@Param("epid") Integer epid, @Param("teacherid") Integer teacherid,
19
+                                         @Param("qorders") String qorders, @Param("classids") String classids);
20
+
21
+    //试题批阅情况
22
+    EPaperSQuestionVo getCheckQuestion(@Param("epid") Integer epid, @Param("teacherid") Integer teacherid,
23
+                                       @Param("qorder") Integer qorder);
24
+
25
+    //修改试卷学生试题为批阅中
26
+    void updateCheckQuestionById(@Param("epsqid") Integer epsqid, @Param("teacherid") Integer teacherid);
27
+
28
+    //获取上一份批阅试题
29
+    Map getPreQuestion(@Param("epid") Integer epid, @Param("teacherid") Integer teacherid);
30
+
31
+    //阅卷记录
32
+    List<Map> listRecord(@Param("epid") Integer epid, @Param("teacherid") Integer teacherid, @Param("qorder") Integer qorder);
33
+
34
+    //批阅试题
35
+    void correctQuestion(@Param("psq") EPaperStudentQuestion psq);
36
+
37
+    //学生未批改试题数量
38
+    Integer getNotCorrect(@Param("epsid") Integer epsid);
39
+
40
+    //修改学生试卷批阅状态
41
+    void updateCheckStuById(@Param("epsid") Integer epsid, @Param("checkid") Integer checkid);
42
+}

+ 89
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperCorrectTeacherService.java Vedi File

@@ -0,0 +1,89 @@
1
+package com.xhkjedu.sexam.service.paper;
2
+
3
+import com.xhkjedu.config.MissingParametersException;
4
+import com.xhkjedu.sexam.mapper.paper.EPaperCorrectTeacherMapper;
5
+import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
6
+import com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo;
7
+import com.xhkjedu.utils.N_Utils;
8
+import com.xhkjedu.vo.ResultVo;
9
+import lombok.extern.slf4j.Slf4j;
10
+import org.springframework.scheduling.annotation.Async;
11
+import org.springframework.stereotype.Service;
12
+
13
+import javax.annotation.Resource;
14
+import java.util.HashMap;
15
+import java.util.List;
16
+import java.util.Map;
17
+import java.util.concurrent.locks.Lock;
18
+import java.util.concurrent.locks.ReentrantLock;
19
+
20
+@Service
21
+@Slf4j
22
+public class EPaperCorrectTeacherService {
23
+    //ReentrantLock(boolean) true为公平锁,默认false不公平锁,性能更好,可以插队!
24
+    Lock lock = new ReentrantLock();
25
+    @Resource
26
+    private EPaperCorrectTeacherMapper correctTeacherMapper;
27
+
28
+    //待阅卷列表
29
+    public List<Map> listPending(Integer teacherid) {
30
+        return correctTeacherMapper.listPending(teacherid);
31
+    }
32
+
33
+    //已阅卷列表
34
+    public List<Map> listMarked(Integer teacherid) {
35
+        return correctTeacherMapper.listMarked(teacherid);
36
+    }
37
+
38
+    //随机获取待批试题
39
+    public ResultVo getCorrectQuestion(Integer epid, Integer teacherid, String qorders, String classids) {
40
+        lock.lock();
41
+        Map map = new HashMap();
42
+        try {
43
+            //随机获取一条待批阅试题
44
+            EPaperSQuestionVo sq = correctTeacherMapper.getCorrectQuestion(epid, teacherid, qorders, classids);
45
+            if (sq == null) return new ResultVo(1, "已批阅完成");
46
+            //修改试卷学生试题为批阅中
47
+            correctTeacherMapper.updateCheckQuestionById(sq.getEpsqid(), teacherid);
48
+            //试题批阅情况
49
+            EPaperSQuestionVo q = correctTeacherMapper.getCheckQuestion(epid, teacherid, sq.getQorder());
50
+            Integer tjnum = q.getTjnum();
51
+            Integer pynum = q.getPynum();
52
+            map.put("sq", sq);//学生待批试题
53
+            map.put("tjnum", tjnum);//提交人数
54
+            map.put("pynum", pynum);//批阅人数
55
+            map.put("wpynum", q.getWpynum());//我批阅人数
56
+            map.put("pyrate", N_Utils.getIntegerDivideAndMulitiply(pynum, tjnum));//批阅进度
57
+        } catch (Exception e) {
58
+            log.error("随机获取待批试题出错", e.getMessage());
59
+            throw new MissingParametersException("随机获取待批试题出错:" + e.getMessage());
60
+        } finally {
61
+            lock.unlock();
62
+        }
63
+        return new ResultVo(0, "获取成功", map);
64
+    }
65
+
66
+    //获取上一份批阅试题
67
+    public ResultVo getPreQuestion(Integer epid, Integer teacherid) {
68
+        Map q = correctTeacherMapper.getPreQuestion(epid, teacherid);
69
+        if (q == null) return new ResultVo(1, "您还没有批阅记录");
70
+        return new ResultVo(0, "获取成功", q);
71
+    }
72
+
73
+    //阅卷记录
74
+    public List<Map> listRecord(Integer epid, Integer teacherid, Integer qorder) {
75
+        return correctTeacherMapper.listRecord(epid, teacherid, qorder);
76
+    }
77
+
78
+    //批阅试题
79
+    @Async("asyncPoolTaskExecutor")
80
+    public ResultVo correctQuestion(EPaperStudentQuestion psq) {
81
+        correctTeacherMapper.correctQuestion(psq);
82
+        Integer epsid = psq.getEpsid();
83
+        Integer num = correctTeacherMapper.getNotCorrect(epsid);//学生未批改试题数量
84
+        if (num == 0) {//批阅完成修改学生试卷批阅状态
85
+            correctTeacherMapper.updateCheckStuById(epsid, psq.getCheckid());
86
+        }
87
+        return new ResultVo(0, "批阅成功");
88
+    }
89
+}

+ 24
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paper/EPTeacherVo.java Vedi File

@@ -0,0 +1,24 @@
1
+package com.xhkjedu.sexam.vo.paper;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @author ywx
7
+ * @classname EPTeacherVo
8
+ * @description 教师阅卷
9
+ * @date 2022/7/27 15:07
10
+ **/
11
+@Data
12
+public class EPTeacherVo {
13
+    //试卷id
14
+    private Integer epid;
15
+
16
+    //教师id
17
+    private Integer teacherid;
18
+
19
+    //试题排序
20
+    private String qorders;
21
+
22
+    //班级ids
23
+    private String classids;
24
+}

+ 22
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paper/EPaperSQuestionVo.java Vedi File

@@ -0,0 +1,22 @@
1
+package com.xhkjedu.sexam.vo.paper;
2
+
3
+import lombok.Data;
4
+
5
+/**
6
+ * @author ywx
7
+ * @classname EPaperSQuestionVo
8
+ * @description 试卷学生试题
9
+ * @date 2022/7/27 15:58
10
+ **/
11
+@Data
12
+public class EPaperSQuestionVo {
13
+    private Integer epsid;//试卷学生id
14
+    private Integer epsqid;//试卷学生试题id
15
+    private String stuanswer;//学生答案
16
+    private String qn;//试题题号
17
+    private Integer qorder;//试题排序
18
+    private double qscore;//分值
19
+    private Integer tjnum;//提交人数
20
+    private Integer pynum;//批阅人数
21
+    private Integer wpynum;//我批阅人数
22
+}

+ 96
- 0
sexam/src/main/resources/mapper/paper/EPaperCorrectTeacherMapper.xml Vedi File

@@ -0,0 +1,96 @@
1
+<?xml version="1.0" encoding="UTF-8"?>
2
+<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
+<mapper namespace="com.xhkjedu.sexam.mapper.paper.EPaperCorrectTeacherMapper">
4
+    <!--待阅卷列表-->
5
+    <select id="listPending" resultType="java.util.Map">
6
+        select a.*,eb.examname,eb.gradeid,eb.examtype,es.sdate,es.begintime,es.endtime,es.subjectname
7
+        ,truncate(count(case when ps.sstate=2 and ps.checked=2 then ps.epsid else null end)*100/
8
+                  count(case when ps.sstate=2 then ps.epsid else null end),2)pgrate
9
+        from(select p.esid,p.epid,group_concat(distinct pq.qn order by pq.qorder)qns
10
+        ,group_concat(distinct pq.qorder order by pq.qorder)qorders,group_concat(pc.classid)classids
11
+        from e_paper p left join e_paper_qtype_question pq on p.epid = pq.epid
12
+        left join e_paper_correctclass pc on p.epid = pc.epid
13
+        where pc.teacherid=#{teacherid} and pq.ctype in(3,14,15)
14
+        union
15
+        select p.esid,p.epid,group_concat(distinct pq.qn order by pq.qorder)qns
16
+        ,group_concat(distinct pq.qorder order by pq.qorder)qorders,0 classids
17
+        from e_paper p left join e_paper_correctquestion pq on p.epid = pq.epid
18
+        where pq.teacherid=#{teacherid})a left join e_subject es on a.esid = es.esid
19
+        left join e_base eb on es.examid = eb.examid
20
+        left join e_paper_student ps on a.epid=ps.epid
21
+        group by a.epid
22
+        having count(case when ps.checked!=2 then ps.epsid else null end)>0
23
+    </select>
24
+    <!--已阅卷列表-->
25
+    <select id="listMarked" resultType="java.util.Map">
26
+        select a.*,eb.examname,eb.gradeid,eb.examtype,es.sdate,es.begintime,es.endtime,es.subjectname
27
+        from(select p.esid,p.epid,group_concat(distinct pq.qn order by pq.qorder)qns
28
+        ,group_concat(distinct pq.qorder order by pq.qorder)qorders,group_concat(pc.classid)classids
29
+        from e_paper p left join e_paper_qtype_question pq on p.epid = pq.epid
30
+        left join e_paper_correctclass pc on p.epid = pc.epid
31
+        where pc.teacherid=#{teacherid} and pq.ctype in(3,14,15)
32
+        union
33
+        select p.esid,p.epid,group_concat(distinct pq.qn order by pq.qorder)qns
34
+        ,group_concat(distinct pq.qorder order by pq.qorder)qorders,0 classids
35
+        from e_paper p left join e_paper_correctquestion pq on p.epid = pq.epid
36
+        where pq.teacherid=#{teacherid})a left join e_subject es on a.esid = es.esid
37
+        left join e_base eb on es.examid = eb.examid
38
+        left join e_paper_student ps on a.epid=ps.epid
39
+        group by a.epid
40
+        having count(case when ps.checked!=2 then ps.epsid else null end)=0
41
+    </select>
42
+    <!--随机获取一条待批阅试题-->
43
+    <select id="getCorrectQuestion" resultType="com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo">
44
+        select psq.epsqid,psq.stuanswer,psq.qn,psq.qorder,psq.qscore,psq.epsid
45
+        from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder in(${qorders})
46
+        and psq.answered=1 and (psq.checked=0 or (psq.checked=1 and psq.checkid=#{teacherid}))
47
+        <if test="classids!=null and classids!=''">
48
+            and psq.classid in(${classids})
49
+        </if>
50
+        order by psq.qorder,psq.checked desc rand() limit 1
51
+    </select>
52
+    <!--试题批阅情况-->
53
+    <select id="getCheckQuestion" resultType="com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo">
54
+        select count(psq.epsqid)tjnum,count(case when psq.checked=1 then psq.epsqid else null end)pynum
55
+        ,count(case when psq.checked=1 and psq.checkid=#{teacherid} then psq.epsqid else null end)wpynum
56
+        from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder} and psq.answered=1
57
+    </select>
58
+    <!--修改试卷学生试题为批阅中-->
59
+    <update id="updateCheckQuestionById">
60
+        update e_paper_student_question set checked=1,checkid=#{teacherid} where epsqid=#{epsqid}
61
+    </update>
62
+    <!--获取上一份批阅试题-->
63
+    <select id="getPreQuestion" resultType="java.util.Map">
64
+        select psq.epsqid,psq.stuanswer,psq.qn,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.epsid
65
+        from e_paper_student_question psq where psq.epid=#{epid} and psq.checked=1 and psq.checkid=#{teacherid}
66
+        order by psq.checktime desc limit 1
67
+    </select>
68
+    <!--阅卷记录-->
69
+    <select id="listRecord" resultType="java.util.Map">
70
+        select psq.epsqid,psq.stuanswer,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.checktime
71
+        from e_paper_student_question psq where psq.epid=#{epid} and psq.qorder=#{qorder}
72
+        and psq.checked=1 and psq.checkid=#{teacherid}
73
+        order by psq.checktime desc
74
+    </select>
75
+    <!--批阅试题-->
76
+    <update id="correctQuestion">
77
+        update e_paper_student_question
78
+        set stuscore=#{psq.stuscore},psq.checked=1
79
+        ,checkid=#{psq.checkid},checktime=unix_timestamp()
80
+        ,good=#{psq.good},bad=#{psq.bad}
81
+        <if test="psq.stuanswer!=null and psq.stuanswer!=''">
82
+            and stuanswer=#{psq.stuanswer}
83
+        </if>
84
+        where psq.epsqid=#{psq.epsqid}
85
+    </update>
86
+    <!--学生未批改试题数量-->
87
+    <select id="getNotCorrect" resultType="java.lang.Integer">
88
+        select count(*) from e_paper_student_question where epsid=#{epsid} and checked!=2
89
+    </select>
90
+    <!--修改学生试卷批阅状态-->
91
+    <update id="updateCheckStuById">
92
+        update e_paper_student ps set ps.checked=2,ps.checkid=#{checkid}
93
+        ,ps.stuscore=(select sum(psq.stuscore) from e_paper_student_question psq where psq.epsid=ps.epsid)
94
+        where ps.epsid=#{epsid}
95
+    </update>
96
+</mapper>

Loading…
Annulla
Salva