|
@@ -22,6 +22,7 @@ import com.xhkjedu.smarking.vo.report.reportclass.ClassTopVo;
|
22
|
22
|
import com.xhkjedu.smarking.vo.report.reportother.*;
|
23
|
23
|
import com.xhkjedu.utils.N_Utils;
|
24
|
24
|
import org.springframework.stereotype.Service;
|
|
25
|
+import org.springframework.transaction.annotation.Transactional;
|
25
|
26
|
|
26
|
27
|
import javax.annotation.Resource;
|
27
|
28
|
import java.util.*;
|
|
@@ -64,6 +65,8 @@ public class MsrExamService {
|
64
|
65
|
private MsrClassRankgroupMapper msrClassRankgroupMapper;
|
65
|
66
|
@Resource
|
66
|
67
|
private MsrClassRankrateMapper msrClassRankrateMapper;
|
|
68
|
+ @Resource
|
|
69
|
+ private MsrClassSectionMapper msrClassSectionMapper;
|
67
|
70
|
|
68
|
71
|
|
69
|
72
|
/**
|
|
@@ -73,6 +76,7 @@ public class MsrExamService {
|
73
|
76
|
* @Param [examid]
|
74
|
77
|
* @Return void
|
75
|
78
|
**/
|
|
79
|
+ @Transactional(rollbackFor = Exception.class)
|
76
|
80
|
public void generateExamReport(Integer examid) {
|
77
|
81
|
MsExam exam = examMapper.selectByPrimaryKey(examid);
|
78
|
82
|
Integer exammode = exam.getExammode();
|
|
@@ -263,7 +267,11 @@ public class MsrExamService {
|
263
|
267
|
|
264
|
268
|
//科目班级分数分布区间分析、班级学科分析
|
265
|
269
|
//区间参数
|
266
|
|
- Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scoresection", "xk");
|
|
270
|
+ Map<String, SzJsonVo> qjMap = new HashMap<>();
|
|
271
|
+ List<MsrReportparam> params = getMsrReportParams(examid, "scoresection", "xk");
|
|
272
|
+ for (MsrReportparam param : params) {
|
|
273
|
+ qjMap.put(param.getSubjectid(), JSON.parseObject(param.getSzjson(), SzJsonVo.class));
|
|
274
|
+ }
|
267
|
275
|
List<MsrSubjectClass> msrSubjectClasses = new ArrayList<>();//科目班级分数分布区间分析
|
268
|
276
|
List<MsrClassSubject> msrClassSubjects = new ArrayList<>();//班级学科分析
|
269
|
277
|
List<MsrClassTop> msrClassTops = new ArrayList<>();//班级学科前60分析
|
|
@@ -287,11 +295,11 @@ public class MsrExamService {
|
287
|
295
|
String key = entry.getKey();
|
288
|
296
|
Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
289
|
297
|
subjectid = key.split("_")[1];
|
290
|
|
- List<SzJsonVo> list = qjMap.get(subjectid);
|
|
298
|
+ SzJsonVo vo = qjMap.get(subjectid);
|
291
|
299
|
List<MsrStudent> studentList = entry.getValue();
|
292
|
300
|
totalnum = studentList.size();//区间总人数
|
293
|
301
|
Double fullscore1 = studentList.get(0).getFullscore();
|
294
|
|
- List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(list.get(0).getDjvalue()));
|
|
302
|
+ List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(vo.getDjvalue()));
|
295
|
303
|
for (RankGroupVo rg : fdScore) {
|
296
|
304
|
int minscore = rg.getMinvalue();
|
297
|
305
|
int maxscore = rg.getMaxvalue();
|
|
@@ -353,12 +361,80 @@ public class MsrExamService {
|
353
|
361
|
saveClassSubjectGrade(examid, "xj", msrStudents);//校级报告-班级学科四率等级分析
|
354
|
362
|
saveClassRankGroup(examid, msrStudents);//学科报告-班级学科名次分组分析
|
355
|
363
|
saveClassRankRate(examid, msrStudents);//综合报表-名次和比例分析
|
|
364
|
+ saveClassSection(examid, 1, "zh", msrStudents);//综合报表-分段统计
|
|
365
|
+ saveClassSection(examid, 2, "zh", msrStudents);//综合报表-累计统计
|
|
366
|
+ saveClassSection(examid, 1, "xj", msrStudents);//校级报告-分段统计
|
|
367
|
+ saveClassSection(examid, 1, "xk", msrStudents);//学科报告-分段统计
|
|
368
|
+ saveClassSection(examid, 1, "bj", msrStudents);//班级报告-分段统计
|
|
369
|
+ saveClassSection(examid, 1, "jxzl", msrStudents);//教学质量-分段统计
|
356
|
370
|
|
357
|
371
|
examMapper.updateExamState(examid, 3);
|
358
|
372
|
}
|
359
|
373
|
|
|
374
|
+ //分段统计
|
|
375
|
+ public void saveClassSection(Integer examid, Integer type, String reportcode, List<MsrStudent> msrStudents) {
|
|
376
|
+ List<MsrReportparam> params = getMsrReportParams(examid, "scoresection", reportcode);
|
|
377
|
+ Integer rptype = params.get(0).getRptype();
|
|
378
|
+ Map<String, List<RankGroupVo>> fdMap = new HashMap<>();
|
|
379
|
+ if (rptype.equals(0)) {//固定步长
|
|
380
|
+ for (MsrReportparam param : params) {
|
|
381
|
+ SzJsonVo vo = JSON.parseObject(param.getSzjson(), SzJsonVo.class);
|
|
382
|
+ List<RankGroupVo> groups = MarkingUtil.fdScore(N_Utils.obj2Int(vo.getMaxvalue()), N_Utils.obj2Int(vo.getMinvalue()), N_Utils.obj2Int(vo.getDjvalue()), type);
|
|
383
|
+ fdMap.put(param.getSubjectid(), groups);
|
|
384
|
+ }
|
|
385
|
+ } else {//不定步长
|
|
386
|
+ for (MsrReportparam param : params) {
|
|
387
|
+ List<SzJsonVo> vos = JSON.parseArray(param.getSzjson(), SzJsonVo.class);
|
|
388
|
+ List<RankGroupVo> groups = MarkingUtil.fdScore(vos, type);
|
|
389
|
+ fdMap.put(param.getSubjectid(), groups);
|
|
390
|
+ }
|
|
391
|
+ }
|
|
392
|
+
|
|
393
|
+ List<MsrClassSection> classSections = new ArrayList<>();
|
|
394
|
+ String subjectid;
|
|
395
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
396
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
397
|
+ String key = entry.getKey();
|
|
398
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
399
|
+ subjectid = key.split("_")[1];
|
|
400
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
401
|
+ Integer stunum = studentList.size();
|
|
402
|
+ List<RankGroupVo> groups = fdMap.get(subjectid);
|
|
403
|
+ for (int i = 0; i < groups.size(); i++) {
|
|
404
|
+ RankGroupVo group = groups.get(i);
|
|
405
|
+ int maxvalue = group.getMaxvalue();
|
|
406
|
+ int minvalue = group.getMinvalue();
|
|
407
|
+ List<MsrStudent> qjstudents;
|
|
408
|
+ if (type.equals(1)) {
|
|
409
|
+ if (i == 0) {
|
|
410
|
+ qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) <= 0).collect(Collectors.toList());
|
|
411
|
+ } else {
|
|
412
|
+ qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), minvalue) >= 0 && MarkingUtil.sub(s.getStuscore(), maxvalue) < 0).collect(Collectors.toList());
|
|
413
|
+ }
|
|
414
|
+ } else {
|
|
415
|
+ qjstudents = studentList.stream().filter(s -> MarkingUtil.sub(s.getStuscore(), maxvalue) >= 0).collect(Collectors.toList());
|
|
416
|
+ }
|
|
417
|
+ MsrClassSection classSection = new MsrClassSection();
|
|
418
|
+ classSection.setExamid(examid);
|
|
419
|
+ classSection.setClassid(classid);
|
|
420
|
+ classSection.setSubjectid(subjectid);
|
|
421
|
+ classSection.setStunum(stunum);
|
|
422
|
+ classSection.setType(type);
|
|
423
|
+ classSection.setReportcode(reportcode);
|
|
424
|
+ classSection.setFzfw(group.getGroupname());
|
|
425
|
+ int qjnum = qjstudents.size();
|
|
426
|
+ classSection.setFzfwnum(qjnum);
|
|
427
|
+ classSection.setFzfwrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, stunum));
|
|
428
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
429
|
+ classSection.setStuids(stuids);
|
|
430
|
+ classSections.add(classSection);
|
|
431
|
+ }
|
|
432
|
+ }
|
|
433
|
+ msrClassSectionMapper.insertList(classSections);
|
|
434
|
+ }
|
|
435
|
+
|
360
|
436
|
//学科报告-班级学科名次分组分析
|
361
|
|
- private void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
|
|
437
|
+ public void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
|
362
|
438
|
List<MsrClassRankgroup> classRankGroups = new ArrayList<>();
|
363
|
439
|
int groupNum = 10;
|
364
|
440
|
String subjectid;
|
|
@@ -389,7 +465,7 @@ public class MsrExamService {
|
389
|
465
|
}
|
390
|
466
|
|
391
|
467
|
//综合报表-名次和比例分析
|
392
|
|
- private void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
|
|
468
|
+ public void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
|
393
|
469
|
List<MsrReportparam> params = getMsrReportParams(examid, "rankrate", "zh");
|
394
|
470
|
Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
|
395
|
471
|
Map<String, Integer> tMap = new HashMap<>();
|
|
@@ -482,7 +558,7 @@ public class MsrExamService {
|
482
|
558
|
}
|
483
|
559
|
|
484
|
560
|
//班级学科四率等级分析
|
485
|
|
- private void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
|
|
561
|
+ public void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
|
486
|
562
|
Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scorerate", reportcode);
|
487
|
563
|
List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
|
488
|
564
|
String subjectid;
|
|
@@ -513,11 +589,11 @@ public class MsrExamService {
|
513
|
589
|
classSubjectGrade.setSubjectid(subjectid);
|
514
|
590
|
classSubjectGrade.setClassid(classid);
|
515
|
591
|
classSubjectGrade.setReportcode(reportcode);
|
516
|
|
- classSubjectGrade.setRange(qjname);
|
|
592
|
+ classSubjectGrade.setRangename(qjname);
|
517
|
593
|
classSubjectGrade.setRangenum(qjnum);
|
518
|
594
|
classSubjectGrade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
519
|
595
|
double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
|
520
|
|
- classSubjectGrade.setDjscore(qjavg);
|
|
596
|
+ classSubjectGrade.setDjscore(N_Utils.formatDouble(qjavg, 2));
|
521
|
597
|
classSubjectGrade.setDjrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
|
522
|
598
|
String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
523
|
599
|
classSubjectGrade.setStuids(stuids);
|
|
@@ -604,12 +680,14 @@ public class MsrExamService {
|
604
|
680
|
student.setCjl(MarkingUtil.cjl(student.getStuscore(), pjf));
|
605
|
681
|
student.setClassrank(classrank);
|
606
|
682
|
student.setSchoolrank(schoolrank);
|
607
|
|
- double rankrate = MarkingUtil.div(schoolrank, msrSubject.getTotalnum());
|
|
683
|
+ Integer totalnum = msrSubject.getTotalnum();
|
|
684
|
+ double rankrate = MarkingUtil.div(schoolrank, totalnum);
|
608
|
685
|
student.setRankrate(rankrate);//个人成绩排名率=自己所在学科成绩分数的名次/总人数
|
609
|
686
|
student.setXkqrz(MarkingUtil.sub(msrSubject.getAvgrank(), rankrate));//学科强弱值 = 平均成绩排名率- 个人成绩排名率
|
610
|
687
|
double dfv = N_Utils.getDoubleDivideAndMulitiply(student.getStuscore(), msrSubject.getFullscore());
|
611
|
688
|
student.setGradevalue(MarkingUtil.dj(dfv, djList));
|
612
|
|
- student.setHighschool(N_Utils.getIntegerDivideAndMulitiply(schoolrank, schoolRankVo.getNum2()));
|
|
689
|
+ int num = totalnum - schoolRankVo.getNum() - schoolRankVo.getNum2();
|
|
690
|
+ student.setHighschool(N_Utils.getIntegerDivideAndMulitiply(num, totalnum));
|
613
|
691
|
}
|
614
|
692
|
|
615
|
693
|
//分数排名
|