|
@@ -222,6 +222,8 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
}
|
|
|
//从考试信息中获取所有学生信息,在获取该学生所有考试成绩
|
|
|
List<ScoreDataStudentBo> scoreDataStudentBoList = bo.getScoreDataStudentBoList();
|
|
|
+ //存放所有学生的成绩详情,计算各学科排名
|
|
|
+ List<ScoreDataDetailBo> scoreDataDetailBoListAll = new ArrayList<>();
|
|
|
if (scoreDataStudentBoList != null && scoreDataStudentBoList.size() > 0) {
|
|
|
for (ScoreDataStudentBo scoreDataStudentBo : scoreDataStudentBoList) {
|
|
|
List<ScoreDataDetailBo> scoreDataDetailBoList = scoreDataStudentBo.getScoreDataDetailBoList();
|
|
@@ -237,15 +239,14 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
//scoreDataDetailBo.setScoreDataNameId(scoreDataStudentBo.getScoreDataNameId());
|
|
|
//插入满分
|
|
|
scoreDataDetailBo.setManfen(map.get(scoreDataDetailBo.getXueke()));
|
|
|
+ //把所有学生各学科成绩详情放入一个LIST
|
|
|
+ scoreDataDetailBoListAll.add(scoreDataDetailBo);
|
|
|
}
|
|
|
classZf = classZf + zf;
|
|
|
scoreDataStudentBo.setZongfen(zf);
|
|
|
//计算个人平均分 = 总分/学科数
|
|
|
scoreDataStudentBo.setAvg(String.valueOf(df.format(zf / scoreDataDetailBoList.size())));
|
|
|
scoreDataStudentBo.setScoreId(scoreId);
|
|
|
-
|
|
|
- scoreDataDetailMapper.insertBatch(MapstructUtils.convert(scoreDataDetailBoList, ScoreDataDetail.class));
|
|
|
-
|
|
|
}
|
|
|
}
|
|
|
//成绩排序
|
|
@@ -261,6 +262,36 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
}
|
|
|
studentBo.setScoreSort(index);
|
|
|
}
|
|
|
+
|
|
|
+ //插入学生成绩详情表
|
|
|
+ //计算各学科排名
|
|
|
+ //首先根据各学科进行分组
|
|
|
+ List<ScoreDataDetailBo> scoreDataDetailBoListResult = new ArrayList<>();
|
|
|
+
|
|
|
+ Map<String, List<ScoreDataDetailBo>> scoreDataDetailBoListAllXueKe = scoreDataDetailBoListAll.stream().collect(Collectors.groupingBy(ScoreDataDetailBo::getXueke));
|
|
|
+ if (scoreDataDetailBoListAllXueKe != null && scoreDataDetailBoListAllXueKe.size() > 0) {
|
|
|
+ int indexD = 0;// 排名
|
|
|
+ double lastScoreD = -1;// 最近一次的分
|
|
|
+ for (List<ScoreDataDetailBo> value : scoreDataDetailBoListAllXueKe.values()) {
|
|
|
+ //根据学科成绩进行倒序排序
|
|
|
+ value = value.stream().sorted(Comparator.comparingDouble(ScoreDataDetailBo::getScore).reversed()).collect(Collectors.toList());
|
|
|
+ indexD = 0;// 排名
|
|
|
+ lastScoreD = -1;// 最近一次的分
|
|
|
+ for (int i = 0; i < value.size(); i++) {
|
|
|
+ ScoreDataDetailBo scoreDataDetailBo = value.get(i);
|
|
|
+ if (Double.compare(lastScoreD, scoreDataDetailBo.getScore()) != 0) {
|
|
|
+ // 如果成绩和上一名的成绩不相同,那么排名+1
|
|
|
+ lastScoreD = scoreDataDetailBo.getScore();
|
|
|
+ indexD++;
|
|
|
+ }
|
|
|
+ scoreDataDetailBo.setScoreSort(indexD);
|
|
|
+ scoreDataDetailBoListResult.add(scoreDataDetailBo);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ scoreDataDetailMapper.insertBatch(MapstructUtils.convert(scoreDataDetailBoListResult, ScoreDataDetail.class));
|
|
|
+
|
|
|
+ //插入到学生表
|
|
|
scoreDataStudentMapper.insertBatch(MapstructUtils.convert(scoreDataStudentBoList, ScoreDataStudent.class));
|
|
|
|
|
|
//计算班级总分平均分=各学生总分/学生人数
|
|
@@ -473,6 +504,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
List<ScoreDataStudentVo> scoreDataStudentVos = scoreDataStudentMapper.gradeRank(scoreData);
|
|
|
Long scoreId = scoreData.getScoreId();
|
|
|
Map<String, Double> map = new HashMap<>();
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
if (scoreId != null) {
|
|
|
//过滤出本班学生id
|
|
|
scoreDataStudentVos = scoreDataStudentVos.stream().filter(scoreDataStudentVo -> scoreDataStudentVo.getScoreId().equals(scoreId)).sorted(Comparator.comparing(ScoreDataStudentVo::getZongfen).reversed()).collect(Collectors.toList());
|
|
@@ -489,7 +521,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
double sum = scoreDataDetailVosXueke.stream().mapToDouble(ScoreDataDetailVo::getScore).sum();
|
|
|
//计算学科平均分 = 学科总分 /人数
|
|
|
double xueKeAvg = sum / studentNumberList.size();
|
|
|
- map.put(xueke, xueKeAvg);
|
|
|
+ map.put(xueke, Double.valueOf(df.format(xueKeAvg)));
|
|
|
}
|
|
|
}
|
|
|
//总成绩均分
|
|
@@ -500,7 +532,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
//对学生成绩根据学生身份证进行分组
|
|
|
Map<String, List<ScoreDataDetailVo>> studentNumberCollect = scoreDataDetailVos.parallelStream().collect(Collectors.groupingBy(ScoreDataDetailVo::getStudentNumber));
|
|
|
for (ScoreDataStudentVo scoreDataStudentVo : scoreDataStudentVos) {
|
|
|
- scoreDataStudentVo.setAvg(String.valueOf(zongFenAvg));
|
|
|
+ scoreDataStudentVo.setAvg(String.valueOf(df.format(zongFenAvg)));
|
|
|
List<ScoreDataDetailVo> scoreDataDetailVosList = studentNumberCollect.get(scoreDataStudentVo.getStudentNumber());
|
|
|
if (scoreDataDetailVosList != null && scoreDataDetailVosList.size() > 0) {
|
|
|
for (ScoreDataDetailVo scoreDataDetailVo : scoreDataDetailVosList) {
|
|
@@ -593,8 +625,10 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
y2.add(scoreDataStudentVosListDown.size());
|
|
|
}
|
|
|
}
|
|
|
+ DecimalFormat df = new DecimalFormat("#.00");
|
|
|
+
|
|
|
map.put("x", x);
|
|
|
- map.put("avg", avg);
|
|
|
+ map.put("avg", df.format(avg));
|
|
|
map.put("y1", y1);
|
|
|
map.put("y2", y2);
|
|
|
}
|
|
@@ -631,7 +665,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
if (scoreDataStudentVosList != null && scoreDataStudentVosList.size() > 0) {
|
|
|
List<ScoreDataStudentVo> scoreDataStudentVosListUp = scoreDataStudentVosList.stream().filter(scoreDataStudent -> scoreDataStudent.getZongfen() >= avg)
|
|
|
.collect(Collectors.toList());
|
|
|
- List<ScoreDataStudentVo> scoreDataStudentVosListDown = scoreDataStudentVosList.stream().filter(scoreDataStudent -> scoreDataStudent.getZongfen()< avg)
|
|
|
+ List<ScoreDataStudentVo> scoreDataStudentVosListDown = scoreDataStudentVosList.stream().filter(scoreDataStudent -> scoreDataStudent.getZongfen() < avg)
|
|
|
.collect(Collectors.toList());
|
|
|
scoreDataVo.setUp(scoreDataStudentVosListUp.size());
|
|
|
scoreDataVo.setDown(scoreDataStudentVosListDown.size());
|
|
@@ -701,41 +735,41 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
}
|
|
|
}
|
|
|
//总人数
|
|
|
- float size = scoreDataStudentVos.size();
|
|
|
+ float size = scoreDataStudentVos.size();
|
|
|
|
|
|
if (size > 0) {
|
|
|
NumberFormat nf = NumberFormat.getPercentInstance();
|
|
|
nf.setMaximumFractionDigits(2);
|
|
|
if (a > 0) {
|
|
|
- map.put("OneZ", nf.format((float) a/size));
|
|
|
+ map.put("OneZ", nf.format((float) a / size));
|
|
|
|
|
|
}
|
|
|
if (b > 0) {
|
|
|
- map.put("TowZ", nf.format((float) b/size));
|
|
|
+ map.put("TowZ", nf.format((float) b / size));
|
|
|
|
|
|
}
|
|
|
if (c > 0) {
|
|
|
- map.put("ThrZ", nf.format((float) c/size));
|
|
|
+ map.put("ThrZ", nf.format((float) c / size));
|
|
|
|
|
|
}
|
|
|
if (d > 0) {
|
|
|
- map.put("ForZ", nf.format((float) d/size));
|
|
|
+ map.put("ForZ", nf.format((float) d / size));
|
|
|
|
|
|
}
|
|
|
if (e > 0) {
|
|
|
- map.put("FivZ", nf.format((float) e/size));
|
|
|
+ map.put("FivZ", nf.format((float) e / size));
|
|
|
|
|
|
}
|
|
|
if (f > 0) {
|
|
|
- map.put("SixZ", nf.format((float) f/size));
|
|
|
+ map.put("SixZ", nf.format((float) f / size));
|
|
|
|
|
|
}
|
|
|
if (g > 0) {
|
|
|
- map.put("SevZ", nf.format((float) g/size));
|
|
|
+ map.put("SevZ", nf.format((float) g / size));
|
|
|
|
|
|
}
|
|
|
if (h > 0) {
|
|
|
- map.put("EigZ", nf.format((float) h/size));
|
|
|
+ map.put("EigZ", nf.format((float) h / size));
|
|
|
|
|
|
}
|
|
|
}
|
|
@@ -810,7 +844,7 @@ public class ScoreDataServiceImpl implements IScoreDataService {
|
|
|
scoreDataVo.setScoreDataStudentVoList(scoreDataStudentVos);
|
|
|
return scoreDataVo;
|
|
|
}
|
|
|
- //查询考试对应的学生和成绩
|
|
|
+ //查询考试所有的学生和成绩
|
|
|
List<ScoreDataStudentVo> scoreDataStudentVos = scoreDataStudentMapper.selectScoreByScoreId(scoreData.getScoreId());
|
|
|
scoreDataVo.setScoreDataStudentVoList(scoreDataStudentVos);
|
|
|
return scoreDataVo;
|