Browse Source

Merge remote-tracking branch 'origin/master' into ywx

tags/正式版本
雍文秀 2 years ago
parent
commit
96971008be

+ 19
- 0
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperController.java View File

@@ -2,6 +2,7 @@ package com.xhkjedu.sexam.controller.paper;
2 2
 
3 3
 import com.xhkjedu.sexam.model.exam.ESubject;
4 4
 import com.xhkjedu.sexam.model.paper.EPaper;
5
+import com.xhkjedu.sexam.model.paper.EPaperBack;
5 6
 import com.xhkjedu.sexam.service.paper.EPaperService;
6 7
 import com.xhkjedu.utils.N_Utils;
7 8
 import com.xhkjedu.vo.ResultVo;
@@ -31,6 +32,24 @@ public class EPaperController {
31 32
         return new ResultVo(0,"成功获取考试试卷信息",list);
32 33
     }
33 34
 
35
+    //退回试卷
36
+    @PostMapping("/sb")
37
+    public ResultVo saveExamPaperBack(@RequestBody EPaperBack ePaperBack){
38
+        N_Utils.validation(new Object[]{ePaperBack.getEpid(),"试卷id",1});
39
+        ePaperService.savePaperBack(ePaperBack);
40
+        return new ResultVo(0,"成功退回试卷",null);
41
+    }
42
+
43
+    //试卷退回列表
44
+    @PostMapping("/bl")
45
+    public ResultVo listPaperBacks(@RequestBody EPaperBack ePaperBack){
46
+        N_Utils.validation(new Object[]{ePaperBack.getEpid(),"试卷id",1});
47
+        List<Map> list = ePaperService.listPaperBacksByEpid(ePaperBack.getEpid());
48
+        return new ResultVo(0,"成功获取试卷退回原因",list);
49
+    }
50
+
51
+
52
+
34 53
     //教师出卷列表
35 54
     @PostMapping("/listt")
