diff --git a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java index f98a5f3..2823c84 100644 --- a/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java +++ b/hz-pm-api/src/main/java/com/hz/pm/api/meeting/task/MsgCallReplyRewriteTask.java @@ -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 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 errorPhones = StrUtil.split(errorPhoneStr, ","); List replies = retReply.getResult(); Map 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 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 records) { CollUtils.group(records, MsgCallRecord::getSubmitKey) - .forEach((submitKey, recordsBySubmitKey) -> { + .forEach((submitKey, currRecords) -> { Runnable function = () -> { try { List retReplies = msgCallHelper.callReply(submitKey); @@ -152,16 +161,12 @@ public class MsgCallReplyRewriteTask { ReplyCallDTO::getRemoteNumber, Comparator.comparing(ReplyCallDTO::getSendDate)); List 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);