|
|
|
@ -4,7 +4,7 @@ import cn.teammodel.common.ErrorCode;
|
|
|
|
|
import cn.teammodel.common.PK;
|
|
|
|
|
import cn.teammodel.config.exception.ServiceException;
|
|
|
|
|
import cn.teammodel.controller.admin.service.CommonService;
|
|
|
|
|
import cn.teammodel.controller.admin.service.MoralEducationService;
|
|
|
|
|
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;
|
|
|
|
@ -32,6 +32,7 @@ import lombok.AllArgsConstructor;
|
|
|
|
|
import lombok.Data;
|
|
|
|
|
import org.apache.commons.lang3.StringUtils;
|
|
|
|
|
import org.jetbrains.annotations.NotNull;
|
|
|
|
|
import org.springframework.beans.BeanUtils;
|
|
|
|
|
import org.springframework.beans.factory.annotation.Autowired;
|
|
|
|
|
import org.springframework.core.env.Environment;
|
|
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
@ -48,9 +49,10 @@ import java.time.ZoneId;
|
|
|
|
|
import java.util.*;
|
|
|
|
|
import java.util.concurrent.ExecutionException;
|
|
|
|
|
import java.util.stream.Collectors;
|
|
|
|
|
import java.util.stream.IntStream;
|
|
|
|
|
|
|
|
|
|
@Service
|
|
|
|
|
public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
public class MoralEducationServiceImpl implements LaborEducationService {
|
|
|
|
|
|
|
|
|
|
@Resource
|
|
|
|
|
private LessonRecordRepository lessonRecordRepository;
|
|
|
|
@ -90,7 +92,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
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();
|
|
|
|
@ -209,13 +211,13 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
classScoreRate = calculateKnowledgeScoreRateForClass(laborDto.getClassId(), examResults, knowledgeMap, appraise, point,res,request);
|
|
|
|
|
}
|
|
|
|
|
if (laborDto.getGrade() != null) {
|
|
|
|
|
gradeScoreRate = calculateKnowledgeScoreForGrade(laborDto.getGrade(), examResults, knowledgeMap,appraise, point,res,gradeAndClassVos);
|
|
|
|
|
gradeScoreRate = calculateKnowledgeScoreForGrade(laborDto.getGrade(), examResults, knowledgeMap,appraise, point,res,gradeAndClassVos,request);
|
|
|
|
|
}
|
|
|
|
|
Map<String,Object> schoolScoreRate = calculateKnowledgeScoreForSchool(examResults, knowledgeMap,appraise, point,res,period,gradeAndClassVos);
|
|
|
|
|
Map<String,Object> schoolScoreRate = calculateKnowledgeScoreForSchool(examResults, knowledgeMap,appraise, point,res,period,gradeAndClassVos,request);
|
|
|
|
|
resMap.put("gradeScoreRate", gradeScoreRate);
|
|
|
|
|
resMap.put("classScoreRate", classScoreRate);
|
|
|
|
|
resMap.put("schoolScoreRate", schoolScoreRate);
|
|
|
|
|
List<Map<String, Object>> scores = calculateScoresWithDetails(res, appraise);
|
|
|
|
|
List<Map<String, Object>> scores = calculateScoresWithDetails(res, appraise, request);
|
|
|
|
|
List<Map<String, Object>> students = combineScoresWithExamResults(scores,examResults,knowledgeMap,point,knowledgeBlockToPointsMap);
|
|
|
|
|
resMap.put("scores", students);
|
|
|
|
|
}
|
|
|
|
@ -239,6 +241,79 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
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,
|
|
|
|
@ -380,7 +455,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static List<Map<String, Object>> calculateScoresWithDetails(List<RecordVo> res, Appraise appraise) {
|
|
|
|
|
public static List<Map<String, Object>> calculateScoresWithDetails(List<RecordVo> res, Appraise appraise,HttpServletRequest request) {
|
|
|
|
|
// 1. 构建知识点到知识块的映射 (一个知识块对应多个知识点)
|
|
|
|
|
Map<String, List<String>> knowledgeBlockToPointsMap = getKnowledgeBlockToPointsMap(appraise);
|
|
|
|
|
|
|
|
|
@ -407,10 +482,47 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
Map<String, Map<String, Integer>> studentScores = new HashMap<>();
|
|
|
|
|
Map<String, List<Map<String, Object>>> studentAppraises = new HashMap<>(); // 存储每个学生的评价记录
|
|
|
|
|
|
|
|
|
|
// 将 classId 转换为 List<String>
|
|
|
|
|
//获取res中的classId集合
|
|
|
|
|
List<String> classIds = res.stream()
|
|
|
|
|
.map(RecordVo::getClassId)
|
|
|
|
|
.distinct()
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
//List<String> classIds = Collections.singletonList(classId);
|
|
|
|
|
GroupDto groupDto = new GroupDto();
|
|
|
|
|
groupDto.setIds(classIds);
|
|
|
|
|
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>>() {});
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
for (RecordVo record : res) {
|
|
|
|
|
String studentId = record.getTargetId(); // 学生 ID
|
|
|
|
|
String studentName = record.getTargetName(); // 学生名称
|
|
|
|
|
String className = record.getClassName(); // 班级名称
|
|
|
|
|
String className = "";
|
|
|
|
|
if (record.getClassName() == null) {
|
|
|
|
|
className = rGroupList.stream()
|
|
|
|
|
.filter(rGroupList1 -> rGroupList1.getId().equals(record.getClassId()))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.map(RGroupList::getName)
|
|
|
|
|
.orElse("未知班级"); // 如果未找到则返回默认值 "未知班级"
|
|
|
|
|
}else {
|
|
|
|
|
className = record.getClassName();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
String appraiseName = record.getAppraiseName(); // 评价内容
|
|
|
|
|
boolean isPraise = record.isPraise(); // 是否为优点
|
|
|
|
|
|
|
|
|
@ -536,22 +648,43 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
Map<String, Integer> parentNodeScoreCount = new HashMap<>(); // 记录每个父节点的知识点数量
|
|
|
|
|
|
|
|
|
|
for (MoralEducationServiceImpl.KnowledgeScoreRate scoreRate : studentScoreRates) {
|
|
|
|
|
AppraiseTreeNode node = findKnowledgeNode(appraise.getNodes(), scoreRate.getKnowledge());
|
|
|
|
|
String knowledge = scoreRate.getKnowledge();
|
|
|
|
|
AppraiseTreeNode node = findKnowledgeNode(appraise.getNodes(), knowledge);
|
|
|
|
|
|
|
|
|
|
// 1. 查找知识点所属的知识块(假设通过knowledgeMap映射)
|
|
|
|
|
String block = findKnowledgeBlock(knowledgeMap, knowledge); // 自定义方法:从knowledgeMap中获取知识点所属的知识块
|
|
|
|
|
|
|
|
|
|
// 2. 查找知识块对应的父节点
|
|
|
|
|
AppraiseTreeNode parentNode = null;
|
|
|
|
|
if (block != null) {
|
|
|
|
|
parentNode = findParentNodeByBlockName(appraise.getNodes(), block); // 自定义方法:按知识块名称查找父节点
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 3. 处理匹配到节点的情况
|
|
|
|
|
if (node != null) {
|
|
|
|
|
AppraiseTreeNode parentNode = findParentNode(appraise.getNodes(), node.getId());
|
|
|
|
|
if (parentNode != null) {
|
|
|
|
|
// 累加父节点的得分
|
|
|
|
|
double currentScore = parentNodeScoreRates.getOrDefault(parentNode.getName(), 0.0);
|
|
|
|
|
parentNodeScoreRates.put(parentNode.getName(), currentScore + scoreRate.getScoreRate());
|
|
|
|
|
|
|
|
|
|
// 累加父节点的知识点数量
|
|
|
|
|
int currentCount = parentNodeScoreCount.getOrDefault(parentNode.getName(), 0);
|
|
|
|
|
parentNodeScoreCount.put(parentNode.getName(), currentCount + 1);
|
|
|
|
|
parentNode = findParentNode(appraise.getNodes(), node.getId());
|
|
|
|
|
} else {
|
|
|
|
|
// 未匹配知识点:默认60分,归入其所属知识块的父节点
|
|
|
|
|
double defaultScore = 60.0;
|
|
|
|
|
if (parentNode == null) {
|
|
|
|
|
// 若知识块无对应父节点,归入全局默认块
|
|
|
|
|
parentNodeScoreRates.merge("默认块", defaultScore, Double::sum);
|
|
|
|
|
parentNodeScoreCount.merge("默认块", 1, Integer::sum);
|
|
|
|
|
} else {
|
|
|
|
|
// 如果没有找到父节点,直接使用当前知识点的得分
|
|
|
|
|
parentNodeScoreRates.put(node.getName(), scoreRate.getScoreRate());
|
|
|
|
|
parentNodeScoreCount.put(node.getName(), 1);
|
|
|
|
|
// 归入知识块对应的父节点
|
|
|
|
|
parentNodeScoreRates.merge(parentNode.getName(), defaultScore, Double::sum);
|
|
|
|
|
parentNodeScoreCount.merge(parentNode.getName(), 1, Integer::sum);
|
|
|
|
|
}
|
|
|
|
|
continue; // 跳过后续匹配逻辑
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 4. 累加得分到父节点(原有逻辑)
|
|
|
|
|
if (parentNode != null) {
|
|
|
|
|
parentNodeScoreRates.merge(parentNode.getName(), scoreRate.getScoreRate(), Double::sum);
|
|
|
|
|
parentNodeScoreCount.merge(parentNode.getName(), 1, Integer::sum);
|
|
|
|
|
} else {
|
|
|
|
|
parentNodeScoreRates.put(node.getName(), scoreRate.getScoreRate());
|
|
|
|
|
parentNodeScoreCount.put(node.getName(), 1);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -583,6 +716,30 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
return parentNodeScoreRates;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 从knowledgeMap中查找知识点所属的知识块
|
|
|
|
|
private static String findKnowledgeBlock(Map<String, List<List<String>>> knowledgeMap, String knowledge) {
|
|
|
|
|
for (Map.Entry<String, List<List<String>>> entry : knowledgeMap.entrySet()) {
|
|
|
|
|
for (List<String> subList : entry.getValue()) {
|
|
|
|
|
if (subList.contains(knowledge)) {
|
|
|
|
|
return entry.getKey();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 按知识块名称查找父节点
|
|
|
|
|
private static AppraiseTreeNode findParentNodeByBlockName(List<AppraiseTreeNode> nodes, String blockName) {
|
|
|
|
|
for (AppraiseTreeNode node : nodes) {
|
|
|
|
|
if (node.getName().equals(blockName)) {
|
|
|
|
|
return node;
|
|
|
|
|
}
|
|
|
|
|
AppraiseTreeNode found = findParentNodeByBlockName(node.getChildren(), blockName);
|
|
|
|
|
if (found != null) return found;
|
|
|
|
|
}
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 计算班级每个学生知识点得分率,并返回每个学生所属节点的父节点得分率
|
|
|
|
@ -655,29 +812,44 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
if (examResults != null && !examResults.isEmpty()) {
|
|
|
|
|
// 遍历班级中的每个学生
|
|
|
|
|
for (ExamClassResult examResult : examResults) {
|
|
|
|
|
if (!examResult.getInfo().getId().equals(classId)) continue;
|
|
|
|
|
List<Integer> statuses = examResult.getStatus();
|
|
|
|
|
for (int i = 0; i < examResult.getStudentIds().size(); i++) {
|
|
|
|
|
String studentId = examResult.getStudentIds().get(i);
|
|
|
|
|
String name = rMembers.stream()
|
|
|
|
|
.filter(member -> member.getId().equals(studentId))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.map(RMember::getName)
|
|
|
|
|
.orElse("未知");
|
|
|
|
|
int status = statuses.get(i);
|
|
|
|
|
if (status == 1) continue;
|
|
|
|
|
|
|
|
|
|
// 正确获取已转换的客观分数(无需二次截断)
|
|
|
|
|
Map<String, Double> scoreRates = calculateKnowledgeScoreRateForStudent(
|
|
|
|
|
studentId, examResults, knowledgeMap, appraise, points
|
|
|
|
|
);
|
|
|
|
|
studentScoreRates.put(name, scoreRates);
|
|
|
|
|
|
|
|
|
|
// 累加班级整体得分率
|
|
|
|
|
for (Map.Entry<String, Double> entry : scoreRates.entrySet()) {
|
|
|
|
|
classScoreRates.put(entry.getKey(), classScoreRates.getOrDefault(entry.getKey(), 0.0) + entry.getValue());
|
|
|
|
|
if (!examResult.getInfo().getId().equals(classId)){
|
|
|
|
|
// 无考试数据时,初始化所有学生的默认分数为60
|
|
|
|
|
if (groupList != null) {
|
|
|
|
|
for (RMember member : groupList.members) {
|
|
|
|
|
String studentId = member.getId();
|
|
|
|
|
String studentName = studentIdToName.getOrDefault(studentId, "未知学生");
|
|
|
|
|
Map<String, Double> defaultScores = new HashMap<>();
|
|
|
|
|
for (String block : knowledgeBlocks) {
|
|
|
|
|
defaultScores.put(block, 84.0); // 初始化为60分
|
|
|
|
|
}
|
|
|
|
|
studentScoreRates.put(studentName, defaultScores);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}else{
|
|
|
|
|
List<Integer> statuses = examResult.getStatus();
|
|
|
|
|
for (int i = 0; i < examResult.getStudentIds().size(); i++) {
|
|
|
|
|
String studentId = examResult.getStudentIds().get(i);
|
|
|
|
|
String name = rMembers.stream()
|
|
|
|
|
.filter(member -> member.getId().equals(studentId))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.map(RMember::getName)
|
|
|
|
|
.orElse("未知");
|
|
|
|
|
int status = statuses.get(i);
|
|
|
|
|
if (status == 1) continue;
|
|
|
|
|
|
|
|
|
|
// 正确获取已转换的客观分数(无需二次截断)
|
|
|
|
|
Map<String, Double> scoreRates = calculateKnowledgeScoreRateForStudent(
|
|
|
|
|
studentId, examResults, knowledgeMap, appraise, points
|
|
|
|
|
);
|
|
|
|
|
studentScoreRates.put(name, scoreRates);
|
|
|
|
|
|
|
|
|
|
// 累加班级整体得分率
|
|
|
|
|
for (Map.Entry<String, Double> entry : scoreRates.entrySet()) {
|
|
|
|
|
classScoreRates.put(entry.getKey(), classScoreRates.getOrDefault(entry.getKey(), 0.0) + entry.getValue());
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}else {
|
|
|
|
|
// 无考试数据时,初始化所有学生的默认分数为60
|
|
|
|
@ -687,7 +859,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
String studentName = studentIdToName.getOrDefault(studentId, "未知学生");
|
|
|
|
|
Map<String, Double> defaultScores = new HashMap<>();
|
|
|
|
|
for (String block : knowledgeBlocks) {
|
|
|
|
|
defaultScores.put(block, 60.0); // 初始化为60分
|
|
|
|
|
defaultScores.put(block, 84.0); // 初始化为60分
|
|
|
|
|
}
|
|
|
|
|
studentScoreRates.put(studentName, defaultScores);
|
|
|
|
|
}
|
|
|
|
@ -695,7 +867,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 2. 获取班级所有学生的主观分数(次数)
|
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise);
|
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise,request);
|
|
|
|
|
|
|
|
|
|
// 3. 将主观次数转换为0-100分数
|
|
|
|
|
Map<String, Map<String, Double>> subjectiveScores = new HashMap<>();
|
|
|
|
@ -833,7 +1005,6 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
Map<String, List<List<String>>> knowledgeMap,
|
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
|
Map<String, Double> knowledgeTotalScore) {
|
|
|
|
|
|
|
|
|
|
Map<String, Double> knowledgeTotalAverage = new HashMap<>();
|
|
|
|
|
Map<String, Integer> knowledgeExamCount = new HashMap<>();
|
|
|
|
|
|
|
|
|
@ -961,7 +1132,8 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
Appraise appraise,
|
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
|
List<RecordVo> res,
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos) {
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
// 1. 获取年级所有班级的客观分数
|
|
|
|
|
Map<String, Map<String, Double>> classScores = new HashMap<>();
|
|
|
|
@ -984,7 +1156,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 2. 获取年级所有学生的主观分数(次数)
|
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise);
|
|
|
|
|
List<Map<String, Object>> subjectiveScoresList = calculateScoresWithDetails(res, appraise,request);
|
|
|
|
|
|
|
|
|
|
// 3. 将主观次数转换为0-100分数,并收集学生班级信息
|
|
|
|
|
Map<String, Map<String, Double>> subjectiveScores = new HashMap<>();
|
|
|
|
@ -1174,7 +1346,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
Map<String, List<Double>> points,
|
|
|
|
|
List<RecordVo> res,
|
|
|
|
|
List<School.Period> period,
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos) {
|
|
|
|
|
List<GradeAndClassVo> gradeAndClassVos,HttpServletRequest request) {
|
|
|
|
|
|
|
|
|
|
// 1. 初始化数据结构
|
|
|
|
|
Map<String, Map<String, Double>> gradeScores = new HashMap<>();
|
|
|
|
@ -1188,7 +1360,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
int index = 0;
|
|
|
|
|
for (String gradeId : gradeIds) {
|
|
|
|
|
Map<String, Object> gradeResult = calculateKnowledgeScoreForGrade(
|
|
|
|
|
String.valueOf(index), examResults, knowledgeMap, appraise, points, res, gradeAndClassVos
|
|
|
|
|
String.valueOf(index), examResults, knowledgeMap, appraise, points, res, gradeAndClassVos,request
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 2.1 提取年级平均分
|
|
|
|
@ -1328,6 +1500,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
return null; // 未找到父节点
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//获取每月各个知识库综合得分以及整体得分内容
|
|
|
|
|
public Map<String,List<Map<String, Object>>> getStudentMonthlyScores(LaborDto laborDto,HttpServletRequest request) {
|
|
|
|
|
// 1. 获取基础信息
|
|
|
|
@ -1385,7 +1558,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
laborDto.getAcademicYearId(),
|
|
|
|
|
laborDto.getClassId(),
|
|
|
|
|
laborDto.getStudentId(),
|
|
|
|
|
"德育"
|
|
|
|
|
"劳育"
|
|
|
|
|
);
|
|
|
|
|
//表扬的次数
|
|
|
|
|
rightCount = (int) res.stream().filter(RecordVo::isPraise).count();
|
|
|
|
@ -1402,7 +1575,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
List<String> targetStudents = laborDto.getClassId() != null ?
|
|
|
|
|
classStudentIds : Collections.singletonList(studentId);
|
|
|
|
|
|
|
|
|
|
Map<Integer, List<MoralEducationServiceImpl.ExamResultWrapper>> monthlyResults = getMonthlyExamResults(
|
|
|
|
|
Map<Integer, List<ExamResultWrapper>> monthlyResults = getMonthlyExamResults(
|
|
|
|
|
schoolId, laborDto.getClassId(), exams, records,
|
|
|
|
|
examKnowledgeMap, points, targetStudents // 传入目标学生列表
|
|
|
|
|
);
|
|
|
|
@ -1465,81 +1638,6 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// 新增方法:添加综合得分
|
|
|
|
|
private List<Map<String, Object>> addOverallScore(
|
|
|
|
@ -1614,12 +1712,12 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<Integer, List<MoralEducationServiceImpl.ExamResultWrapper>> getMonthlyExamResults(
|
|
|
|
|
private Map<Integer, List<ExamResultWrapper>> getMonthlyExamResults(
|
|
|
|
|
String schoolId, String classId, List<ExamVo> exams,
|
|
|
|
|
List<LessonRecord> records, Map<String, List<List<String>>> examKnowledgeMap,
|
|
|
|
|
Map<String, List<Double>> points, List<String> studentIds) { // 新增studentIds参数
|
|
|
|
|
|
|
|
|
|
Map<Integer, List<MoralEducationServiceImpl.ExamResultWrapper>> monthlyResults = new HashMap<>();
|
|
|
|
|
Map<Integer, List<ExamResultWrapper>> monthlyResults = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
if (classId == null) {
|
|
|
|
|
exams.forEach(exam -> {
|
|
|
|
@ -1641,7 +1739,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
.filter(studentIds::contains) // 仅处理班级学生
|
|
|
|
|
.forEach(studentId -> {
|
|
|
|
|
monthlyResults.computeIfAbsent(month, k -> new ArrayList<>())
|
|
|
|
|
.add(new MoralEducationServiceImpl.ExamResultWrapper(
|
|
|
|
|
.add(new ExamResultWrapper(
|
|
|
|
|
exam.getId(),
|
|
|
|
|
result,
|
|
|
|
|
knowledge,
|
|
|
|
@ -1672,7 +1770,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
.filter(studentIds::contains) // 仅处理班级学生
|
|
|
|
|
.forEach(studentId -> {
|
|
|
|
|
monthlyResults.computeIfAbsent(month, k -> new ArrayList<>())
|
|
|
|
|
.add(new MoralEducationServiceImpl.ExamResultWrapper(
|
|
|
|
|
.add(new ExamResultWrapper(
|
|
|
|
|
exam.getId(),
|
|
|
|
|
result,
|
|
|
|
|
knowledge,
|
|
|
|
@ -1692,7 +1790,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
private Map<String,List<Map<String, Object>>> processMonthlyData(
|
|
|
|
|
List<LessonRecord> records,List<RecordVo> res,int rightCount,int wrongCount,
|
|
|
|
|
List<String> targetStudentIds,
|
|
|
|
|
Map<Integer, List<MoralEducationServiceImpl.ExamResultWrapper>> monthlyResults,
|
|
|
|
|
Map<Integer, List<ExamResultWrapper>> monthlyResults,
|
|
|
|
|
Map<String, List<String>> knowledgeBlockMap,
|
|
|
|
|
Set<Integer> months,
|
|
|
|
|
Map<String, Map<Integer, Integer>> blockMonthlyCounts) {
|
|
|
|
@ -1712,11 +1810,11 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
List<Map<String, Object>> scoreList = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 按学生分组考试结果
|
|
|
|
|
Map<String, List<MoralEducationServiceImpl.ExamResultWrapper>> studentResults = monthlyResults
|
|
|
|
|
Map<String, List<ExamResultWrapper>> studentResults = monthlyResults
|
|
|
|
|
.getOrDefault(month, Collections.emptyList())
|
|
|
|
|
.stream()
|
|
|
|
|
.filter(wrapper -> targetStudentIds.contains(wrapper.getStudentId()))
|
|
|
|
|
.collect(Collectors.groupingBy(MoralEducationServiceImpl.ExamResultWrapper::getStudentId));
|
|
|
|
|
.collect(Collectors.groupingBy(ExamResultWrapper::getStudentId));
|
|
|
|
|
|
|
|
|
|
// 初始化知识块总分计数器
|
|
|
|
|
Map<String, Double> blockTotalScores = new HashMap<>();
|
|
|
|
@ -1724,9 +1822,9 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
|
|
|
|
|
// 遍历所有目标学生
|
|
|
|
|
targetStudentIds.forEach(studentId -> {
|
|
|
|
|
List<MoralEducationServiceImpl.ExamResultWrapper> wrappers = studentResults.getOrDefault(studentId, Collections.emptyList());
|
|
|
|
|
List<ExamResultWrapper> wrappers = studentResults.getOrDefault(studentId, Collections.emptyList());
|
|
|
|
|
List<ExamClassResult> examResults = wrappers.stream()
|
|
|
|
|
.map(MoralEducationServiceImpl.ExamResultWrapper::getResult)
|
|
|
|
|
.map(ExamResultWrapper::getResult)
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
|
|
|
|
|
// 1. 计算知识点得分(保留原始逻辑)
|
|
|
|
@ -1734,11 +1832,11 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
studentId,
|
|
|
|
|
examResults,
|
|
|
|
|
wrappers.stream().collect(Collectors.toMap(
|
|
|
|
|
MoralEducationServiceImpl.ExamResultWrapper::getExamId,
|
|
|
|
|
MoralEducationServiceImpl.ExamResultWrapper::getKnowledge)),
|
|
|
|
|
ExamResultWrapper::getExamId,
|
|
|
|
|
ExamResultWrapper::getKnowledge)),
|
|
|
|
|
wrappers.stream().collect(Collectors.toMap(
|
|
|
|
|
MoralEducationServiceImpl.ExamResultWrapper::getExamId,
|
|
|
|
|
MoralEducationServiceImpl.ExamResultWrapper::getPoints))
|
|
|
|
|
ExamResultWrapper::getExamId,
|
|
|
|
|
ExamResultWrapper::getPoints))
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
// 2. 计算每个知识块的客观得分(新增关键逻辑)
|
|
|
|
@ -1971,14 +2069,14 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
public Map<String, Object> getStudentSemesterScores(LaborDto laborDto,HttpServletRequest request) {
|
|
|
|
|
// 1. 获取学期配置
|
|
|
|
|
List<School.Semester> semesters = schoolRepository.findSemestersById(laborDto.getCode(), laborDto.getPeriodId());
|
|
|
|
|
List<MoralEducationServiceImpl.SemesterConfig> configs = new ArrayList<>();
|
|
|
|
|
List<SemesterConfig> configs = new ArrayList<>();
|
|
|
|
|
for (School.Semester semester : semesters) {
|
|
|
|
|
configs.add(new MoralEducationServiceImpl.SemesterConfig(semester.getName(), semester.getStart(), semester.getMonth(), semester.getDay(), semester.getId()));
|
|
|
|
|
configs.add(new SemesterConfig(semester.getName(), semester.getStart(), semester.getMonth(), semester.getDay(), semester.getId()));
|
|
|
|
|
}
|
|
|
|
|
// 2. 计算学期时间范围
|
|
|
|
|
Map<String, MoralEducationServiceImpl.SemesterPeriod> periods = calculateSemesters(configs);
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod current = periods.get("current");
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod last = periods.get("last");
|
|
|
|
|
Map<String, SemesterPeriod> periods = calculateSemesters(configs);
|
|
|
|
|
SemesterPeriod current = periods.get("current");
|
|
|
|
|
SemesterPeriod last = periods.get("last");
|
|
|
|
|
|
|
|
|
|
// 学生数据处理
|
|
|
|
|
Map<String, Object> studentResult = Collections.emptyMap();
|
|
|
|
@ -2012,8 +2110,8 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> processIndividual(LaborDto dto,
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod current,
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod last,
|
|
|
|
|
SemesterPeriod current,
|
|
|
|
|
SemesterPeriod last,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
// 原有学生处理逻辑
|
|
|
|
|
Map<String, Object> currentData = processSemesterData(dto, current, request, true, false);
|
|
|
|
@ -2022,8 +2120,8 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Map<String, Object> processClass(LaborDto dto,
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod current,
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod last,
|
|
|
|
|
SemesterPeriod current,
|
|
|
|
|
SemesterPeriod last,
|
|
|
|
|
HttpServletRequest request) {
|
|
|
|
|
// 克隆DTO并清除学生ID
|
|
|
|
|
LaborDto classDto = new LaborDto();
|
|
|
|
@ -2123,12 +2221,12 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 核心学期计算逻辑
|
|
|
|
|
private Map<String, MoralEducationServiceImpl.SemesterPeriod> calculateSemesters(List<MoralEducationServiceImpl.SemesterConfig> semesters) {
|
|
|
|
|
private Map<String, SemesterPeriod> calculateSemesters(List<SemesterConfig> semesters) {
|
|
|
|
|
LocalDate now = LocalDate.now();
|
|
|
|
|
int currentYear = now.getYear();
|
|
|
|
|
|
|
|
|
|
// 1. 确定学年起始学期
|
|
|
|
|
MoralEducationServiceImpl.SemesterConfig startSemester = semesters.stream()
|
|
|
|
|
SemesterConfig startSemester = semesters.stream()
|
|
|
|
|
.filter(s -> s.start == 1)
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElseThrow(() -> new IllegalArgumentException("未配置起始学期"));
|
|
|
|
@ -2138,51 +2236,51 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
int academicYear = calculateAcademicYear(startSemester, LocalDate.now());
|
|
|
|
|
|
|
|
|
|
// 3. 生成当前学年学期
|
|
|
|
|
List<MoralEducationServiceImpl.SemesterPeriod> currentYearSemesters = generateYearSemesters(
|
|
|
|
|
List<SemesterPeriod> currentYearSemesters = generateYearSemesters(
|
|
|
|
|
semesters, academicYear, startSemester);
|
|
|
|
|
|
|
|
|
|
// 4. 确定当前学期
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod current = currentYearSemesters.stream()
|
|
|
|
|
SemesterPeriod current = currentYearSemesters.stream()
|
|
|
|
|
.filter(sp -> !now.isBefore(sp.startDate) && !now.isAfter(sp.endDate))
|
|
|
|
|
.findFirst()
|
|
|
|
|
.orElse(null);
|
|
|
|
|
|
|
|
|
|
// 5. 确定上学期
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod last = findLastSemester(current, semesters, academicYear, startSemester);
|
|
|
|
|
SemesterPeriod last = findLastSemester(current, semesters, academicYear, startSemester);
|
|
|
|
|
|
|
|
|
|
return new HashMap<String, MoralEducationServiceImpl.SemesterPeriod>() {{
|
|
|
|
|
return new HashMap<String, SemesterPeriod>() {{
|
|
|
|
|
put("current", current);
|
|
|
|
|
put("last", last);
|
|
|
|
|
}};
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 增强学术年度计算方法
|
|
|
|
|
private int calculateAcademicYear(MoralEducationServiceImpl.SemesterConfig startSemester, LocalDate currentDate) {
|
|
|
|
|
private int calculateAcademicYear(SemesterConfig startSemester, LocalDate currentDate) {
|
|
|
|
|
int currentYear = currentDate.getYear();
|
|
|
|
|
int currentMonth = currentDate.getMonthValue();
|
|
|
|
|
|
|
|
|
|
return (currentMonth < startSemester.month) ? currentYear -1 : currentYear;
|
|
|
|
|
}
|
|
|
|
|
// 生成学年学期时间范围
|
|
|
|
|
private List<MoralEducationServiceImpl.SemesterPeriod> generateYearSemesters(List<MoralEducationServiceImpl.SemesterConfig> semesters,
|
|
|
|
|
int academicYear,
|
|
|
|
|
MoralEducationServiceImpl.SemesterConfig startSemester) {
|
|
|
|
|
List<MoralEducationServiceImpl.SemesterPeriod> periods = new ArrayList<>();
|
|
|
|
|
private List<SemesterPeriod> generateYearSemesters(List<SemesterConfig> semesters,
|
|
|
|
|
int academicYear,
|
|
|
|
|
SemesterConfig startSemester) {
|
|
|
|
|
List<SemesterPeriod> periods = new ArrayList<>();
|
|
|
|
|
|
|
|
|
|
// 1. 生成各学期开始日期
|
|
|
|
|
for (MoralEducationServiceImpl.SemesterConfig sc : semesters) {
|
|
|
|
|
for (SemesterConfig sc : semesters) {
|
|
|
|
|
int year = academicYear;
|
|
|
|
|
if (sc.month < startSemester.month) {
|
|
|
|
|
year += 1; // 跨年学期(如 2024 学年下学期是 2025 年 2 月)
|
|
|
|
|
}
|
|
|
|
|
LocalDate startDate = LocalDate.of(year, sc.month, sc.day);
|
|
|
|
|
periods.add(new MoralEducationServiceImpl.SemesterPeriod(sc.name, startDate, null));
|
|
|
|
|
periods.add(new SemesterPeriod(sc.name, startDate, null));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
periods.sort(Comparator.comparing(MoralEducationServiceImpl.SemesterPeriod::getStartDate));
|
|
|
|
|
periods.sort(Comparator.comparing(SemesterPeriod::getStartDate));
|
|
|
|
|
// 2. 计算结束日期
|
|
|
|
|
for (int i = 0; i < periods.size(); i++) {
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod curr = periods.get(i);
|
|
|
|
|
SemesterPeriod curr = periods.get(i);
|
|
|
|
|
|
|
|
|
|
if (i < periods.size() - 1) {
|
|
|
|
|
// 非最后学期:下一学期开始前 1 天
|
|
|
|
@ -2205,13 +2303,13 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// 查找上学期(含跨学年处理)
|
|
|
|
|
private MoralEducationServiceImpl.SemesterPeriod findLastSemester(MoralEducationServiceImpl.SemesterPeriod current,
|
|
|
|
|
List<MoralEducationServiceImpl.SemesterConfig> semesters,
|
|
|
|
|
int academicYear,
|
|
|
|
|
MoralEducationServiceImpl.SemesterConfig startSemester) {
|
|
|
|
|
private SemesterPeriod findLastSemester(SemesterPeriod current,
|
|
|
|
|
List<SemesterConfig> semesters,
|
|
|
|
|
int academicYear,
|
|
|
|
|
SemesterConfig startSemester) {
|
|
|
|
|
if (current == null) return null;
|
|
|
|
|
|
|
|
|
|
List<MoralEducationServiceImpl.SemesterPeriod> currentYearSemesters = generateYearSemesters(
|
|
|
|
|
List<SemesterPeriod> currentYearSemesters = generateYearSemesters(
|
|
|
|
|
semesters, academicYear, startSemester);
|
|
|
|
|
|
|
|
|
|
int index = currentYearSemesters.indexOf(current);
|
|
|
|
@ -2219,7 +2317,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
return currentYearSemesters.get(index-1);
|
|
|
|
|
} else {
|
|
|
|
|
// 获取去年最后一个学期
|
|
|
|
|
List<MoralEducationServiceImpl.SemesterPeriod> lastYear = generateYearSemesters(
|
|
|
|
|
List<SemesterPeriod> lastYear = generateYearSemesters(
|
|
|
|
|
semesters, academicYear-1, startSemester);
|
|
|
|
|
return lastYear.isEmpty() ? null : lastYear.get(lastYear.size()-1);
|
|
|
|
|
}
|
|
|
|
@ -2227,7 +2325,7 @@ public class MoralEducationServiceImpl implements MoralEducationService {
|
|
|
|
|
|
|
|
|
|
// 处理学期数据
|
|
|
|
|
private Map<String, Object> processSemesterData(LaborDto laborDto,
|
|
|
|
|
MoralEducationServiceImpl.SemesterPeriod semester,
|
|
|
|
|
SemesterPeriod semester,
|
|
|
|
|
HttpServletRequest request,
|
|
|
|
|
boolean isCurrent,
|
|
|
|
|
boolean isClassMod) {
|
|
|
|
|