|
@@ -60,6 +60,10 @@ public class MsrExamService {
|
60
|
60
|
private MsrClassTopMapper msrClassTopMapper;
|
61
|
61
|
@Resource
|
62
|
62
|
private MsrClassSubjectGradeMapper msrClassSubjectGradeMapper;
|
|
63
|
+ @Resource
|
|
64
|
+ private MsrClassRankgroupMapper msrClassRankgroupMapper;
|
|
65
|
+ @Resource
|
|
66
|
+ private MsrClassRankrateMapper msrClassRankrateMapper;
|
63
|
67
|
|
64
|
68
|
|
65
|
69
|
/**
|
|
@@ -345,15 +349,141 @@ public class MsrExamService {
|
345
|
349
|
msrClassSubjectMapper.insertList(msrClassSubjects);
|
346
|
350
|
msrClassTopMapper.insertList(msrClassTops);
|
347
|
351
|
|
348
|
|
- saveClassSubjectGrade(examid, "scorerate", "zh", msrStudents);//综合报告-班级学科四率等级分析
|
349
|
|
- saveClassSubjectGrade(examid, "scorerate", "xj", msrStudents);//校级报告-班级学科四率等级分析
|
|
352
|
+ saveClassSubjectGrade(examid, "zh", msrStudents);//综合报告-班级学科四率等级分析
|
|
353
|
+ saveClassSubjectGrade(examid, "xj", msrStudents);//校级报告-班级学科四率等级分析
|
|
354
|
+ saveClassRankGroup(examid, msrStudents);//学科报告-班级学科名次分组分析
|
|
355
|
+ saveClassRankRate(examid, msrStudents);//综合报表-名次和比例分析
|
350
|
356
|
|
351
|
357
|
examMapper.updateExamState(examid, 3);
|
352
|
358
|
}
|
353
|
359
|
|
|
360
|
+ //学科报告-班级学科名次分组分析
|
|
361
|
+ private void saveClassRankGroup(Integer examid, List<MsrStudent> msrStudents) {
|
|
362
|
+ List<MsrClassRankgroup> classRankGroups = new ArrayList<>();
|
|
363
|
+ int groupNum = 10;
|
|
364
|
+ String subjectid;
|
|
365
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
366
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
367
|
+ String key = entry.getKey();
|
|
368
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
369
|
+ subjectid = key.split("_")[1];
|
|
370
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
371
|
+ int maxRank = studentList.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMax();
|
|
372
|
+ List<RankGroupVo> groups = MarkingUtil.rankGroup(maxRank, groupNum);
|
|
373
|
+ for (RankGroupVo group : groups) {
|
|
374
|
+ int maxvalue = group.getMaxvalue();
|
|
375
|
+ int minvalue = group.getMinvalue();
|
|
376
|
+ List<MsrStudent> qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(minvalue) >= 0 && s.getSchoolrank().compareTo(maxvalue) <= 0).collect(Collectors.toList());
|
|
377
|
+ MsrClassRankgroup cg = new MsrClassRankgroup();
|
|
378
|
+ cg.setExamid(examid);
|
|
379
|
+ cg.setClassid(classid);
|
|
380
|
+ cg.setSubjectid(subjectid);
|
|
381
|
+ cg.setRname(group.getGroupname());
|
|
382
|
+ cg.setRnum(qjstudents.size());
|
|
383
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
384
|
+ cg.setStuids(stuids);
|
|
385
|
+ classRankGroups.add(cg);
|
|
386
|
+ }
|
|
387
|
+ }
|
|
388
|
+ msrClassRankgroupMapper.insertList(classRankGroups);
|
|
389
|
+ }
|
|
390
|
+
|
|
391
|
+ //综合报表-名次和比例分析
|
|
392
|
+ private void saveClassRankRate(Integer examid, List<MsrStudent> msrStudents) {
|
|
393
|
+ List<MsrReportparam> params = getMsrReportParams(examid, "rankrate", "zh");
|
|
394
|
+ Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
|
|
395
|
+ Map<String, Integer> tMap = new HashMap<>();
|
|
396
|
+ for (MsrReportparam param : params) {
|
|
397
|
+ String subjectid = param.getSubjectid();
|
|
398
|
+ qjMap.put(subjectid, JSON.parseArray(param.getSzjson(), SzJsonVo.class));
|
|
399
|
+ tMap.put(subjectid, param.getRptype());
|
|
400
|
+ }
|
|
401
|
+ List<MsrClassRankrate> classRankrates = new ArrayList<>();
|
|
402
|
+ String subjectid;
|
|
403
|
+ int totalnum;
|
|
404
|
+ Map<String, List<MsrStudent>> scCollect = msrStudents.stream().collect(Collectors.groupingBy(s -> s.getClassid() + "_" + s.getSubjectid()));
|
|
405
|
+ for (Map.Entry<String, List<MsrStudent>> entry : scCollect.entrySet()) {
|
|
406
|
+ String key = entry.getKey();
|
|
407
|
+ Integer classid = N_Utils.obj2Int(key.split("_")[0]);
|
|
408
|
+ subjectid = key.split("_")[1];
|
|
409
|
+ List<SzJsonVo> list = qjMap.get(subjectid);
|
|
410
|
+ Integer rptype = tMap.get(subjectid);
|
|
411
|
+ List<MsrStudent> studentList = entry.getValue();
|
|
412
|
+ if (rptype.equals(3)) {
|
|
413
|
+ studentList = studentList.stream().sorted(Comparator.comparing(MsrStudent::getStuscore).reversed()).collect(Collectors.toList());
|
|
414
|
+ }
|
|
415
|
+ totalnum = studentList.size();//区间总人数
|
|
416
|
+ Double max = null;
|
|
417
|
+ Integer minRank = null;
|
|
418
|
+ int minIndex = 0;
|
|
419
|
+ Object minRate = null;
|
|
420
|
+ for (SzJsonVo rg : list) {
|
|
421
|
+ Object djvalue = rg.getDjvalue();
|
|
422
|
+ List<MsrStudent> qjstudents;
|
|
423
|
+ String ztname;
|
|
424
|
+ String ctname;
|
|
425
|
+ if (rptype.equals(1)) {//按名次
|
|
426
|
+ ztname = "前" + djvalue + "名";
|
|
427
|
+ Integer rank = N_Utils.obj2Int(djvalue);
|
|
428
|
+ if (minRank == null) {
|
|
429
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(rank) >= 0).collect(Collectors.toList());
|
|
430
|
+ } else {
|
|
431
|
+ Integer finalMinRank = minRank;
|
|
432
|
+ qjstudents = studentList.stream().filter(s -> s.getSchoolrank().compareTo(finalMinRank) >= 0 && s.getSchoolrank().compareTo(rank) < 0).collect(Collectors.toList());
|
|
433
|
+ }
|
|
434
|
+ minRank = rank;
|
|
435
|
+ double minScore = N_Utils.handleInfinity(qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getMin());
|
|
436
|
+ ctname = ">=" + minScore + "分";
|
|
437
|
+ } else if (rptype.equals(2)) {//按分数
|
|
438
|
+ ztname = ">=" + djvalue + "分";
|
|
439
|
+ Double score = MarkingUtil.objToDouble(djvalue);
|
|
440
|
+ if (max == null) {
|
|
441
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0).collect(Collectors.toList());
|
|
442
|
+ } else {
|
|
443
|
+ Double finalMax = max;
|
|
444
|
+ qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(score) >= 0 && s.getStuscore().compareTo(finalMax) < 0).collect(Collectors.toList());
|
|
445
|
+ }
|
|
446
|
+ max = score;
|
|
447
|
+ minRank = qjstudents.stream().mapToInt(MsrStudent::getSchoolrank).summaryStatistics().getMin();
|
|
448
|
+ ctname = "前" + minRank + "名";
|
|
449
|
+ } else {//按比例
|
|
450
|
+ if (minIndex == 0) {
|
|
451
|
+ ztname = "前" + djvalue + "%";
|
|
452
|
+ } else {
|
|
453
|
+ ztname = "前" + minRate + "%-" + djvalue + "%";
|
|
454
|
+ }
|
|
455
|
+ int index = (int) Math.ceil(MarkingUtil.div(totalnum * 100, djvalue));
|
|
456
|
+ if (index > totalnum) index = totalnum;
|
|
457
|
+ qjstudents = studentList.subList(minIndex, index);
|
|
458
|
+ minIndex = index;
|
|
459
|
+ minRate = djvalue;
|
|
460
|
+ DoubleSummaryStatistics statistics = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics();
|
|
461
|
+ double minScore = N_Utils.handleInfinity(statistics.getMin());
|
|
462
|
+ double maxScore = N_Utils.handleInfinity(statistics.getMax());
|
|
463
|
+ ctname = "[" + minScore + "-" + maxScore + "]";
|
|
464
|
+ }
|
|
465
|
+ int qjnum = qjstudents.size();
|
|
466
|
+ MsrClassRankrate rankrate = new MsrClassRankrate();
|
|
467
|
+ rankrate.setExamid(examid);
|
|
468
|
+ rankrate.setSubjectid(subjectid);
|
|
469
|
+ rankrate.setClassid(classid);
|
|
470
|
+ rankrate.setStunum(totalnum);
|
|
471
|
+ rankrate.setRtype(rptype);
|
|
472
|
+ rankrate.setZtname(ztname);
|
|
473
|
+ rankrate.setCtname(ctname);
|
|
474
|
+ rankrate.setRnum(qjnum);
|
|
475
|
+ rankrate.setRrate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
|
476
|
+ String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
|
477
|
+ rankrate.setStuids(stuids);
|
|
478
|
+ classRankrates.add(rankrate);
|
|
479
|
+ }
|
|
480
|
+ }
|
|
481
|
+ msrClassRankrateMapper.insertList(classRankrates);
|
|
482
|
+ }
|
|
483
|
+
|
354
|
484
|
//班级学科四率等级分析
|
355
|
|
- private void saveClassSubjectGrade(Integer examid, String rpbelong, String reportcode, List<MsrStudent> msrStudents) {
|
356
|
|
- Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, rpbelong, reportcode);
|
|
485
|
+ private void saveClassSubjectGrade(Integer examid, String reportcode, List<MsrStudent> msrStudents) {
|
|
486
|
+ Map<String, List<SzJsonVo>> qjMap = getReportParams(examid, "scorerate", reportcode);
|
357
|
487
|
List<MsrClassSubjectGrade> msrClassSubjectGrades = new ArrayList<>();//班级学科分析
|
358
|
488
|
String subjectid;
|
359
|
489
|
int totalnum;
|
|
@@ -367,13 +497,10 @@ public class MsrExamService {
|
367
|
497
|
List<MsrStudent> studentList = entry.getValue();
|
368
|
498
|
totalnum = studentList.size();//区间总人数
|
369
|
499
|
Double fullscore1 = studentList.get(0).getFullscore();
|
370
|
|
- List<RankGroupVo> fdScore = MarkingUtil.fdScore(fullscore1, N_Utils.obj2Int(list.get(0).getDjvalue()));
|
371
|
|
- for (RankGroupVo rg : fdScore) {
|
372
|
|
- int minscore = rg.getMinvalue();
|
373
|
|
- int maxscore = rg.getMaxvalue();
|
374
|
|
- String qjname = rg.getGroupname();
|
375
|
|
- double min = MarkingUtil.objToDouble(minscore);
|
376
|
|
- double max = MarkingUtil.objToDouble(maxscore);
|
|
500
|
+ for (SzJsonVo rg : list) {
|
|
501
|
+ String qjname = rg.getDjkey();
|
|
502
|
+ double min = MarkingUtil.mul(rg.getMinvalue(), fullscore1);
|
|
503
|
+ double max = MarkingUtil.mul(rg.getMaxvalue(), fullscore1);
|
377
|
504
|
List<MsrStudent> qjstudents;
|
378
|
505
|
if (fullscore1.compareTo(max) == 0) {
|
379
|
506
|
qjstudents = studentList.stream().filter(s -> s.getStuscore().compareTo(min) >= 0).collect(Collectors.toList());
|
|
@@ -389,8 +516,9 @@ public class MsrExamService {
|
389
|
516
|
classSubjectGrade.setRange(qjname);
|
390
|
517
|
classSubjectGrade.setRangenum(qjnum);
|
391
|
518
|
classSubjectGrade.setRangerate(N_Utils.getIntegerDivideAndMulitiply(qjnum, totalnum));
|
392
|
|
- //double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
|
393
|
|
- //classSubjectGrade.setQjavgrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
|
|
519
|
+ double qjavg = qjstudents.stream().mapToDouble(MsrStudent::getStuscore).summaryStatistics().getAverage();
|
|
520
|
+ classSubjectGrade.setDjscore(qjavg);
|
|
521
|
+ classSubjectGrade.setDjrate(N_Utils.getDoubleDivideAndMulitiply(qjavg, fullscore1));
|
394
|
522
|
String stuids = qjstudents.stream().map(s -> s.getStudentid().toString()).collect(Collectors.joining(","));
|
395
|
523
|
classSubjectGrade.setStuids(stuids);
|
396
|
524
|
msrClassSubjectGrades.add(classSubjectGrade);
|
|
@@ -408,10 +536,12 @@ public class MsrExamService {
|
408
|
536
|
|
409
|
537
|
//获取报告参数
|
410
|
538
|
private Map<String, List<SzJsonVo>> getReportParams(Integer examid, String rpbelong, String reportcode) {
|
411
|
|
- List<MsrReportparam> list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, reportcode);
|
412
|
|
- if (N_Utils.isListEmpty(list)) {
|
413
|
|
- list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, "all");
|
414
|
|
- }
|
|
539
|
+ List<MsrReportparam> list = getMsrReportParams(examid, rpbelong, reportcode);
|
|
540
|
+ return formatSzJson(list);
|
|
541
|
+ }
|
|
542
|
+
|
|
543
|
+ //格式化报告参数
|
|
544
|
+ private Map<String, List<SzJsonVo>> formatSzJson(List<MsrReportparam> list) {
|
415
|
545
|
Map<String, List<SzJsonVo>> qjMap = new HashMap<>();
|
416
|
546
|
for (MsrReportparam param : list) {
|
417
|
547
|
qjMap.put(param.getSubjectid(), JSON.parseArray(param.getSzjson(), SzJsonVo.class));
|
|
@@ -419,6 +549,15 @@ public class MsrExamService {
|
419
|
549
|
return qjMap;
|
420
|
550
|
}
|
421
|
551
|
|
|
552
|
+ //获取报告参数
|
|
553
|
+ private List<MsrReportparam> getMsrReportParams(Integer examid, String rpbelong, String reportcode) {
|
|
554
|
+ List<MsrReportparam> list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, reportcode);
|
|
555
|
+ if (N_Utils.isListEmpty(list)) {
|
|
556
|
+ list = msrReportparamMapper.listReportparamByRpbelong(examid, rpbelong, "all");
|
|
557
|
+ }
|
|
558
|
+ return list;
|
|
559
|
+ }
|
|
560
|
+
|
422
|
561
|
//设置科目分析计算参数
|
423
|
562
|
private void setSubject(MsrSubject msrSubject, List<MsrStudent> schoolStudents2) {
|
424
|
563
|
Double avgscore = msrSubject.getAvgscore();
|