浏览代码

学科、学生成绩分析

ywx
雍文秀 1 个月前
父节点
当前提交
dd44f6995d

+ 3
- 1
smarking/src/main/java/com/xhkjedu/smarking/model/report/reportsubject/MsrSubject.java 查看文件

@@ -31,8 +31,10 @@ public class MsrSubject extends BaseBean {
31 31
     private Double minscore;
32 32
     //平均分
33 33
     private Double avgscore;
34
-    //平均成绩排名
34
+    //平均成绩排名
35 35
     private Integer avgrank;
36
+    //平均成绩排名率
37
+    private Double avgrankrate;
36 38
     //得分率
37 39
     private Double scorerate;
38 40
     //总人数

+ 90
- 39
smarking/src/main/java/com/xhkjedu/smarking/service/report/reportother/MsrExamService.java 查看文件

@@ -2,13 +2,14 @@ package com.xhkjedu.smarking.service.report.reportother;
2 2
 
3 3
 import com.xhkjedu.smarking.mapper.exam.*;
4 4
 import com.xhkjedu.smarking.mapper.report.reportother.MsrExamMapper;
5
+import com.xhkjedu.smarking.mapper.report.reportstu.MsrStudentMapper;
6
+import com.xhkjedu.smarking.mapper.report.reportsubject.MsrSubjectMapper;
5 7
 import com.xhkjedu.smarking.mapper.stupaper.MsPaperStudentMapper;
6 8
 import com.xhkjedu.smarking.model.exam.*;
7 9
 import com.xhkjedu.smarking.model.paper.MsPaper;
8 10
 import com.xhkjedu.smarking.model.report.reportother.MsrExam;
9 11
 import com.xhkjedu.smarking.model.report.reportstu.MsrStudent;
10 12
 import com.xhkjedu.smarking.model.report.reportsubject.MsrSubject;
11
-import com.xhkjedu.smarking.model.stupaper.MsPaperStudent;
12 13
 import com.xhkjedu.smarking.utils.MarkingUtil;
13 14
 import com.xhkjedu.utils.N_Utils;
14 15
 import org.springframework.stereotype.Service;
@@ -36,6 +37,10 @@ public class MsrExamService {
36 37
     private MsClassStudentMapper classStudentMapper;
37 38
     @Resource
38 39
     private MsPaperStudentMapper paperStudentMapper;
40
+    @Resource
41
+    private MsrSubjectMapper msrSubjectMapper;
42
+    @Resource
43
+    private MsrStudentMapper msrStudentMapper;
39 44
 
40 45
     /**
41 46
      * @Description 生成报告
@@ -52,15 +57,13 @@ public class MsrExamService {
52 57
         List<MsClass> classes = classMapper.listClassByExamId(examid);//获取考试关联班级
53 58
         List<MsClassStudent> students = classStudentMapper.listStudentByExamId(examid);//获取考试关联学生
54 59
         List<Integer> mpids = new ArrayList<>();
55
-        Map<String, Double> paperScoreMap = new HashMap<>();
56 60
         for (MsPaper subject : subjects) {
57 61
             Integer mpid = subject.getMpid();
58 62
             mpids.add(mpid);
59
-            paperScoreMap.put(subject.getSubjectid(), subject.getPscore());
60 63
         }
61 64
         List<MsrStudent> paperStudents = paperStudentMapper.listPaperStudentByExamId(examid, mpids);//试学生成绩列表
62 65
         for (MsrStudent student : paperStudents) {
63
-            student.setScorerate(N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), paperScoreMap.get(student.getSubjectid())));
66
+            student.setScorerate(N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), student.getFullscore()));
64 67
         }
65 68
 
66 69
         Integer classnum = N_Utils.obj2Int(classes.stream().map(MsClass::getClassid).distinct().count());
@@ -69,8 +72,7 @@ public class MsrExamService {
69 72
         Integer missnum = totalnum - stunum;
70 73
         double fullscore = subjects.stream().mapToDouble(MsPaper::getPscore).sum();
71 74
         List<MsrStudent> schoolStudents = new ArrayList<>();//学校学生成绩
72
-        List<MsrStudent> schoolSubjectStudents = new ArrayList<>();//学校科目学生成绩
73
-        List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩
75
+        List<MsrStudent> classStudents = new ArrayList<>();//班级学生成绩(总分)
74 76
         List<MsrStudent> classSubjectStudents = new ArrayList<>();//班级科目学生成绩
75 77
         Map<String, Integer> schoolStuRank = new HashMap<>();//学校学生分数排名
76 78
         Map<String, Integer> schoolSubStuRank = new HashMap<>();//学校科目学生分数排名
@@ -106,6 +108,7 @@ public class MsrExamService {
106 108
             }
107 109
         }
108 110
         String subjectid;
111
+        Map<String, Double> bjdfMap = new HashMap<>();//班级得分
109 112
         Map<Integer, List<MsrStudent>> cCollect = paperStudents2.stream().collect(Collectors.groupingBy(MsrStudent::getClassid));
110 113
         for (Map.Entry<Integer, List<MsrStudent>> entry : cCollect.entrySet()) {
111 114
             Integer classid = entry.getKey();
@@ -123,15 +126,19 @@ public class MsrExamService {
123 126
                 cs.setStuscore(csEntry.getValue().stream().mapToDouble(MsrStudent::getStuscore).sum());
124 127
                 rstudents.add(cs);
125 128
             }
129
+            bjdfMap.put(classid + "_" + subjectid, rstudents.stream().mapToDouble(MsrStudent::getStuscore).sum());
126 130
             setRank(rstudents, classStuRank, 3);//班级学生分数排名
127 131
             classStudents.addAll(rstudents);
128 132
             Map<String, List<MsrStudent>> subCollect = studentList.stream().collect(Collectors.groupingBy(MsrStudent::getSubjectid));
129 133
             for (Map.Entry<String, List<MsrStudent>> ssEntry : subCollect.entrySet()) {
134
+                subjectid = ssEntry.getKey();
130 135
                 rstudents = ssEntry.getValue();
136
+                bjdfMap.put(classid + "_" + subjectid, rstudents.stream().mapToDouble(MsrStudent::getStuscore).sum());
131 137
                 setRank(rstudents, classSubStuRank, 4);//班级科目学生分数排名
132 138
                 classSubjectStudents.addAll(rstudents);
133 139
             }
134 140
         }
141
+        setRank(schoolStudents, schoolStuRank, 1);//学校学生分数排名
135 142
 
136 143
         List<MsrStudent> schoolStudents2 = schoolStudents.stream().filter(s -> s.getSstate().equals(2)).collect(Collectors.toList());//参与统计学生列表
137 144
         DoubleSummaryStatistics schoolStatistics = schoolStudents2.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
@@ -154,42 +161,33 @@ public class MsrExamService {
154 161
         msrExamMapper.insert(msrExam);
155 162
 
156 163
         //科目分析
164
+        Map<String, MsrSubject> subjectMap = new HashMap<>();//科目分析map
157 165
         Map<String, List<MsrStudent>> subjectCollect = paperStudents.stream().collect(Collectors.groupingBy(MsrStudent::getSubjectid));
158 166
         List<MsrSubject> msrSubjects = new ArrayList<>();
159 167
         MsrSubject msrSubject = new MsrSubject();
160 168
         msrSubject.setExamid(examid);
161
-        msrSubject.setSubjectid("zf");
169
+        subjectid = "zf";
170
+        msrSubject.setSubjectid(subjectid);
162 171
         msrSubject.setSubjectname("总分");
163 172
         msrSubject.setFullscore(fullscore);
164 173
         msrSubject.setMaxscore(schoolStatisticsMax);
165 174
         msrSubject.setMinscore(schoolStatisticsMin);
166 175
         msrSubject.setAvgscore(schoolStatisticsAverage);
167
-        msrSubject.setScorerate(N_Utils.getDoubleDivideAndMulitiply(schoolStatisticsAverage, fullscore));
168
-        List<Double> scores = schoolStudents2.stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
169
-        double bzc = MarkingUtil.bzc(scores);
170
-        msrSubject.setBzc(bzc);
171
-        msrSubject.setCyxs(N_Utils.getDoubleDivideAndMulitiply(bzc, schoolStatisticsAverage));
172
-        msrSubject.setNd(MarkingUtil.div(schoolStatisticsAverage, fullscore));
173
-        msrSubject.setQfd(MarkingUtil.qfd(scores));
174
-        List<Double> scoreRates = schoolStudents2.stream().map(MsrStudent::getScorerate).sorted().collect(Collectors.toList());
175
-        double dfllc = MarkingUtil.sub(scoreRates.get(scoreRates.size() - 1), scoreRates.get(0));
176
-        msrSubject.setDfllc(dfllc);
177
-        msrSubject.setDflxdlc(MarkingUtil.div(dfllc, schoolStatisticsAverage));
178
-        msrSubject.setEsscore(MarkingUtil.cynjdf(scores, 0.2));
179
-        msrSubject.setSsscore(MarkingUtil.cynjdf(scores, 0.4));
180
-        msrSubject.setLsscore(MarkingUtil.cynjdf(scores, 0.6));
181
-        msrSubject.setBsscore(MarkingUtil.cynjdf(scores, 0.8));
182 176
         msrSubject.setTotalnum(totalnum);
183 177
         msrSubject.setStunum(stunum);
184 178
         msrSubject.setMissnum(missnum);
179
+        setSubject(msrSubject, schoolStudents2);
185 180
         msrSubjects.add(msrSubject);
181
+        subjectMap.put(subjectid, msrSubject);
186 182
         for (MsPaper subject : subjects) {
183
+            subjectid = subject.getSubjectid();
187 184
             msrSubject = new MsrSubject();
188 185
             msrSubject.setExamid(examid);
189
-            msrSubject.setSubjectid(subject.getSubjectid());
186
+            msrSubject.setSubjectid(subjectid);
190 187
             msrSubject.setSubjectname(subject.getSubjectname());
191 188
             msrSubject.setFullscore(subject.getPscore());
192
-            List<MsrStudent> studentList = subjectCollect.get(subject.getSubjectid());
189
+            List<MsrStudent> studentList = subjectCollect.get(subjectid);
190
+            setRank(studentList, schoolSubStuRank, 2);//学校科目学生分数排名
193 191
             List<MsrStudent> studentList2 = studentList.stream().filter(s -> s.getSstate().equals(2)).collect(Collectors.toList());//参与统计学生列表
194 192
             totalnum = studentList.size();
195 193
             stunum = studentList2.size();
@@ -205,27 +203,80 @@ public class MsrExamService {
205 203
             msrSubject.setMaxscore(subjectStatisticsMax);
206 204
             msrSubject.setMinscore(subjectStatisticsMin);
207 205
             msrSubject.setAvgscore(subjectStatisticsAverage);
208
-            msrSubject.setScorerate(N_Utils.getDoubleDivideAndMulitiply(subjectStatisticsAverage, fullscore));
209
-            scores = studentList2.stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
210
-            bzc = MarkingUtil.bzc(scores);
211
-            msrSubject.setBzc(bzc);
212
-            msrSubject.setCyxs(N_Utils.getDoubleDivideAndMulitiply(bzc, subjectStatisticsAverage));
213
-            msrSubject.setNd(MarkingUtil.div(subjectStatisticsAverage, fullscore));
214
-            msrSubject.setQfd(MarkingUtil.qfd(scores));
215
-            scoreRates = studentList2.stream().map(MsrStudent::getScorerate).sorted().collect(Collectors.toList());
216
-            dfllc = MarkingUtil.sub(scoreRates.get(scoreRates.size() - 1), scoreRates.get(0));
217
-            msrSubject.setDfllc(dfllc);
218
-            msrSubject.setDflxdlc(MarkingUtil.div(dfllc, subjectStatisticsAverage));
219
-            msrSubject.setEsscore(MarkingUtil.cynjdf(scores, 0.2));
220
-            msrSubject.setSsscore(MarkingUtil.cynjdf(scores, 0.4));
221
-            msrSubject.setLsscore(MarkingUtil.cynjdf(scores, 0.6));
222
-            msrSubject.setBsscore(MarkingUtil.cynjdf(scores, 0.8));
206
+            setSubject(msrSubject, studentList2);
223 207
             msrSubjects.add(msrSubject);
208
+            subjectMap.put(subjectid, msrSubject);
209
+        }
210
+        List<Double> avgScores = msrSubjects.stream().map(MsrSubject::getAvgscore).sorted().collect(Collectors.toList());
211
+        Map<Double, Integer> fspm = MarkingUtil.fspm(avgScores);//平均分排名
212
+        for (MsrSubject subject : msrSubjects) {
213
+            subject.setAvgrank(fspm.get(subject.getAvgscore()));
214
+            subject.setAvgrankrate(MarkingUtil.div(subject.getAvgrank(), subject.getTotalnum()));
215
+        }
216
+        msrSubjectMapper.insertList(msrSubjects);
217
+
218
+        //学生成绩分析
219
+        for (MsrStudent student : classStudents) {
220
+            setStudent(student, classStuRank, schoolStuRank, classSubStuRank, schoolSubStuRank, bjdfMap, subjectMap);
221
+        }
222
+        for (MsrStudent student : classSubjectStudents) {
223
+            setStudent(student, classStuRank, schoolStuRank, classSubStuRank, schoolSubStuRank, bjdfMap, subjectMap);
224 224
         }
225
+        if (N_Utils.isListNotEmpty(classStudents)) msrStudentMapper.insertList(classStudents);
226
+        if (N_Utils.isListNotEmpty(classSubjectStudents)) msrStudentMapper.insertList(classSubjectStudents);
225 227
 
226 228
         examMapper.updateExamState(examid, 3);
227 229
     }
228 230
 
231
+    //设置科目分析计算参数
232
+    private void setSubject(MsrSubject msrSubject, List<MsrStudent> schoolStudents2) {
233
+        Double avgscore = msrSubject.getAvgscore();
234
+        Double fullscore = msrSubject.getFullscore();
235
+        msrSubject.setScorerate(N_Utils.getDoubleDivideAndMulitiply(avgscore, fullscore));
236
+        List<Double> scores = schoolStudents2.stream().map(MsrStudent::getStuscore).sorted().collect(Collectors.toList());
237
+        double bzc = MarkingUtil.bzc(scores);
238
+        msrSubject.setBzc(bzc);
239
+        msrSubject.setCyxs(N_Utils.getDoubleDivideAndMulitiply(bzc, avgscore));
240
+        msrSubject.setNd(MarkingUtil.div(avgscore, fullscore));
241
+        msrSubject.setQfd(MarkingUtil.qfd(scores));
242
+        List<Double> scoreRates = schoolStudents2.stream().map(MsrStudent::getScorerate).sorted().collect(Collectors.toList());
243
+        double dfllc = MarkingUtil.sub(scoreRates.get(scoreRates.size() - 1), scoreRates.get(0));
244
+        msrSubject.setDfllc(dfllc);
245
+        msrSubject.setDflxdlc(MarkingUtil.div(dfllc, avgscore));
246
+        msrSubject.setEsscore(MarkingUtil.cynjdf(scores, 0.2));
247
+        msrSubject.setSsscore(MarkingUtil.cynjdf(scores, 0.4));
248
+        msrSubject.setLsscore(MarkingUtil.cynjdf(scores, 0.6));
249
+        msrSubject.setBsscore(MarkingUtil.cynjdf(scores, 0.8));
250
+    }
251
+
252
+    //设置学生分析计算参数
253
+    private void setStudent(MsrStudent student, Map<String, Integer> classStuRank, Map<String, Integer> schoolStuRank
254
+            , Map<String, Integer> classSubStuRank, Map<String, Integer> schoolSubStuRank
255
+            , Map<String, Double> bjdfMap, Map<String, MsrSubject> subjectMap) {
256
+        String subjectid;
257
+        Integer classid = student.getClassid();
258
+        Integer studentid = student.getStudentid();
259
+        subjectid = student.getSubjectid();
260
+        MsrSubject msrSubject = subjectMap.get(subjectid);
261
+        Double pjf = msrSubject.getAvgscore();//年级平均分
262
+        student.setBzf(MarkingUtil.bzf(bjdfMap.get(classid + "_" + subjectid), pjf, msrSubject.getBzc()));
263
+        Integer classrank;
264
+        Integer schoolrank;
265
+        if (subjectid.equals("zf")) {
266
+            classrank = classStuRank.get(classid + "_" + studentid);
267
+            schoolrank = schoolStuRank.get(studentid.toString());
268
+        } else {
269
+            classrank = classSubStuRank.get(classid + "_" + subjectid + "_" + studentid);
270
+            schoolrank = schoolSubStuRank.get(subjectid + "_" + studentid);
271
+        }
272
+        student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
273
+        student.setClassrank(classrank);
274
+        student.setSchoolrank(schoolrank);
275
+        double rankrate = MarkingUtil.div(schoolrank, msrSubject.getTotalnum());
276
+        student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
277
+        student.setXkqrz(MarkingUtil.sub(msrSubject.getAvgrank(), rankrate));//学科强弱值 = 平均成绩排名率- 个人成绩排名率
278
+    }
279
+
229 280
     //分数排名
230 281
     private void setRank(List<MsrStudent> students, Map<String, Integer> rank, Integer code) {
231 282
         List<Map.Entry<Double, List<MsrStudent>>> gslist2 = students.stream()

+ 12
- 0
smarking/src/main/java/com/xhkjedu/smarking/utils/MarkingUtil.java 查看文件

@@ -536,4 +536,16 @@ public class MarkingUtil {
536 536
         return scores.get(totalCount - topCount);
537 537
     }
538 538
 
539
+    //分数排名
540
+    public static Map<Double,Integer> fspm(List<Double> scores) {
541
+        // 创建一个地图来存储分数和出现次数
542
+        Map<Double, Integer> scoreCountMap = new HashMap<>();
543
+
544
+        // 遍历 scores 计算分数出现的次数
545
+        for (Double score : scores) {
546
+            scoreCountMap.put(score, scoreCountMap.getOrDefault(score, 0) + 1);
547
+        }
548
+        return scoreCountMap;
549
+    }
550
+
539 551
 }

+ 1
- 1
smarking/src/main/resources/mapper/exam/MsSubjectMapper.xml 查看文件

@@ -169,7 +169,7 @@
169 169
     <select id="listReportSubject" resultType="com.xhkjedu.smarking.model.paper.MsPaper">
170 170
         select s.subjectid,s.subjectname,p.mpid,p.pnum,p.mergepnum,p.pscore,p.correcttype
171 171
         from ms_subject s inner join ms_paper p on s.msid=p.msid
172
-        where s.examid=#{examid}
172
+        where s.examid=#{examid} and s.msid=2
173 173
         <if test="exammode!=3">
174 174
             and s.msstate=2
175 175
         </if>

+ 2
- 2
smarking/src/main/resources/mapper/stupaper/MsPaperStudentMapper.xml 查看文件

@@ -256,9 +256,9 @@
256 256
     </select>
257 257
     <!--考试学生成绩列表-->
258 258
     <select id="listPaperStudentByExamId" resultType="com.xhkjedu.smarking.model.report.reportstu.MsrStudent">
259
-        select mpid,subjectid,studentid,stuscore
259
+        select mpid,subjectid,studentid,stuscore,sstate,pscore as fullscore
260 260
         from ms_paper_student where examid=#{examid}
261
-        <foreach collection="mpids" item="mpid" separator="and mpid in (">
261
+        <foreach collection="mpids" item="mpid" open="and mpid in (" separator="," close=")">
262 262
             #{mpid}
263 263
         </foreach>
264 264
     </select>

正在加载...
取消
保存