Browse Source

短信电话回填结果修改

dev
WendyYang 3 weeks ago
parent
commit
5a3fa744ba
1 changed files with 23 additions and 16 deletions
  1. +23
    -16
      hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java

+ 23
- 16
hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java View File

@@ -23,7 +23,6 @@ import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
import org.springframework.stereotype.Component;

import java.time.Instant;
import java.time.LocalDateTime;
import java.util.*;
import java.util.concurrent.ThreadPoolExecutor;
@@ -104,9 +103,14 @@ public class MsgCallReplyRewriteTask {
}
}

/**
* 获取短信回复结果
*
* @param records 短信记录
*/
private void rewriteSmsReply(List<MsgCallRecord> records) {
CollUtils.group(records, MsgCallRecord::getSubmitKey)
.forEach((submitKey, recordsBySubmitKey) -> {
.forEach((submitKey, currRecords) -> {
Runnable function = () -> {
try {
SmsReplyDTO retReply = msgCallHelper.smsReply(submitKey);
@@ -114,37 +118,42 @@ public class MsgCallReplyRewriteTask {
List<String> errorPhones = StrUtil.split(errorPhoneStr, ",");
List<SmsReply> replies = retReply.getResult();
Map<String, SmsReply> currReplyMap = new HashMap<>();
if (replies != null && !replies.isEmpty()) {
if (CollUtil.isNotEmpty(replies)) {
replies.sort(Comparator.comparing(SmsReply::getReplyReplytime));
replies.forEach(w -> currReplyMap.putIfAbsent(w.getReplyMobile(), w));
}
List<MsgCallRecord> updates = new ArrayList<>();
for (MsgCallRecord w : recordsBySubmitKey) {
for (MsgCallRecord w : currRecords) {
if (errorPhones.contains(w.getReceivePhone())) {
w.setReplyStatus(ReplyStatus.FAILED);
w.setReplyOn(LocalDateTime.now());
} else if (currReplyMap.containsKey(w.getReceivePhone())) {
SmsReply reply = currReplyMap.get(w.getReceivePhone());
w.setReplyOn(LocalDateTime.from(Instant.ofEpochMilli(reply.getReplyReplytime())));
w.setReplyOn(LocalDateTimeUtil.of(reply.getReplyReplytime()));
w.setReplyContent(reply.getReplyContent());
w.setReplyStatus(ReplyStatus.SUCCESS);
} else {
continue;
}
if (w.getReplyOn() != null) {
updates.add(w);
}
updates.add(w);
}
msgCallRecordService.updateBatchById(updates);
} catch (Exception e) {
log.error("回复结果回填失败:{}", submitKey, e);
log.error("短信回复结果回填失败:{}", submitKey, e);
}
};
EXECUTOR.execute(function);
});
}

/**
* 获取电话回复结果
*
* @param records 电话记录
**/
private void rewriteCallReply(List<MsgCallRecord> records) {
CollUtils.group(records, MsgCallRecord::getSubmitKey)
.forEach((submitKey, recordsBySubmitKey) -> {
.forEach((submitKey, currRecords) -> {
Runnable function = () -> {
try {
List<ReplyCallDTO> retReplies = msgCallHelper.callReply(submitKey);
@@ -152,16 +161,12 @@ public class MsgCallReplyRewriteTask {
ReplyCallDTO::getRemoteNumber,
Comparator.comparing(ReplyCallDTO::getSendDate));
List<MsgCallRecord> updates = new ArrayList<>();
for (MsgCallRecord w : recordsBySubmitKey) {
for (MsgCallRecord w : currRecords) {
ReplyCallDTO reply = replyMap.get(w.getReceivePhone());
if (reply == null) {
continue;
}
switch (CallDialStatus.getNoNull(reply.getDialStatus())) {
case DIALING:
case IN_CALL:
case NOT_DIALED:
break;
case CALL_ENDED_CONNECTED:
w.setReplyStatus(ReplyStatus.SUCCESS);
w.setReplyContent(reply.getDtmf());
@@ -174,6 +179,8 @@ public class MsgCallReplyRewriteTask {
w.setReplyContent(reply.getDtmf());
w.setErrorRemark(reply.getRemark());
break;
default:
break;
}
if (!ReplyStatus.WAITING.equals(w.getReplyStatus())) {
updates.add(w);
@@ -181,7 +188,7 @@ public class MsgCallReplyRewriteTask {
}
msgCallRecordService.updateBatchById(updates);
} catch (Exception e) {
log.error("回复结果回填失败:{}", submitKey, e);
log.error("电话回复结果回填失败:{}", submitKey, e);
}
};
EXECUTOR.execute(function);


Loading…
Cancel
Save