From 95d484a3f23d9495f462151b2f0023bb3ecb236a Mon Sep 17 00:00:00 2001 From: WendyYang Date: Fri, 14 Apr 2023 14:41:42 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=93=E5=AE=B6=E6=8A=BD?= =?UTF-8?q?=E5=8F=96=E4=B8=BA=E7=A9=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/meeting/entity/dto/MergeExpertIdDTO.java | 30 +++++++++ .../pmapi/meeting/manage/ExpertInviteManage.java | 76 +++++++++++++--------- 2 files changed, 77 insertions(+), 29 deletions(-) create mode 100644 pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java new file mode 100644 index 0000000..328e14a --- /dev/null +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/MergeExpertIdDTO.java @@ -0,0 +1,30 @@ +package com.ningdatech.pmapi.meeting.entity.dto; + +import lombok.Data; + +import java.util.List; + +/** + *

+ * MergeExpertIdDTO + *

+ * + * @author WendyYang + * @since 2023/4/14 + **/ +@Data +public class MergeExpertIdDTO { + + private List expertIdsIn; + + private List expertIdsNotIn; + + private Boolean skip; + + public static MergeExpertIdDTO noExpert() { + MergeExpertIdDTO condition = new MergeExpertIdDTO(); + condition.setSkip(Boolean.TRUE); + return condition; + } + +} diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java index 4183bf4..08adf25 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java @@ -16,10 +16,7 @@ import com.ningdatech.pmapi.meeting.builder.ExpertInviteBuilder; import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; import com.ningdatech.pmapi.meeting.entity.domain.Meeting; import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; -import com.ningdatech.pmapi.meeting.entity.dto.AvoidRuleDTO; -import com.ningdatech.pmapi.meeting.entity.dto.ExpertChooseDTO; -import com.ningdatech.pmapi.meeting.entity.dto.ExpertDictChooseDTO; -import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; +import com.ningdatech.pmapi.meeting.entity.dto.*; import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; @@ -124,30 +121,32 @@ public class ExpertInviteManage { return new ArrayList<>(); } LambdaQueryWrapper query = Wrappers.lambdaQuery(ExpertAvoidCompany.class) + .select(ExpertAvoidCompany::getUserId) .in(ExpertAvoidCompany::getCompanyUniqCode, unitCodeList); List expertAvoidCompanyList = expertAvoidCompanyService.list(query); return CollUtils.fieldList(expertAvoidCompanyList, ExpertAvoidCompany::getUserId); } - private List mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) { + private MergeExpertIdDTO mergeExpertIdsByCondition(RandomInviteRuleDTO rule, AvoidRuleDTO avoidInfo) { // 处理履职意向地 List expertIdsByIntentionRegion = expertIdsByRegion(rule); if (COLL_EMPTY.evaluate(expertIdsByIntentionRegion)) { - return null; + return MergeExpertIdDTO.noExpert(); } // 处理专家标签 List expertIdsByTag = expertIdsByTag(rule); if (COLL_EMPTY.evaluate(expertIdsByTag)) { - return null; + return MergeExpertIdDTO.noExpert(); } // 处理专家字典 List expertIdsByDict = expertIdsByDict(rule); if (COLL_EMPTY.evaluate(expertIdsByDict)) { - return null; + return MergeExpertIdDTO.noExpert(); } // 处理专家回避单位 与 抽取回避单位是否相同 - List avoidCompanyExpertIds = avoidCompanyExpertIds(avoidInfo.getAvoidUnitIdList()); + List avoidExpertIdsByUnit = avoidCompanyExpertIds(avoidInfo.getAvoidUnitIdList()); + MergeExpertIdDTO merge = new MergeExpertIdDTO(); // 聚合用户ID List expertIdsIn = new ArrayList<>(); if (ObjectUtils.anyNotNull(expertIdsByDict, expertIdsByTag, expertIdsByIntentionRegion)) { @@ -167,17 +166,22 @@ public class ExpertInviteManage { } }); if (expertIdsIn.isEmpty()) { - return null; + return MergeExpertIdDTO.noExpert(); } + merge.setExpertIdsIn(expertIdsIn); } - - if (CollUtil.isNotEmpty(avoidCompanyExpertIds)) { - expertIdsIn.removeIf(avoidCompanyExpertIds::contains); + if (CollUtil.isNotEmpty(avoidExpertIdsByUnit)) { if (expertIdsIn.isEmpty()) { - return null; + merge.setExpertIdsNotIn(avoidExpertIdsByUnit); + } else { + expertIdsIn.removeIf(avoidExpertIdsByUnit::contains); + if (expertIdsIn.isEmpty()) { + return MergeExpertIdDTO.noExpert(); + } } } - return expertIdsIn; + merge.setSkip(Boolean.FALSE); + return merge; } /** @@ -253,8 +257,8 @@ public class ExpertInviteManage { LocalDateTime sTime, LocalDateTime eTime) { ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); - List expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); - if (expertIdsIn == null) { + MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); + if (merge.getSkip()) { return result; } boolean avoidExpert = CollUtil.isNotEmpty(avoidRule.getExpertIds()); @@ -270,14 +274,20 @@ public class ExpertInviteManage { 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.getAvoidUnitIdList())); } + Set expertIdsIn = new HashSet<>(); + Set expertIdsNotIn = new HashSet<>(); + if (CollUtil.isNotEmpty(merge.getExpertIdsIn())) { + expertIdsIn.addAll(merge.getExpertIdsIn()); + } else { + expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); + } // 处理专家层级 addRegionLimit(query, randomRule); if (!expertIdsIn.isEmpty()) { if (avoidExpert) { expertIdsIn.removeIf(w -> avoidRule.getExpertIds().contains(w)); if (expertIdsIn.isEmpty()) { - // 字典、标签、履职意向地筛选出的专家ID移除需要回避的专家ID - // 如果为空则说明没有符合条件的 + // 字典、标签、履职意向地 筛选出的专家ID移除需要回避的专家ID、如果为空则说明没有符合条件的 return result; } } @@ -293,15 +303,17 @@ public class ExpertInviteManage { if (expertIdsIn.isEmpty()) { return result; } - query.in(ExpertUserFullInfo::getUserId, expertIdsIn); } else if (avoidExpert || CollUtil.isNotEmpty(appointExpertIds)) { - Set tempExperts = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); - query.notIn(ExpertUserFullInfo::getUserId, tempExperts); + Set tmpExpert = expertInviteHelper.getAvoidExpert(appointExpertIds, avoidRule, sTime, eTime); + expertIdsNotIn.addAll(tmpExpert); } else { - Set notInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); - if (!notInUserIds.isEmpty()) { - query.notIn(ExpertUserFullInfo::getUserId, notInUserIds); - } + Set tmpNotInUserIds = expertInviteHelper.listExpertLeaveOrInvited(sTime, eTime); + expertIdsNotIn.addAll(tmpNotInUserIds); + } + if (!expertIdsIn.isEmpty()) { + query.in(ExpertUserFullInfo::getUserId, expertIdsIn); + } else if (!expertIdsNotIn.isEmpty()) { + query.notIn(ExpertUserFullInfo::getUserId, expertIdsNotIn); } List userInfoList = expertUserFullInfoService.list(query); if (userInfoList.isEmpty()) { @@ -334,11 +346,17 @@ public class ExpertInviteManage { boolean invitedRefused) { ExpertChooseDTO result = new ExpertChooseDTO(new ArrayList<>(), 0); // 合并标签、字典 - List expertIdsIn = mergeExpertIdsByCondition(randomRule, avoidRule); - List expertIdsNotIn = new ArrayList<>(); - if (expertIdsIn == null) { + MergeExpertIdDTO merge = mergeExpertIdsByCondition(randomRule, avoidRule); + if (merge.getSkip()) { return result; } + Set expertIdsIn = new HashSet<>(); + Set expertIdsNotIn = new HashSet<>(); + if (CollUtil.isNotEmpty(merge.getExpertIdsIn())) { + expertIdsIn.addAll(merge.getExpertIdsIn()); + } else { + expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); + } LambdaQueryWrapper query = buildBaseExpertQuery(); // 设置回避单位 Set notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList());