Procházet zdrojové kódy

考试报告

tags/正式版本
雍文秀 před 2 roky
rodič
revize
90d52a65f6

+ 8
- 1
sexam/src/main/java/com/xhkjedu/sexam/mapper/report/EReportGenerateMapper.java Zobrazit soubor

@@ -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
 }

+ 0
- 42
sexam/src/main/java/com/xhkjedu/sexam/model/reportclass/ERclassQuestionError.java Zobrazit soubor

@@ -1,42 +0,0 @@
1
-package com.xhkjedu.sexam.model.reportclass;
2
-
3
-import com.xhkjedu.sexam.model.BaseBean;
4
-import lombok.Data;
5
-
6
-import javax.persistence.Id;
7
-import javax.persistence.Table;
8
-
9
-@Table(name = "e_rclass_question_error")
10
-@Data
11
-public class ERclassQuestionError extends BaseBean {
12
-    @Id
13
-    //考试报告班级单科高频错题表
14
-    private Integer rceqid;
15
-
16
-    //考试id
17
-    private Integer examid;
18
-
19
-    //班级id
20
-    private Integer classid;
21
-
22
-    //科目id
23
-    private String subjectid;
24
-
25
-    //题号
26
-    private String qn;
27
-
28
-    //题型名称
29
-    private String qtypename;
30
-
31
-    //知识点
32
-    private String pointname;
33
-
34
-    //班级得分率
35
-    private Double classrate;
36
-
37
-    //年级得分率
38
-    private Double graderate;
39
-
40
-    //高频错误项
41
-    private String errormsg;
42
-}

+ 37
- 35
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java Zobrazit soubor

@@ -20,22 +20,25 @@ import com.xhkjedu.sexam.model.report.ERsubject;
20 20
 import com.xhkjedu.sexam.model.reportclass.ERclass;
21 21
 import com.xhkjedu.sexam.model.reportclass.ERclassQtype;
22 22
 import com.xhkjedu.sexam.model.reportclass.ERclassQuestion;
23
-import com.xhkjedu.sexam.model.reportclass.ERclassQuestionError;
24
-import com.xhkjedu.sexam.model.reportclass.ERclassQuestionPoint;
25 23
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
26 24
 import com.xhkjedu.sexam.utils.ExamUtil;
27 25
 import com.xhkjedu.sexam.vo.paper.EPaperQPointVo;
28
-import com.xhkjedu.sexam.vo.paper.EPaperQsVo;
29 26
 import com.xhkjedu.sexam.vo.paper.EPaperQtypeQuestionVo;
30 27
 import com.xhkjedu.sexam.vo.paper.EPaperQtypeVo;
31 28
 import com.xhkjedu.sexam.vo.report.ERClassScoreVo;
32 29
 import com.xhkjedu.sexam.vo.report.ERPaperVo;
33 30
 import com.xhkjedu.utils.N_Utils;
34
-
35 31
 import org.springframework.beans.BeanUtils;
36 32
 import org.springframework.stereotype.Service;
33
+import org.springframework.transaction.annotation.Transactional;
34
+
37 35
 import javax.annotation.Resource;
38
-import java.util.*;
36
+import java.util.ArrayList;
37
+import java.util.Comparator;
38
+import java.util.DoubleSummaryStatistics;
39
+import java.util.HashMap;
40
+import java.util.List;
41
+import java.util.Map;
39 42
 import java.util.stream.Collectors;
40 43
 
