@@ -70,6 +70,9 @@ public class ExpertInviteManage { | |||||
@Value("#{randomInviteProperties.recentMeetingCount}") | @Value("#{randomInviteProperties.recentMeetingCount}") | ||||
private Integer recentMeetingCount; | private Integer recentMeetingCount; | ||||
@Value("#{randomInviteProperties.recentDays}") | |||||
private Integer recentDays; | |||||
private static final Predicate<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty(); | private static final Predicate<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty(); | ||||
private LambdaQueryWrapper<ExpertUserFullInfo> buildBaseExpertQuery() { | private LambdaQueryWrapper<ExpertUserFullInfo> buildBaseExpertQuery() { | ||||
@@ -97,6 +100,23 @@ public class ExpertInviteManage { | |||||
} | } | ||||
/** | /** | ||||
* 获取一周内被抽中并同意参会的专家ID | |||||
* | |||||
* @param agreeCnt 一周内被抽中并同意参会次数 | |||||
* @param sTime 会议开始时间 | |||||
* @param days 天数 | |||||
* @return java.util.List<java.lang.Long> | |||||
* @author WendyYang | |||||
**/ | |||||
private List<Long> 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 查询 | * @param query 查询 | ||||
@@ -294,6 +314,12 @@ public class ExpertInviteManage { | |||||
} else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { | } else if (CollUtil.isNotEmpty(merge.getExpertIdsNotIn())) { | ||||
expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); | expertIdsNotIn.addAll(merge.getExpertIdsNotIn()); | ||||
} | } | ||||
// 处理回避专家次数 | |||||
if (avoidRule.getWeekInviteCount() != null) { | |||||
Integer weekInviteCount = avoidRule.getWeekInviteCount(); | |||||
List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, sTime); | |||||
expertIdsNotIn.addAll(tmpExpertIdsNotIn); | |||||
} | |||||
// 处理专家层级 | // 处理专家层级 | ||||
addRegionLimit(query, randomRule); | addRegionLimit(query, randomRule); | ||||
if (!expertIdsIn.isEmpty()) { | if (!expertIdsIn.isEmpty()) { | ||||
@@ -378,6 +404,12 @@ public class ExpertInviteManage { | |||||
Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); | Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList()); | ||||
// 处理回避单位与回避条线 | // 处理回避单位与回避条线 | ||||
buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); | buildAvoidCompanyAndBusinessStrip(query, avoidRule.getAvoidUnitIdList(), avoidRule.getAvoidOrgIdList()); | ||||
// 处理回避专家次数 | |||||
if (avoidRule.getWeekInviteCount() != null) { | |||||
Integer weekInviteCount = avoidRule.getWeekInviteCount(); | |||||
List<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, msTime); | |||||
expertIdsNotIn.addAll(tmpExpertIdsNotIn); | |||||
} | |||||
// 处理专家层级 | // 处理专家层级 | ||||
addRegionLimit(query, randomRule); | addRegionLimit(query, randomRule); | ||||
@@ -9,6 +9,7 @@ import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||||
import com.ningdatech.pmapi.meeting.entity.req.ReviewProjectListReq; | import com.ningdatech.pmapi.meeting.entity.req.ReviewProjectListReq; | ||||
import org.apache.ibatis.annotations.Param; | import org.apache.ibatis.annotations.Param; | ||||
import java.time.LocalDateTime; | |||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -62,6 +63,19 @@ public interface MeetingExpertMapper extends BaseMapper<MeetingExpert> { | |||||
@Param("meetingIds") Collection<Long> meetingIds); | @Param("meetingIds") Collection<Long> meetingIds); | ||||
/** | /** | ||||
* 查询时间窗口之内参与会议不超过{@code agreeCount}次的专家ID | |||||
* | |||||
* @param agreeCount 参与次数(包含) | |||||
* @param startTime 开始时间 | |||||
* @param endTime 结束时间 | |||||
* @return 专家ID集合 | |||||
* @author WendyYang | |||||
**/ | |||||
List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(@Param("agreeCount") Integer agreeCount, | |||||
@Param("startTime") LocalDateTime startTime, | |||||
@Param("endTime") LocalDateTime endTime); | |||||
/** | |||||
* 根据会议ID与参与状态统计专家数量 | * 根据会议ID与参与状态统计专家数量 | ||||
* | * | ||||
* @param status 会议状态 | * @param status 会议状态 | ||||
@@ -50,6 +50,15 @@ | |||||
</if> | </if> | ||||
</select> | </select> | ||||
<select id="listAgreeExpertIdByRecentDaysAndAgreeCount" resultType="long"> | |||||
SELECT expert_id FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC ) | |||||
rowNumber,expert_id, status FROM meeting_expert | |||||
where meeting_id in (select id from meeting m where m.status = 1 | |||||
and ((m.start_time >= #{startTime} and m.start_time < #{endTime}) | |||||
or (m.end_time >= #{startTime} and m.end_time < #{endTime})) )) em | |||||
WHERE rowNumber = 1 and status = 3 group by expert_id having count(1) <= #{agreeCount} | |||||
</select> | |||||
<select id="countExpertByStatusAndMeetingId" | <select id="countExpertByStatusAndMeetingId" | ||||
resultType="int"> | resultType="int"> | ||||
SELECT count(1) FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC ) | SELECT count(1) FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC ) | ||||
@@ -9,8 +9,8 @@ import com.ningdatech.pmapi.meeting.entity.dto.ReviewProjectDTO; | |||||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | ||||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; | import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; | ||||
import com.ningdatech.pmapi.meeting.entity.req.ReviewProjectListReq; | 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.Collection; | ||||
import java.util.Collections; | import java.util.Collections; | ||||
import java.util.List; | import java.util.List; | ||||
@@ -155,4 +155,6 @@ public interface IMeetingExpertService extends IService<MeetingExpert> { | |||||
**/ | **/ | ||||
Page<ReviewProjectDTO> pageReviewProjectList(ReviewProjectListReq req); | Page<ReviewProjectDTO> pageReviewProjectList(ReviewProjectListReq req); | ||||
List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(int agreeCount, LocalDateTime sTime, LocalDateTime eTime); | |||||
} | } |
@@ -19,6 +19,7 @@ import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; | |||||
import lombok.RequiredArgsConstructor; | import lombok.RequiredArgsConstructor; | ||||
import org.springframework.stereotype.Service; | import org.springframework.stereotype.Service; | ||||
import java.time.LocalDateTime; | |||||
import java.util.Collection; | import java.util.Collection; | ||||
import java.util.List; | import java.util.List; | ||||
import java.util.Map; | import java.util.Map; | ||||
@@ -134,4 +135,9 @@ public class MeetingExpertServiceImpl extends ServiceImpl<MeetingExpertMapper, M | |||||
return baseMapper.pageReviewProjectList(req.page(), req); | return baseMapper.pageReviewProjectList(req.page(), req); | ||||
} | } | ||||
@Override | |||||
public List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(int agreeCount, LocalDateTime sTime, LocalDateTime eTime) { | |||||
return baseMapper.listAgreeExpertIdByRecentDaysAndAgreeCount(agreeCount, sTime, eTime); | |||||
} | |||||
} | } |
@@ -42,4 +42,10 @@ public class RandomInviteProperties { | |||||
* 近期会议数量(以此来降低专家抽中间隔) | * 近期会议数量(以此来降低专家抽中间隔) | ||||
*/ | */ | ||||
private Integer recentMeetingCount = 5; | private Integer recentMeetingCount = 5; | ||||
/** | |||||
* 参会次数限制天数 | |||||
*/ | |||||
private Integer recentDays = 7; | |||||
} | } |