|
@@ -44,6 +44,7 @@ import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Stream; |
|
|
import java.util.stream.Stream; |
|
|
|
|
|
|
|
|
|
|
|
import static com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum.*; |
|
|
import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertInviteRule; |
|
|
import static com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper.getExpertInviteRule; |
|
|
|
|
|
|
|
|
/** |
|
|
/** |
|
@@ -336,25 +337,23 @@ public class ExpertInviteManage { |
|
|
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); |
|
|
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); |
|
|
// 合并标签、字典 |
|
|
// 合并标签、字典 |
|
|
List<Long> expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); |
|
|
List<Long> expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); |
|
|
|
|
|
List<Long> expertIdsNotIn = new ArrayList<>(); |
|
|
if (expertIdsIn == null) { |
|
|
if (expertIdsIn == null) { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); |
|
|
LambdaQueryWrapper<ExpertUserFullInfo> query = buildBaseExpertQuery(); |
|
|
query.notIn(ExpertUserFullInfo::getCompanyUniqCode, avoidRule.getAvoidUnitIdList()); |
|
|
|
|
|
|
|
|
// 设置回避单位 |
|
|
|
|
|
Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); |
|
|
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" + |
|
|
query.notExists("select 1 from expert_avoid_company eac where eac.user_id = nd_expert_user_full_info.user_id" + |
|
|
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidOrgIdList())); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
" and company_uniq_code in ({0})", CollUtils.joinByComma(avoidRule.getAvoidUnitIdList())); |
|
|
// 处理专家层级 |
|
|
// 处理专家层级 |
|
|
if (StrUtils.isNotBlank(randomRule.getExpertRegionCode())) { |
|
|
|
|
|
query.eq(ExpertUserFullInfo::getRegionCode, randomRule.getExpertRegionCode()); |
|
|
|
|
|
query.eq(ExpertUserFullInfo::getRegionLevel, randomRule.getExpertRegionLevel()); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
addRegionLimit(query, randomRule); |
|
|
|
|
|
|
|
|
if (expertIdsIn.size() > 0) { |
|
|
if (expertIdsIn.size() > 0) { |
|
|
if (CollectionUtils.isNotEmpty(avoidRule.getExpertIds())) { |
|
|
if (CollectionUtils.isNotEmpty(avoidRule.getExpertIds())) { |
|
|
expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); |
|
|
expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); |
|
|
if (expertIdsIn.isEmpty()) { |
|
|
if (expertIdsIn.isEmpty()) { |
|
|
// 字典、标签、履职意向地筛选出的专家ID移除需要回避的专家ID |
|
|
|
|
|
// 如果为空则说明没有符合条件的 |
|
|
|
|
|
|
|
|
// 字典、标签、履职意向地筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的 |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -363,37 +362,52 @@ public class ExpertInviteManage { |
|
|
if (expertIdsIn.isEmpty()) { |
|
|
if (expertIdsIn.isEmpty()) { |
|
|
return result; |
|
|
return result; |
|
|
} |
|
|
} |
|
|
query.in(ExpertUserFullInfo::getUserId, expertIdsIn); |
|
|
|
|
|
} else if (CollUtil.isNotEmpty(avoidRule.getExpertIds())) { |
|
|
} else if (CollUtil.isNotEmpty(avoidRule.getExpertIds())) { |
|
|
Set<Long> notInExpertIds = expertInviteHelper.getAvoidExpert(avoidRule.getExpertIds(), null, start, end); |
|
|
Set<Long> notInExpertIds = expertInviteHelper.getAvoidExpert(avoidRule.getExpertIds(), null, start, end); |
|
|
query.notIn(ExpertUserFullInfo::getUserId, notInExpertIds); |
|
|
|
|
|
|
|
|
expertIdsNotIn.addAll(notInExpertIds); |
|
|
} else { |
|
|
} else { |
|
|
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(start, end); |
|
|
Set<Long> notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(start, end); |
|
|
if (notInUserIds.size() > 0) { |
|
|
|
|
|
query.notIn(ExpertUserFullInfo::getUserId, notInUserIds); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
List<ExpertUserFullInfo> userFullInfos = expertUserFullInfoService.list(query); |
|
|
|
|
|
if (userFullInfos.size() == 0) { |
|
|
|
|
|
return result; |
|
|
|
|
|
|
|
|
expertIdsNotIn.addAll(notInUserIds); |
|
|
} |
|
|
} |
|
|
Map<ExpertAttendStatusEnum, List<MeetingExpert>> expertGroupByStatus = invitedExperts.stream() |
|
|
Map<ExpertAttendStatusEnum, List<MeetingExpert>> expertGroupByStatus = invitedExperts.stream() |
|
|
.collect(Collectors.groupingBy(w -> ExpertAttendStatusEnum.getByCode(w.getStatus()))); |
|
|
.collect(Collectors.groupingBy(w -> ExpertAttendStatusEnum.getByCode(w.getStatus()))); |
|
|
// 回避同单位其他专家 |
|
|
// 回避同单位其他专家 |
|
|
List<MeetingExpert> removeExpertByCompany = new ArrayList<>(); |
|
|
|
|
|
BizUtils.notEmpty(expertGroupByStatus.get(ExpertAttendStatusEnum.AGREED), removeExpertByCompany::addAll); |
|
|
|
|
|
BizUtils.notEmpty(expertGroupByStatus.get(ExpertAttendStatusEnum.NOTICING), removeExpertByCompany::addAll); |
|
|
|
|
|
List<Long> removeExpertIds = new ArrayList<>(); |
|
|
|
|
|
|
|
|
List<MeetingExpert> agreeOrNoticing = new ArrayList<>(); |
|
|
|
|
|
BizUtils.notEmpty(expertGroupByStatus.get(AGREED), agreeOrNoticing::addAll); |
|
|
|
|
|
BizUtils.notEmpty(expertGroupByStatus.get(NOTICING), agreeOrNoticing::addAll); |
|
|
|
|
|
List<Long> agreeOrNoticingExpertIds = CollUtils.fieldList(agreeOrNoticing, MeetingExpert::getExpertId); |
|
|
|
|
|
if (agreeOrNoticingExpertIds.size() > 0) { |
|
|
|
|
|
expertIdsNotIn.addAll(agreeOrNoticingExpertIds); |
|
|
|
|
|
List<ExpertUserFullInfo> agreeOrNoticingUserInfos = expertUserFullInfoService.listByUserIds(agreeOrNoticingExpertIds); |
|
|
|
|
|
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
|
|
|
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); |
|
|
|
|
|
} |
|
|
if (invitedRefused) { |
|
|
if (invitedRefused) { |
|
|
// 拒绝参加的不可以被再次抽中 |
|
|
// 拒绝参加的不可以被再次抽中 |
|
|
BizUtils.notEmpty(expertGroupByStatus.get(ExpertAttendStatusEnum.REFUSED), w -> { |
|
|
|
|
|
List<Long> tempRefused = CollUtils.fieldList(w, MeetingExpert::getExpertId); |
|
|
|
|
|
removeExpertIds.addAll(tempRefused); |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
List<MeetingExpert> refusedExperts = expertGroupByStatus.get(REFUSED); |
|
|
|
|
|
if (refusedExperts.size() > 0) { |
|
|
|
|
|
List<Long> refusedExpertIds = CollUtils.fieldList(refusedExperts, MeetingExpert::getExpertId); |
|
|
|
|
|
expertIdsNotIn.addAll(refusedExpertIds); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
boolean hasExpertIdIn = !expertIdsIn.isEmpty(); |
|
|
|
|
|
boolean hasExpertIdNotIn = !expertIdsNotIn.isEmpty(); |
|
|
|
|
|
if (hasExpertIdIn && hasExpertIdNotIn) { |
|
|
|
|
|
expertIdsIn.removeAll(expertIdsNotIn); |
|
|
|
|
|
if (expertIdsIn.isEmpty()) { |
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
query.in(ExpertUserFullInfo::getUserId, expertIdsIn); |
|
|
|
|
|
} else if (hasExpertIdIn) { |
|
|
|
|
|
query.in(ExpertUserFullInfo::getUserId, expertIdsIn); |
|
|
|
|
|
} else if (hasExpertIdNotIn) { |
|
|
|
|
|
query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn); |
|
|
|
|
|
} |
|
|
|
|
|
query.notIn(notInCompanyUniqCodeList.size() > 0, ExpertUserFullInfo::getCompanyUniqCode, notInCompanyUniqCodeList); |
|
|
|
|
|
List<ExpertUserFullInfo> userFullInfos = expertUserFullInfoService.list(query); |
|
|
|
|
|
if (userFullInfos.size() == 0) { |
|
|
|
|
|
return result; |
|
|
} |
|
|
} |
|
|
List<Long> tempExpertIds = CollUtils.fieldList(removeExpertByCompany, MeetingExpert::getExpertId); |
|
|
|
|
|
// 移除确认参加、通知中的、拒绝参加、已取消 |
|
|
|
|
|
userFullInfos.removeIf(w -> tempExpertIds.contains(w.getUserId()) || removeExpertIds.contains(w.getUserId())); |
|
|
|
|
|
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
Map<String, List<ExpertUserFullInfo>> userGroupByUnit = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
result.setTotal(userGroupByUnit.size()); |
|
|
result.setTotal(userGroupByUnit.size()); |
|
|
result.setExperts(inviteGroupByCompany(userGroupByUnit, count)); |
|
|
result.setExperts(inviteGroupByCompany(userGroupByUnit, count)); |
|
@@ -538,7 +552,7 @@ public class ExpertInviteManage { |
|
|
Long ruleId = randoms.get(i).getId(); |
|
|
Long ruleId = randoms.get(i).getId(); |
|
|
expertsByRandom.get(i).getExperts().forEach(w -> { |
|
|
expertsByRandom.get(i).getExperts().forEach(w -> { |
|
|
MeetingExpert expert = ExpertInviteBuilder.getExpertByRandom(meeting.getId(), w, ruleId); |
|
|
MeetingExpert expert = ExpertInviteBuilder.getExpertByRandom(meeting.getId(), w, ruleId); |
|
|
expert.setStatus(ExpertAttendStatusEnum.NOTICING.getCode()); |
|
|
|
|
|
|
|
|
expert.setStatus(NOTICING.getCode()); |
|
|
expertInserts.add(expert); |
|
|
expertInserts.add(expert); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|