From 0444d2f794ab8205c5503d0693f47695cde522fb Mon Sep 17 00:00:00 2001 From: WendyYang Date: Tue, 18 Apr 2023 10:50:18 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E4=B8=80=E5=91=A8=E5=8F=82?= =?UTF-8?q?=E4=B8=8E=E6=AC=A1=E6=95=B0=E9=99=90=E5=88=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../pmapi/meeting/manage/ExpertInviteManage.java | 32 ++++++++++++++++++++++ .../pmapi/meeting/mapper/MeetingExpertMapper.java | 14 ++++++++++ .../pmapi/meeting/mapper/MeetingExpertMapper.xml | 9 ++++++ .../meeting/service/IMeetingExpertService.java | 4 ++- .../service/impl/MeetingExpertServiceImpl.java | 6 ++++ .../pmapi/meeting/task/RandomInviteProperties.java | 6 ++++ 6 files changed, 70 insertions(+), 1 deletion(-) 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 923a93a..87447bc 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 @@ -70,6 +70,9 @@ public class ExpertInviteManage { @Value("#{randomInviteProperties.recentMeetingCount}") private Integer recentMeetingCount; + @Value("#{randomInviteProperties.recentDays}") + private Integer recentDays; + private static final Predicate> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty(); private LambdaQueryWrapper buildBaseExpertQuery() { @@ -97,6 +100,23 @@ public class ExpertInviteManage { } /** + * 获取一周内被抽中并同意参会的专家ID + * + * @param agreeCnt 一周内被抽中并同意参会次数 + * @param sTime 会议开始时间 + * @param days 天数 + * @return java.util.List + * @author WendyYang + **/ + private List listAgreedUserIdByRecentMeetings(int agreeCnt, int days, LocalDateTime sTime) { + if (agreeCnt == 0 || days == 0) { + return Collections.emptyList(); + } + LocalDateTime beginLimit = sTime.minusDays(days); + return meetingExpertService.listAgreeExpertIdByRecentDaysAndAgreeCount(agreeCnt, beginLimit, sTime); + } + + /** * 增加专家层级限制 * * @param query 查询 @@ -294,6 +314,12 @@ public class ExpertInviteManage { } else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); } + // 处理回避专家次数 + if (avoidRule.getWeekInviteCount() != null) { + Integer weekInviteCount = avoidRule.getWeekInviteCount(); + List tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, sTime); + expertIdsNotIn.addAll(tmpExpertIdsNotIn); + } // 处理专家层级 addRegionLimit(query, randomRule); if (!expertIdsIn.isEmpty()) { @@ -378,6 +404,12 @@ public class ExpertInviteManage { Set notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); // 处理回避单位与回避条线 buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); + // 处理回避专家次数 + if (avoidRule.getWeekInviteCount() != null) { + Integer weekInviteCount = avoidRule.getWeekInviteCount(); + List tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, msTime); + expertIdsNotIn.addAll(tmpExpertIdsNotIn); + } // 处理专家层级 addRegionLimit(query, randomRule); diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.java index e6332e3..d13b407 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.java @@ -9,6 +9,7 @@ import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; import com.ningdatech.pmapi.meeting.entity.req.ReviewProjectListReq; import org.apache.ibatis.annotations.Param; +import java.time.LocalDateTime; import java.util.Collection; import java.util.List; @@ -62,6 +63,19 @@ public interface MeetingExpertMapper extends BaseMapper { @Param("meetingIds") Collection meetingIds); /** + * 查询时间窗口之内参与会议不超过{@code agreeCount}次的专家ID + * + * @param agreeCount 参与次数(包含) + * @param startTime 开始时间 + * @param endTime 结束时间 + * @return 专家ID集合 + * @author WendyYang + **/ + List listAgreeExpertIdByRecentDaysAndAgreeCount(@Param("agreeCount") Integer agreeCount, + @Param("startTime") LocalDateTime startTime, + @Param("endTime") LocalDateTime endTime); + + /** * 根据会议ID与参与状态统计专家数量 * * @param status 会议状态 diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml index 4dc5475..dd1c32c 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml @@ -50,6 +50,15 @@ + +