41 44
 /**
@@ -77,7 +80,13 @@ public class EReportGenerateService {
77 80
 
78 81
 
79 82
     //生成考试报告
83
+    @Transactional(rollbackFor = Exception.class)
80 84
     public void generateExamReport(Integer examid) {
85
+        //生成前先删除以前的考试报告
86
+        eReportGenerateMapper.deleteExamReport(examid);
87
+        //学生上次考试排名及目标
88
+        List<ERstudent> stuRankGoals = eReportGenerateMapper.listStuRankAndGoal(examid);
89
+
81 90
         List<Map> classes = eClassMapper.listByExamId(examid);
82 91
         List<Map> subjects = eReportGenerateMapper.listSubject(examid);
83 92
         List<ERPaperVo> papers = eReportGenerateMapper.listPaper(examid);
@@ -159,10 +168,6 @@ public class EReportGenerateService {
159 168
         Map<String, List<ERstudent>> subCollect = students.stream().collect(Collectors.groupingBy(s -> s.getSubjectid()));
160 169
         List<ERsubject> subjectList = new ArrayList<>();//考试报告科目情况
161 170
         List<ERclass> classList = new ArrayList<>();//考试报告班级情况
162
-        List<ERclassQtype> qtypeList = new ArrayList<>();//考试报告班级题型情况
163
-        List<ERclassQuestion> questionList = new ArrayList<>();//考试报告班级试题情况
164
-        List<ERclassQuestionError> errorList = new ArrayList<>();//考试报告班级高频错题情况
165
-        List<ERclassQuestionPoint> pointList = new ArrayList<>();//考试报告班级试题知识点情况
166 171
         for (Map.Entry<String, List<ERstudent>> ssEntry : subCollect.entrySet()) {
167 172
             subjectid = ssEntry.getKey();
168 173
             subjectname = subjectMap.get(subjectid);
@@ -246,30 +251,6 @@ public class EReportGenerateService {
246 251
                 rc.setDfrate(N_Utils.getIntegerDivideAndMulitiply(dfnum, stunum));
247 252
                 rc.setBzc(ExamUtil.standardDiviation(scores));
248 253
                 classList.add(rc);
249
-                List<EPaperQsVo> typelist = JSON.parseArray(rp.getQnumjson(), EPaperQsVo.class);
250
-                for (EPaperQsVo t : typelist) {
251
-                    ERclassQtype rt = new ERclassQtype();
252
-                    rt.setExamid(examid);
253
-                    rt.setClassid(classid);
254
-                    rt.setSubjectid(subjectid);
255
-                    rt.setQtypename(t.getQtname());
256
-                    rt.setScore(t.getScore());
257
-                    rt.setNum(t.getNum());
258
-                    rt.setSrate(t.getSrate());
259
-                    qtypeList.add(rt);
260
-                }
261
-
262
-                List<Map> points = JSON.parseArray(rp.getQnumjson(), Map.class);
263
-                for (Map p : points) {
264
-                    ERclassQuestionPoint rqp = new ERclassQuestionPoint();
265
-                    rqp.setExamid(examid);
266
-                    rqp.setClassid(classid);
267
-                    rqp.setSubjectid(subjectid);
268
-                    rqp.setPointname(p.get("pointname").toString());
269
-                    rqp.setScore((Double) p.get("score"));
270
-                    rqp.setSrate((Double) p.get("srate"));
271
-                    pointList.add(rqp);
272
-                }
273 254
             }
274 255
         }
275 256
 
@@ -286,9 +267,11 @@ public class EReportGenerateService {
286 267
             cs.setClassrank(classStuRank.get(cs.getClassid() + "_" + studentid));
287 268
             cs.setClassmaxscore(classStatistics.getMax());
288 269
             cs.setClassavgscore(classStatistics.getAverage());
289
-            cs.setSchoolrank(schoolStuRank.get(studentid));
270
+            Integer schoolrank = schoolStuRank.get(studentid);
271
+            cs.setSchoolrank(schoolrank);
290 272
             cs.setSchoolmaxscore(schoolStatisticsMax);
291 273
             cs.setSchoolavgscore(schoolStatisticsAverage);
274
+            setStuGoal(stuRankGoals, cs, schoolrank);//设置学生目标
292 275
         }
293 276
         eRstudentMapper.insertList(classStudents);
294 277
 
@@ -300,11 +283,30 @@ public class EReportGenerateService {
300 283
             cs.setClassrank(classSubStuRank.get(classid + "_" + subjectid + "_" + studentid));
301 284
             cs.setClassmaxscore(cSStatistics.getMax());
302 285
             cs.setClassavgscore(cSStatistics.getAverage());
303
-            cs.setSchoolrank(schoolSubStuRank.get(subjectid + "_" + studentid));
286
+            Integer schoolrank = schoolSubStuRank.get(subjectid + "_" + studentid);
287
+            cs.setSchoolrank(schoolrank);
304 288
             cs.setSchoolmaxscore(sSStatistics.getMax());
305 289
             cs.setSchoolavgscore(sSStatistics.getAverage());
290
+            setStuGoal(stuRankGoals, cs, schoolrank);//设置学生目标
306 291
         }
307 292
         eRstudentMapper.insertList(classSubjectStudents);
293
+
294
+        setClassQuestion(examid, subjects, classes);//题型试题
295
+    }
296
+
297
+    //设置学生目标
298
+    private void setStuGoal(List<ERstudent> stuRankGoals, ERstudent cs, Integer schoolrank) {
299
+        String goalparam = "0.2";
300
+        ERstudent rg = stuRankGoals.stream().filter(s -> s.getStudentid().equals(cs.getStudentid())
301
+                && s.getSubjectid().equals(cs.getSubjectid())).findFirst().orElse(null);
302
+        Integer goal = 0;
303
+        Integer nextgoal = 0;
304
+        if (rg != null) {
305
+            goal = rg.getNextgoal();
306
+            nextgoal = ExamUtil.getUserGroupGoalByParam(schoolrank, goalparam);
307
+        }
308
+        cs.setGoal(goal);
309
+        cs.setNextgoal(nextgoal);
308 310
     }
309 311
 
310 312
     //分数排名

+ 20
- 0
sexam/src/main/java/com/xhkjedu/sexam/utils/ExamUtil.java Zobrazit soubor

@@ -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
 }

+ 18
- 5
sexam/src/main/resources/mapper/report/EReportGenerateMapper.xml Zobrazit soubor

@@ -8,12 +8,25 @@
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}
14 12
     </select>
15
-    <select id="listStu" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
16
-        select er.studentid,er.subjectid,er.classrank,er.schoolrank
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
17 30
         from(select max(er.rsid)rsid from e_class_student ecs left join e_rstudent er on ecs.studentid = er.studentid
18 31
         where ecs.examid=#{examid} group by er.studentid,er.subjectid)a left join e_rstudent er on a.rsid=er.rsid
19 32
     </select>

Načítá se…
Zrušit
Uložit