|
|
|
@ -7,6 +7,7 @@ import cn.teammodel.controller.admin.service.CommonService;
|
|
|
|
|
import cn.teammodel.controller.admin.service.LaborEducationService;
|
|
|
|
|
import cn.teammodel.model.dto.admin.common.GCDto;
|
|
|
|
|
import cn.teammodel.model.dto.admin.common.GroupDto;
|
|
|
|
|
import cn.teammodel.model.dto.admin.common.RGroupList;
|
|
|
|
|
import cn.teammodel.model.dto.admin.common.RMember;
|
|
|
|
|
import cn.teammodel.model.dto.admin.labor.LaborDto;
|
|
|
|
|
import cn.teammodel.model.entity.appraise.Appraise;
|
|
|
|
@ -27,6 +28,7 @@ import com.alibaba.fastjson.JSON;
|
|
|
|
|
import com.alibaba.fastjson.TypeReference;
|
|
|
|
|
import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -171,6 +173,7 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos = commonService.getGradeAndClass(new GCDto(schoolId, periodId));
|
|
|
|
|
Map<String, Object> resMap = new HashMap<>();
|
|
|
|
|
//处理德育知识块和知识点的关联关系
|
|
|
|
|
resMap.put("exams",exams);//评测明细
|
|
|
|
|
resMap.put("subjectiveCount", res.size()); //主观评价数
|
|
|
|
|
resMap.put("examCount", exams.size());//评测数量
|
|
|
|
|
resMap.put("lessonCount", records.size());//班会课数量
|
|
|
|
@ -310,7 +313,6 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> calculateScoresWithDetails(List<RecordVo> res, Appraise appraise) {
|
|
|
|
|
// 1. 构建知识点到知识块的映射 (一个知识块对应多个知识点)
|
|
|
|
|
Map<String, List<String>> knowledgeBlockToPointsMap = getKnowledgeBlockToPointsMap(appraise);
|
|
|
|
@ -336,6 +338,8 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
|
|
|
|
|
// 4. 遍历评价记录并统计得分
|
|
|
|
|
Map<String, Map<String, Integer>> studentScores = new HashMap<>();
|
|
|
|
|
Map<String, List<Map<String, Object>>> studentAppraises = new HashMap<>(); // 存储每个学生的评价记录
|
|
|
|
|
|
|
|
|
|
for (RecordVo record : res) {
|
|
|
|
|
String studentId = record.getTargetId(); // 学生 ID
|
|
|
|
|
String studentName = record.getTargetName(); // 学生名称
|
|
|
|
@ -354,11 +358,17 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
studentScores.putIfAbsent(studentKey, new HashMap<>());
|
|
|
|
|
Map<String, Integer> studentScoreMap = studentScores.get(studentKey);
|
|
|
|
|
|
|
|
|
|
// 计分
|
|
|
|
|
// 计分
|
|
|
|
|
int score = isPraise ? 1 : -1;
|
|
|
|
|
int currentScore = studentScoreMap.getOrDefault(knowledgeBlock, 0) + score;
|
|
|
|
|
studentScoreMap.put(knowledgeBlock, Math.max(currentScore, 0));
|
|
|
|
|
studentScoreMap.put(knowledgeBlock, currentScore);
|
|
|
|
|
|
|
|
|
|
// 存储每个学生的评价记录
|
|
|
|
|
studentAppraises.putIfAbsent(studentKey, new ArrayList<>());
|
|
|
|
|
Map<String, Object> appraiseRecord = new HashMap<>();
|
|
|
|
|
appraiseRecord.put("appraiseName", appraiseName);
|
|
|
|
|
appraiseRecord.put("isPraise", isPraise);
|
|
|
|
|
studentAppraises.get(studentKey).add(appraiseRecord);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. 初始化缺失的二级知识块分数
|
|
|
|
@ -370,9 +380,39 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6. 整理并返回结果
|
|
|
|
|
return getMaps(studentScores);
|
|
|
|
|
return getMaps(studentScores, studentAppraises);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 整理并返回结果
|
|
|
|
|
private static List<Map<String, Object>> getMaps(Map<String, Map<String, Integer>> studentScores, Map<String, List<Map<String, Object>>> studentAppraises) {
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
for (Map.Entry<String, Map<String, Integer>> entry : studentScores.entrySet()) {
|
|
|
|
|
String studentKey = entry.getKey();
|
|
|
|
|
Map<String, Integer> scoreMap = entry.getValue();
|
|
|
|
|
List<Map<String, Object>> appraiseList = studentAppraises.get(studentKey); // 获取学生的评价记录
|
|
|
|
|
|
|
|
|
|
// 解析学生唯一标识
|
|
|
|
|
String[] studentInfo = studentKey.split("\\|");
|
|
|
|
|
String studentId = studentInfo[0];
|
|
|
|
|
String studentName = studentInfo[1];
|
|
|
|
|
String className = studentInfo[2];
|
|
|
|
|
|
|
|
|
|
// 构建返回结果
|
|
|
|
|
Map<String, Object> studentResult = new HashMap<>();
|
|
|
|
|
studentResult.put("studentId", studentId);
|
|
|
|
|
studentResult.put("studentName", studentName);
|
|
|
|
|
studentResult.put("className", className);
|
|
|
|
|
studentResult.put("scores", scoreMap);
|
|
|
|
|
studentResult.put("appraises", appraiseList); // 添加评价记录
|
|
|
|
|
|
|
|
|
|
result.add(studentResult);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 整理并返回结果
|
|
|
|
|
private static List<Map<String, Object>> getMaps(Map<String, Map<String, Integer>> studentScores) {
|
|
|
|
|
List<Map<String, Object>> result = new ArrayList<>();
|
|
|
|
@ -495,8 +535,9 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
Map<String, List<List<String>>> knowledgeMap,
|
|
|
|
|
Appraise appraise,
|
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
|
List<RecordVo> res
|
|
|
|
|
, HttpServletRequest request) { // 新增主观评价记录
|
|
|
|
|
List<RecordVo> res,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
// 将 classId 转换为 List<String>
|
|
|
|
|
List<String> classIds = Collections.singletonList(classId);
|
|
|
|
|
GroupDto groupDto = new GroupDto();
|
|
|
|
@ -504,15 +545,25 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
groupDto.setSchoolId(appraise.getSchoolId());
|
|
|
|
|
String url = environment.getProperty("ies.server-url-group");
|
|
|
|
|
Map<String, Object> groupId = GroupUtil.getGroupId(groupDto, new GroupUtil(environment), request, url);
|
|
|
|
|
List<RGroupList> rGroupList = new ArrayList<>();
|
|
|
|
|
List<RMember> rMembers = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Object> entry : groupId.entrySet()) {
|
|
|
|
|
String key = entry.getKey();
|
|
|
|
|
Object value = entry.getValue();
|
|
|
|
|
if (key.equals("groups")) {
|
|
|
|
|
String jsonGroups = JSON.toJSONString(value);
|
|
|
|
|
rGroupList = JSON.parseObject(jsonGroups, new TypeReference<List<RGroupList>>() {});
|
|
|
|
|
}
|
|
|
|
|
if (key.equals("members")) {
|
|
|
|
|
String jsonGroups = JSON.toJSONString(value);
|
|
|
|
|
rMembers = JSON.parseObject(jsonGroups, new TypeReference<List<RMember>>() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
String className = rGroupList.stream()
|
|
|
|
|
.filter(rGroupList1 -> rGroupList1.getId().equals(classId))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.map(RGroupList::getName)
|
|
|
|
|
.orElse("未知班级"); // 如果未找到则返回默认值 "未知班级"
|
|
|
|
|
|
|
|
|
|
// 1. 获取班级所有学生的客观分数
|
|
|
|
|
Map<String, Map<String, Double>> studentScoreRates = new HashMap<>();
|
|
|
|
@ -552,7 +603,6 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
Map<String, Map<String, Double>> subjectiveScores = new HashMap<>();
|
|
|
|
|
for (Map<String, Object> studentScore : subjectiveScoresList) {
|
|
|
|
|
String studentId = (String) studentScore.get("studentId");
|
|
|
|
|
// 修改这里:假设 scores 是 Map<String, Integer>
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
Map<String, Integer> scores = (Map<String, Integer>) studentScore.get("scores");
|
|
|
|
|
Map<String, Double> convertedScores = new HashMap<>();
|
|
|
|
@ -614,10 +664,44 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 7. 返回结果
|
|
|
|
|
// 7. 转换 classScoreRates 和 studentScoreRates 为新的数据结构
|
|
|
|
|
List<Map<String, Object>> adjustedClassScoreRates = new ArrayList<>();
|
|
|
|
|
Map<String, Object> classScore = new HashMap<>();
|
|
|
|
|
classScore.put("className", className); // 设置班级名称
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> classBlocks = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Double> entry : compositeClassScoreRates.entrySet()) {
|
|
|
|
|
Map<String, Object> block = new HashMap<>();
|
|
|
|
|
block.put("name", entry.getKey());
|
|
|
|
|
block.put("score", entry.getValue());
|
|
|
|
|
classBlocks.add(block);
|
|
|
|
|
}
|
|
|
|
|
classScore.put("blocks", classBlocks);
|
|
|
|
|
adjustedClassScoreRates.add(classScore);
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> adjustedStudentScoreRates = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Map<String, Double>> entry : compositeStudentScores.entrySet()) {
|
|
|
|
|
String studentId = entry.getKey();
|
|
|
|
|
Map<String, Double> scores = entry.getValue();
|
|
|
|
|
|
|
|
|
|
Map<String, Object> studentScore = new HashMap<>();
|
|
|
|
|
studentScore.put("studentName", studentId); // 设置学生名称
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> studentBlocks = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Double> scoreEntry : scores.entrySet()) {
|
|
|
|
|
Map<String, Object> block = new HashMap<>();
|
|
|
|
|
block.put("name", scoreEntry.getKey());
|
|
|
|
|
block.put("score", scoreEntry.getValue());
|
|
|
|
|
studentBlocks.add(block);
|
|
|
|
|
}
|
|
|
|
|
studentScore.put("blocks", studentBlocks);
|
|
|
|
|
adjustedStudentScoreRates.add(studentScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 8. 返回结果
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put("classScoreRates", compositeClassScoreRates); // 班级整体得分率
|
|
|
|
|
result.put("studentScoreRates", compositeStudentScores); // 每个学生的综合得分率
|
|
|
|
|
result.put("classScoreRates", adjustedClassScoreRates); // 班级整体得分率
|
|
|
|
|
result.put("studentScoreRates", adjustedStudentScoreRates); // 每个学生的综合得分率
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -730,7 +814,11 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
.filter(gradeAndClassVo -> String.valueOf(gradeAndClassVo.getGradeId()).equals(gradeId))
|
|
|
|
|
.flatMap(gradeAndClassVo -> gradeAndClassVo.getClasses().stream())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
String gradeName = gradeAndClassVos.stream()
|
|
|
|
|
.filter(gradeAndClassVo -> String.valueOf(gradeAndClassVo.getGradeId()).equals(gradeId))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.map(GradeAndClassVo::getGradeName)
|
|
|
|
|
.orElse("");
|
|
|
|
|
// 过滤出该年级的考试结果
|
|
|
|
|
List<ExamClassResult> gradeExamResults = examResults.stream()
|
|
|
|
|
.filter(examResult -> examResult.getGradeId().equals(gradeId))
|
|
|
|
@ -743,7 +831,6 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
Map<String, Map<String, Double>> subjectiveScores = new HashMap<>();
|
|
|
|
|
for (Map<String, Object> studentScore : subjectiveScoresList) {
|
|
|
|
|
String studentId = (String) studentScore.get("studentId");
|
|
|
|
|
// 修改这里:假设 scores 是 Map<String, Integer>
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
Map<String, Integer> scores = (Map<String, Integer>) studentScore.get("scores");
|
|
|
|
|
Map<String, Double> convertedScores = new HashMap<>();
|
|
|
|
@ -854,15 +941,50 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
// 6. 转换 gradeScores 和 classScores 为新的数据结构
|
|
|
|
|
return getStringObjectMap(gradeName, gradeScores, classScores);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 6. 返回结果
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put("gradeScores", gradeScores); // 年级平均得分
|
|
|
|
|
result.put("classScores", classScores); // 每个班级的平均得分
|
|
|
|
|
return result;
|
|
|
|
|
private static @NotNull Map<String, Object> getStringObjectMap(String gradeName, Map<String, Double> gradeScores, Map<String, Map<String, Double>> classScores) {
|
|
|
|
|
List<Map<String, Object>> adjustedGradeScores = new ArrayList<>();
|
|
|
|
|
Map<String, Object> gradeScore = new HashMap<>();
|
|
|
|
|
gradeScore.put("gradeName", gradeName); // 设置年级名称
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> gradeBlocks = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Double> entry : gradeScores.entrySet()) {
|
|
|
|
|
Map<String, Object> block = new HashMap<>();
|
|
|
|
|
block.put("name", entry.getKey());
|
|
|
|
|
block.put("score", entry.getValue());
|
|
|
|
|
gradeBlocks.add(block);
|
|
|
|
|
}
|
|
|
|
|
gradeScore.put("blocks", gradeBlocks);
|
|
|
|
|
adjustedGradeScores.add(gradeScore);
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> adjustedClassScores = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Map<String, Double>> entry : classScores.entrySet()) {
|
|
|
|
|
String className = entry.getKey();
|
|
|
|
|
Map<String, Double> scores = entry.getValue();
|
|
|
|
|
|
|
|
|
|
Map<String, Object> classScore = new HashMap<>();
|
|
|
|
|
classScore.put("className", className); // 设置班级名称
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> classBlocks = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Double> scoreEntry : scores.entrySet()) {
|
|
|
|
|
Map<String, Object> block = new HashMap<>();
|
|
|
|
|
block.put("name", scoreEntry.getKey());
|
|
|
|
|
block.put("score", scoreEntry.getValue());
|
|
|
|
|
classBlocks.add(block);
|
|
|
|
|
}
|
|
|
|
|
classScore.put("blocks", classBlocks);
|
|
|
|
|
adjustedClassScores.add(classScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 7. 返回结果
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put("gradeScores", adjustedGradeScores); // 年级平均得分
|
|
|
|
|
result.put("classScores", adjustedClassScores); // 每个班级的平均得分
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static Map<String, Object> calculateKnowledgeScoreForSchool(
|
|
|
|
@ -872,22 +994,17 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
|
List<RecordVo> res,
|
|
|
|
|
List<School.Period> period,
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos) { // 新增主观评价记录
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos) {
|
|
|
|
|
|
|
|
|
|
// 1. 获取全校所有年级的客观分数
|
|
|
|
|
Map<String, Map<String, Double>> gradeScores = new HashMap<>();
|
|
|
|
|
Map<String, Double> schoolScores = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 获取所有年级的 ID
|
|
|
|
|
List<String> gradeIds = period.stream()
|
|
|
|
|
.flatMap(period1 -> period1.getGrades().stream())
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
/*Set<String> gradeIds = examResults.stream()
|
|
|
|
|
.map(ExamClassResult::getGradeId)
|
|
|
|
|
.collect(Collectors.toSet());*/
|
|
|
|
|
|
|
|
|
|
// 2. 获取全校所有学生的主观分数(次数)
|
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise);
|
|
|
|
|
|
|
|
|
@ -895,7 +1012,6 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
Map<String, Map<String, Double>> subjectiveScores = new HashMap<>();
|
|
|
|
|
for (Map<String, Object> studentScore : subjectiveScoresList) {
|
|
|
|
|
String studentId = (String) studentScore.get("studentId");
|
|
|
|
|
// 修改这里:假设 scores 是 Map<String, Integer>
|
|
|
|
|
@SuppressWarnings("unchecked")
|
|
|
|
|
Map<String, Integer> scores = (Map<String, Integer>) studentScore.get("scores");
|
|
|
|
|
Map<String, Double> convertedScores = new HashMap<>();
|
|
|
|
@ -914,24 +1030,45 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
// 4. 遍历所有年级
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (String gradeId : gradeIds) {
|
|
|
|
|
// 计算该年级的平均得分(包含主观和客观分数)
|
|
|
|
|
// 调用改造后的方法,返回的 gradeResult 包含列表结构的 gradeScores 和 classScores
|
|
|
|
|
Map<String, Object> gradeResult = calculateKnowledgeScoreForGrade(
|
|
|
|
|
String.valueOf(index), examResults, knowledgeMap, appraise, points, res, gradeAndClassVos
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 获取该年级的平均得分
|
|
|
|
|
Map<String, Double> gradeScoresInner = (Map<String, Double>) gradeResult.get("gradeScores");
|
|
|
|
|
// 1. 提取年级平均得分(gradeScores)
|
|
|
|
|
List<Map<String, Object>> adjustedGradeScores = (List<Map<String, Object>>) gradeResult.get("gradeScores");
|
|
|
|
|
Map<String, Double> gradeScoresInner = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 遍历年级得分列表(通常只有一个元素)
|
|
|
|
|
for (Map<String, Object> gradeScoreEntry : adjustedGradeScores) {
|
|
|
|
|
String gradeName = (String) gradeScoreEntry.get("gradeName");
|
|
|
|
|
List<Map<String, Object>> blocks = (List<Map<String, Object>>) gradeScoreEntry.get("blocks");
|
|
|
|
|
|
|
|
|
|
// 将 blocks 转换为 Map<String, Double>
|
|
|
|
|
for (Map<String, Object> block : blocks) {
|
|
|
|
|
String nodeName = (String) block.get("name");
|
|
|
|
|
Double score = (Double) block.get("score");
|
|
|
|
|
gradeScoresInner.put(nodeName, score);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 保存年级得分
|
|
|
|
|
gradeScores.put(gradeId, gradeScoresInner);
|
|
|
|
|
|
|
|
|
|
// 累加全校的得分总和
|
|
|
|
|
Map<String, Map<String, Double>> classScores = (Map<String, Map<String, Double>>) gradeResult.get("classScores");
|
|
|
|
|
for (Map<String, Double> classScoresInner : classScores.values()) {
|
|
|
|
|
for (Map.Entry<String, Double> entry : classScoresInner.entrySet()) {
|
|
|
|
|
String nodeName = entry.getKey();
|
|
|
|
|
double score = entry.getValue();
|
|
|
|
|
// 2. 累加全校得分总和(从 classScores 中提取)
|
|
|
|
|
List<Map<String, Object>> adjustedClassScores = (List<Map<String, Object>>) gradeResult.get("classScores");
|
|
|
|
|
|
|
|
|
|
for (Map<String, Object> classScoreEntry : adjustedClassScores) {
|
|
|
|
|
List<Map<String, Object>> classBlocks = (List<Map<String, Object>>) classScoreEntry.get("blocks");
|
|
|
|
|
|
|
|
|
|
// 遍历班级的每个评分项
|
|
|
|
|
for (Map<String, Object> block : classBlocks) {
|
|
|
|
|
String nodeName = (String) block.get("name");
|
|
|
|
|
Double score = (Double) block.get("score");
|
|
|
|
|
schoolScores.put(nodeName, schoolScores.getOrDefault(nodeName, 0.0) + score);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
index++;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -959,10 +1096,45 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 7. 返回结果
|
|
|
|
|
// 7. 转换 gradeScores 为新的数据结构
|
|
|
|
|
List<Map<String, Object>> adjustedGradeScores = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Map<String, Double>> entry : gradeScores.entrySet()) {
|
|
|
|
|
String gradeName = entry.getKey();
|
|
|
|
|
Map<String, Double> scores = entry.getValue();
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> blocks = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Double> scoreEntry : scores.entrySet()) {
|
|
|
|
|
Map<String, Object> block = new HashMap<>();
|
|
|
|
|
block.put("name", scoreEntry.getKey());
|
|
|
|
|
block.put("score", scoreEntry.getValue());
|
|
|
|
|
blocks.add(block);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
Map<String, Object> gradeScore = new HashMap<>();
|
|
|
|
|
gradeScore.put("gradeName", gradeName);
|
|
|
|
|
gradeScore.put("blocks", blocks);
|
|
|
|
|
adjustedGradeScores.add(gradeScore);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 8. 转换 schoolScores 为新的数据结构
|
|
|
|
|
List<Map<String, Object>> adjustedSchoolScores = new ArrayList<>();
|
|
|
|
|
Map<String, Object> schoolScore = new HashMap<>();
|
|
|
|
|
schoolScore.put("gradeName", "全校"); // 全校的 gradeName 设置为 "全校"
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> schoolBlocks = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, Double> entry : schoolScores.entrySet()) {
|
|
|
|
|
Map<String, Object> block = new HashMap<>();
|
|
|
|
|
block.put("name", entry.getKey());
|
|
|
|
|
block.put("score", entry.getValue());
|
|
|
|
|
schoolBlocks.add(block);
|
|
|
|
|
}
|
|
|
|
|
schoolScore.put("blocks", schoolBlocks);
|
|
|
|
|
adjustedSchoolScores.add(schoolScore);
|
|
|
|
|
|
|
|
|
|
// 9. 返回结果
|
|
|
|
|
Map<String, Object> result = new HashMap<>();
|
|
|
|
|
result.put("schoolScores", schoolScores); // 全校平均得分
|
|
|
|
|
result.put("gradeScores", gradeScores); // 每个年级的平均得分
|
|
|
|
|
result.put("schoolScores", adjustedSchoolScores); // 全校平均得分
|
|
|
|
|
result.put("gradeScores", adjustedGradeScores); // 每个年级的平均得分
|
|
|
|
|
return result;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|