|
|
@@ -109,13 +109,18 @@ public class ExpertInviteTask { |
|
|
|
log.info("暂无需要初始化的抽取会议信息"); |
|
|
|
return; |
|
|
|
} |
|
|
|
Integer inviteDelay = properties.getInviteDelay(); |
|
|
|
for (InviteCacheDTO cache : caches.values()) { |
|
|
|
addInviteTask(cache.getMeetingId(), true, properties.getInviteDelay(), cache.getInvitedRefused()); |
|
|
|
Boolean invitedRefused = cache.getInvitedRefused(); |
|
|
|
boolean added = addInviteTask(cache.getMeetingId(), true, inviteDelay, invitedRefused); |
|
|
|
if (!added) { |
|
|
|
cachePlusOps.hDel(getCacheKey(cache.getMeetingId())); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 专家抽取校验 |
|
|
|
* 专家抽取校验(抽取数量是否不足) |
|
|
|
* |
|
|
|
* @param meetingId 会议ID |
|
|
|
* @return boolean |
|
|
@@ -132,16 +137,16 @@ public class ExpertInviteTask { |
|
|
|
.in(MeetingExpert::getStatus, ExpertAttendStatusEnum.AGREED.getCode()); |
|
|
|
List<MeetingExpert> experts = meetingExpertService.list(query); |
|
|
|
if (experts.isEmpty()) { |
|
|
|
return Boolean.FALSE; |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
Map<Long, Long> cntMap = CollUtils.groupCount(experts, MeetingExpert::getRuleId); |
|
|
|
for (Map.Entry<Long, RandomInviteRuleDTO> entry : ruleMap.entrySet()) { |
|
|
|
Long agreeCnt = cntMap.getOrDefault(entry.getKey(), 0L); |
|
|
|
if (agreeCnt < entry.getValue().getCount()) { |
|
|
|
return Boolean.FALSE; |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
} |
|
|
|
return Boolean.TRUE; |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
@@ -157,14 +162,15 @@ public class ExpertInviteTask { |
|
|
|
tmpInvitedRefused = invitedRefused[0]; |
|
|
|
} |
|
|
|
if (!INVITE_TASK_MAP.containsKey(meetingId)) { |
|
|
|
addInviteTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused); |
|
|
|
log.info("重置会议的随机抽取状态:{}", meetingId); |
|
|
|
LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class); |
|
|
|
update.set(Meeting::getInviteStatus, false); |
|
|
|
update.eq(Meeting::getId, meetingId); |
|
|
|
meetingService.update(update); |
|
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpInvitedRefused); |
|
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
|
if (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused)) { |
|
|
|
log.info("重置会议的随机抽取状态:{}", meetingId); |
|
|
|
LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class); |
|
|
|
update.set(Meeting::getInviteStatus, false); |
|
|
|
update.eq(Meeting::getId, meetingId); |
|
|
|
meetingService.update(update); |
|
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpInvitedRefused); |
|
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -175,12 +181,13 @@ public class ExpertInviteTask { |
|
|
|
* @param checked 是否前置校验 |
|
|
|
* @param delayedMinutes 延迟执行时间 |
|
|
|
* @param invitedRefused 是否可以邀请被拒绝的专家 |
|
|
|
* @return 是否添加任务成功 |
|
|
|
* @author WendyYang |
|
|
|
**/ |
|
|
|
public void addInviteTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused) { |
|
|
|
public boolean addInviteTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused) { |
|
|
|
if (checked && !inviteCountCheck(meetingId)) { |
|
|
|
// 如果抽取数量满足直接返回 |
|
|
|
return; |
|
|
|
return Boolean.FALSE; |
|
|
|
} |
|
|
|
Instant startTime = LocalDateTime.now().plusMinutes(delayedMinutes).atZone(ZoneId.systemDefault()).toInstant(); |
|
|
|
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> { |
|
|
@@ -193,6 +200,7 @@ public class ExpertInviteTask { |
|
|
|
}, startTime, Duration.ofMinutes(properties.getInviteFixedRate())); |
|
|
|
INVITE_TASK_MAP.putIfAbsent(meetingId, future); |
|
|
|
log.info("添加专家抽取后台任务:{}", meetingId); |
|
|
|
return Boolean.TRUE; |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|