fix: 电话通知逻辑,功能修改,完善机制。
This commit is contained in:
@@ -56,10 +56,11 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService {
|
||||
|
||||
/**
|
||||
* 回执超时时间(分钟)
|
||||
* VMS 回执延迟较长,设为 15 分钟,给 VMS 平台充足的回调缓冲时间
|
||||
* 注意:超时判断基于 callTime(预计呼叫时间),实际呼叫发起后回调可能延迟数分钟到达
|
||||
* 从呼叫实际发出(callTime 已修正为真实发出时间)到收到 VMS 回执的最长等待时间。
|
||||
* 正常链路:通话约 30s + VMS 生成回执约 1~2min,3 分钟内完成。
|
||||
* 设为 5 分钟,兼顾回执延迟容忍与批次重试及时性(批次间隔 3 分钟)。
|
||||
*/
|
||||
private static final int CALLBACK_TIMEOUT_MINUTES = 15;
|
||||
private static final int CALLBACK_TIMEOUT_MINUTES = 5;
|
||||
|
||||
@Override
|
||||
@Transactional(rollbackFor = Exception.class)
|
||||
@@ -258,6 +259,20 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService {
|
||||
int sentCount = 0;
|
||||
for (AquWarnCallNotice notice : pendingList) {
|
||||
try {
|
||||
// 发出前先检查同设备同批次窗口内的状态
|
||||
// 批次窗口 = 当前记录的 callTime 往前 CALLBACK_TIMEOUT_MINUTES 分钟(足够覆盖整个批次)
|
||||
// - status=1(等待回执中):前一条已发出但回执未到,不重复拨打,等其超时后再发
|
||||
// - status=3(已成功):已有成功回执,跳过该条记录
|
||||
if (notice.getDeviceId() != null) {
|
||||
LocalDateTime batchWindowStart = notice.getCallTime().minusMinutes(CALLBACK_TIMEOUT_MINUTES);
|
||||
long blockingCount = warnCallNoticeMapper.countWaitingOrSuccessByDeviceAfter(
|
||||
notice.getDeviceId(), batchWindowStart);
|
||||
if (blockingCount > 0) {
|
||||
log.info("[待发通知] 设备 {} 同批次内已有等待回执或成功的记录,跳过记录ID: {}", notice.getDeviceId(), notice.getId());
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
// 查询关联的告警标题(title),作为 TTS warnMessage 参数
|
||||
// 使用 title(如"设备离线"、"溶解氧")而非完整 message,避免长字符串被 TTS 逐字播报
|
||||
String warnTitle = warnCallNoticeMapper.selectWarnTitleByCallNoticeId(notice.getId());
|
||||
@@ -291,6 +306,7 @@ public class WarnCallNoticeServiceImpl implements WarnCallNoticeService {
|
||||
notice.setCallStatus(CALL_STATUS_CALL_SUCCESS);
|
||||
notice.setCallId(response.getCallId());
|
||||
notice.setOutId(outId);
|
||||
notice.setCallTime(LocalDateTime.now()); // 记录实际发出时间,用于超时判断
|
||||
warnCallNoticeMapper.updateById(notice);
|
||||
sentCount++;
|
||||
log.info("[待发通知] 呼叫成功: {} - 记录ID: {}", notice.getMobilePhone(), notice.getId());
|
||||
|
||||
Reference in New Issue
Block a user