瀏覽代碼

专家抽取算法优化

tags/24080901
WendyYang 1 年之前
父節點
當前提交
9dc5f77a69
共有 1 個檔案被更改,包括 6 行新增2 行删除
  1. +6
    -2
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/helper/ExpertRandomInviteAlgorithm.java

+ 6
- 2
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<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);
for (List<MeetingExpert> experts : expertsByRecentMeeting) {
List<ExpertUserFullInfo> 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<MeetingExpert> experts : expertsByRecentMeeting) {
List<ExpertUserFullInfo> 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);


Loading…
取消
儲存