瀏覽代碼

增加一周参与次数限制

master
WendyYang 1 年之前
父節點
當前提交
0444d2f794
共有 6 個文件被更改,包括 70 次插入1 次删除
  1. +32
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/manage/ExpertInviteManage.java
  2. +14
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.java
  3. +9
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml
  4. +3
    -1
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IMeetingExpertService.java
  5. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingExpertServiceImpl.java
  6. +6
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/RandomInviteProperties.java

+ 32
- 0
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<Collection<?>> COLL_EMPTY = (coll) -> coll != null && coll.isEmpty();

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 查询
@@ -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<Long> tmpExpertIdsNotIn = listAgreedUserIdByRecentMeetings(weekInviteCount, recentDays, sTime);
expertIdsNotIn.addAll(tmpExpertIdsNotIn);
}
// 处理专家层级
addRegionLimit(query, randomRule);
if (!expertIdsIn.isEmpty()) {
@@ -378,6 +404,12 @@ public class ExpertInviteManage {
Set<String> notInCompanyUniqCodeList = new HashSet<>(avoidRule.getAvoidUnitIdList());
// 处理回避单位与回避条线
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);



+ 14
- 0
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<MeetingExpert> {
@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与参与状态统计专家数量
*
* @param status 会议状态


+ 9
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/mapper/MeetingExpertMapper.xml 查看文件

@@ -50,6 +50,15 @@
</if>
</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 &gt;= #{startTime} and m.start_time &lt; #{endTime})
or (m.end_time &gt;= #{startTime} and m.end_time &lt; #{endTime})) )) em
WHERE rowNumber = 1 and status = 3 group by expert_id having count(1) &lt;= #{agreeCount}
</select>

<select id="countExpertByStatusAndMeetingId"
resultType="int">
SELECT count(1) FROM (SELECT ROW_NUMBER() OVER ( PARTITION BY expert_id, meeting_id ORDER BY update_on DESC )


+ 3
- 1
pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/IMeetingExpertService.java 查看文件

@@ -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.ExpertInviteTypeEnum;
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.Collections;
import java.util.List;
@@ -155,4 +155,6 @@ public interface IMeetingExpertService extends IService<MeetingExpert> {
**/
Page<ReviewProjectDTO> pageReviewProjectList(ReviewProjectListReq req);

List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(int agreeCount, LocalDateTime sTime, LocalDateTime eTime);

}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingExpertServiceImpl.java 查看文件

@@ -19,6 +19,7 @@ import com.ningdatech.pmapi.meeting.service.IMeetingExpertService;
import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;

import java.time.LocalDateTime;
import java.util.Collection;
import java.util.List;
import java.util.Map;
@@ -134,4 +135,9 @@ public class MeetingExpertServiceImpl extends ServiceImpl<MeetingExpertMapper, M
return baseMapper.pageReviewProjectList(req.page(), req);
}

@Override
public List<Long> listAgreeExpertIdByRecentDaysAndAgreeCount(int agreeCount, LocalDateTime sTime, LocalDateTime eTime) {
return baseMapper.listAgreeExpertIdByRecentDaysAndAgreeCount(agreeCount, sTime, eTime);
}

}

+ 6
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/RandomInviteProperties.java 查看文件

@@ -42,4 +42,10 @@ public class RandomInviteProperties {
* 近期会议数量(以此来降低专家抽中间隔)
*/
private Integer recentMeetingCount = 5;

/**
* 参会次数限制天数
*/
private Integer recentDays = 7;

}

Loading…
取消
儲存