diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingServiceImpl.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingServiceImpl.java index 3f11b37..116e429 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingServiceImpl.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/service/impl/MeetingServiceImpl.java @@ -1,5 +1,7 @@ package com.ningdatech.pmapi.meeting.service.impl; +import com.baomidou.mybatisplus.core.conditions.update.LambdaUpdateWrapper; +import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; import com.ningdatech.basic.util.CollUtils; import com.ningdatech.pmapi.common.model.entity.CountGroupByDTO; @@ -25,10 +27,10 @@ public class MeetingServiceImpl extends ServiceImpl impl @Override public void stopRandomInvite(Long meetingId) { - Meeting meeting = new Meeting(); - meeting.setId(meetingId); - meeting.setInviteStatus(Boolean.TRUE); - baseMapper.updateById(meeting); + LambdaUpdateWrapper update = Wrappers.lambdaUpdate(Meeting.class) + .eq(Meeting::getId, meetingId) + .set(Meeting::getInviteStatus, Boolean.TRUE); + update(update); } @Override diff --git a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertRandomInviteTask.java b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertRandomInviteTask.java index 3d04d7a..dde344d 100644 --- a/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertRandomInviteTask.java +++ b/pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertRandomInviteTask.java @@ -228,9 +228,9 @@ public class ExpertRandomInviteTask { public void invite(Long meetingId, Boolean reInvite, LocalDateTime tsTime) { log.info("开始进行专家后台抽取:{}", meetingId); Meeting meeting = meetingService.getById(meetingId); - if (meeting.getStartTime().isBefore(LocalDateTime.now())) { + if (meeting.getInviteStatus() || meeting.getStartTime().isBefore(LocalDateTime.now())) { log.info("会议已开始停止抽取:{}", meeting); - cancelByMeetingId(meetingId); + killTaskAndDelCacheMeetingId(meetingId); return; } // 随机邀请规则 @@ -275,9 +275,13 @@ public class ExpertRandomInviteTask { }); if (notIgnoreCnt.get() == 0 || notIgnoreCnt.get() == notSupportCnt.get()) { log.info("停止会议随机邀请:{} 未完成抽取规则数量 {} 无可抽取专家规则数量 {}", meetingId, notIgnoreCnt, notSupportCnt); - currProxy().cancelByMeetingId(meetingId); - meetingCallOrMsgHelper.sendInviteStopMsg(meeting.getCreateBy(), meetingId, meeting.getName()); + meetingService.stopRandomInvite(meetingId); + if (notIgnoreCnt.get() == notSupportCnt.get() && notIgnoreCnt.get() > 0) { + // 当未完成抽取且无专家可抽取时 + meetingCallOrMsgHelper.sendInviteStopMsg(meeting.getCreateBy(), meetingId, meeting.getName()); + } } + // 所有抽取规则抽取人数满足 自动召开会议 if (notIgnoreCnt.get() == 0 && notSupportCnt.get() == 0) { MeetingManage meetingManage = SpringUtils.getBean(MeetingManage.class); ConfirmedRosterReq req = new ConfirmedRosterReq(); @@ -287,10 +291,7 @@ public class ExpertRandomInviteTask { } } - @Transactional(rollbackFor = Exception.class) - public void cancelByMeetingId(Long meetingId) { - log.info("终止专家抽取:{}", meetingId); - meetingService.stopRandomInvite(meetingId); + private void killTaskAndDelCacheMeetingId(Long meetingId) { cachePlusOps.hDel(getCacheKey(meetingId)); ScheduledFuture future = INVITE_TASK_MAP.get(meetingId); if (future != null) { @@ -301,6 +302,13 @@ public class ExpertRandomInviteTask { } } + @Transactional(rollbackFor = Exception.class) + public void cancelByMeetingIdAndKillTask(Long meetingId) { + log.info("终止专家抽取:{}", meetingId); + meetingService.stopRandomInvite(meetingId); + killTaskAndDelCacheMeetingId(meetingId); + } + //================================================================================================================== private Map countByAttendStatus(Map expertMap) {