|
|
@@ -292,21 +292,21 @@ public class ExpertInviteManage { |
|
|
|
* @return 满足抽取条件的专家 |
|
|
|
* @author WendyYang |
|
|
|
**/ |
|
|
|
public ExpertChooseDTO expertInviteByRandomRule(AvoidRuleDTO avoidRule, |
|
|
|
RandomInviteRuleDTO randomRule, |
|
|
|
List<Long> invitedExpertIds, |
|
|
|
LocalDateTime sTime, |
|
|
|
LocalDateTime eTime, |
|
|
|
LocalDateTime meetingCreateOn) { |
|
|
|
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); |
|
|
|
public ExpertChoseDTO expertInviteByRandomRule(AvoidRuleDTO avoidRule, |
|
|
|
RandomInviteRuleDTO randomRule, |
|
|
|
List<Long> invitedExpertIds, |
|
|
|
LocalDateTime sTime, |
|
|
|
LocalDateTime eTime, |
|
|
|
LocalDateTime meetingCreateOn) { |
|
|
|
ExpertChoseDTO result = new ExpertChoseDTO(new ArrayList<>(), 0); |
|
|
|
MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); |
|
|
|
if (merge.isSkip()) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
boolean avoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds()); |
|
|
|
boolean avoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList()); |
|
|
|
boolean hasAvoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds()); |
|
|
|
boolean hasAvoidCompany = CollUtil.isNotEmpty(avoidRule.getAvoidUnitIdList()); |
|
|
|
Set<String> avoidCompanyUniqCodes = new HashSet<>(); |
|
|
|
if (avoidCompany) { |
|
|
|
if (hasAvoidCompany) { |
|
|
|
avoidCompanyUniqCodes.addAll(avoidRule.getAvoidUnitIdList()); |
|
|
|
} |
|
|
|
if (CollUtil.isNotEmpty(invitedExpertIds)) { |
|
|
@@ -334,7 +334,7 @@ public class ExpertInviteManage { |
|
|
|
// 处理专家层级 |
|
|
|
addRegionLimit(query, randomRule); |
|
|
|
if (!expertIdsIn.isEmpty()) { |
|
|
|
if (avoidExpert) { |
|
|
|
if (hasAvoidExpert) { |
|
|
|
expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); |
|
|
|
if (expertIdsIn.isEmpty()) { |
|
|
|
// 字典、标签、履职意向地 筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的 |
|
|
@@ -353,7 +353,7 @@ public class ExpertInviteManage { |
|
|
|
if (expertIdsIn.isEmpty()) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
} else if (avoidExpert || CollUtil.isNotEmpty(invitedExpertIds)) { |
|
|
|
} else if (hasAvoidExpert || CollUtil.isNotEmpty(invitedExpertIds)) { |
|
|
|
Set<Long> tmpExpert = expertInviteHelper.getAvoidExpert(invitedExpertIds, avoidRule, sTime, eTime); |
|
|
|
expertIdsNotIn.addAll(tmpExpert); |
|
|
|
} else { |
|
|
@@ -405,18 +405,18 @@ public class ExpertInviteManage { |
|
|
|
* @param msTime 会议开始时间 |
|
|
|
* @param meTime 会议结束时间 |
|
|
|
* @param reInvite 邀请已拒绝 |
|
|
|
* @return {@link ExpertChooseDTO} |
|
|
|
* @return {@link ExpertChoseDTO} |
|
|
|
* @author WendyYang |
|
|
|
**/ |
|
|
|
public ExpertChooseDTO expertReplaceByRandomRule(AvoidRuleDTO avoidRule, |
|
|
|
RandomInviteRuleDTO randomRule, |
|
|
|
Collection<MeetingExpert> invitedExperts, |
|
|
|
Integer count, |
|
|
|
LocalDateTime msTime, |
|
|
|
LocalDateTime meTime, |
|
|
|
LocalDateTime tsTime, |
|
|
|
boolean reInvite) { |
|
|
|
ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); |
|
|
|
public ExpertChoseDTO expertReplaceByRandomRule(AvoidRuleDTO avoidRule, |
|
|
|
RandomInviteRuleDTO randomRule, |
|
|
|
Collection<MeetingExpert> invitedExperts, |
|
|
|
Integer count, |
|
|
|
LocalDateTime msTime, |
|
|
|
LocalDateTime meTime, |
|
|
|
LocalDateTime tsTime, |
|
|
|
boolean reInvite) { |
|
|
|
ExpertChoseDTO result = new ExpertChoseDTO(new ArrayList<>(), 0); |
|
|
|
// 合并标签、字典 |
|
|
|
MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); |
|
|
|
if (merge.isSkip()) { |
|
|
@@ -466,15 +466,26 @@ public class ExpertInviteManage { |
|
|
|
Map<ExpertAttendStatusEnum, List<MeetingExpert>> expertGroupByStatus = invitedExperts.stream() |
|
|
|
.collect(Collectors.groupingBy(w -> ExpertAttendStatusEnum.getByCode(w.getStatus()))); |
|
|
|
// 回避同单位其他专家 |
|
|
|
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.NONE : AvoidTypeEnum.getByCode(avoidRule.getAvoidType()); |
|
|
|
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.isEmpty()) { |
|
|
|
expertIdsNotIn.addAll(agreeOrNoticingExpertIds); |
|
|
|
List<ExpertUserFullInfo> agreeOrNoticingUserInfos = expertUserFullInfoService.listByUserIds(agreeOrNoticingExpertIds); |
|
|
|
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
|
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); |
|
|
|
if (AvoidTypeEnum.CURR_UNIT.equals(avoidType)) { |
|
|
|
List<ExpertUserFullInfo> agreeOrNoticingUserInfos = expertUserFullInfoService.listByUserIds(agreeOrNoticingExpertIds); |
|
|
|
List<String> tmpUniqCompanyCodes = CollUtils.fieldList(agreeOrNoticingUserInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
|
notInCompanyUniqCodeList.addAll(tmpUniqCompanyCodes); |
|
|
|
} else if (AvoidTypeEnum.CURR_STRIP.equals(avoidType)) { |
|
|
|
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(agreeOrNoticingExpertIds); |
|
|
|
if (CollUtil.isNotEmpty(expertStrips)) { |
|
|
|
List<String> businessStripCodes = CollUtils.fieldList(expertStrips, ExpertGovBusinessStrip::getBusinessStripCode); |
|
|
|
query.notExists("select 1 from expert_gov_business_strip egbs " + |
|
|
|
"where egbs.expertUserId = nd_expert_user_full_info.user_id " + |
|
|
|
"and egbs.business_strip_code in " + BizUtils.inSqlJoin(businessStripCodes)); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
// 已请假的专家不再抽取 |
|
|
|
List<MeetingExpert> expertsOnLeave = expertGroupByStatus.get(ON_LEAVE); |
|
|
@@ -513,15 +524,14 @@ public class ExpertInviteManage { |
|
|
|
if (userFullInfos.isEmpty()) { |
|
|
|
return result; |
|
|
|
} |
|
|
|
AvoidTypeEnum avoidType = avoidRule.getAvoidType() == null ? AvoidTypeEnum.CURR_UNIT : AvoidTypeEnum.getByCode(avoidRule.getAvoidType()); |
|
|
|
switch (avoidType) { |
|
|
|
case NONE: |
|
|
|
result.setExperts(inviteWithoutCompany(userFullInfos, expertsByRecentMeeting(), randomRule.getCount())); |
|
|
|
result.setExperts(inviteWithoutCompany(userFullInfos, expertsByRecentMeeting(), count)); |
|
|
|
result.setTotal(userFullInfos.size()); |
|
|
|
break; |
|
|
|
case CURR_UNIT: |
|
|
|
Map<String, List<ExpertUserFullInfo>> unitGroup = CollUtils.group(userFullInfos, ExpertUserFullInfo::getCompanyUniqCode); |
|
|
|
result.setExperts(inviteGroupByUnit(unitGroup, expertsByRecentMeeting(), randomRule.getCount())); |
|
|
|
result.setExperts(inviteGroupByUnit(unitGroup, expertsByRecentMeeting(), count)); |
|
|
|
result.setTotal(unitGroup.size()); |
|
|
|
break; |
|
|
|
case CURR_STRIP: |
|
|
@@ -529,7 +539,7 @@ public class ExpertInviteManage { |
|
|
|
List<ExpertGovBusinessStrip> expertStrips = expertGovBusinessStripService.listByUserIds(userIds); |
|
|
|
if (!expertStrips.isEmpty()) { |
|
|
|
Map<String, List<ExpertGovBusinessStrip>> stripGroup = CollUtils.group(expertStrips, ExpertGovBusinessStrip::getBusinessStripCode); |
|
|
|
result.setExperts(inviteGroupByStrip(stripGroup, userFullInfos, expertsByRecentMeeting(), randomRule.getCount())); |
|
|
|
result.setExperts(inviteGroupByStrip(stripGroup, userFullInfos, expertsByRecentMeeting(), count)); |
|
|
|
result.setTotal(stripGroup.size()); |
|
|
|
} else { |
|
|
|
result.setTotal(0); |
|
|
@@ -573,13 +583,13 @@ public class ExpertInviteManage { |
|
|
|
// 处理随机抽取规则 |
|
|
|
if (CollUtil.isNotEmpty(randomRules)) { |
|
|
|
List<ExpertInviteRule> randoms = new ArrayList<>(); |
|
|
|
List<ExpertChooseDTO> expertsByRandom = new ArrayList<>(); |
|
|
|
List<ExpertChoseDTO> expertsByRandom = new ArrayList<>(); |
|
|
|
List<Long> chooseExpertIds = new ArrayList<>(); |
|
|
|
LocalDateTime sTime = meeting.getStartTime(); |
|
|
|
LocalDateTime eTime = meeting.getEndTime(); |
|
|
|
LocalDateTime createOn = meeting.getCreateOn(); |
|
|
|
randomRules.forEach(rule -> { |
|
|
|
ExpertChooseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime, createOn); |
|
|
|
ExpertChoseDTO tmpExperts = expertInviteByRandomRule(avoidRule, rule, chooseExpertIds, sTime, eTime, createOn); |
|
|
|
if (tmpExperts.getTotal() < rule.getCount()) { |
|
|
|
throw BizException.wrap("可抽取专家数量不足"); |
|
|
|
} |
|
|
|