|
@@ -23,7 +23,6 @@ import org.springframework.scheduling.annotation.Scheduled; |
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor; |
|
|
import org.springframework.stereotype.Component; |
|
|
import org.springframework.stereotype.Component; |
|
|
|
|
|
|
|
|
import java.time.Instant; |
|
|
|
|
|
import java.time.LocalDateTime; |
|
|
import java.time.LocalDateTime; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
|
import java.util.concurrent.ThreadPoolExecutor; |
|
@@ -104,9 +103,14 @@ public class MsgCallReplyRewriteTask { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取短信回复结果 |
|
|
|
|
|
* |
|
|
|
|
|
* @param records 短信记录 |
|
|
|
|
|
*/ |
|
|
private void rewriteSmsReply(List<MsgCallRecord> records) { |
|
|
private void rewriteSmsReply(List<MsgCallRecord> records) { |
|
|
CollUtils.group(records, MsgCallRecord::getSubmitKey) |
|
|
CollUtils.group(records, MsgCallRecord::getSubmitKey) |
|
|
.forEach((submitKey, recordsBySubmitKey) -> { |
|
|
|
|
|
|
|
|
.forEach((submitKey, currRecords) -> { |
|
|
Runnable function = () -> { |
|
|
Runnable function = () -> { |
|
|
try { |
|
|
try { |
|
|
SmsReplyDTO retReply = msgCallHelper.smsReply(submitKey); |
|
|
SmsReplyDTO retReply = msgCallHelper.smsReply(submitKey); |
|
@@ -114,37 +118,42 @@ public class MsgCallReplyRewriteTask { |
|
|
List<String> errorPhones = StrUtil.split(errorPhoneStr, ","); |
|
|
List<String> errorPhones = StrUtil.split(errorPhoneStr, ","); |
|
|
List<SmsReply> replies = retReply.getResult(); |
|
|
List<SmsReply> replies = retReply.getResult(); |
|
|
Map<String, SmsReply> currReplyMap = new HashMap<>(); |
|
|
Map<String, SmsReply> currReplyMap = new HashMap<>(); |
|
|
if (replies != null && !replies.isEmpty()) { |
|
|
|
|
|
|
|
|
if (CollUtil.isNotEmpty(replies)) { |
|
|
replies.sort(Comparator.comparing(SmsReply::getReplyReplytime)); |
|
|
replies.sort(Comparator.comparing(SmsReply::getReplyReplytime)); |
|
|
replies.forEach(w -> currReplyMap.putIfAbsent(w.getReplyMobile(), w)); |
|
|
replies.forEach(w -> currReplyMap.putIfAbsent(w.getReplyMobile(), w)); |
|
|
} |
|
|
} |
|
|
List<MsgCallRecord> updates = new ArrayList<>(); |
|
|
List<MsgCallRecord> updates = new ArrayList<>(); |
|
|
for (MsgCallRecord w : recordsBySubmitKey) { |
|
|
|
|
|
|
|
|
for (MsgCallRecord w : currRecords) { |
|
|
if (errorPhones.contains(w.getReceivePhone())) { |
|
|
if (errorPhones.contains(w.getReceivePhone())) { |
|
|
w.setReplyStatus(ReplyStatus.FAILED); |
|
|
w.setReplyStatus(ReplyStatus.FAILED); |
|
|
w.setReplyOn(LocalDateTime.now()); |
|
|
w.setReplyOn(LocalDateTime.now()); |
|
|
} else if (currReplyMap.containsKey(w.getReceivePhone())) { |
|
|
} else if (currReplyMap.containsKey(w.getReceivePhone())) { |
|
|
SmsReply reply = currReplyMap.get(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.setReplyContent(reply.getReplyContent()); |
|
|
w.setReplyStatus(ReplyStatus.SUCCESS); |
|
|
w.setReplyStatus(ReplyStatus.SUCCESS); |
|
|
|
|
|
} else { |
|
|
|
|
|
continue; |
|
|
} |
|
|
} |
|
|
if (w.getReplyOn() != null) { |
|
|
|
|
|
updates.add(w); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
updates.add(w); |
|
|
} |
|
|
} |
|
|
msgCallRecordService.updateBatchById(updates); |
|
|
msgCallRecordService.updateBatchById(updates); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("回复结果回填失败:{}", submitKey, e); |
|
|
|
|
|
|
|
|
log.error("短信回复结果回填失败:{}", submitKey, e); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
EXECUTOR.execute(function); |
|
|
EXECUTOR.execute(function); |
|
|
}); |
|
|
}); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
* 获取电话回复结果 |
|
|
|
|
|
* |
|
|
|
|
|
* @param records 电话记录 |
|
|
|
|
|
**/ |
|
|
private void rewriteCallReply(List<MsgCallRecord> records) { |
|
|
private void rewriteCallReply(List<MsgCallRecord> records) { |
|
|
CollUtils.group(records, MsgCallRecord::getSubmitKey) |
|
|
CollUtils.group(records, MsgCallRecord::getSubmitKey) |
|
|
.forEach((submitKey, recordsBySubmitKey) -> { |
|
|
|
|
|
|
|
|
.forEach((submitKey, currRecords) -> { |
|
|
Runnable function = () -> { |
|
|
Runnable function = () -> { |
|
|
try { |
|
|
try { |
|
|
List<ReplyCallDTO> retReplies = msgCallHelper.callReply(submitKey); |
|
|
List<ReplyCallDTO> retReplies = msgCallHelper.callReply(submitKey); |
|
@@ -152,16 +161,12 @@ public class MsgCallReplyRewriteTask { |
|
|
ReplyCallDTO::getRemoteNumber, |
|
|
ReplyCallDTO::getRemoteNumber, |
|
|
Comparator.comparing(ReplyCallDTO::getSendDate)); |
|
|
Comparator.comparing(ReplyCallDTO::getSendDate)); |
|
|
List<MsgCallRecord> updates = new ArrayList<>(); |
|
|
List<MsgCallRecord> updates = new ArrayList<>(); |
|
|
for (MsgCallRecord w : recordsBySubmitKey) { |
|
|
|
|
|
|
|
|
for (MsgCallRecord w : currRecords) { |
|
|
ReplyCallDTO reply = replyMap.get(w.getReceivePhone()); |
|
|
ReplyCallDTO reply = replyMap.get(w.getReceivePhone()); |
|
|
if (reply == null) { |
|
|
if (reply == null) { |
|
|
continue; |
|
|
continue; |
|
|
} |
|
|
} |
|
|
switch (CallDialStatus.getNoNull(reply.getDialStatus())) { |
|
|
switch (CallDialStatus.getNoNull(reply.getDialStatus())) { |
|
|
case DIALING: |
|
|
|
|
|
case IN_CALL: |
|
|
|
|
|
case NOT_DIALED: |
|
|
|
|
|
break; |
|
|
|
|
|
case CALL_ENDED_CONNECTED: |
|
|
case CALL_ENDED_CONNECTED: |
|
|
w.setReplyStatus(ReplyStatus.SUCCESS); |
|
|
w.setReplyStatus(ReplyStatus.SUCCESS); |
|
|
w.setReplyContent(reply.getDtmf()); |
|
|
w.setReplyContent(reply.getDtmf()); |
|
@@ -174,6 +179,8 @@ public class MsgCallReplyRewriteTask { |
|
|
w.setReplyContent(reply.getDtmf()); |
|
|
w.setReplyContent(reply.getDtmf()); |
|
|
w.setErrorRemark(reply.getRemark()); |
|
|
w.setErrorRemark(reply.getRemark()); |
|
|
break; |
|
|
break; |
|
|
|
|
|
default: |
|
|
|
|
|
break; |
|
|
} |
|
|
} |
|
|
if (!ReplyStatus.WAITING.equals(w.getReplyStatus())) { |
|
|
if (!ReplyStatus.WAITING.equals(w.getReplyStatus())) { |
|
|
updates.add(w); |
|
|
updates.add(w); |
|
@@ -181,7 +188,7 @@ public class MsgCallReplyRewriteTask { |
|
|
} |
|
|
} |
|
|
msgCallRecordService.updateBatchById(updates); |
|
|
msgCallRecordService.updateBatchById(updates); |
|
|
} catch (Exception e) { |
|
|
} catch (Exception e) { |
|
|
log.error("回复结果回填失败:{}", submitKey, e); |
|
|
|
|
|
|
|
|
log.error("电话回复结果回填失败:{}", submitKey, e); |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
EXECUTOR.execute(function); |
|
|
EXECUTOR.execute(function); |
|
|