|
@@ -1,7 +1,6 @@ |
|
|
package com.ningdatech.pmapi.meeting.task; |
|
|
package com.ningdatech.pmapi.meeting.task; |
|
|
|
|
|
|
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import cn.hutool.core.util.ObjectUtil; |
|
|
import com.alibaba.fastjson.JSON; |
|
|
|
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.alibaba.fastjson.JSONObject; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
|
import com.baomidou.mybatisplus.core.toolkit.Wrappers; |
|
@@ -14,6 +13,7 @@ import com.ningdatech.pmapi.meeting.entity.domain.ExpertInviteRule; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.Meeting; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; |
|
|
import com.ningdatech.pmapi.meeting.entity.domain.MeetingExpert; |
|
|
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; |
|
|
import com.ningdatech.pmapi.meeting.entity.dto.RandomInviteRuleDTO; |
|
|
|
|
|
import com.ningdatech.pmapi.meeting.entity.dto.YxtCallBackDTO; |
|
|
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; |
|
|
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertAttendStatusEnum; |
|
|
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; |
|
|
import com.ningdatech.pmapi.meeting.entity.enumeration.ExpertInviteTypeEnum; |
|
|
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; |
|
|
import com.ningdatech.pmapi.meeting.helper.YxtCallOrSmsHelper; |
|
@@ -28,7 +28,6 @@ import com.ningdatech.yxt.model.cmd.SendSmsCmd.SendSmsContext; |
|
|
import com.ningdatech.yxt.service.ISysMsgRecordDetailService; |
|
|
import com.ningdatech.yxt.service.ISysMsgRecordDetailService; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.AllArgsConstructor; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import lombok.extern.slf4j.Slf4j; |
|
|
import org.apache.commons.lang3.StringUtils; |
|
|
|
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; |
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
@@ -69,6 +68,8 @@ public class ExpertCallResultRewriteTask { |
|
|
private final IExpertUserFullInfoService userFullInfoService; |
|
|
private final IExpertUserFullInfoService userFullInfoService; |
|
|
private final static int MINUTES_CALL_RESULT_FEEDBACK = 15; |
|
|
private final static int MINUTES_CALL_RESULT_FEEDBACK = 15; |
|
|
|
|
|
|
|
|
|
|
|
private static final String AGREE_KEY = "1"; |
|
|
|
|
|
|
|
|
@PostConstruct |
|
|
@PostConstruct |
|
|
public void initTask() { |
|
|
public void initTask() { |
|
|
if (!randomInviteProperties.getEnable()) { |
|
|
if (!randomInviteProperties.getEnable()) { |
|
@@ -77,7 +78,8 @@ public class ExpertCallResultRewriteTask { |
|
|
} |
|
|
} |
|
|
Instant startTime = Instant.now().plus(randomInviteProperties.getResultRewriteFixedRate(), ChronoUnit.MINUTES); |
|
|
Instant startTime = Instant.now().plus(randomInviteProperties.getResultRewriteFixedRate(), ChronoUnit.MINUTES); |
|
|
// 处理电话结果回填 |
|
|
// 处理电话结果回填 |
|
|
scheduler.scheduleAtFixedRate(this::rewritePhoneCallResult, startTime, Duration.ofMinutes(randomInviteProperties.getResultRewriteFixedRate())); |
|
|
|
|
|
|
|
|
Duration fixedRate = Duration.ofMinutes(randomInviteProperties.getResultRewriteFixedRate()); |
|
|
|
|
|
scheduler.scheduleAtFixedRate(this::rewritePhoneCallResult, startTime, fixedRate); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
@@ -101,7 +103,7 @@ public class ExpertCallResultRewriteTask { |
|
|
if (!randomRuleIds.isEmpty()) { |
|
|
if (!randomRuleIds.isEmpty()) { |
|
|
List<ExpertInviteRule> inviteRules = inviteRuleService.listByIds(randomRuleIds); |
|
|
List<ExpertInviteRule> inviteRules = inviteRuleService.listByIds(randomRuleIds); |
|
|
inviteRules.forEach(w -> { |
|
|
inviteRules.forEach(w -> { |
|
|
RandomInviteRuleDTO rule = JSON.parseObject(w.getInviteRule(), RandomInviteRuleDTO.class); |
|
|
|
|
|
|
|
|
RandomInviteRuleDTO rule = JSONObject.parseObject(w.getInviteRule(), RandomInviteRuleDTO.class); |
|
|
callbackMinutes.put(w.getId(), rule.getWaitForCallbackMinutes()); |
|
|
callbackMinutes.put(w.getId(), rule.getWaitForCallbackMinutes()); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
@@ -172,44 +174,37 @@ public class ExpertCallResultRewriteTask { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private static Optional<Integer> getStatusByMsgRecordDetail(SysMsgRecordDetail msgRecordDetail, int minutes, LocalDateTime createOn) { |
|
|
|
|
|
LocalDateTime time = LocalDateTime.now().minusMinutes(minutes); |
|
|
|
|
|
String callBackJson = msgRecordDetail.getCallBackJson(); |
|
|
|
|
|
if (StrUtils.isBlank(callBackJson) && time.isBefore(createOn)) { |
|
|
|
|
|
|
|
|
private static Optional<Integer> getStatusByMsgRecordDetail(SysMsgRecordDetail mrd, int minutes, LocalDateTime createOn) { |
|
|
|
|
|
LocalDateTime limitTime = LocalDateTime.now().minusMinutes(minutes); |
|
|
|
|
|
String callBackJson = mrd.getCallBackJson(); |
|
|
|
|
|
boolean waiting = limitTime.isBefore(createOn); |
|
|
|
|
|
boolean hasCallBack = StrUtils.isBlank(callBackJson); |
|
|
|
|
|
if (!hasCallBack && waiting) { |
|
|
return Optional.empty(); |
|
|
return Optional.empty(); |
|
|
} |
|
|
} |
|
|
ExpertAttendStatusEnum status; |
|
|
ExpertAttendStatusEnum status; |
|
|
if (StrUtils.isNotBlank(callBackJson)) { |
|
|
|
|
|
|
|
|
if (hasCallBack) { |
|
|
try { |
|
|
try { |
|
|
JSONObject callbackObject = JSON.parseObject(callBackJson); |
|
|
|
|
|
Date dialBeginTime = callbackObject.getDate("dialBeginTime"); |
|
|
|
|
|
|
|
|
YxtCallBackDTO callback = JSONObject.parseObject(callBackJson, YxtCallBackDTO.class); |
|
|
|
|
|
LocalDateTime dialBeginTime = callback.getDialBeginTime(); |
|
|
if (dialBeginTime == null) { |
|
|
if (dialBeginTime == null) { |
|
|
return Optional.empty(); |
|
|
return Optional.empty(); |
|
|
} |
|
|
} |
|
|
Integer resultCode = callbackObject.getInteger("resultCode"); |
|
|
|
|
|
|
|
|
Integer resultCode = callback.getResultCode(); |
|
|
if (resultCode != null && resultCode == 0) { |
|
|
if (resultCode != null && resultCode == 0) { |
|
|
String pressKeyStr = callbackObject.getString("pressKey"); |
|
|
|
|
|
if (Objects.nonNull(pressKeyStr)) { |
|
|
|
|
|
pressKeyStr = pressKeyStr.replaceAll("\\*", "").trim(); |
|
|
|
|
|
} |
|
|
|
|
|
Integer pressKey = null; |
|
|
|
|
|
if (StringUtils.isNotBlank(pressKeyStr)) { |
|
|
|
|
|
pressKey = Integer.parseInt(pressKeyStr); |
|
|
|
|
|
|
|
|
String pressKey = callback.getPressKey(); |
|
|
|
|
|
if (pressKey != null) { |
|
|
|
|
|
pressKey = pressKey.replaceAll("\\*", "").trim(); |
|
|
} |
|
|
} |
|
|
if (pressKey == null) { |
|
|
|
|
|
if (time.isBefore(createOn)) { |
|
|
|
|
|
return Optional.empty(); |
|
|
|
|
|
} |
|
|
|
|
|
status = REFUSED; |
|
|
|
|
|
} else { |
|
|
|
|
|
if (pressKey == 1) { |
|
|
|
|
|
status = AGREED; |
|
|
|
|
|
} else { |
|
|
|
|
|
status = REFUSED; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (StrUtils.isBlank(pressKey) && waiting) { |
|
|
|
|
|
return Optional.empty(); |
|
|
} |
|
|
} |
|
|
|
|
|
status = AGREE_KEY.equals(pressKey) ? AGREED : REFUSED; |
|
|
} else { |
|
|
} else { |
|
|
status = UNANSWERED; |
|
|
|
|
|
|
|
|
if (waiting) { |
|
|
|
|
|
return Optional.empty(); |
|
|
|
|
|
} |
|
|
|
|
|
status = REFUSED; |
|
|
} |
|
|
} |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("获取电话回调结果异常", e); |
|
|
log.error("获取电话回调结果异常", e); |
|
|