|
|
|
@ -92,7 +92,7 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
Long startTime = laborDto.getStartTime();
|
|
|
|
|
Long endTime = laborDto.getEndTime();
|
|
|
|
|
String subjectId = laborDto.getSubjectId();
|
|
|
|
|
String tmdId = laborDto.getTmdId();
|
|
|
|
|
//String tmdId = laborDto.getTmdId();
|
|
|
|
|
String grade = laborDto.getGrade();
|
|
|
|
|
String periodId = laborDto.getPeriodId();
|
|
|
|
|
String academicYearId = laborDto.getAcademicYearId();
|
|
|
|
@ -241,6 +241,79 @@ public class LaborEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
}
|
|
|
|
|
return resMap;
|
|
|
|
|
}
|
|
|
|
|
@Override
|
|
|
|
|
public Map<String, Object> getExamDetails(LaborDto laborDto, HttpServletRequest request) {
|
|
|
|
|
Map<String, Object> resMap = new HashMap<>();
|
|
|
|
|
try {
|
|
|
|
|
List<ExamClassResult> examResults = new ArrayList<>();
|
|
|
|
|
if (!laborDto.getExamId().isEmpty()) {
|
|
|
|
|
Map<String, List<List<String>>> knowledgeMap = new HashMap<>();
|
|
|
|
|
Map<String, List<Double>> points = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
// 1. 查询考试信息
|
|
|
|
|
Exam exam = examRepository.findExamById(String.format(PK.EXAM, laborDto.getTmdId()), laborDto.getExamId()).get(0);
|
|
|
|
|
if (exam.getPapers() != null && !exam.getPapers().isEmpty()) {
|
|
|
|
|
knowledgeMap.put(exam.getId(), exam.getPapers().get(0).getKnowledge());
|
|
|
|
|
points.put(exam.getId(), exam.getPapers().get(0).getPoint());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 查询考试结果
|
|
|
|
|
examResults = examClassResultRepository.findById(
|
|
|
|
|
String.format(PK.CLASS_RESULT, laborDto.getCode()),
|
|
|
|
|
laborDto.getClassId(),
|
|
|
|
|
laborDto.getExamId()
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 3. 查询知识块-知识点映射关系
|
|
|
|
|
Appraise appraise = appraiseRepository.findAppraiseBySchoolIdAndPeriodIdAndCode(
|
|
|
|
|
laborDto.getCode(),
|
|
|
|
|
laborDto.getPeriodId(),
|
|
|
|
|
PK.PK_APPRAISE
|
|
|
|
|
);
|
|
|
|
|
appraise = evaluationService.buildTree(appraise);
|
|
|
|
|
Map<String, List<String>> knowledgeBlockToPointsMap = getKnowledgeBlockToPointsMap(appraise);
|
|
|
|
|
|
|
|
|
|
// 4. 计算每个知识点的得分(调用 calculateStudentScoreRates)
|
|
|
|
|
Map<String, Double> knowledgeTotalScore = new HashMap<>();
|
|
|
|
|
if (!examResults.isEmpty()) {
|
|
|
|
|
// 假设计算所有学生的平均分(或指定某个学生)
|
|
|
|
|
String studentId = laborDto.getStudentId(); // 如果传入了学生ID
|
|
|
|
|
calculateStudentScoreRates(studentId, examResults, knowledgeMap, points, knowledgeTotalScore);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果没有考试数据,默认所有知识点60分
|
|
|
|
|
knowledgeMap.values().stream()
|
|
|
|
|
.flatMap(List::stream)
|
|
|
|
|
.flatMap(List::stream)
|
|
|
|
|
.forEach(knowledge -> knowledgeTotalScore.put(knowledge, 60.0));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 5. 按知识块分组,计算每个知识块下知识点的得分
|
|
|
|
|
List<Map<String, Object>> knowledgeBlockScores = new ArrayList<>();
|
|
|
|
|
for (Map.Entry<String, List<String>> entry : knowledgeBlockToPointsMap.entrySet()) {
|
|
|
|
|
String blockName = entry.getKey();
|
|
|
|
|
List<String> knowledgePoints = entry.getValue();
|
|
|
|
|
|
|
|
|
|
List<Map<String, Object>> pointScores = new ArrayList<>();
|
|
|
|
|
for (String point : knowledgePoints) {
|
|
|
|
|
double score = knowledgeTotalScore.getOrDefault(point, 60.0); // 默认60分
|
|
|
|
|
pointScores.add(new HashMap<String, Object>() {{
|
|
|
|
|
put("name", point);
|
|
|
|
|
put("score", score);
|
|
|
|
|
}});
|
|
|
|
|
}
|
|
|
|
|
knowledgeBlockScores.add(new HashMap<String, Object>() {{
|
|
|
|
|
put("name", blockName);
|
|
|
|
|
put("children", pointScores);
|
|
|
|
|
}});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
resMap.put("data", knowledgeBlockScores);
|
|
|
|
|
}
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(ErrorCode.SYSTEM_ERROR.getCode(), "数据查询异常");
|
|
|
|
|
}
|
|
|
|
|
return resMap;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Map<String, Object>> combineScoresWithExamResults(
|
|
|
|
|
List<Map<String, Object>> scores,
|
|
|
|
|