fix: 物联网平台,amqp数据接入并插入TD数据库相关逻辑编码。
This commit is contained in:
@@ -0,0 +1,55 @@
|
||||
package com.intc.iot.task;
|
||||
|
||||
import com.intc.iot.service.WarnCallNoticeService;
|
||||
import lombok.RequiredArgsConstructor;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.boot.autoconfigure.condition.ConditionalOnBean;
|
||||
import org.springframework.scheduling.annotation.Scheduled;
|
||||
import org.springframework.stereotype.Component;
|
||||
|
||||
/**
|
||||
* VMS 回执处理定时任务
|
||||
* 对应 C# AlarmProcessor 中的 ProcessVmsCallbacks + CleanupExpiredNotifications 定时逻辑
|
||||
*
|
||||
* @author intc-iot
|
||||
*/
|
||||
@Component
|
||||
@RequiredArgsConstructor
|
||||
@ConditionalOnBean(WarnCallNoticeService.class)
|
||||
@Slf4j
|
||||
public class VmsCallbackProcessTask {
|
||||
|
||||
private final WarnCallNoticeService warnCallNoticeService;
|
||||
|
||||
/**
|
||||
* 定时处理 VMS 回执
|
||||
* 每 5 秒执行一次(对应 C# 的处理频率)
|
||||
*/
|
||||
@Scheduled(fixedDelay = 5000)
|
||||
public void processVmsCallbacks() {
|
||||
try {
|
||||
int count = warnCallNoticeService.processUnhandledCallbacks();
|
||||
if (count > 0) {
|
||||
log.debug("[VMS回执处理] 本次处理了 {} 条回执", count);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[VMS回执处理] 处理回执异常: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 定时清理超时的通知记录
|
||||
* 每 30 秒执行一次(对应 C# CleanupExpiredNotifications 逻辑)
|
||||
*/
|
||||
@Scheduled(fixedDelay = 30000)
|
||||
public void cleanupExpiredNotifications() {
|
||||
try {
|
||||
int count = warnCallNoticeService.cleanupExpiredNotifications();
|
||||
if (count > 0) {
|
||||
log.info("[VMS超时清理] 本次清理了 {} 条超时记录", count);
|
||||
}
|
||||
} catch (Exception e) {
|
||||
log.error("[VMS超时清理] 清理超时记录异常: {}", e.getMessage(), e);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user