Browse Source

单科等级分布

tags/正式版本
雍文秀 2 years ago
parent
commit
476d6271b7

+ 3
- 0
sexam/src/main/java/com/xhkjedu/sexam/mapper/report/EReportGenerateMapper.java View File

31
 
31
 
32
     //学生优秀行为
32
     //学生优秀行为
33
     List<Map> listGoodActionByExamId(@Param("examid") Integer examid);
33
     List<Map> listGoodActionByExamId(@Param("examid") Integer examid);
34
+
35
+    //获取试卷分数
36
+    Double getScoreByExamAndSubjectId(@Param("examid") Integer examid, @Param("subjectid") String subjectid);
34
 }
37
 }

+ 0
- 4
sexam/src/main/java/com/xhkjedu/sexam/mapper/report/EReportSchoolMapper.java View File

1
 package com.xhkjedu.sexam.mapper.report;
1
 package com.xhkjedu.sexam.mapper.report;
2
 
2
 
3
 import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
3
 import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
4
-import com.xhkjedu.sexam.vo.report.ERPaperVo;
5
 import org.apache.ibatis.annotations.Param;
4
 import org.apache.ibatis.annotations.Param;
6
 
5
 
7
 import java.util.List;
6
 import java.util.List;
14
  * @date 2022/8/29 10:00
13
  * @date 2022/8/29 10:00
15
  **/
14
  **/
16
 public interface EReportSchoolMapper {
15
 public interface EReportSchoolMapper {
17
-    //考试试卷
18
-    List<ERPaperVo> listByExamAndSubjectId(@Param("examid") Integer examid, @Param("subjectid") String subjectid);
19
-
20
     //删除考试等级报告
16
     //删除考试等级报告
21
     void delByExamAndSubjectId(@Param("examid") Integer examid, @Param("subjectid") String subjectid, @Param("ranktype") Integer ranktype);
17
     void delByExamAndSubjectId(@Param("examid") Integer examid, @Param("subjectid") String subjectid, @Param("ranktype") Integer ranktype);
22
 
18
 

+ 1
- 11
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportClassService.java View File

7
 import com.xhkjedu.sexam.mapper.reportclass.ERclassRankMapper;
7
 import com.xhkjedu.sexam.mapper.reportclass.ERclassRankMapper;
8
 import com.xhkjedu.sexam.mapper.reportclass.EReportClassMapper;
8
 import com.xhkjedu.sexam.mapper.reportclass.EReportClassMapper;
9
 import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
9
 import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
10
-import com.xhkjedu.sexam.mapper.system.UserMapper;
11
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
10
 import com.xhkjedu.sexam.model.paper.EPaperQtype;
12
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
11
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
13
 import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
12
 import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
14
-import com.xhkjedu.sexam.vo.report.ERPaperVo;
15
 import com.xhkjedu.sexam.vo.report.ERankParamVo;
13
 import com.xhkjedu.sexam.vo.report.ERankParamVo;
16
-import com.xhkjedu.sexam.vo.system.UserVo;
17
 import com.xhkjedu.utils.N_Utils;
14
 import com.xhkjedu.utils.N_Utils;
18
 import org.springframework.stereotype.Service;
15
 import org.springframework.stereotype.Service;
19
 import org.springframework.transaction.annotation.Transactional;
16
 import org.springframework.transaction.annotation.Transactional;
47
     private EReportSchoolMapper eReportSchoolMapper;
44
     private EReportSchoolMapper eReportSchoolMapper;
48
     @Resource
45
     @Resource
49
     private EPaperStudentMapper ePaperStudentMapper;
46
     private EPaperStudentMapper ePaperStudentMapper;
50
-    @Resource
51
-    private UserMapper userMapper;
52
 
47
 
53
     //考试概况-学科成绩
48
     //考试概况-学科成绩
54
     public List<Map> listXkCj(Integer examid, Integer classid) {
49
     public List<Map> listXkCj(Integer examid, Integer classid) {
73
         Integer createid = rank.getCreateid();
68
         Integer createid = rank.getCreateid();
74
         Integer ranktype = rank.getRanktype();
69
         Integer ranktype = rank.getRanktype();
75
         eReportSchoolMapper.delByExamAndSubjectId(examid, subjectid, ranktype);//删除考试等级报告
70
         eReportSchoolMapper.delByExamAndSubjectId(examid, subjectid, ranktype);//删除考试等级报告
76
-        List<ERPaperVo> papers = eReportSchoolMapper.listByExamAndSubjectId(examid, subjectid);//考试试卷
77
-        List<ERstudent> students = ePaperStudentMapper.listByExamAndSubjectId(examid, subjectid);//考试试卷学生
78
-        List<Integer> userids = students.stream().map(ERstudent::getStudentid).distinct().collect(Collectors.toList());
79
-        List<UserVo> users = userMapper.listNameByUserIds(userids);
80
-        Map<Integer, String> userMap = users.stream().collect(Collectors.toMap(UserVo::getUserid, UserVo::getUsername));
81
-        eReportGenerateService.setClassGradeRank(examid, papers, students, rank.getRranks(), createid, userMap);//生成考试等级报告
71
+        eReportGenerateService.setSubjectRank(examid, subjectid, createid, rank.getRranks(), ranktype);//生成考试等级报告
82
         return eRclassRankMapper.listByExamId(rank);//考试等级报告列表
72
         return eRclassRankMapper.listByExamId(rank);//考试等级报告列表
83
     }
73
     }
84
 
74
 

+ 374
- 0
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportGenerateService.java View File

890
         eRclassRankMapper.insertList(rclassRankList);
890
         eRclassRankMapper.insertList(rclassRankList);
891
     }
891
     }
