update 德育 劳育接口调整

develop
hhb@hotmail.com 3 weeks ago
parent 2826c6616b
commit 6093f4f227

@ -1569,12 +1569,14 @@ public Map<String,List<Map<String, Object>>> getStudentMonthlyScores(LaborDto la
// 3. 获取考试及知识点映射 // 3. 获取考试及知识点映射
Map<String, List<List<String>>> examKnowledgeMap = new HashMap<>(); Map<String, List<List<String>>> examKnowledgeMap = new HashMap<>();
Map<String, List<Double>> points = new HashMap<>(); Map<String, List<Double>> points = new HashMap<>();
List<ExamVo> exams = getExamsWithKnowledge(laborDto, records, examKnowledgeMap, points); List<ExamVo> exams = getExamsWithKnowledge(laborDto, records, examKnowledgeMap, points);
// 4. 获取考试结果并按月份分组 // 4. 获取考试结果并按月份分组
List<String> targetStudents = laborDto.getClassId() != null ? List<String> targetStudents = laborDto.getClassId() != null ?
classStudentIds : Collections.singletonList(studentId); classStudentIds : Collections.singletonList(studentId);
//records有可能没有数据 重写monthlyResults
Map<Integer, List<ExamResultWrapper>> monthlyResults = getMonthlyExamResults( Map<Integer, List<ExamResultWrapper>> monthlyResults = getMonthlyExamResults(
schoolId, laborDto.getClassId(), exams, records, schoolId, laborDto.getClassId(), exams, records,
examKnowledgeMap, points, targetStudents // 传入目标学生列表 examKnowledgeMap, points, targetStudents // 传入目标学生列表
@ -1697,7 +1699,20 @@ public Map<String,List<Map<String, Object>>> getStudentMonthlyScores(LaborDto la
private List<ExamVo> getExamsWithKnowledge(LaborDto laborDto, List<LessonRecord> records, private List<ExamVo> getExamsWithKnowledge(LaborDto laborDto, List<LessonRecord> records,
Map<String, List<List<String>>> examKnowledgeMap, Map<String, List<List<String>>> examKnowledgeMap,
Map<String, List<Double>> points) { Map<String, List<Double>> points) {
List<String> lessonRecordIds = records.stream().map(LessonRecord::getId).collect(Collectors.toList()); if (records == null || records.isEmpty()) {
return Collections.emptyList();
}
List<String> lessonRecordIds = records.stream()
.map(LessonRecord::getId)
.filter(id -> id != null && !id.isEmpty())
.distinct()
.collect(Collectors.toList());
if (lessonRecordIds.isEmpty()) {
return Collections.emptyList();
}
List<ExamVo> exams = examRepository.findExamsByIds(laborDto.getSource(), lessonRecordIds); List<ExamVo> exams = examRepository.findExamsByIds(laborDto.getSource(), lessonRecordIds);
exams.forEach(exam -> { exams.forEach(exam -> {
@ -1712,13 +1727,16 @@ public Map<String,List<Map<String, Object>>> getStudentMonthlyScores(LaborDto la
.collect(Collectors.toList()); .collect(Collectors.toList());
} }
private Map<Integer, List<ExamResultWrapper>> getMonthlyExamResults( private Map<Integer, List<ExamResultWrapper>> getMonthlyExamResults(
String schoolId, String classId, List<ExamVo> exams, String schoolId, String classId, List<ExamVo> exams,
List<LessonRecord> records, Map<String, List<List<String>>> examKnowledgeMap, List<LessonRecord> records, Map<String, List<List<String>>> examKnowledgeMap,
Map<String, List<Double>> points, List<String> studentIds) { // 新增studentIds参数 Map<String, List<Double>> points, List<String> studentIds) { // 新增studentIds参数
Map<Integer, List<ExamResultWrapper>> monthlyResults = new HashMap<>(); Map<Integer, List<ExamResultWrapper>> monthlyResults = new HashMap<>();
if (exams == null || exams.isEmpty() || records == null || records.isEmpty()) {
return monthlyResults; // 安全退出,返回空 map
}
if (classId == null) { if (classId == null) {
exams.forEach(exam -> { exams.forEach(exam -> {
List<ExamClassResult> results = examClassResultRepository.findByStudentId( List<ExamClassResult> results = examClassResultRepository.findByStudentId(

@ -11,6 +11,7 @@ import cn.teammodel.model.dto.admin.common.GroupDto;
import cn.teammodel.model.dto.admin.common.RGroupList; import cn.teammodel.model.dto.admin.common.RGroupList;
import cn.teammodel.model.dto.admin.common.RMember; import cn.teammodel.model.dto.admin.common.RMember;
import cn.teammodel.model.dto.admin.labor.FindDto; import cn.teammodel.model.dto.admin.labor.FindDto;
import cn.teammodel.model.dto.admin.labor.LaborDto;
import cn.teammodel.model.entity.appraise.Appraise; import cn.teammodel.model.entity.appraise.Appraise;
import cn.teammodel.model.entity.appraise.AppraiseTreeNode; import cn.teammodel.model.entity.appraise.AppraiseTreeNode;
import cn.teammodel.model.entity.common.Exam; import cn.teammodel.model.entity.common.Exam;
@ -1697,7 +1698,20 @@ public class MoralEducationServiceImpl implements MoralEducationService {
private List<ExamVo> getExamsWithKnowledge(MoralDto moralDto, List<LessonRecord> records, private List<ExamVo> getExamsWithKnowledge(MoralDto moralDto, List<LessonRecord> records,
Map<String, List<List<String>>> examKnowledgeMap, Map<String, List<List<String>>> examKnowledgeMap,
Map<String, List<Double>> points) { Map<String, List<Double>> points) {
List<String> lessonRecordIds = records.stream().map(LessonRecord::getId).collect(Collectors.toList()); if (records == null || records.isEmpty()) {
return Collections.emptyList();
}
List<String> lessonRecordIds = records.stream()
.map(LessonRecord::getId)
.filter(id -> id != null && !id.isEmpty())
.distinct()
.collect(Collectors.toList());
if (lessonRecordIds.isEmpty()) {
return Collections.emptyList();
}
List<ExamVo> exams = examRepository.findExamsByIds(moralDto.getSource(), lessonRecordIds); List<ExamVo> exams = examRepository.findExamsByIds(moralDto.getSource(), lessonRecordIds);
exams.forEach(exam -> { exams.forEach(exam -> {

@ -64,7 +64,7 @@ public class AsyncTeacherService {
.collect(Collectors.toList()); .collect(Collectors.toList());
if (!updates.isEmpty()) { if (!updates.isEmpty()) {
ptTeacherRepository.saveAll(updates); //ptTeacherRepository.saveAll(updates);
// updates.forEach(pt -> PT_TEACHER_CACHE.put(pt.getCode(), pt)); // updates.forEach(pt -> PT_TEACHER_CACHE.put(pt.getCode(), pt));
} }
} catch (Exception e) { } catch (Exception e) {

Loading…
Cancel
Save