|
@@ -112,7 +112,8 @@ public class ExpertInviteTask { |
|
|
Integer inviteDelay = properties.getInviteDelay(); |
|
|
Integer inviteDelay = properties.getInviteDelay(); |
|
|
for (InviteCacheDTO cache : caches.values()) { |
|
|
for (InviteCacheDTO cache : caches.values()) { |
|
|
Boolean invitedRefused = cache.getInvitedRefused(); |
|
|
Boolean invitedRefused = cache.getInvitedRefused(); |
|
|
boolean added = addInviteTask(cache.getMeetingId(), true, inviteDelay, invitedRefused); |
|
|
|
|
|
|
|
|
LocalDateTime tsTime = cache.getTaskStartTime(); |
|
|
|
|
|
boolean added = addInviteTask(cache.getMeetingId(), true, inviteDelay, invitedRefused, tsTime); |
|
|
if (!added) { |
|
|
if (!added) { |
|
|
cachePlusOps.hDel(getCacheKey(cache.getMeetingId())); |
|
|
cachePlusOps.hDel(getCacheKey(cache.getMeetingId())); |
|
|
} |
|
|
} |
|
@@ -162,13 +163,13 @@ public class ExpertInviteTask { |
|
|
tmpInvitedRefused = invitedRefused[0]; |
|
|
tmpInvitedRefused = invitedRefused[0]; |
|
|
} |
|
|
} |
|
|
if (!INVITE_TASK_MAP.containsKey(meetingId)) { |
|
|
if (!INVITE_TASK_MAP.containsKey(meetingId)) { |
|
|
if (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused)) { |
|
|
|
|
|
|
|
|
if (addInviteTask(meetingId, false, properties.getInviteDelay(), tmpInvitedRefused, LocalDateTime.now())) { |
|
|
log.info("重置会议的随机抽取状态:{}", meetingId); |
|
|
log.info("重置会议的随机抽取状态:{}", meetingId); |
|
|
LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class); |
|
|
LambdaUpdateWrapper<Meeting> update = Wrappers.lambdaUpdate(Meeting.class); |
|
|
update.set(Meeting::getInviteStatus, false); |
|
|
update.set(Meeting::getInviteStatus, false); |
|
|
update.eq(Meeting::getId, meetingId); |
|
|
update.eq(Meeting::getId, meetingId); |
|
|
meetingService.update(update); |
|
|
meetingService.update(update); |
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpInvitedRefused); |
|
|
|
|
|
|
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, tmpInvitedRefused, LocalDateTime.now()); |
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
@@ -184,7 +185,7 @@ public class ExpertInviteTask { |
|
|
* @return 是否添加任务成功 |
|
|
* @return 是否添加任务成功 |
|
|
* @author WendyYang |
|
|
* @author WendyYang |
|
|
**/ |
|
|
**/ |
|
|
public boolean addInviteTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused) { |
|
|
|
|
|
|
|
|
public boolean addInviteTask(Long meetingId, boolean checked, int delayedMinutes, boolean invitedRefused, LocalDateTime tsTime) { |
|
|
if (checked && !inviteCountCheck(meetingId)) { |
|
|
if (checked && !inviteCountCheck(meetingId)) { |
|
|
// 如果抽取数量满足直接返回 |
|
|
// 如果抽取数量满足直接返回 |
|
|
return Boolean.FALSE; |
|
|
return Boolean.FALSE; |
|
@@ -193,7 +194,7 @@ public class ExpertInviteTask { |
|
|
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> { |
|
|
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> { |
|
|
ExpertInviteTask bean = SpringContextHolder.getBean(ExpertInviteTask.class); |
|
|
ExpertInviteTask bean = SpringContextHolder.getBean(ExpertInviteTask.class); |
|
|
try { |
|
|
try { |
|
|
bean.invite(meetingId, invitedRefused); |
|
|
|
|
|
|
|
|
bean.invite(meetingId, invitedRefused, tsTime); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("执行专家邀请任务异常:{}", meetingId, e); |
|
|
log.error("执行专家邀请任务异常:{}", meetingId, e); |
|
|
} |
|
|
} |
|
@@ -208,12 +209,13 @@ public class ExpertInviteTask { |
|
|
* |
|
|
* |
|
|
* @param meetingId 会议ID |
|
|
* @param meetingId 会议ID |
|
|
* @param delayedMinutes 延迟时间 |
|
|
* @param delayedMinutes 延迟时间 |
|
|
|
|
|
* @param tsTime 开始时间 |
|
|
* @author WendyYang |
|
|
* @author WendyYang |
|
|
**/ |
|
|
**/ |
|
|
public void addInviteTaskByMeetingCreate(Long meetingId, int delayedMinutes) { |
|
|
|
|
|
|
|
|
public void addInviteTaskByMeetingCreate(Long meetingId, int delayedMinutes, LocalDateTime tsTime) { |
|
|
Assert.isTrue(properties.getEnable(), "随机邀请已关闭"); |
|
|
Assert.isTrue(properties.getEnable(), "随机邀请已关闭"); |
|
|
addInviteTask(meetingId, false, delayedMinutes, false); |
|
|
|
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, false); |
|
|
|
|
|
|
|
|
addInviteTask(meetingId, false, delayedMinutes, false, tsTime); |
|
|
|
|
|
InviteCacheDTO cacheVal = InviteCacheDTO.of(meetingId, false, tsTime); |
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
cachePlusOps.hSet(getCacheKey(meetingId), cacheVal); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
@@ -222,9 +224,10 @@ public class ExpertInviteTask { |
|
|
* |
|
|
* |
|
|
* @param meetingId 会议ID |
|
|
* @param meetingId 会议ID |
|
|
* @param invitedRefused 是否可以邀请已拒绝的专家 |
|
|
* @param invitedRefused 是否可以邀请已拒绝的专家 |
|
|
|
|
|
* @param tsTime 任务开启时间 |
|
|
*/ |
|
|
*/ |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
@Transactional(rollbackFor = Exception.class) |
|
|
public void invite(Long meetingId, Boolean invitedRefused) { |
|
|
|
|
|
|
|
|
public void invite(Long meetingId, Boolean invitedRefused, LocalDateTime tsTime) { |
|
|
log.info("开始进行专家后台抽取:{}", meetingId); |
|
|
log.info("开始进行专家后台抽取:{}", meetingId); |
|
|
Meeting meeting = meetingService.getById(meetingId); |
|
|
Meeting meeting = meetingService.getById(meetingId); |
|
|
if (meeting.getStartTime().isBefore(LocalDateTime.now())) { |
|
|
if (meeting.getStartTime().isBefore(LocalDateTime.now())) { |
|
@@ -239,6 +242,8 @@ public class ExpertInviteTask { |
|
|
// 还需要抽取的规则数量 |
|
|
// 还需要抽取的规则数量 |
|
|
AtomicInteger notIgnoreCnt = new AtomicInteger(ruleMap.size()); |
|
|
AtomicInteger notIgnoreCnt = new AtomicInteger(ruleMap.size()); |
|
|
AtomicInteger notSupportCnt = new AtomicInteger(0); |
|
|
AtomicInteger notSupportCnt = new AtomicInteger(0); |
|
|
|
|
|
LocalDateTime msTime = meeting.getStartTime(); |
|
|
|
|
|
LocalDateTime meTime = meeting.getStartTime(); |
|
|
ruleMap.forEach((ruleId, value) -> { |
|
|
ruleMap.forEach((ruleId, value) -> { |
|
|
List<MeetingExpert> tmpExperts = meetingExpertService.listExpertLastByMeetingId(meetingId); |
|
|
List<MeetingExpert> tmpExperts = meetingExpertService.listExpertLastByMeetingId(meetingId); |
|
|
Map<Long, MeetingExpert> expertMap = CollUtils.listToMap(tmpExperts, MeetingExpert::getExpertId); |
|
|
Map<Long, MeetingExpert> expertMap = CollUtils.listToMap(tmpExperts, MeetingExpert::getExpertId); |
|
@@ -254,7 +259,7 @@ public class ExpertInviteTask { |
|
|
} |
|
|
} |
|
|
int needInviteCnt = value.getCount() - wouldAttendCnt; |
|
|
int needInviteCnt = value.getCount() - wouldAttendCnt; |
|
|
ExpertChooseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value, |
|
|
ExpertChooseDTO expertChoose = expertInviteManage.expertReplaceByRandomRule(avoidRule, value, |
|
|
tmpExperts, needInviteCnt, meeting.getStartTime(), meeting.getEndTime(), invitedRefused); |
|
|
|
|
|
|
|
|
tmpExperts, needInviteCnt, msTime, meTime, tsTime, invitedRefused); |
|
|
|
|
|
|
|
|
if (expertChoose.getTotal() > 0) { |
|
|
if (expertChoose.getTotal() > 0) { |
|
|
List<MeetingExpert> expertMeetings = CollUtils.convert(expertChoose.getExperts(), w -> { |
|
|
List<MeetingExpert> expertMeetings = CollUtils.convert(expertChoose.getExperts(), w -> { |
|
|