892
 
892
 
893
+    //单科等级分布
894
+    public void setSubjectRank(Integer examid, String subjectid, Integer createid, List<ERrank> rranks, Integer ranktype) {
895
+        Double pscore = eReportGenerateMapper.getScoreByExamAndSubjectId(examid, subjectid);//获取试卷分数
896
+        List<ERstudent> students = ePaperStudentMapper.listByExamAndSubjectId(examid, subjectid);//考试试卷学生
897
+        List<Integer> userids = students.stream().map(ERstudent::getStudentid).distinct().collect(Collectors.toList());
898
+        List<UserVo> users = userMapper.listNameByUserIds(userids);
899
+        Map<Integer, String> userMap = users.stream().collect(Collectors.toMap(UserVo::getUserid, UserVo::getUsername));
900
+        List<ERstudent> cstudents = new ArrayList<>();//班级学生
901
+        Map<String, List<ERstudent>> cscollect = students.stream().collect(
902
+                Collectors.groupingBy(s -> s.getClassid() + "_" + s.getStudentid()));
903
+        setStuScore(cscollect, cstudents);
904
+        //总分统计
905
+        Map<Integer, List<ERstudent>> zfcollect = cstudents.stream().collect(
906
+                Collectors.groupingBy(s -> s.getClassid()));
907
+        List<ERstudent> sstudents = new ArrayList<>();//科目学生
908
+        Map<String, List<ERstudent>> sscollect = students.stream().collect(
909
+                Collectors.groupingBy(s -> s.getSubjectid() + "_" + s.getStudentid()));
910
+        setStuScore(sscollect, sstudents);
911
+        //全部班级统计
912
+        Map<String, List<ERstudent>> qbbjcollect = sstudents.stream().collect(
913
+                Collectors.groupingBy(s -> s.getSubjectid()));
914
+
915
+        List<ERrank> rrankList = new ArrayList<>();//考试报告等级
916
+        List<ERclassRank> rclassRankList = new ArrayList<>();//考试报告班级统计
917
+        ERrank eRrank = rranks.get(0);
918
+        if (ranktype == 1) {//等级(A[85%~100%],B[70%~85%),C[60%~70%),D[40%~60%),E[0%~40%))
919
+            for (ERrank rank : rranks) {
920
+                Double maxrate = rank.getMaxscore();
921
+                Double minrate = rank.getMinscore();
922
+                String rankname = rank.getRankname();
923
+                if ("zf".equals(subjectid)) {
924
+                    //总分统计
925
+                    double zfmaxscore = ExamUtil.mul(maxrate, pscore);
926
+                    double zfminscore = ExamUtil.mul(minrate, pscore);
927
+                    ERrank rr = new ERrank();
928
+                    rr.setRanktype(ranktype);
929
+                    rr.setRankname(rankname);
930
+                    rr.setMaxscore(zfmaxscore);
931
+                    rr.setMinscore(zfminscore);
932
+                    rr.setSubjectid("zf");
933
+                    String zfrankrange = "[" + zfminscore + "," + zfmaxscore;
934
+                    if (rr.getRankname().equals("A")) {
935
+                        zfrankrange = zfrankrange + "]";
936
+                    } else {
937
+                        zfrankrange = zfrankrange + ")";
938
+                    }
939
+                    for (Map.Entry<Integer, List<ERstudent>> entry : zfcollect.entrySet()) {
940
+                        Integer classid = entry.getKey();
941
+                        List<ERstudent> list = entry.getValue();
942
+                        setDjTj(examid, userMap, rclassRankList, rr, zfrankrange, subjectid, classid, list);
943
+                    }
944
+                    IntSummaryStatistics zfstatistics = cstudents.stream().mapToInt(s -> s.getSchoolrank()).summaryStatistics();
945
+                    rr.setLinescore(zfstatistics.getMax());
946
+                    rr.setFloatscore(zfstatistics.getMin());
947
+                    rrankList.add(rr);
948
+                } else {
949
+                    //分科统计
950
+                    ERrank rrank = new ERrank();
951
+                    rrank.setRanktype(ranktype);
952
+                    rrank.setRankname(rankname);
953
+                    rrank.setSubjectid(subjectid);
954
+                    double maxscore = ExamUtil.mul(maxrate, pscore);
955
+                    double minscore = ExamUtil.mul(minrate, pscore);
956
+                    rrank.setMaxscore(maxscore);
957
+                    rrank.setMinscore(minscore);
958
+                    String rankrange = "[" + minscore + "," + maxscore;
959
+                    if (rankname.equals("A")) {
960
+                        rankrange = rankrange + "]";
961
+                    } else {
962
+                        rankrange = rankrange + ")";
963
+                    }
964
+
965
+                    //全部班级统计
966
+                    Integer classid = 0;
967
+                    List<ERstudent> list = qbbjcollect.get(subjectid);
968
+                    setDjTj(examid, userMap, rclassRankList, rrank, rankrange, subjectid, classid, list);
969
+                    IntSummaryStatistics statistics = list.stream().mapToInt(s -> s.getSchoolrank()).summaryStatistics();
970
+                    rrank.setLinescore(statistics.getMax());
971
+                    rrank.setFloatscore(statistics.getMin());
972
+                    rrankList.add(rrank);
973
+
974
+                    //班级科目统计
975
+                    Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
976
+                            .collect(Collectors.groupingBy(s -> s.getClassid()));
977
+                    for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
978
+                        classid = entry.getKey();
979
+                        list = entry.getValue();
980
+                        setDjTj(examid, userMap, rclassRankList, rrank, rankrange, subjectid, classid, list);
981
+                    }
982
+                }
983
+            }
984
+        } else if (ranktype == 2) {//分数段(10分/段)
985
+            Integer linescore = eRrank.getLinescore();
986
+            if ("zf".equals(subjectid)) {
987
+                //总分统计
988
+                Integer gnum = ExamUtil.divUp(pscore, linescore);
989
+                for (Integer i = 1; i <= gnum; i++) {
990
+                    ERrank rrank = new ERrank();
991
+                    rrank.setRanktype(ranktype);
992
+                    double maxscore = ExamUtil.mul(i, linescore);
993
+                    double minscore = ExamUtil.mul(i - 1, linescore);
994
+                    if (maxscore > pscore) {
995
+                        maxscore = pscore;
996
+                    }
997
+                    rrank.setMaxscore(maxscore);
998
+                    rrank.setMinscore(minscore);
999
+                    String rankrange = "[" + minscore + "," + maxscore;
1000
+                    if (i == gnum) {
1001
+                        rankrange = rankrange + "]";
1002
+                    } else {
1003
+                        rankrange = rankrange + ")";
1004
+                    }
1005
+                    rrank.setRankname(rankrange);
1006
+                    rrank.setSubjectid("zf");
1007
+                    rrankList.add(rrank);
1008
+
1009
+                    for (Map.Entry<Integer, List<ERstudent>> entry : zfcollect.entrySet()) {
1010
+                        Integer classid = entry.getKey();
1011
+                        List<ERstudent> list = entry.getValue();
1012
+                        setFdTj(examid, userMap, rclassRankList, gnum, i, rrank, rankrange, classid, list);
1013
+                    }
1014
+                }
1015
+            } else {
1016
+                //分科统计
1017
+                Integer cnum = ExamUtil.divUp(pscore, linescore);
1018
+                for (Integer i = 1; i <= cnum; i++) {
1019
+                    ERrank rrank = new ERrank();
1020
+                    rrank.setSubjectid(subjectid);
1021
+                    rrank.setRanktype(ranktype);
1022
+                    rrank.setSubjectid(subjectid);
1023
+                    double maxscore = ExamUtil.mul(i, linescore);
1024
+                    double minscore = ExamUtil.mul(i - 1, linescore);
1025
+                    if (maxscore > pscore) {
1026
+                        maxscore = pscore;
1027
+                    }
1028
+                    rrank.setMaxscore(maxscore);
1029
+                    rrank.setMinscore(minscore);
1030
+                    String rankrange = "[" + minscore + "," + maxscore;
1031
+                    if (i == cnum) {
1032
+                        rankrange = rankrange + "]";
1033
+                    } else {
1034
+                        rankrange = rankrange + ")";
1035
+                    }
1036
+                    rrank.setRankname(rankrange);
1037
+                    rrankList.add(rrank);
1038
+
1039
+                    //全部班级统计
1040
+                    Integer classid = 0;
1041
+                    List<ERstudent> list = qbbjcollect.get(subjectid);
1042
+                    setFdTj(examid, userMap, rclassRankList, cnum, i, rrank, rankrange, classid, list);
1043
+
1044
+                    //班级科目统计
1045
+                    Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
1046
+                            .collect(Collectors.groupingBy(s -> s.getClassid()));
1047
+                    for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
1048
+                        classid = entry.getKey();
1049
+                        list = entry.getValue();
1050
+                        setFdTj(examid, userMap, rclassRankList, cnum, i, rrank, rankrange, classid, list);
1051
+                    }
1052
+                }
1053
+            }
1054
+        } else {
1055
+            Integer lscore = eRrank.getLinescore();
1056
+            if (ranktype == 3) {//临界分(临界分:总分*80%,浮动分:5分)
1057
+                Integer linescore = lscore;
1058
+                Integer floatscore = eRrank.getFloatscore();
1059
+                ERrank rr = new ERrank();
1060
+                rr.setRanktype(ranktype);
1061
+                if ("zf".equals(subjectid)) {
1062
+                    //总分统计
1063
+                    if (N_Utils.isEmptyInteger(linescore)) linescore = (int) (ExamUtil.mul(pscore, 0.8));
1064
+                    double zfmaxscore = ExamUtil.add(linescore, floatscore);
1065
+                    double zfminscore = ExamUtil.sub(linescore, floatscore);
1066
+                    if (zfmaxscore > pscore) zfmaxscore = pscore;
1067
+                    if (zfminscore < 0) zfminscore = 0;
1068
+                    rr.setMaxscore(zfmaxscore);
1069
+                    rr.setMinscore(zfminscore);
1070
+                    rr.setLinescore(linescore);
1071
+                    rr.setFloatscore(floatscore);
1072
+                    String zfrankrange = "[" + zfminscore + "," + zfmaxscore + "]";
1073
+                    rr.setRankname(zfrankrange);
1074
+                    rr.setSubjectid("zf");
1075
+                    rrankList.add(rr);
1076
+
1077
+                    for (Map.Entry<Integer, List<ERstudent>> entry : zfcollect.entrySet()) {
1078
+                        Integer classid = entry.getKey();
1079
+                        List<ERstudent> list = entry.getValue();
1080
+                        setLjfTj(examid, userMap, rclassRankList, rr, zfrankrange, classid, subjectid, list);
1081
+                    }
1082
+                } else {
1083
+                    //分科统计
1084
+                    ERrank rrank = new ERrank();
1085
+                    rrank.setRanktype(ranktype);
1086
+                    rrank.setSubjectid(subjectid);
1087
+                    linescore = lscore;
1088
+                    if (N_Utils.isEmptyInteger(linescore)) linescore = (int) (ExamUtil.mul(pscore, 0.8));
1089
+                    double maxscore = ExamUtil.add(linescore, floatscore);
1090
+                    double minscore = ExamUtil.sub(linescore, floatscore);
1091
+                    if (maxscore > pscore) maxscore = pscore;
1092
+                    if (minscore < 0) minscore = 0;
1093
+                    rrank.setMaxscore(maxscore);
1094
+                    rrank.setMinscore(minscore);
1095
+                    rrank.setLinescore(linescore);
1096
+                    rrank.setFloatscore(floatscore);
1097
+                    String rankrange = "[" + minscore + "," + maxscore + "]";
1098
+                    rrank.setRankname(rankrange);
1099
+                    rrankList.add(rrank);
1100
+
1101
+                    //全部班级统计
1102
+                    Integer classid = 0;
1103
+                    List<ERstudent> list = qbbjcollect.get(subjectid);
1104
+                    setLjfTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1105
+
1106
+                    //班级科目统计
1107
+                    Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
1108
+                            .collect(Collectors.groupingBy(s -> s.getClassid()));
1109
+                    for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
1110
+                        classid = entry.getKey();
1111
+                        list = entry.getValue();
1112
+                        setLjfTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1113
+                    }
1114
+                }
1115
+
1116
+            } else if (ranktype == 4) {//临界名次(临界名次10,浮动名次5)
1117
+                Integer linescore = lscore;
1118
+                Integer floatscore = eRrank.getFloatscore();
1119
+                ERrank rr = new ERrank();
1120
+                rr.setRanktype(ranktype);
1121
+                if ("zf".equals(subjectid)) {
1122
+                    //总分统计
1123
+                    double zfmaxscore = ExamUtil.sub(linescore, floatscore);//最高名次
1124
+                    double zfminscore = ExamUtil.add(linescore, floatscore);//最低名次
1125
+                    if (zfmaxscore < 1) zfmaxscore = 1;//最高名次为1
1126
+                    int zfstunum = (int) students.stream().map(s -> s.getStudentid()).distinct().count();//学生数量
1127
+                    if (zfminscore > zfstunum) zfminscore = zfstunum;//最低名次=学生数量
1128
+                    rr.setMaxscore(zfmaxscore);
1129
+                    rr.setMinscore(zfminscore);
1130
+                    rr.setLinescore(linescore);
1131
+                    rr.setFloatscore(floatscore);
1132
+                    String zfrankrange = "[" + zfminscore + "," + zfmaxscore + "]";
1133
+                    rr.setRankname(zfrankrange);
1134
+                    rr.setSubjectid("zf");
1135
+                    rrankList.add(rr);
1136
+
1137
+                    for (Map.Entry<Integer, List<ERstudent>> entry : zfcollect.entrySet()) {
1138
+                        Integer classid = entry.getKey();
1139
+                        List<ERstudent> list = entry.getValue();
1140
+                        setLjmcTj(examid, userMap, rclassRankList, rr, zfrankrange, classid, subjectid, list);
1141
+                    }
1142
+                } else {
1143
+                    //分科统计
1144
+                    double maxscore = ExamUtil.sub(linescore, floatscore);//最高名次
1145
+                    double minscore = ExamUtil.add(linescore, floatscore);//最低名次
1146
+                    if (maxscore < 1) maxscore = 1;//最高名次为1
1147
+                    Integer stunum = students.size();//学生数量
1148
+                    if (minscore > stunum) minscore = stunum;//最低名次=学生数量
1149
+                    ERrank rrank = new ERrank();
1150
+                    rrank.setRanktype(ranktype);
1151
+                    rrank.setSubjectid(subjectid);
1152
+                    rrank.setMaxscore(maxscore);
1153
+                    rrank.setMinscore(minscore);
1154
+                    rrank.setLinescore(linescore);
1155
+                    rrank.setFloatscore(floatscore);
1156
+                    String rankrange = "[" + minscore + "," + maxscore + "]";
1157
+                    rrank.setRankname(rankrange);
1158
+                    rrankList.add(rrank);
1159
+
1160
+                    //全部班级统计
1161
+                    Integer classid = 0;
1162
+                    List<ERstudent> list = qbbjcollect.get(subjectid);
1163
+                    setLjmcTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1164
+
1165
+                    //班级科目统计
1166
+                    Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
1167
+                            .collect(Collectors.groupingBy(s -> s.getClassid()));
1168
+                    for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
1169
+                        classid = entry.getKey();
1170
+                        list = entry.getValue();
1171
+                        setLjmcTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1172
+                    }
1173
+                }
1174
+
1175
+            } else if (ranktype == 5) {//优秀年级前(10名)
1176
+                Integer linescore = lscore;
1177
+                ERrank rr = new ERrank();
1178
+                rr.setRanktype(ranktype);
1179
+                rr.setLinescore(linescore);
1180
+                String rankrange = "年级前" + linescore + "名";
1181
+                rr.setRankname(rankrange);
1182
+                if ("zf".equals(subjectid)) {
1183
+                    //总分统计
1184
+                    rr.setSubjectid("zf");
1185
+                    rrankList.add(rr);
1186
+                    for (Map.Entry<Integer, List<ERstudent>> entry : zfcollect.entrySet()) {
1187
+                        Integer classid = entry.getKey();
1188
+                        List<ERstudent> list = entry.getValue();
1189
+                        setNjqTj(examid, userMap, rclassRankList, rr, rankrange, classid, subjectid, list);
1190
+                    }
1191
+                } else {
1192
+                    //分科统计
1193
+                    ERrank rrank = new ERrank();
1194
+                    rrank.setRanktype(ranktype);
1195
+                    rrank.setRankname(rankrange);
1196
+                    rrank.setLinescore(linescore);
1197
+                    rrank.setSubjectid(subjectid);
1198
+                    rrankList.add(rrank);
1199
+                    //全部班级统计
1200
+                    Integer classid = 0;
1201
+                    List<ERstudent> list = qbbjcollect.get(subjectid);
1202
+                    setNjqTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1203
+
1204
+                    //班级科目统计
1205
+                    Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
1206
+                            .collect(Collectors.groupingBy(s -> s.getClassid()));
1207
+                    for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
1208
+                        classid = entry.getKey();
1209
+                        list = entry.getValue();
1210
+                        setNjqTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1211
+                    }
1212
+                }
1213
+            } else if (ranktype == 6) {//学困年级后(10名)
1214
+                Integer linescore = lscore;
1215
+                ERrank rr = new ERrank();
1216
+                rr.setRanktype(ranktype);
1217
+                rr.setLinescore(linescore);
1218
+                String rankrange = "年级后" + linescore + "名";
1219
+                rr.setRankname(rankrange);
1220
+                if ("zf".equals(subjectid)) {
1221
+                    //总分统计
1222
+                    rr.setSubjectid("zf");
1223
+                    rrankList.add(rr);
1224
+                    for (Map.Entry<Integer, List<ERstudent>> entry : zfcollect.entrySet()) {
1225
+                        Integer classid = entry.getKey();
1226
+                        List<ERstudent> list = entry.getValue();
1227
+                        setNjqTj(examid, userMap, rclassRankList, rr, rankrange, classid, subjectid, list);
1228
+                    }
1229
+                } else {
1230
+                    //分科统计
1231
+                    ERrank rrank = new ERrank();
1232
+                    rrank.setRanktype(ranktype);
1233
+                    rrank.setRankname(rankrange);
1234
+                    rrank.setLinescore(linescore);
1235
+                    rrank.setSubjectid(subjectid);
1236
+                    rrankList.add(rrank);
1237
+                    //全部班级统计
1238
+                    Integer classid = 0;
1239
+                    List<ERstudent> list = qbbjcollect.get(subjectid);
1240
+                    rrank.setMaxscore(getMaxScore(list, linescore));
1241
+                    setNjhTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1242
+
1243
+                    //班级科目统计
1244
+                    Map<Integer, List<ERstudent>> ccollect = students.stream().filter(s -> s.getSubjectid().equals(subjectid))
1245
+                            .collect(Collectors.groupingBy(s -> s.getClassid()));
1246
+                    for (Map.Entry<Integer, List<ERstudent>> entry : ccollect.entrySet()) {
1247
+                        classid = entry.getKey();
1248
+                        list = entry.getValue();
1249
+                        rrank.setMaxscore(getMaxScore(list, linescore));
1250
+                        setNjhTj(examid, userMap, rclassRankList, rrank, rankrange, classid, subjectid, list);
1251
+                    }
1252
+                    rrank.setMaxscore(null);
1253
+                }
1254
+            }
1255
+        }
1256
+
1257
+        int timestamp = N_Utils.getSecondTimestamp();
1258
+        rrankList.forEach(r -> {
1259
+            r.setExamid(examid);
1260
+            r.setCreateid(createid);
1261
+            r.setCreatetime(timestamp);
1262
+        });
1263
+        eRrankMapper.insertList(rrankList);
1264
+        eRclassRankMapper.insertList(rclassRankList);
1265
+    }
1266
+
893
     //获取最高分
