@@ -41,12 +41,10 @@ import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.MeetingStatusEnum; | |||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||
import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; | |||
import com.ningdatech.pmapi.meeting.service.IMeetingService; | |||
import com.ningdatech.pmapi.meeting.task.ExpertInviteTask; | |||
import com.ningdatech.pmapi.meeting.task.ExpertRandomInviteTask; | |||
import com.ningdatech.pmapi.sms.utils.DateUtil; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import com.ningdatech.pmapi.user.util.LoginUserUtil; | |||
import lombok.AllArgsConstructor; | |||
import org.springframework.aop.framework.AopContext; | |||
@@ -71,7 +69,7 @@ import java.util.stream.Collectors; | |||
@AllArgsConstructor | |||
public class LeaveManage { | |||
private final ExpertInviteTask inviteTask; | |||
private final ExpertRandomInviteTask inviteTask; | |||
private final IMeetingService meetingService; | |||
private final IMeetingExpertService meetingExpertService; | |||
private final IExpertLeaveService leaveService; | |||
@@ -79,8 +77,6 @@ public class LeaveManage { | |||
private final IExpertMetaApplyService metaApplyService; | |||
private final FileService fileService; | |||
private final IExpertUserFullInfoService userFullInfoService; | |||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||
private final IUserInfoService userInfoService; | |||
private static final int HOURS_BEFORE_MEETING = 2; | |||
@@ -1,6 +1,5 @@ | |||
package com.ningdatech.pmapi.meeting.helper; | |||
import cn.hutool.core.date.DatePattern; | |||
import cn.hutool.core.util.StrUtil; | |||
import com.alibaba.fastjson.JSON; | |||
import com.baomidou.mybatisplus.core.toolkit.Wrappers; | |||
@@ -13,6 +12,8 @@ import com.ningdatech.pmapi.organization.model.entity.DingEmployeeInfo; | |||
import com.ningdatech.pmapi.organization.model.entity.DingOrganization; | |||
import com.ningdatech.pmapi.organization.service.IDingEmployeeInfoService; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
import com.ningdatech.pmapi.sms.constant.VoiceSmsTemplateConst; | |||
import com.ningdatech.pmapi.sms.utils.DateUtil; | |||
import com.ningdatech.pmapi.staging.enums.MsgTypeEnum; | |||
import com.ningdatech.pmapi.staging.service.INdWorkNoticeStagingService; | |||
import com.ningdatech.pmapi.sys.model.entity.Notify; | |||
@@ -21,6 +22,7 @@ import com.ningdatech.pmapi.todocenter.bean.entity.WorkNoticeInfo; | |||
import com.ningdatech.pmapi.user.entity.UserInfo; | |||
import com.ningdatech.pmapi.user.service.IUserInfoService; | |||
import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext; | |||
import com.ningdatech.yxt.model.cmd.SubmitTaskCallCmd.SubmitTaskCallContext; | |||
import lombok.AllArgsConstructor; | |||
import org.springframework.stereotype.Component; | |||
import org.springframework.transaction.annotation.Transactional; | |||
@@ -42,7 +44,7 @@ import java.util.stream.Collectors; | |||
**/ | |||
@Component | |||
@AllArgsConstructor | |||
public class MeetingMsgHelper { | |||
public class MeetingCallOrMsgHelper { | |||
private final IUserInfoService userInfoService; | |||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||
@@ -52,7 +54,7 @@ public class MeetingMsgHelper { | |||
private final INotifyService notifyService; | |||
private static String officialTime(LocalDateTime time) { | |||
return time.format(DatePattern.NORM_DATETIME_MINUTE_FORMATTER); | |||
return time.format(DateUtil.DTF_YMD_HM); | |||
} | |||
private Notify getNotify(Long userId, String msg, MsgTypeEnum type, Map<String, Object> extraPara) { | |||
@@ -164,4 +166,25 @@ public class MeetingMsgHelper { | |||
yxtCallOrSmsHelper.sendSms(contexts); | |||
} | |||
/** | |||
* 提交专家通知音信通任务 | |||
* | |||
* @param meeting 会议信息 | |||
* @param experts 待通知专家 | |||
* @author WendyYang | |||
**/ | |||
public void callExpertByMeeting(Meeting meeting, List<MeetingExpert> experts) { | |||
String voiceContent = String.format(VoiceSmsTemplateConst.OFFLINE_TEMPLATE, | |||
meeting.getHoldOrg(), meeting.getName(), officialTime(meeting.getStartTime()), | |||
meeting.getMeetingAddress()); | |||
List<SubmitTaskCallContext> callContexts = CollUtils.convert(experts, w -> { | |||
SubmitTaskCallContext context = new SubmitTaskCallContext(); | |||
context.setContent(voiceContent); | |||
context.setReceiveNumber(w.getMobile()); | |||
return context; | |||
}); | |||
String submitKey = yxtCallOrSmsHelper.submitCallTask(callContexts); | |||
experts.forEach(w -> w.setSubmitKey(submitKey)); | |||
} | |||
} |
@@ -1,10 +1,5 @@ | |||
package com.ningdatech.pmapi.meeting.helper; | |||
import com.ningdatech.basic.util.CollUtils; | |||
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; | |||
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | |||
import com.ningdatech.pmapi.sms.constant.VoiceSmsTemplateConst; | |||
import com.ningdatech.pmapi.sms.utils.DateUtil; | |||
import com.ningdatech.yxt.client.YxtClient; | |||
import com.ningdatech.yxt.constants.YxtSmsSignEnum; | |||
import com.ningdatech.yxt.model.cmd.SendSmsCmd; | |||
@@ -33,18 +28,9 @@ public class YxtCallOrSmsHelper { | |||
private final YxtClient yxtClient; | |||
public void callByMeetingExperts(Meeting meeting, List<MeetingExpert> experts) { | |||
String callContent = String.format(VoiceSmsTemplateConst.OFFLINE_TEMPLATE, | |||
meeting.getHoldOrg(), meeting.getName(), | |||
meeting.getStartTime().format(DateUtil.DTF_YMD_HM), meeting.getMeetingAddress()); | |||
List<SubmitTaskCallContext> callContexts = CollUtils.convert(experts, w -> { | |||
SubmitTaskCallContext context = new SubmitTaskCallContext(); | |||
context.setContent(callContent); | |||
context.setReceiveNumber(w.getMobile()); | |||
return context; | |||
}); | |||
public String submitCallTask(List<SubmitTaskCallContext> callContexts) { | |||
SubmitTaskCallResponse callResponse = yxtClient.submitTaskCall(of(callContexts)); | |||
experts.forEach(w -> w.setSubmitKey(callResponse.getSubmitKey())); | |||
return callResponse.getSubmitKey(); | |||
} | |||
public void sendSms(List<SendSmsContext> smsList) { | |||
@@ -19,7 +19,7 @@ import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; | |||
import com.ningdatech.pmapi.meeting.entity.dto.*; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||
import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | |||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper; | |||
import com.ningdatech.pmapi.meeting.service.IExpertInviteRuleService; | |||
import com.ningdatech.pmapi.meeting.service.IMeetingExpertService; | |||
import com.ningdatech.pmapi.meeting.service.IMeetingService; | |||
@@ -65,7 +65,7 @@ public class ExpertInviteManage { | |||
private final IExpertUserFullInfoService expertUserFullInfoService; | |||
private final IMeetingService meetingService; | |||
private final IExpertAvoidCompanyService expertAvoidCompanyService; | |||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||
private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; | |||
@Value("#{randomInviteProperties.recentMeetingCount}") | |||
private Integer recentMeetingCount; | |||
@@ -547,7 +547,7 @@ public class ExpertInviteManage { | |||
expertInserts.add(expert); | |||
}); | |||
} | |||
yxtCallOrSmsHelper.callByMeetingExperts(meeting, expertInserts); | |||
meetingCallOrMsgHelper.callExpertByMeeting(meeting, expertInserts); | |||
} | |||
meetingExpertService.saveBatch(expertInserts); | |||
} | |||
@@ -36,10 +36,10 @@ import com.ningdatech.pmapi.meeting.entity.req.*; | |||
import com.ningdatech.pmapi.meeting.entity.vo.*; | |||
import com.ningdatech.pmapi.meeting.helper.ExpertInviteHelper; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingManageHelper; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingMsgHelper; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper; | |||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||
import com.ningdatech.pmapi.meeting.service.*; | |||
import com.ningdatech.pmapi.meeting.task.ExpertInviteTask; | |||
import com.ningdatech.pmapi.meeting.task.ExpertRandomInviteTask; | |||
import com.ningdatech.pmapi.meta.helper.DictionaryCache; | |||
import com.ningdatech.pmapi.meta.helper.TagCache; | |||
import com.ningdatech.pmapi.organization.service.IDingOrganizationService; | |||
@@ -85,7 +85,7 @@ public class MeetingManage { | |||
private final DictionaryCache dictionaryCache; | |||
private final IMeetingExpertService meetingExpertService; | |||
private final ExpertInviteManage expertInviteManage; | |||
private final ExpertInviteTask expertInviteTask; | |||
private final ExpertRandomInviteTask expertRandomInviteTask; | |||
private final MeetingManageHelper meetingManageHelper; | |||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||
private final DistributedLock distributedLock; | |||
@@ -97,7 +97,7 @@ public class MeetingManage { | |||
private final IDingOrganizationService dingOrganizationService; | |||
private final IExpertReviewService expertReviewService; | |||
private final ExpertInviteHelper expertInviteHelper; | |||
private final MeetingMsgHelper meetingMsgHelper; | |||
private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; | |||
private static final String INVITED_RULE_CREATE = "INVITED_RULE_CREATE:"; | |||
private static final String MEETING_CREATE_KEY = "MEETING_CREATE:"; | |||
@@ -183,7 +183,7 @@ public class MeetingManage { | |||
if (!invitedContinue) { | |||
throw BizException.wrap("抽取人员数量已满足抽取规则"); | |||
} | |||
expertInviteTask.notifyInviteTask(meetingId); | |||
expertRandomInviteTask.notifyInviteTask(meetingId); | |||
} finally { | |||
distributedLock.releaseLock(key); | |||
} | |||
@@ -200,7 +200,7 @@ public class MeetingManage { | |||
if (!MeetingStatusEnum.NORMAL.eq(meeting.getStatus())) { | |||
throw BizException.wrap("转换失败,请刷新后重试"); | |||
} | |||
expertInviteTask.cancelByMeetingId(meetingId); | |||
expertRandomInviteTask.cancelByMeetingId(meetingId); | |||
LambdaUpdateWrapper<Meeting> meetingUpdate = Wrappers.lambdaUpdate(Meeting.class) | |||
.set(Meeting::getInviteType, APPOINT.getCode()) | |||
.eq(Meeting::getId, meetingId); | |||
@@ -241,7 +241,7 @@ public class MeetingManage { | |||
// 随机抽取的话则需进行抽取数量校验 | |||
LocalDateTime now = LocalDateTime.now(); | |||
expertInviteManage.expertInviteByMeetingCreate(meeting, randomRules, avoidInfo); | |||
expertInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), now); | |||
expertRandomInviteTask.addInviteTaskByMeetingCreate(meeting.getId(), now); | |||
LambdaUpdateWrapper<Meeting> mUpdate = Wrappers.lambdaUpdate(Meeting.class) | |||
.set(Meeting::getInviteStatus, false) | |||
.eq(Meeting::getId, meeting.getId()); | |||
@@ -638,7 +638,7 @@ public class MeetingManage { | |||
} | |||
public void stopRandomInvite(Long meetingId) { | |||
expertInviteTask.cancelByMeetingId(meetingId); | |||
expertRandomInviteTask.cancelByMeetingId(meetingId); | |||
} | |||
@Transactional(rollbackFor = Exception.class) | |||
@@ -660,11 +660,11 @@ public class MeetingManage { | |||
.set(Meeting::getStatus, MeetingStatusEnum.CANCELED.getCode()) | |||
.eq(Meeting::getId, meetingId); | |||
meetingService.update(meetingUpdate); | |||
expertInviteTask.cancelByMeetingId(meetingId); | |||
expertRandomInviteTask.cancelByMeetingId(meetingId); | |||
// 发送通知给专家 | |||
List<MeetingExpert> experts = meetingExpertService.listAgreedExperts(meetingId); | |||
if (!experts.isEmpty()) { | |||
meetingMsgHelper.sendCancelMeetingMsg(experts, meeting); | |||
meetingCallOrMsgHelper.sendCancelMeetingMsg(experts, meeting); | |||
} | |||
} finally { | |||
distributedLock.releaseLock(key); | |||
@@ -824,7 +824,7 @@ public class MeetingManage { | |||
.in(MeetingExpert::getId, currConfirmedMeIds) | |||
.set(MeetingExpert::getConfirmedRoster, Boolean.TRUE); | |||
meetingExpertService.update(meUpdate); | |||
meetingMsgHelper.sendConfirmedRosterMsg(expertNoticing, meeting); | |||
meetingCallOrMsgHelper.sendConfirmedRosterMsg(expertNoticing, meeting); | |||
} finally { | |||
distributedLock.releaseLock(key); | |||
} | |||
@@ -16,8 +16,7 @@ import com.ningdatech.pmapi.meeting.entity.dto.ExpertChooseDTO; | |||
import com.ningdatech.pmapi.meeting.entity.dto.InviteCacheDTO; | |||
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; | |||
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingMsgHelper; | |||
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; | |||
import com.ningdatech.pmapi.meeting.helper.MeetingCallOrMsgHelper; | |||
import com.ningdatech.pmapi.meeting.manage.ExpertInviteManage; | |||
import com.ningdatech.pmapi.meeting.service.IExpertInviteAvoidRuleService; | |||
import com.ningdatech.pmapi.meeting.service.IExpertInviteRuleService; | |||
@@ -50,7 +49,7 @@ import java.util.concurrent.atomic.AtomicInteger; | |||
/** | |||
* <p> | |||
* ExpertInviteTask | |||
* 专家随机邀请任务 | |||
* </p> | |||
* | |||
* @author WendyYang | |||
@@ -59,7 +58,7 @@ import java.util.concurrent.atomic.AtomicInteger; | |||
@Slf4j | |||
@Component | |||
@AllArgsConstructor | |||
public class ExpertInviteTask { | |||
public class ExpertRandomInviteTask { | |||
private final RandomInviteProperties properties; | |||
private static final String MEETING_ID_INVITE_RANDOM = "MEETING_ID_INVITE_RANDOM"; | |||
@@ -74,16 +73,15 @@ public class ExpertInviteTask { | |||
private final IMeetingService meetingService; | |||
private final ExpertInviteManage expertInviteManage; | |||
private final IExpertInviteAvoidRuleService inviteAvoidRuleService; | |||
private final YxtCallOrSmsHelper yxtCallOrSmsHelper; | |||
private final MeetingMsgHelper meetingMsgHelper; | |||
private final MeetingCallOrMsgHelper meetingCallOrMsgHelper; | |||
/** | |||
* 用来存入线程执行句柄, 停止定时任务时使用 | |||
*/ | |||
private static final ConcurrentMap<Long, ScheduledFuture<?>> INVITE_TASK_MAP = new ConcurrentHashMap<>(); | |||
private ExpertInviteTask currProxy() { | |||
return (ExpertInviteTask) AopContext.currentProxy(); | |||
private ExpertRandomInviteTask currProxy() { | |||
return (ExpertRandomInviteTask) AopContext.currentProxy(); | |||
} | |||
private CacheHashKey getCacheKey(Long meetingId) { | |||
@@ -190,7 +188,7 @@ public class ExpertInviteTask { | |||
} | |||
Instant startTime = LocalDateTime.now().plusMinutes(delayTime).atZone(ZoneId.systemDefault()).toInstant(); | |||
ScheduledFuture<?> future = scheduler.scheduleAtFixedRate(() -> { | |||
ExpertInviteTask bean = SpringContextHolder.getBean(ExpertInviteTask.class); | |||
ExpertRandomInviteTask bean = SpringContextHolder.getBean(ExpertRandomInviteTask.class); | |||
try { | |||
bean.invite(meetingId, reInvite, tsTime); | |||
} catch (Exception e) { | |||
@@ -264,7 +262,7 @@ public class ExpertInviteTask { | |||
expert.setStatus(ExpertAttendStatusEnum.NOTICING.getCode()); | |||
return expert; | |||
}); | |||
yxtCallOrSmsHelper.callByMeetingExperts(meeting, expertMeetings); | |||
meetingCallOrMsgHelper.callExpertByMeeting(meeting, expertMeetings); | |||
log.info("会议:{} 后台抽取专家:{}名", meetingId, expertMeetings.size()); | |||
meetingExpertService.saveBatch(expertMeetings); | |||
} else { | |||
@@ -275,7 +273,7 @@ public class ExpertInviteTask { | |||
if (notIgnoreCnt.get() == 0 || notIgnoreCnt.get() == notSupportCnt.get()) { | |||
log.info("停止会议随机邀请:{} 未完成抽取规则数量 {} 无可抽取专家规则数量 {}", meetingId, notIgnoreCnt, notSupportCnt); | |||
currProxy().cancelByMeetingId(meetingId); | |||
meetingMsgHelper.sendInviteStopMsg(meeting.getCreateBy(), meetingId, meeting.getName()); | |||
meetingCallOrMsgHelper.sendInviteStopMsg(meeting.getCreateBy(), meetingId, meeting.getName()); | |||
} | |||
} | |||