|
|
@@ -78,9 +78,9 @@ public class ExpertInviteTask { |
|
|
|
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; |
|
|
|
|
|
|
|
/** |
|
|
|
* 用来存入线程执行情况, 方便于停止定时任务时使用 |
|
|
|
* 用来存入线程执行句柄, 停止定时任务时使用 |
|
|
|
*/ |
|
|
|
protected static final ConcurrentMap<Long, ScheduledFuture<?>> INVITE_MAP = new ConcurrentHashMap<>(); |
|
|
|
private static final ConcurrentMap<Long, ScheduledFuture<?>> INVITE_TASK_MAP = new ConcurrentHashMap<>(); |
|
|
|
|
|
|
|
public ExpertInviteTask currProxy() { |
|
|
|
return (ExpertInviteTask) AopContext.currentProxy(); |
|
|
@@ -109,7 +109,7 @@ public class ExpertInviteTask { |
|
|
|
return; |
|
|
|
} |
|
|
|
for (InviteCacheDTO cache : caches.values()) { |
|
|
|
addInviteExpertTask(cache.getMeetingId(), true, properties.getInviteDelay(), cache.getInvitedRefused()); |
|
|
|
addInviteTask(cache.getMeetingId(), true, properties.getInviteDelay(), cache.getInvitedRefused()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
@@ -155,8 +155,8 @@ public class ExpertInviteTask { |
|
|
|
if (ArrayUtil.isNotEmpty(invitedRefused)) { |
|
|
|
tmpInvitedRefused = invitedRefused[0]; |
|
|
|
} |
|
|
|
if (!INVITE_MAP.containsKey(meetingId)) { |
|
|
|
addInviteExpertTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused); |
|
|
|
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); |
|
|
@@ -176,7 +176,7 @@ public class ExpertInviteTask { |
|
|
|
* @param invitedRefused 是否可以邀请被拒绝的专家 |
|
|
|
* @author WendyYang |
|
|
|
**/ |
|
|
|
public void addInviteExpertTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused) { |
|
|
|
public void addInviteTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused) { |
|
|
|
if (checked && !inviteCountCheck(meetingId)) { |
|
|
|
// 如果抽取数量满足直接返回 |
|
|
|
return; |
|
|
@@ -190,7 +190,7 @@ public class ExpertInviteTask { |
|
|
|
log.error("执行专家邀请任务异常:{}", meetingId, e); |
|
|
|
} |
|
|
|
}, startTime, Duration.ofMinutes(properties.getInviteFixedRate())); |
|
|
|
INVITE_MAP.putIfAbsent(meetingId, future); |
|
|
|
INVITE_TASK_MAP.putIfAbsent(meetingId, future); |
|
|
|
log.info("添加专家抽取后台任务:{}", meetingId); |
|
|
|
} |
|
|
|
|
|
|
@@ -201,13 +201,19 @@ public class ExpertInviteTask { |
|
|
|
* @param delayedMinutes 延迟时间 |
|
|
|
* @author WendyYang |
|
|
|
**/ |
|
|
|
public void addInviteExpertTaskByMeetingCreate(Long meetingId, int delayedMinutes) { |
|
|
|
public void addInviteTaskByMeetingCreate(Long meetingId, int delayedMinutes) { |
|
|
|
Assert.isTrue(properties.getEnable(), "随机邀请已关闭"); |
|
|
|
addInviteExpertTask(meetingId, false, delayedMinutes, false); |
|
|
|
addInviteTask(meetingId, false, delayedMinutes, false); |
|
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, false); |
|
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
|
} |
|
|
|
|
|
|
|
/** |
|
|
|
* 抽取过程 |
|
|
|
* |
|
|
|
* @param meetingId 会议ID |
|
|
|
* @param invitedRefused 是否可以邀请已拒绝的专家 |
|
|
|
*/ |
|
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
|
public void invite(Long meetingId, Boolean invitedRefused) { |
|
|
|
log.info("开始进行专家后台抽取:{}", meetingId); |
|
|
@@ -269,9 +275,9 @@ public class ExpertInviteTask { |
|
|
|
log.info("终止专家抽取:{}", meetingId); |
|
|
|
meetingService.stopRandomInvite(meetingId); |
|
|
|
cachePlusOps.hDel(getCacheKey(meetingId)); |
|
|
|
ScheduledFuture<?> future = INVITE_MAP.get(meetingId); |
|
|
|
ScheduledFuture<?> future = INVITE_TASK_MAP.get(meetingId); |
|
|
|
if (future != null) { |
|
|
|
INVITE_MAP.remove(meetingId); |
|
|
|
INVITE_TASK_MAP.remove(meetingId); |
|
|
|
if (!future.isCancelled()) { |
|
|
|
future.cancel(true); |
|
|
|
} |
|
|
|