1267
     //获取最高分
894
     private Double getMaxScore(List<ERstudent> cstudents, Integer linescore) {
1268
     private Double getMaxScore(List<ERstudent> cstudents, Integer linescore) {
895
         List<Double> cScore = cstudents.stream().map(s -> s.getScore()).distinct().sorted().collect(Collectors.toList());
1269
         List<Double> cScore = cstudents.stream().map(s -> s.getScore()).distinct().sorted().collect(Collectors.toList());

+ 1
- 14
sexam/src/main/java/com/xhkjedu/sexam/service/report/EReportSchoolService.java View File

1
 package com.xhkjedu.sexam.service.report;
1
 package com.xhkjedu.sexam.service.report;
2
 
2
 
3
-import com.xhkjedu.sexam.mapper.paperstudent.EPaperStudentMapper;
4
 import com.xhkjedu.sexam.mapper.report.ERbaseMapper;
3
 import com.xhkjedu.sexam.mapper.report.ERbaseMapper;
5
 import com.xhkjedu.sexam.mapper.report.EReportSchoolMapper;
4
 import com.xhkjedu.sexam.mapper.report.EReportSchoolMapper;
6
 import com.xhkjedu.sexam.mapper.report.ERsubjectMapper;
5
 import com.xhkjedu.sexam.mapper.report.ERsubjectMapper;
7
 import com.xhkjedu.sexam.mapper.reportclass.ERclassMapper;
6
 import com.xhkjedu.sexam.mapper.reportclass.ERclassMapper;
8
 import com.xhkjedu.sexam.mapper.reportclass.ERclassRankMapper;
7
 import com.xhkjedu.sexam.mapper.reportclass.ERclassRankMapper;
9
 import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
8
 import com.xhkjedu.sexam.mapper.reportstu.ERstudentMapper;
10
-import com.xhkjedu.sexam.mapper.system.UserMapper;
11
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
9
 import com.xhkjedu.sexam.model.reportstu.ERstudent;
12
 import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
10
 import com.xhkjedu.sexam.model.reportstu.ERstudentAction;
13
-import com.xhkjedu.sexam.vo.report.ERPaperVo;
14
 import com.xhkjedu.sexam.vo.report.ERankParamVo;
11
 import com.xhkjedu.sexam.vo.report.ERankParamVo;
15
-import com.xhkjedu.sexam.vo.system.UserVo;
16
 import org.springframework.stereotype.Service;
12
 import org.springframework.stereotype.Service;
17
 import org.springframework.transaction.annotation.Transactional;
13
 import org.springframework.transaction.annotation.Transactional;
18
 
14
 
44
     private EReportGenerateService eReportGenerateService;
40
     private EReportGenerateService eReportGenerateService;
45
     @Resource
41
     @Resource
46
     private EReportSchoolMapper eReportSchoolMapper;
42
     private EReportSchoolMapper eReportSchoolMapper;
47
-    @Resource
48
-    private EPaperStudentMapper ePaperStudentMapper;
49
-    @Resource
50
-    private UserMapper userMapper;
51
 
43
 
52
     //考试概况
44
     //考试概况
53
     public Map getKsGk(Integer examid) {
45
     public Map getKsGk(Integer examid) {
97
         Integer createid = rank.getCreateid();
89
         Integer createid = rank.getCreateid();
98
         Integer ranktype = rank.getRanktype();
90
         Integer ranktype = rank.getRanktype();
99
         eReportSchoolMapper.delByExamAndSubjectId(examid, subjectid, ranktype);//删除考试等级报告
91
         eReportSchoolMapper.delByExamAndSubjectId(examid, subjectid, ranktype);//删除考试等级报告
100
-        List<ERPaperVo> papers = eReportSchoolMapper.listByExamAndSubjectId(examid, subjectid);//考试试卷
101
-        List<ERstudent> students = ePaperStudentMapper.listByExamAndSubjectId(examid, subjectid);//考试试卷学生
102
-        List<Integer> userids = students.stream().map(ERstudent::getStudentid).distinct().collect(Collectors.toList());
103
-        List<UserVo> users = userMapper.listNameByUserIds(userids);
104
-        Map<Integer, String> userMap = users.stream().collect(Collectors.toMap(UserVo::getUserid, UserVo::getUsername));
105
-        eReportGenerateService.setClassGradeRank(examid, papers, students, rank.getRranks(), createid, userMap);//生成考试等级报告
92
+        eReportGenerateService.setSubjectRank(examid, subjectid, createid, rank.getRranks(), ranktype);//生成考试等级报告
106
         return eRclassRankMapper.listByExamId(rank);//考试等级报告列表
93
         return eRclassRankMapper.listByExamId(rank);//考试等级报告列表
107
     }
94
     }
108
 
95
 

+ 4
- 1
sexam/src/main/resources/mapper/paperstudent/EPaperStudentMapper.xml View File

198
     <!--考试试卷学生-->
198
     <!--考试试卷学生-->
199
     <select id="listByExamAndSubjectId" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
199
     <select id="listByExamAndSubjectId" resultType="com.xhkjedu.sexam.model.reportstu.ERstudent">
200
         select classid,examid,subjectid,studentid,stuscore score,sstate
200
         select classid,examid,subjectid,studentid,stuscore score,sstate
201
-        from e_paper_student where examid=#{examid} and subjectid=#{subjectid} and sstate!=0
201
+        from e_paper_student where examid=#{examid} and sstate!=0
202
+        <if test="subjectid!='zf'">
203
+            and subjectid=#{subjectid}
204
+        </if>
202
     </select>
205
     </select>
203
 
206
 
204
     <!--更改单个学生试卷分值-->
207
     <!--更改单个学生试卷分值-->

+ 7
- 0
sexam/src/main/resources/mapper/report/EReportGenerateMapper.xml View File

51
         where examid=#{examid} and good=1
51
         where examid=#{examid} and good=1
52
         group by studentid, subjectid, good
52
         group by studentid, subjectid, good
53
     </select>
53
     </select>
54
+    <!--获取试卷分数-->
55
+    <select id="getScoreByExamAndSubjectId" resultType="java.lang.Double">
56
+        select sum(ep.pscore) from e_paper ep where ep.examid=#{examid}
57
+        <if test="subjectid!='zf'">
58
+            and ep.subjectid=#{subjectid}
59
+        </if>
60
+    </select>
54
 </mapper>
61
 </mapper>

+ 0
- 4
sexam/src/main/resources/mapper/report/EReportSchoolMapper.xml View File

1
 <?xml version="1.0" encoding="UTF-8" ?>
1
 <?xml version="1.0" encoding="UTF-8" ?>
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
2
 <!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
3
 <mapper namespace="com.xhkjedu.sexam.mapper.report.EReportSchoolMapper">
3
 <mapper namespace="com.xhkjedu.sexam.mapper.report.EReportSchoolMapper">
4
-    <!--考试试卷-->
5
-    <select id="listByExamAndSubjectId" resultType="com.xhkjedu.sexam.vo.report.ERPaperVo">
6
-        select ep.subjectid,ep.pscore from e_paper ep where ep.examid=#{examid} and subjectid=#{subjectid}
7
-    </select>
8
     <!--删除考试等级报告-->
4
     <!--删除考试等级报告-->
9
     <delete id="delByExamAndSubjectId">
5
     <delete id="delByExamAndSubjectId">
10
         delete from e_rclass_rank where examid=#{examid} and subjectid=#{subjectid} and ranktype=#{ranktype};
6
         delete from e_rclass_rank where examid=#{examid} and subjectid=#{subjectid} and ranktype=#{ranktype};

Loading…
Cancel
Save