Explorar el Código

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

# Conflicts:
#	sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java
tags/正式版本
王宁 hace 2 años
padre
commit
37fc2ad3fc

+ 6
- 6
sexam/src/main/java/com/xhkjedu/sexam/controller/paper/EPaperCorrectTeacherController.java Ver fichero

@@ -81,10 +81,10 @@ public class EPaperCorrectTeacherController {
81 81
     @PostMapping("/get_cq")
82 82
     public ResultVo getCorrectQuestion(@RequestBody EPTeacherVo vo) {
83 83
         Integer teacherid = vo.getTeacherid();
84
-        String eptqids = vo.getEptqids();
84
+        Integer eptqid = vo.getEptqid();
85 85
         Integer esid = vo.getEsid();
86
-        N_Utils.validation(new Object[]{teacherid, "教师id", 1, eptqids, "试卷试题ids", 2, esid, "考试科目id", 1});
87
-        return correctTeacherService.getCorrectQuestion(teacherid, eptqids, vo.getClassids(), esid);
86
+        N_Utils.validation(new Object[]{teacherid, "教师id", 1, eptqid, "试卷试题id", 1, esid, "考试科目id", 1});
87
+        return correctTeacherService.getCorrectQuestion(teacherid, eptqid, vo.getClassids(), esid);
88 88
     }
89 89
 
90 90
     /**
@@ -97,10 +97,10 @@ public class EPaperCorrectTeacherController {
97 97
      **/
98 98
     @PostMapping("/get_pre")
99 99
     public ResultVo getPreQuestion(@RequestBody EPTeacherVo vo) {
100
-        Integer epid = vo.getEpid();
100
+        Integer eptqid = vo.getEptqid();
101 101
         Integer teacherid = vo.getTeacherid();
102
-        N_Utils.validation(new Object[]{epid, "试卷id", 1, teacherid, "教师id", 1});
103
-        return correctTeacherService.getPreQuestion(epid, teacherid);
102
+        N_Utils.validation(new Object[]{eptqid, "试卷试题id", 1, teacherid, "教师id", 1});
103
+        return correctTeacherService.getPreQuestion(eptqid, teacherid);
104 104
     }
105 105
 
106 106
     /**

+ 2
- 2
sexam/src/main/java/com/xhkjedu/sexam/mapper/paper/EPaperCorrectTeacherMapper.java Ver fichero

@@ -16,7 +16,7 @@ public interface EPaperCorrectTeacherMapper {
16 16
 
17 17
     //随机获取一条待批阅试题
18 18
     EPaperSQuestionVo getCorrectQuestion(@Param("teacherid") Integer teacherid,
19
-                                         @Param("eptqids") String eptqids, @Param("classids") String classids);
19
+                                         @Param("eptqid") Integer eptqid, @Param("classids") String classids);
20 20
 
21 21
     //试题批阅情况
22 22
     EPaperSQuestionVo getCheckQuestion(@Param("eptqid") Integer eptqid, @Param("teacherid") Integer teacherid);
@@ -25,7 +25,7 @@ public interface EPaperCorrectTeacherMapper {
25 25
     void updateCheckQuestionById(@Param("epsqid") Integer epsqid, @Param("teacherid") Integer teacherid);
26 26
 
27 27
     //获取上一份批阅试题
28
-    Map getPreQuestion(@Param("epid") Integer epid, @Param("teacherid") Integer teacherid);
28
+    Map getPreQuestion(@Param("eptqid") Integer eptqid, @Param("teacherid") Integer teacherid);
29 29
 
30 30
     //阅卷记录
31 31
     List<Map> listRecord(@Param("eptqid") Integer eptqid, @Param("teacherid") Integer teacherid);

+ 8
- 1
sexam/src/main/java/com/xhkjedu/sexam/mapper/report/EReportGenerateMapper.java Ver fichero

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sexam.mapper.report;
2 2
 
3
+import com.xhkjedu.sexam.model.reportstu.ERstudent;
3 4
 import com.xhkjedu.sexam.vo.report.ERPaperVo;
4 5
 import org.apache.ibatis.annotations.Param;
5 6
 
@@ -17,5 +18,11 @@ public interface EReportGenerateMapper {
17 18
     List<Map> listSubject(@Param("examid") Integer examid);
18 19
 
19 20
     //考试试卷
20
-    public List<ERPaperVo> listPaper(@Param("examid") Integer examid);
21
+    List<ERPaperVo> listPaper(@Param("examid") Integer examid);
22
+
23
+    //删除考试报告
24
+    void deleteExamReport(@Param("examid") Integer examid);
25
+
26
+    //学生上次考试排名及目标
27
+    List<ERstudent> listStuRankAndGoal(@Param("examid") Integer examid);
21 28
 }

+ 2
- 2
sexam/src/main/java/com/xhkjedu/sexam/service/paper/EPaperCorrectTeacherService.java Ver fichero

@@ -37,12 +37,12 @@ public class EPaperCorrectTeacherService {
37 37
     }
38 38
 
39 39
     //随机获取待批试题
40
-    public ResultVo getCorrectQuestion(Integer teacherid, String eptqids, String classids, Integer esid) {
40
+    public ResultVo getCorrectQuestion(Integer teacherid, Integer eptqid, String classids, Integer esid) {
41 41
         lock.lock();
42 42
         Map map = correctTeacherMapper.getExamNameByEsId(esid);//根据考试科目id获取考试名称
43 43
         try {
44 44
             //随机获取一条待批阅试题
45
-            EPaperSQuestionVo sq = correctTeacherMapper.getCorrectQuestion(teacherid, eptqids, classids);
45
+            EPaperSQuestionVo sq = correctTeacherMapper.getCorrectQuestion(teacherid, eptqid, classids);
46 46
             if (sq == null) return new ResultVo(0, "已批阅完成");
47 47
             //修改试卷学生试题为批阅中
48 48
             correctTeacherMapper.updateCheckQuestionById(sq.getEpsqid(), teacherid);

+ 39
- 58
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java Ver fichero

@@ -2,7 +2,6 @@ package com.xhkjedu.sexam.service.report;
2 2
 
3 3
 import com.alibaba.fastjson.JSON;
4 4
 import com.xhkjedu.sexam.mapper.exam.EClassMapper;
5
-import com.xhkjedu.sexam.mapper.paper.EPaperAnalyzeMapper;
6 5
 import com.xhkjedu.sexam.mapper.paper.EPaperQtypeMapper;
7 6
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
8 7
 import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentQuestionMapper;
@@ -14,28 +13,31 @@ import com.xhkjedu.sexam.mapper.reportclass.ERclassQtypeMapper;
14 13
 import com.xhkjedu.sexam.mapper.reportclass.ERclassQuestionMapper;
15 14
 import com.xhkjedu.sexam.mapper.reportclass.ERclassQuestionPointMapper;
16 15
 import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
17
-import com.xhkjedu.sexam.model.paper.EPaperAnalyze;
18 16
 import com.xhkjedu.sexam.model.paperstudent.EPaperStudentQuestion;
19 17
 import com.xhkjedu.sexam.model.report.ERbase;
20 18
 import com.xhkjedu.sexam.model.report.ERsubject;
21 19
 import com.xhkjedu.sexam.model.reportclass.ERclass;
22 20
 import com.xhkjedu.sexam.model.reportclass.ERclassQtype;
23 21
 import com.xhkjedu.sexam.model.reportclass.ERclassQuestion;
24
-import com.xhkjedu.sexam.model.reportclass.ERclassQuestionPoint;
25 22
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
26 23
 import com.xhkjedu.sexam.utils.ExamUtil;
27 24
 import com.xhkjedu.sexam.vo.paper.EPaperQPointVo;
28
-import com.xhkjedu.sexam.vo.paper.EPaperQsVo;
29 25
 import com.xhkjedu.sexam.vo.paper.EPaperQtypeQuestionVo;
30 26
 import com.xhkjedu.sexam.vo.paper.EPaperQtypeVo;
31 27
 import com.xhkjedu.sexam.vo.report.ERClassScoreVo;
32 28
 import com.xhkjedu.sexam.vo.report.ERPaperVo;
33 29
 import com.xhkjedu.utils.N_Utils;
34
-
35 30
 import org.springframework.beans.BeanUtils;
36 31
 import org.springframework.stereotype.Service;
32
+import org.springframework.transaction.annotation.Transactional;
33
+
37 34
 import javax.annotation.Resource;
38
-import java.util.*;
35
+import java.util.ArrayList;
36
+import java.util.Comparator;
37
+import java.util.DoubleSummaryStatistics;
38
+import java.util.HashMap;
39
+import java.util.List;
40
+import java.util.Map;
39 41
 import java.util.stream.Collectors;
40 42
 
41 43
 /**
@@ -56,8 +58,7 @@ public class EReportGenerateService {
56 58
     private EPaperQtypeMapper ePaperQtypeMapper;
57 59
     @Resource
58 60
     private EPaperStudentQuestionMapper ePaperStudentQuestionMapper;
59
-    @Resource
60
-    private EPaperAnalyzeMapper ePaperAnalyzeMapper;
61
+
61 62
 
62 63
     @Resource
63 64
     private ERbaseMapper eRbaseMapper;
@@ -76,7 +77,13 @@ public class EReportGenerateService {
76 77
 
77 78
 
78 79
     //生成考试报告
80
+    @Transactional(rollbackFor = Exception.class)
79 81
     public void generateExamReport(Integer examid) {
82
+        //生成前先删除以前的考试报告
83
+        eReportGenerateMapper.deleteExamReport(examid);
84
+        //学生上次考试排名及目标
85
+        List<ERstudent> stuRankGoals = eReportGenerateMapper.listStuRankAndGoal(examid);
86
+
80 87
         List<Map> classes = eClassMapper.listByExamId(examid);
81 88
         List<Map> subjects = eReportGenerateMapper.listSubject(examid);
82 89
         List<ERPaperVo> papers = eReportGenerateMapper.listPaper(examid);
@@ -158,9 +165,6 @@ public class EReportGenerateService {
158 165
         Map<String, List<ERstudent>> subCollect = students.stream().collect(Collectors.groupingBy(s -> s.getSubjectid()));
159 166
         List<ERsubject> subjectList = new ArrayList<>();//考试报告科目情况
160 167
         List<ERclass> classList = new ArrayList<>();//考试报告班级情况
161
-        List<ERclassQtype> qtypeList = new ArrayList<>();//考试报告班级题型情况
162
-        List<ERclassQuestion> questionList = new ArrayList<>();//考试报告班级试题情况
163
-        List<ERclassQuestionPoint> pointList = new ArrayList<>();//考试报告班级试题知识点情况
164 168
         for (Map.Entry<String, List<ERstudent>> ssEntry : subCollect.entrySet()) {
165 169
             subjectid = ssEntry.getKey();
166 170
             subjectname = subjectMap.get(subjectid);
@@ -244,30 +248,6 @@ public class EReportGenerateService {
244 248
                 rc.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
245 249
                 rc.setBzc(ExamUtil.standardDiviation(scores));
246 250
                 classList.add(rc);
247
-                List<EPaperQsVo> typelist = JSON.parseArray(rp.getQnumjson(), EPaperQsVo.class);
248
-                for (EPaperQsVo t : typelist) {
249
-                    ERclassQtype rt = new ERclassQtype();
250
-                    rt.setExamid(examid);
251
-                    rt.setClassid(classid);
252
-                    rt.setSubjectid(subjectid);
253
-                    rt.setQtypename(t.getQtname());
254
-                    rt.setScore(t.getScore());
255
-                    rt.setNum(t.getNum());
256
-                    rt.setSrate(t.getSrate());
257
-                    qtypeList.add(rt);
258
-                }
259
-
260
-                List<Map> points = JSON.parseArray(rp.getQnumjson(), Map.class);
261
-                for (Map p : points) {
262
-                    ERclassQuestionPoint rqp = new ERclassQuestionPoint();
263
-                    rqp.setExamid(examid);
264
-                    rqp.setClassid(classid);
265
-                    rqp.setSubjectid(subjectid);
266
-                    rqp.setPointname(p.get("pointname").toString());
267
-                    rqp.setScore((Double) p.get("score"));
268
-                    rqp.setSrate((Double) p.get("srate"));
269
-                    pointList.add(rqp);
270
-                }
271 251
             }
272 252
         }
273 253
 
@@ -284,9 +264,11 @@ public class EReportGenerateService {
284 264
             cs.setClassrank(classStuRank.get(cs.getClassid() + "_" + studentid));
285 265
             cs.setClassmaxscore(classStatistics.getMax());
286 266
             cs.setClassavgscore(classStatistics.getAverage());
287
-            cs.setSchoolrank(schoolStuRank.get(studentid));
267
+            Integer schoolrank = schoolStuRank.get(studentid);
268
+            cs.setSchoolrank(schoolrank);
288 269
             cs.setSchoolmaxscore(schoolStatisticsMax);
289 270
             cs.setSchoolavgscore(schoolStatisticsAverage);
271
+            setStuGoal(stuRankGoals, cs, schoolrank);//设置学生目标
290 272
         }
291 273
         eRstudentMapper.insertList(classStudents);
292 274
 
@@ -298,11 +280,30 @@ public class EReportGenerateService {
298 280
             cs.setClassrank(classSubStuRank.get(classid + "_" + subjectid + "_" + studentid));
299 281
             cs.setClassmaxscore(cSStatistics.getMax());
300 282
             cs.setClassavgscore(cSStatistics.getAverage());
301
-            cs.setSchoolrank(schoolSubStuRank.get(subjectid + "_" + studentid));
283
+            Integer schoolrank = schoolSubStuRank.get(subjectid + "_" + studentid);
284
+            cs.setSchoolrank(schoolrank);
302 285
             cs.setSchoolmaxscore(sSStatistics.getMax());
303 286
             cs.setSchoolavgscore(sSStatistics.getAverage());
287
+            setStuGoal(stuRankGoals, cs, schoolrank);//设置学生目标
304 288
         }
305 289
         eRstudentMapper.insertList(classSubjectStudents);
290
+
291
+        setClassQuestion(examid, subjects, classes);//题型试题
292
+    }
293
+
294
+    //设置学生目标
295
+    private void setStuGoal(List<ERstudent> stuRankGoals, ERstudent cs, Integer schoolrank) {
296
+        String goalparam = "0.2";
297
+        ERstudent rg = stuRankGoals.stream().filter(s -> s.getStudentid().equals(cs.getStudentid())
298
+                && s.getSubjectid().equals(cs.getSubjectid())).findFirst().orElse(null);
299
+        Integer goal = 0;
300
+        Integer nextgoal = 0;
301
+        if (rg != null) {
302
+            goal = rg.getNextgoal();
303
+            nextgoal = ExamUtil.getUserGroupGoalByParam(schoolrank, goalparam);
304
+        }
305
+        cs.setGoal(goal);
306
+        cs.setNextgoal(nextgoal);
306 307
     }
307 308
 
308 309
     //分数排名
@@ -334,7 +335,7 @@ public class EReportGenerateService {
334 335
         }
335 336
     }
336 337
 
337
-    //试卷题型试题、知识点
338
+    //题型试题
338 339
     private void setClassQuestion(Integer examid,List<Map> subjects,List<Map> classes){
339 340
         //考试所有学生提交试卷情况
340 341
         List<EPaperStudentQuestion> stulist = ePaperStudentQuestionMapper.listExamStudentsAnswer(examid);
@@ -460,26 +461,6 @@ public class EReportGenerateService {
460 461
                     rtypelist.add(eRclassQtype);
461 462
                 }
462 463
             }
463
-
464
-            if(ptype == 1){
465
-                //获取试卷只是分析
466
-                Map epa = ePaperAnalyzeMapper.getPaperAnalzyeByEpid(epid);
467
-                String pointjson = epa.get("pointjson").toString();
468
-                List<Map> pointlist = JSON.parseArray(pointjson,Map.class);
469
-                //遍历知识点处理年级班级知识点情况
470
-                for(int j=0;j<pointlist.size();j++){
471
-                    Map pointmap = pointlist.get(j);
472
-                    String pointname = pointmap.get("pointname").toString();
473
-                    Double score = Double.parseDouble(pointmap.get("score").toString());
474
-                    Double scorerate = Double.parseDouble(pointmap.get("scorerate").toString());
475
-                    String order = pointmap.get("order").toString();
476
-
477
-                
478
-                }
479
-
480
-            }
481
-
482
-
483 464
         }
484 465
         eRclassQtypeMapper.insertList(rtypelist);
485 466
         eRclassQuestionMapper.insertList(rqlist);

+ 20
- 0
sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java Ver fichero

@@ -1,5 +1,6 @@
1 1
 package com.xhkjedu.sexam.utils;
2 2
 
3
+import com.xhkjedu.utils.N_Utils;
3 4
 import lombok.extern.slf4j.Slf4j;
4 5
 
5 6
 import java.math.BigDecimal;
@@ -153,4 +154,23 @@ public class ExamUtil {
153 154
     public static double standardDiviation(List<Double> x) {
154 155
         return Math.sqrt(variance(x));
155 156
     }
157
+
158
+    /**
159
+     * 根据本次排名和参数计算下次的目标
160
+     *
161
+     * @param countschool:本次排名
162
+     * @param goalparam:进步目标参数
163
+     * @return
164
+     */
165
+    public static Integer getUserGroupGoalByParam(Integer countschool, String goalparam) {
166
+        if (countschool != null && (1 == countschool || 2 == countschool)) {//若本次是第一名或者第二名,则下次目标一定是第一名
167
+            return 1;
168
+        } else {
169
+            BigDecimal count = countschool == null || N_Utils.isEmpty(goalparam) ? new BigDecimal(0) :
170
+                    new BigDecimal(goalparam).multiply(new BigDecimal(countschool.toString()));//进步的名次
171
+            Integer thiscount = countschool == null ? 0 : new BigDecimal(countschool.toString()).subtract(count).intValue();
172
+            //舍弃小数点
173
+            return thiscount;
174
+        }
175
+    }
156 176
 }

