|
@@ -22,6 +22,10 @@ import java.util.stream.Collectors; |
|
|
**/ |
|
|
**/ |
|
|
public class ExpertRandomInviteAlgorithm { |
|
|
public class ExpertRandomInviteAlgorithm { |
|
|
|
|
|
|
|
|
|
|
|
private static boolean expertMatchNone(List<MeetingExpert> experts, ExpertUserFullInfo userInfo) { |
|
|
|
|
|
return experts.stream().noneMatch(w -> w.getExpertId().equals(userInfo.getUserId())); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
|
* 每个单位只抽取一人 |
|
|
* 每个单位只抽取一人 |
|
|
* |
|
|
* |
|
@@ -49,7 +53,7 @@ public class ExpertRandomInviteAlgorithm { |
|
|
List<ExpertUserFullInfo> expertsByCompany = expertGroupByUnit.get(company); |
|
|
List<ExpertUserFullInfo> expertsByCompany = expertGroupByUnit.get(company); |
|
|
for (List<MeetingExpert> experts : expertsByRecentMeeting) { |
|
|
for (List<MeetingExpert> experts : expertsByRecentMeeting) { |
|
|
List<ExpertUserFullInfo> notInvitedUsers = expertsByCompany.stream() |
|
|
List<ExpertUserFullInfo> notInvitedUsers = expertsByCompany.stream() |
|
|
.filter(w -> experts.stream().noneMatch(expert -> expert.getExpertId().equals(w.getUserId()))) |
|
|
|
|
|
|
|
|
.filter(w -> expertMatchNone(experts, w)) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
if (!notInvitedUsers.isEmpty()) { |
|
|
if (!notInvitedUsers.isEmpty()) { |
|
|
result.add(RandomUtil.randomEle(notInvitedUsers)); |
|
|
result.add(RandomUtil.randomEle(notInvitedUsers)); |
|
@@ -88,7 +92,7 @@ public class ExpertRandomInviteAlgorithm { |
|
|
result = new ArrayList<>(); |
|
|
result = new ArrayList<>(); |
|
|
for (List<MeetingExpert> experts : expertsByRecentMeeting) { |
|
|
for (List<MeetingExpert> experts : expertsByRecentMeeting) { |
|
|
List<ExpertUserFullInfo> notInvitedUsers = userFullInfos.stream() |
|
|
List<ExpertUserFullInfo> notInvitedUsers = userFullInfos.stream() |
|
|
.filter(w -> experts.stream().noneMatch(expert -> expert.getExpertId().equals(w.getUserId()))) |
|
|
|
|
|
|
|
|
.filter(w -> expertMatchNone(experts, w)) |
|
|
.collect(Collectors.toList()); |
|
|
.collect(Collectors.toList()); |
|
|
if (!notInvitedUsers.isEmpty()) { |
|
|
if (!notInvitedUsers.isEmpty()) { |
|
|
result.addAll(notInvitedUsers); |
|
|
result.addAll(notInvitedUsers); |
|
|