|
|
|
@ -885,6 +885,7 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
.findFirst()
|
|
|
|
|
.map(GradeAndClassVo::getGradeName)
|
|
|
|
|
.orElse("");
|
|
|
|
|
|
|
|
|
|
// 过滤出该年级的考试结果
|
|
|
|
|
List<ExamClassResult> gradeExamResults = examResults.stream()
|
|
|
|
|
.filter(examResult -> examResult.getGradeId().equals(gradeId))
|
|
|
|
@ -893,8 +894,13 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
// 2. 获取年级所有学生的主观分数(次数)
|
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise);
|
|
|
|
|
|
|
|
|
|
// 3. 将主观次数转换为0-100分数
|
|
|
|
|
// 3. 将主观次数转换为0-100分数,并收集学生班级信息
|
|
|
|
|
Map<String, Map<String, Double>> subjectiveScores = new HashMap<>();
|
|
|
|
|
Map<String, String> studentClassMap = new HashMap<>(); // 学生ID到班级ID的映射
|
|
|
|
|
for (RecordVo record : res) {
|
|
|
|
|
// 假设RecordVo中有getStudentId()和getClassId()方法
|
|
|
|
|
studentClassMap.put(record.getTargetId(), record.getClassId());
|
|
|
|
|
}
|
|
|
|
|
for (Map<String, Object> studentScore : subjectiveScoresList) {
|
|
|
|
|
String studentId = (String) studentScore.get("studentId");
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
@ -905,37 +911,39 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
String block = entry.getKey();
|
|
|
|
|
int count = entry.getValue();
|
|
|
|
|
double maxCount = 50.0;
|
|
|
|
|
double convertedScore;
|
|
|
|
|
if (count > maxCount) {
|
|
|
|
|
convertedScore = 100.0; // 如果次数超过最大次数,设置为满分
|
|
|
|
|
} else {
|
|
|
|
|
convertedScore = (count / maxCount) * 100;
|
|
|
|
|
double convertedScore = (count > maxCount) ? 100.0 : (count / maxCount) * 100;
|
|
|
|
|
convertedScore = Double.parseDouble(String.format("%.2f", convertedScore));
|
|
|
|
|
}
|
|
|
|
|
convertedScores.put(block, convertedScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
subjectiveScores.put(studentId, convertedScores);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. 遍历年级下的所有班级
|
|
|
|
|
for (GradeAndClassVo.CI info : classInfos) {
|
|
|
|
|
String classId = info.getClassId();
|
|
|
|
|
String className = info.getClassName();
|
|
|
|
|
Map<String, Double> classScoresInner = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
for (ExamClassResult examResult : gradeExamResults) {
|
|
|
|
|
if (examResult.getInfo().getId().equals(info.getClassId())) {
|
|
|
|
|
// 获取该班级的所有学生ID(来自res记录)
|
|
|
|
|
List<String> studentIdsInClass = studentClassMap.entrySet().stream()
|
|
|
|
|
.filter(entry -> entry.getValue().equals(classId))
|
|
|
|
|
.map(Map.Entry::getKey)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
Map<String, Double> classScoreSum = new HashMap<>();
|
|
|
|
|
Map<String, Integer> classScoreCount = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 获取学生状态列表
|
|
|
|
|
List<Integer> statuses = examResult.getStatus();
|
|
|
|
|
// 遍历班级中的每个学生
|
|
|
|
|
for (int i = 0; i < examResult.getStudentIds().size(); i++) {
|
|
|
|
|
String studentId = examResult.getStudentIds().get(i);
|
|
|
|
|
if (statuses.get(i) == 1) {
|
|
|
|
|
continue;
|
|
|
|
|
for (String studentId : studentIdsInClass) {
|
|
|
|
|
// 获取学生状态(从考试结果中查找,默认为有效)
|
|
|
|
|
int status = 0;
|
|
|
|
|
for (ExamClassResult examResult : gradeExamResults) {
|
|
|
|
|
int index = examResult.getStudentIds().indexOf(studentId);
|
|
|
|
|
if (index != -1) {
|
|
|
|
|
status = examResult.getStatus().get(index);
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (status == 1) continue;
|
|
|
|
|
|
|
|
|
|
// 计算学生的知识点得分(客观分数)
|
|
|
|
|
Map<String, Double> studentObjectiveScores = calculateKnowledgeScoreRateForStudent(
|
|
|
|
@ -945,75 +953,65 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
// 获取学生的主观分数
|
|
|
|
|
Map<String, Double> studentSubjectiveScores = subjectiveScores.getOrDefault(studentId, new HashMap<>());
|
|
|
|
|
|
|
|
|
|
// 确定所有需要处理的评分块(合并主客观的块)
|
|
|
|
|
Set<String> allBlocks = new HashSet<>();
|
|
|
|
|
allBlocks.addAll(studentObjectiveScores.keySet());
|
|
|
|
|
allBlocks.addAll(studentSubjectiveScores.keySet());
|
|
|
|
|
|
|
|
|
|
// 计算综合得分(主观60%,客观40%)
|
|
|
|
|
Map<String, Double> studentCompositeScores = new HashMap<>();
|
|
|
|
|
for (Map.Entry<String, Double> entry : studentObjectiveScores.entrySet()) {
|
|
|
|
|
String block = entry.getKey();
|
|
|
|
|
double objectiveScore = entry.getValue();
|
|
|
|
|
for (String block : allBlocks) {
|
|
|
|
|
double objectiveScore = studentObjectiveScores.getOrDefault(block, 0.0);
|
|
|
|
|
double subjectiveScore = studentSubjectiveScores.getOrDefault(block, 0.0);
|
|
|
|
|
double compositeScore = (subjectiveScore * 0.6) + (objectiveScore * 0.4);
|
|
|
|
|
studentCompositeScores.put(block, compositeScore);
|
|
|
|
|
}
|
|
|
|
|
compositeScore = Double.parseDouble(String.format("%.2f", compositeScore));
|
|
|
|
|
|
|
|
|
|
// 累加班级整体得分
|
|
|
|
|
for (Map.Entry<String, Double> entry : studentCompositeScores.entrySet()) {
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
|
double score = entry.getValue();
|
|
|
|
|
classScoreSum.put(nodeName, classScoreSum.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
|
classScoreCount.put(nodeName, classScoreCount.getOrDefault(nodeName, 0) + 1);
|
|
|
|
|
// 累加班级得分
|
|
|
|
|
classScoreSum.put(block, classScoreSum.getOrDefault(block, 0.0) + compositeScore);
|
|
|
|
|
classScoreCount.put(block, classScoreCount.getOrDefault(block, 0) + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 计算班级平均得分
|
|
|
|
|
for (Map.Entry<String, Double> entry : classScoreSum.entrySet()) {
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
|
double totalScore = entry.getValue();
|
|
|
|
|
int count = classScoreCount.get(nodeName);
|
|
|
|
|
classScoresInner.put(nodeName, Double.parseDouble(String.format("%.2f", totalScore / count))); // 保留小数点后两位
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (String block : classScoreSum.keySet()) {
|
|
|
|
|
double total = classScoreSum.get(block);
|
|
|
|
|
int count = classScoreCount.getOrDefault(block, 1);
|
|
|
|
|
classScoresInner.put(block, Double.parseDouble(String.format("%.2f", total / count)));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化所有同层的父节点
|
|
|
|
|
// 初始化所有同层的父节点(确保结构完整)
|
|
|
|
|
for (AppraiseTreeNode node : appraise.getNodes()) {
|
|
|
|
|
if ("德育".equals(node.getName())) {
|
|
|
|
|
for (AppraiseTreeNode child : node.getChildren()) {
|
|
|
|
|
classScoresInner.putIfAbsent(child.getName(), 0.0);
|
|
|
|
|
}
|
|
|
|
|
node.getChildren().forEach(child ->
|
|
|
|
|
classScoresInner.putIfAbsent(child.getName(), 0.0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 存储班级的平均得分
|
|
|
|
|
classScores.put(className, classScoresInner);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. 计算年级的平均得分
|
|
|
|
|
Map<String, Double> gradeScoreSum = new HashMap<>();
|
|
|
|
|
Map<String, Integer> gradeScoreCount = new HashMap<>();
|
|
|
|
|
for (Map<String, Double> classScore : classScores.values()) {
|
|
|
|
|
for (Map.Entry<String, Double> entry : classScore.entrySet()) {
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
|
double score = entry.getValue();
|
|
|
|
|
gradeScoreSum.put(nodeName, gradeScoreSum.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
|
gradeScoreCount.put(nodeName, gradeScoreCount.getOrDefault(nodeName, 0) + 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (Map.Entry<String, Double> entry : gradeScoreSum.entrySet()) {
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
|
double totalScore = entry.getValue();
|
|
|
|
|
int count = gradeScoreCount.get(nodeName);
|
|
|
|
|
gradeScores.put(nodeName, Double.parseDouble(String.format("%.2f", totalScore / count))); // 保留小数点后两位
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 初始化所有同层的父节点
|
|
|
|
|
classScores.values().forEach(classScore ->
|
|
|
|
|
classScore.forEach((block, score) -> {
|
|
|
|
|
gradeScoreSum.put(block, gradeScoreSum.getOrDefault(block, 0.0) + score);
|
|
|
|
|
gradeScoreCount.put(block, gradeScoreCount.getOrDefault(block, 0) + 1);
|
|
|
|
|
}));
|
|
|
|
|
|
|
|
|
|
gradeScoreSum.forEach((block, total) -> {
|
|
|
|
|
int count = gradeScoreCount.getOrDefault(block, 1);
|
|
|
|
|
gradeScores.put(block, Double.parseDouble(String.format("%.2f", total / count)));
|
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
// 初始化年级层级的父节点
|
|
|
|
|
for (AppraiseTreeNode node : appraise.getNodes()) {
|
|
|
|
|
if ("德育".equals(node.getName())) {
|
|
|
|
|
for (AppraiseTreeNode child : node.getChildren()) {
|
|
|
|
|
gradeScores.putIfAbsent(child.getName(), 0.0);
|
|
|
|
|
node.getChildren().forEach(child ->
|
|
|
|
|
gradeScores.putIfAbsent(child.getName(), 0.0));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 6. 转换 gradeScores 和 classScores 为新的数据结构
|
|
|
|
|
|
|
|
|
|
// 6. 转换数据结构并返回
|
|
|
|
|
return getStringObjectMap(gradeName, gradeScores, classScores);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|