+ 1
- 1
sexam/src/main/java/com/xhkjedu/sexam/vo/paper/EPTeacherVo.java Ver fichero

@@ -20,7 +20,7 @@ public class EPTeacherVo {
20 20
     private Integer teacherid;
21 21
 
22 22
     //试卷试题ids
23
-    private String eptqids;
23
+    private Integer eptqid;
24 24
 
25 25
     //班级ids
26 26
     private String classids;

+ 2
- 2
sexam/src/main/resources/mapper/paper/EPaperCorrectTeacherMapper.xml Ver fichero

@@ -50,7 +50,7 @@
50 50
     <!--随机获取一条待批阅试题-->
51 51
     <select id="getCorrectQuestion" resultType="com.xhkjedu.sexam.vo.paper.EPaperSQuestionVo">
52 52
         select psq.epsqid,psq.stuanswer,psq.qn,psq.eptqid,psq.qscore,psq.epsid
53
-        from e_paper_student_question psq where psq.eptqid in(${eptqids})
53
+        from e_paper_student_question psq where psq.eptqid=#{eptqid}
54 54
         and psq.answered=1 and (psq.checked=0 or (psq.checked=1 and psq.checkid=#{teacherid}))
55 55
         <if test="classids!=null and classids!=''">
56 56
             and psq.classid in(${classids})
@@ -70,7 +70,7 @@
70 70
     <!--获取上一份批阅试题-->
71 71
     <select id="getPreQuestion" resultType="java.util.Map">
72 72
         select psq.epsqid,psq.stuanswer,psq.qn,psq.qorder,psq.qscore,psq.stuscore,psq.good,psq.bad,psq.epsid
73
-        from e_paper_student_question psq where psq.epid=#{epid} and psq.checked=2 and psq.checkid=#{teacherid}
73
+        from e_paper_student_question psq where psq.eptqid=#{eptqid} and psq.checked=2 and psq.checkid=#{teacherid}
74 74
         order by psq.checktime desc limit 1
75 75
     </select>
76 76
     <!--阅卷记录-->

+ 21
- 3
sexam/src/main/resources/mapper/report/EReportGenerateMapper.xml Ver fichero

@@ -8,8 +8,26 @@
8 8
     </select>
9 9
     <!--考试试卷-->
10 10
     <select id="listPaper" resultType="com.xhkjedu.sexam.vo.report.ERPaperVo">
11
-        select ep.subjectid,ep.pscore,epa.qnumjson,epa.complexityjson,epa.pointjson
12
-        from e_paper ep left join e_paper_analyze epa on ep.epid = epa.epid
13
-        where ep.examid=#{examid}
11
+        select ep.subjectid,ep.pscore from e_paper ep where ep.examid=#{examid}
12
+    </select>
13
+    <!--删除考试报告-->
14
+    <delete id="deleteExamReport">
15
+        delete from e_rbase where examid=#{examid};
16
+        delete from e_rclass where examid=#{examid};
17
+        delete from e_rclass_qtype where examid=#{examid};
18
+        delete from e_rclass_question where examid=#{examid};
19
+        delete from e_rclass_question_point where examid=#{examid};
20
+        delete from e_rclass_rank where examid=#{examid};
21
+        delete from e_rgrade_rank where examid=#{examid};
22
+        delete from e_rrank where examid=#{examid};
23
+        delete from e_rstudent where examid=#{examid};
24
+        delete from e_rstudent_point where examid=#{examid};
25
+        delete from e_rsubject where examid=#{examid};
26
+    </delete>
27
+    <!--学生上次考试排名及目标-->
28
+    <select id="listStuRankAndGoal" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
29
+        select er.studentid,er.subjectid,er.schoolrank,er.nextgoal
30
+        from(select max(er.rsid)rsid from e_class_student ecs left join e_rstudent er on ecs.studentid = er.studentid
31
+        where ecs.examid=#{examid} group by er.studentid,er.subjectid)a left join e_rstudent er on a.rsid=er.rsid
14 32
     </select>
15 33
 </mapper>

Loading…
Cancelar
Guardar