Ver código fonte

优化电话结果回填任务

tags/24080901
WendyYang 1 ano atrás
pai
commit
5ee20feac1
2 arquivos alterados com 69 adições e 31 exclusões
  1. +43
    -0
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/YxtCallBackDTO.java
  2. +26
    -31
      pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertCallResultRewriteTask.java

+ 43
- 0
pmapi/src/main/java/com/ningdatech/pmapi/meeting/entity/dto/YxtCallBackDTO.java Ver arquivo

@@ -0,0 +1,43 @@
/**
* Copyright 2023 json.cn
*/
package com.ningdatech.pmapi.meeting.entity.dto;

import lombok.Data;

import java.time.LocalDateTime;

/**
* <p>
* 电话结果回调内容
* </p>
*
* @author WendyYang
* @since 2023/4/17
**/
@Data
public class YxtCallBackDTO {

private Integer duration;

private String pressKey;

private String receiveNumber;

private LocalDateTime dialEndTime;

private Integer resultCode;

private Integer retryNumber;

private String failCode;

private LocalDateTime dialBeginTime;

private String sendNumber;

private String failReason;

private String transactionId;

}

+ 26
- 31
pmapi/src/main/java/com/ningdatech/pmapi/meeting/task/ExpertCallResultRewriteTask.java Ver arquivo

@@ -1,7 +1,6 @@
package com.ningdatech.pmapi.meeting.task;

import cn.hutool.core.util.ObjectUtil;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
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.MeetingExpert;
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.ExpertInviteTypeEnum;
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 lombok.AllArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.StringUtils;
import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler;
import org.springframework.stereotype.Component;

@@ -69,6 +68,8 @@ public class ExpertCallResultRewriteTask {
private final IExpertUserFullInfoService userFullInfoService;
private final static int MINUTES_CALL_RESULT_FEEDBACK = 15;

private static final String AGREE_KEY = "1";

@PostConstruct
public void initTask() {
if (!randomInviteProperties.getEnable()) {
@@ -77,7 +78,8 @@ public class ExpertCallResultRewriteTask {
}
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()) {
List<ExpertInviteRule> inviteRules = inviteRuleService.listByIds(randomRuleIds);
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());
});
}
@@ -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();
}
ExpertAttendStatusEnum status;
if (StrUtils.isNotBlank(callBackJson)) {
if (hasCallBack) {
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) {
return Optional.empty();
}
Integer resultCode = callbackObject.getInteger("resultCode");
Integer resultCode = callback.getResultCode();
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 {
status = UNANSWERED;
if (waiting) {
return Optional.empty();
}
status = REFUSED;
}
} catch (Exception e) {
log.error("获取电话回调结果异常", e);


Carregando…
Cancelar
Salvar