diff --git a/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java b/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java index 36bd0ab..b9d9dcb 100644 --- a/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java +++ b/src/main/java/cn/teammodel/controller/admin/service/impl/TeacherServiceImpl.java @@ -128,8 +128,10 @@ public class TeacherServiceImpl implements TeacherService { private static @NotNull Map getPeriodCountMap(List groupLists,List periods) { Map periodNameMap = new HashMap<>(); + List periodNames = new ArrayList<>(); for (School.Period period : periods) { periodNameMap.put(period.getId(), period.getName()); + periodNames.add(period.getName()); } Map periodCountMap = getStringIntegerMap(groupLists); // 更新 periodCountMap 的 key 为 period 名称 @@ -142,19 +144,27 @@ public class TeacherServiceImpl implements TeacherService { updatedPeriodCountMap.put(periodName, count); } } + for(Map.Entry entry : updatedPeriodCountMap.entrySet()) { + String name = entry.getKey(); + for (String periodName : periodNames) { + if(!name.equals(periodName)){ + updatedPeriodCountMap.put(periodName, 0); + } + } + + } return updatedPeriodCountMap; } private static @NotNull Map getStringIntegerMap(List groupLists) { Map periodCountMap = new HashMap<>(); - // 遍历所有 GroupList 对象 for (GroupList group : groupLists) { // 获取 periodId String periodId = group.getPeriodId(); if (periodId != null) { // 计算成员数量 - int memberCount = group.getMembers().size(); + int memberCount = (int) group.getMembers().stream().filter(member -> member.type == 1).count(); // 更新 periodCountMap periodCountMap.put(periodId, periodCountMap.getOrDefault(periodId, 0) + memberCount);