From 3449d2bcbd70db47bd4fb9debbbdb644dd574b94 Mon Sep 17 00:00:00 2001 From: "hhb@hotmail.com" Date: Wed, 13 Nov 2024 19:39:56 +0800 Subject: [PATCH] =?UTF-8?q?update=20=E6=95=99=E5=B8=88=E7=9B=B8=E5=85=B3?= =?UTF-8?q?=E6=95=B0=E6=8D=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../admin/service/impl/TeacherServiceImpl.java | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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);