36 55
     public ResultVo examTeacherPaperList(@RequestBody ESubject subject){

+ 13
- 1
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperFjtypeController.java View File

@@ -1,11 +1,15 @@
1 1
 package com.xhkjedu.sexam.controller.paper;
2 2
 
3
+import com.xhkjedu.sexam.model.paper.EPaper;
3 4
 import com.xhkjedu.sexam.service.paper.EPaperFjtypeService;
5
+import com.xhkjedu.utils.N_Utils;
6
+import com.xhkjedu.vo.ResultVo;
7
+import org.springframework.web.bind.annotation.PostMapping;
8
+import org.springframework.web.bind.annotation.RequestBody;
4 9
 import org.springframework.web.bind.annotation.RequestMapping;
5 10
 import org.springframework.web.bind.annotation.RestController;
6 11
 
7 12
 import javax.annotation.Resource;
8
-
9 13
 /**
10 14
  * @Description 附件试卷
11 15
  * @Author WN
@@ -18,4 +22,12 @@ public class EPaperFjtypeController {
18 22
     @Resource
19 23
     private EPaperFjtypeService ePaperFjtypeService;
20 24
 
25
+    //保存试卷信息
26
+    @PostMapping("/save")
27
+    public ResultVo savePaperFj(@RequestBody EPaper paper){
28
+        N_Utils.validation(new Object[]{paper.getExamid(),"考试id",1});
29
+        ePaperFjtypeService.saveFjPaper(paper);
30
+        return new ResultVo(0,"成功保存试卷信息",null);
31
+    }
32
+
21 33
 }

+ 6
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/exam/ESubjectMapper.java View File

@@ -13,4 +13,10 @@ public interface ESubjectMapper extends TkMapper<ESubject> {
13 13
 
14 14
     //考试下所有科目
15 15
     List<ESubjectVo> listExamSubjects(@Param("examid") Integer examid);
16
+
17
+    //更新考试科目状态
18
+    void updateExamSubjectState(@Param("esubject") ESubject esubject);
19
+
20
+    //根据试卷id更新考试科目状态
21
+    void updateEsubjectStateByEpid(@Param("esstate") Integer esstate,@Param("epid") Integer epid);
16 22
 }

+ 19
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paper/EPaperBackMapper.java View File

@@ -0,0 +1,19 @@
1
+package com.xhkjedu.sexam.mapper.paper;
2
+
3
+import com.xhkjedu.sexam.base.TkMapper;
4
+import com.xhkjedu.sexam.model.paper.EPaperBack;
5
+import org.apache.ibatis.annotations.Param;
6
+
7
+import java.util.List;
8
+import java.util.Map;
9
+
10
+/**
11
+ * @Description 试卷回退
12
+ * @Author WN
13
+ * Date 2022/7/18 16:38
14
+ **/
15
+public interface EPaperBackMapper extends TkMapper<EPaperBack> {
16
+
17
+    //获取试卷退回原因
18
+    List<Map> listPaperBacksByEpid(@Param("epid")Integer epid);
19
+}

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/paper/EPaperMapper.java View File

@@ -21,4 +21,7 @@ public interface EPaperMapper extends TkMapper<EPaper> {
21 21
 
22 22
     //教师出卷列表
23 23
     List<Map> listExamPapersByTeacherid(@Param("teacherid") Integer teacherid);
24
+
25
+    //试卷详情
26
+    Map getExamPaperDetailByEpid(@Param("epid") Integer epid);
24 27
 }

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/model/paper/EPaper.java View File

@@ -33,6 +33,9 @@ public class EPaper extends BaseBean {
33 33
     //试卷总分
34 34
     private Double pscore;
35 35
 
36
+    //是否设置正确答案0未设置1已设置
37
+    private Integer answered;
38
+
36 39
     //批阅设置:1按班设置2按题设置
37 40
     private Integer correcttype;
38 41
 

+ 55
- 4
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperFjtypeService.java View File

@@ -1,15 +1,20 @@
1 1
 package com.xhkjedu.sexam.service.paper;
2 2
 
3
+import com.alibaba.fastjson.JSON;
3 4
 import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
4 5
 import com.xhkjedu.sexam.mapper.paper.*;
5 6
 import com.xhkjedu.sexam.model.exam.ESubject;
6 7
 import com.xhkjedu.sexam.model.paper.*;
8
+import com.xhkjedu.sexam.vo.paper.EPaperQsVo;
7 9
 import com.xhkjedu.utils.N_Utils;
8 10
 import org.springframework.stereotype.Service;
11
+import org.springframework.transaction.annotation.Transactional;
9 12
 
10 13
 import javax.annotation.Resource;
11 14
 import java.util.ArrayList;
15
+import java.util.HashMap;
12 16
 import java.util.List;
17
+import java.util.Map;
13 18
 import java.util.stream.Collectors;
14 19
 
15 20
 /**
@@ -32,7 +37,8 @@ public class EPaperFjtypeService {
32 37
     @Resource
33 38
     private EPaperAnalyzeMapper ePaperAnalyzeMapper;
34 39
 
35
-
40
+    //保存试卷
41
+    @Transactional(rollbackFor = Exception.class)
36 42
     public void saveFjPaper(EPaper paper){
37 43
         int epid = 0;
38 44
 
@@ -57,6 +63,7 @@ public class EPaperFjtypeService {
57 63
         paper.setCreatetime(timestamp);
58 64
         paper.setHandletime(timestamp);
59 65
         paper.setHandleid(paper.getCreateid());
66
+        paper.setAnswered(0);
60 67
         ePaperMapper.insertUseGeneratedKeys(paper);
61 68
         epid = paper.getId();
62 69
         paper.setEpid(epid);
@@ -65,10 +72,12 @@ public class EPaperFjtypeService {
65 72
         savePaperFile(paper);
66 73
         //保存答题卡信息
67 74
         saveFjtypeQuestion(paper,fjtypelist);
68
-
75
+        //更加试卷状态是否需要生成分析和更改科目状态
69 76
         if(paper.getPstate()!=null && paper.getPstate() == 1){
70
-            //如果提交试卷,则生成试卷分析
77
+            //如果提交试卷,则生成试卷分析,更改科目状态
71 78
             savePaperAnalyze(paper,fjtypelist,queslist);
79
+            eSubject.setEsstate(1);
80
+            eSubjectMapper.updateExamSubjectState(eSubject);
72 81
         }
73 82
     }
74 83
 
@@ -127,9 +136,51 @@ public class EPaperFjtypeService {
127 136
         double zscore = 0;
128 137
         int knum = 0;
129 138
         double kscore = 0;
130
-        
139
+        for(EPaperFjtypeQuestion q : queslist){
140
+            if(q.getCtype() == 3 || q.getCtype() == 11){
141
+                znum ++;
142
+                zscore = zscore + q.getScore();
143
+            }else{
144
+                knum ++;
145
+                kscore = kscore + q.getScore();
146
+            }
147
+        }
148
+
149
+        double znumrate = N_Utils.getIntegerDivideAndMulitiply(znum, ePaper.getPnum());
150
+        double knumrate = 100-znumrate;
151
+        double zscorerate = N_Utils.getDoubleDivideAndMulitiply(zscore, ePaper.getPscore());
152
+        double kscorerate = 100 - zscorerate;
153
+
154
+        List<EPaperQsVo> ranglist = new ArrayList<>();
155
+        ranglist.add(new EPaperQsVo("主观题",zscore,znum,zscorerate,znumrate));
156
+        ranglist.add(new EPaperQsVo("客观题",kscore,knum,kscorerate,knumrate));
131 157
 
158
+        Map ztmap = new HashMap<>();
159
+        ztmap.put("pnum", ePaper.getPnum());
160
+        ztmap.put("pscore",ePaper.getPscore());
161
+        ztmap.put("ranglist",ranglist);
162
+
163
+        //题型分布
164
+        List<EPaperQsVo> qtlist = new ArrayList<>();
165
+        for(EPaperFjtype fjt : fjtypelist){
166
+            EPaperQsVo qvo = new EPaperQsVo();
167
+            qvo.setQtname(fjt.getEpfjname());
168
+            qvo.setNum(fjt.getEpfjnum());
169
+            qvo.setScore(fjt.getEpfjscore());
170
+            double scorerate = N_Utils.getDoubleDivideAndMulitiply(fjt.getEpfjscore(), ePaper.getPscore());
171
+            qvo.setSrate(scorerate);
172
+            qtlist.add(qvo);
173
+        }
174
+
175
+        EPaperAnalyze epa = new EPaperAnalyze();
176
+        epa.setEpaid(ePaper.getEpid());
177
+        epa.setAlljson(JSON.toJSONString(ztmap));
178
+        epa.setQnumjson(JSON.toJSONString(qtlist));
179
+        ePaperAnalyzeMapper.insertUseGeneratedKeys(epa);
180
+    }
132 181
 
182
+    //试卷详情
183
+    public void getPaperDetail(Integer epid){
133 184
 
134 185
     }
135 186
 }

+ 40
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperService.java View File

@@ -1,10 +1,14 @@
1 1
 package com.xhkjedu.sexam.service.paper;
2 2
 
3 3
 import com.xhkjedu.sexam.mapper.exam.ESubjectMapper;
4
+import com.xhkjedu.sexam.mapper.paper.EPaperBackMapper;
4 5
 import com.xhkjedu.sexam.mapper.paper.EPaperMapper;
5 6
 import com.xhkjedu.sexam.model.paper.EPaper;
7
+import com.xhkjedu.sexam.model.paper.EPaperBack;
6 8
 import com.xhkjedu.sexam.vo.exam.ESubjectVo;
9
+import com.xhkjedu.utils.N_Utils;
7 10
 import org.springframework.stereotype.Service;
11
+import org.springframework.transaction.annotation.Transactional;
8 12
 
9 13
 import javax.annotation.Resource;
10 14
 import java.util.ArrayList;
@@ -23,16 +27,52 @@ public class EPaperService {
23 27
     @Resource
24 28
     private EPaperMapper ePaperMapper;
25 29
     @Resource
30
+    private EPaperBackMapper ePaperBackMapper;
31
+    @Resource
26 32
     private ESubjectMapper eSubjectMapper;
27 33
 
28 34
 
35
+
29 36
     //考试各科目试卷设置
30 37
     public List<Map> listExamPapers(Integer examid) {
31 38
         return ePaperMapper.listExamPapers(examid);
32 39
     }
33 40
 
41
+    //试卷退回
42
+    @Transactional(rollbackFor = Exception.class)
43
+    public void savePaperBack(EPaperBack ePaperBack){
44
+        int timestamp = N_Utils.getSecondTimestamp();
45
+        ePaperBack.setCreatetime(timestamp);
46
+        ePaperBackMapper.insertUseGeneratedKeys(ePaperBack);
47
+        //更改试卷科目状态
48
+        eSubjectMapper.updateEsubjectStateByEpid(2,ePaperBack.getEpid());
49
+        //试卷回退需要发送通知和短息,后续添加
50
+    }
51
+
52
+    //试卷退回原因
53
+    public List<Map> listPaperBacksByEpid(Integer epid){
54
+        return ePaperBackMapper.listPaperBacksByEpid(epid);
55
+    }
56
+
34 57
     //教师出卷列表
35 58
     public List<Map> listExamPapersByTeacherid(Integer teacherid){
36 59
         return ePaperMapper.listExamPapersByTeacherid(teacherid);
37 60
     }
61
+
62
+    //试卷详情
63
+    public Map getExamPaperDetailByEpid(Integer epid){
64
+        Map map = ePaperMapper.getExamPaperDetailByEpid(epid);
65
+        //试卷类型1题库2答题卡3仅答题卡
66
+        int ptype = Integer.parseInt(map.get("ptype").toString());
67
+        if(ptype == 1){
68
+
69
+        }else if(ptype == 2){
70
+
71
+        }else{
72
+
73
+        }
74
+
75
+        return null;
76
+    }
77
+
38 78
 }

+ 34
- 0
sexam/src/main/java/com/xhkjedu/sexam/vo/paper/EPaperQsVo.java View File

@@ -0,0 +1,34 @@
1
+package com.xhkjedu.sexam.vo.paper;
2
+
3
+import lombok.Data;
4
+import org.springframework.format.annotation.DateTimeFormat;
5
+
6
+/**
7
+ * @Description 试卷分值分析
8
+ * @Author WN
9
+ * Date 2022/7/18 15:45
10
+ **/
11
+@Data
12
+public class EPaperQsVo {
13
+
14
+    private String qtname;//名称
15
+
16
+    private double score;//分值
17
+
18
+    private int num;//数量
19
+
20
+    private double srate;//分值占比
21
+
22
+    private double nrate;//数量占比
23
+    public EPaperQsVo(){
24
+
25
+    }
26
+
27
+    public EPaperQsVo(String qtname,double score,int num,double srate,double nrate){
28
+        this.qtname = qtname;
29
+        this.score = score;
30
+        this.num = num;
31
+        this.srate = srate;
32
+        this.nrate = nrate;
33
+    }
34
+}

+ 4
- 3
sexam/src/main/resources/application.properties View File

@@ -1,9 +1,9 @@
1 1
 server.port=8088
2 2
 spring.application.name=sexam
3 3
 #注册到我们本地的eureka注册中心,端口8081
4
-eureka.client.service-url.defaultZone=http://127.0.0.1:8081/eureka/
5
-#eureka.client.register-with-eureka=false
6
-#eureka.client.fetch-registry=false
4
+#eureka.client.service-url.defaultZone=http://127.0.0.1:8081/eureka/
5
+eureka.client.register-with-eureka=false
6
+eureka.client.fetch-registry=false
7 7
 #设置eureka输出日志级别
8 8
 logging.level.com.netflix=error
9 9
 
@@ -29,6 +29,7 @@ spring.datasource.hikari.connection-test-query=SELECT 1
29 29
 # 所有Entity别名类所在包
30 30
 mybatis.type-aliases-package=com.xhkjedu.sexam.model,com.xhkjedu.sexam.vo
31 31
 mybatis.mapper-Locations=classpath*:mapper/**/*.xml
32
+mybatis.configuration.call-setters-on-nulls=true
32 33
 mapper.mappers=com.xhkjedu.sexam.base.TkMapper
33 34
 mapper.identity=MYSQL
34 35
 #打印日志

+ 10
- 0
sexam/src/main/resources/mapper/exam/ESubjectMapper.xml View File

@@ -17,4 +17,14 @@
17 17
         left join t_subject s on es.subjectid=s.subjectid
18 18
         where es.examid=#{examid} order by s.subjectorder
19 19
     </select>
20
+
21
+    <!--根据考试科目id更改考试科目状态-->
22
+    <update id="updateExamSubjectState">
23
+        update e_subject set esstate=#{esubject.esstate} where esid = #{esubject.esid};
24
+    </update>
25
+
26
+    <!--根据试卷id更新考试科目状态-->
27
+    <update id="updateEsubjectStateByEpid">
28
+        update e_subject es,e_paper ep set es.esstate=#{esstate} where es.esid=ep.esid and ep.epid=#{epid}
29
+    </update>
20 30
 </mapper>

+ 10
- 0
sexam/src/main/resources/mapper/paper/EPaperBackMapper.xml View File

@@ -0,0 +1,10 @@
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.EPaperBackMapper">
4
+    <!--试卷退回原因-->
5
+    <select id="listPaperBacksByEpid" resultType="java.util.Map">
6
+        select eb.*,u.username createname
7
+        from e_paper_back eb left join t_user u on eb.createid=u.userid
8
+        where eb.epid=#{epid}
9
+    </select>
10
+</mapper>

+ 28
- 1
sexam/src/main/resources/mapper/paper/EPaperFjtypeMapper.xml View File

@@ -2,5 +2,32 @@
2 2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3 3
 <mapper namespace="com.xhkjedu.sexam.mapper.paper.EPaperFjtypeMapper">
4 4
 
5
-
5
+    <resultMap id="fjtypeQuestions" type="java.util.Map">
6
+        <result column="epfjid" property="epfjid"></result>
7
+        <result column="epid" property="epid"></result>
8
+        <result column="epfjname" property="epfjname"></result>
9
+        <result column="epfjnum" property="epfjnum"></result>
10
+        <result column="epfjorder" property="epfjorder"></result>
11
+        <result column="epfjscore" property="epfjscore"></result>
12
+        <collection property="questions" ofType="java.util.Map">
13
+            <result column="epfjqid" property="epfjqid"></result>
14
+            <result column="epfjid" property="epfjid"></result>
15
+            <result column="epid" property="epid"></result>
16
+            <result column="qtypeid" property="qtypeid"></result>
17
+            <result column="qtypename" property="qtypename"></result>
18
+            <result column="ctype" property="ctype"></result>
19
+            <result column="score" property="score"></result>
20
+            <result column="qn" property="qn"></result>
21
+            <result column="order" property="order"></result>
22
+            <result column="answer" property="answer"></result>
23
+            <result column="optionnum" property="optionnum"></result>
24
+        </collection>
25
+    </resultMap>
26
+    <select id="listPaperFjtypeQuestions" resultMap="fjtypeQuestions">
27
+        select t.epfjid,t.epid,t.epfjname,t.epfjnum,t.epfjorder,t.epfjscore,
28
+               q.epfjqid,q.epfjid,q.epid,q.qtypeid,q.qtypename,q.ctype,q.score,q.qn,q.order,q.answer,q.optionnum
29
+        from e_paper_fjtype t left join e_paper_fjtype_question q on t.epfjid=q.epfjid
30
+        where t.epid=#{epid}
31
+    </select>
32
+    
6 33
 </mapper>

+ 12
- 2
sexam/src/main/resources/mapper/paper/EPaperMapper.xml View File

@@ -5,7 +5,7 @@
5 5
     <!--获取考试下有科目试卷信息-->
6 6
     <select id="listExamPapers" resultType="java.util.Map">
7 7
         select es.esid,es.subjectid,es.sdate,es.begintime,es.endtime,es.teacherid,u2.username as teachername,es.esstate,es.ptype
8
-        ,ep.epid,ep.pnum,ep.pscore,s.subjectname,ep.handleid,u.username as handlename
8
+        ,ep.epid,ep.pnum,ep.pscore,ep.answered,s.subjectname,ep.handleid,u.username as handlename
9 9
         from e_subject es left join e_paper ep on es.esid=ep.esid
10 10
         left join t_subject s on es.subjectid=s.subjectid
11 11
         left join t_user u on ep.handleid=u.userid
@@ -16,7 +16,7 @@
16 16
     <!--教师出卷列表-->
17 17
     <select id="listExamPapersByTeacherid" resultType="java.util.Map">
18 18
         select es.esid,es.subjectid,es.sdate,es.begintime,es.endtime,es.teacherid,u2.username as teachername,es.esstate,es.ptype
19
-        ,ep.epid,ep.pnum,ep.pscore,s.subjectname,ep.handleid,u.username as handlename,es.examid,e.examname
19
+        ,ep.epid,ep.pnum,ep.pscore,ep.answered,s.subjectname,ep.handleid,u.username as handlename,es.examid,e.examname
20 20
         from e_subject es left join e_paper ep on es.esid=ep.esid
21 21
         left join t_subject s on es.subjectid=s.subjectid
22 22
         left join e_base e on es.examid=e.examid
@@ -25,4 +25,14 @@
25 25
         where es.teacherid=#{teacherid} order by es.examid desc, s.subjectorder asc
26 26
 
27 27
     </select>
28
+
29
+    <!--试卷详情-->
30
+    <select id="getExamPaperDetailByEpid" resultType="java.util.Map">
31
+        select ep.epid,ep.examid,ep.ptype,ep.pnum,ep.pscore,ep.answered,ep.hearfile,
32
+        ep.handleid,ep.handletime,s.subjectname,u.username as handlename
33
+        from e_paper ep left join e_base e on ep.examid=e.examid
34
+        left join t_subject s on ep.subjectid=s.subjectid
35
+        left join t_user u on ep.handleid=u.userid
36
+        where ep.epid=#{epid}
37
+    </select>
28 38
 </mapper>

Loading…
Cancel
Save