From 9dc5f77a6966a82bce0914c0aa4411ce1ff1eab0 Mon Sep 17 00:00:00 2001 From: WendyYang Date: Sun, 16 Apr 2023 17:16:17 +0800 Subject: [PATCH] =?UTF-8?q?=E4=B8=93=E5=AE=B6=E6=8A=BD=E5=8F=96=E7=AE=97?= =?UTF-8?q?=E6=B3=95=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java index 4adc9d3..d71a8d7 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java @@ -22,6 +22,10 @@ import java.util.stream.Collectors; **/ public class ExpertRandomInviteAlgorithm { + private static boolean expertMatchNone(List experts, ExpertUserFullInfo userInfo) { + return experts.stream().noneMatch(w -> w.getExpertId().equals(userInfo.getUserId())); + } + /** * 每个单位只抽取一人 * @@ -49,7 +53,7 @@ public class ExpertRandomInviteAlgorithm { List expertsByCompany = expertGroupByUnit.get(company); for (List experts : expertsByRecentMeeting) { List notInvitedUsers = expertsByCompany.stream() - .filter(w -> experts.stream().noneMatch(expert -> expert.getExpertId().equals(w.getUserId()))) + .filter(w -> expertMatchNone(experts, w)) .collect(Collectors.toList()); if (!notInvitedUsers.isEmpty()) { result.add(RandomUtil.randomEle(notInvitedUsers)); @@ -88,7 +92,7 @@ public class ExpertRandomInviteAlgorithm { result = new ArrayList<>(); for (List experts : expertsByRecentMeeting) { List notInvitedUsers = userFullInfos.stream() - .filter(w -> experts.stream().noneMatch(expert -> expert.getExpertId().equals(w.getUserId()))) + .filter(w -> expertMatchNone(experts, w)) .collect(Collectors.toList()); if (!notInvitedUsers.isEmpty()) { result.addAll(notInvitedUsers);