From 27eaffb9d721b3e4c3fb2bf7e9a5a84dadc66d27 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Thu, 5 Feb 2026 13:31:38 +0800 Subject: [PATCH] =?UTF-8?q?feat(aiot):=20=E6=96=B0=E5=A2=9E=E6=96=B9?= =?UTF-8?q?=E6=A1=88B=20Service=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - IAiAlertService: AI告警服务接口 - IAiAlgoTemplateService: 算法模板服务接口 - IAiConfigSnapshotService: 配置快照服务接口 - IAiEdgeDeviceService: 边缘设备服务接口 - IAiRedisConfigService: Redis配置同步服务接口 Co-Authored-By: Claude Opus 4.5 --- .../iot/vmp/aiot/service/IAiAlertService.java | 22 ++++++++ .../aiot/service/IAiAlgoTemplateService.java | 21 ++++++++ .../service/IAiConfigSnapshotService.java | 50 +++++++++++++++++ .../aiot/service/IAiEdgeDeviceService.java | 16 ++++++ .../aiot/service/IAiRedisConfigService.java | 53 +++++++++++++++++++ 5 files changed, 162 insertions(+) create mode 100644 src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlertService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlgoTemplateService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/aiot/service/IAiConfigSnapshotService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/aiot/service/IAiEdgeDeviceService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/aiot/service/IAiRedisConfigService.java diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlertService.java b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlertService.java new file mode 100644 index 000000000..a8791340e --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlertService.java @@ -0,0 +1,22 @@ +package com.genersoft.iot.vmp.aiot.service; + +import com.genersoft.iot.vmp.aiot.bean.AiAlert; +import com.github.pagehelper.PageInfo; + +import java.util.List; +import java.util.Map; + +public interface IAiAlertService { + + void save(AiAlert alert); + + AiAlert queryByAlertId(String alertId); + + PageInfo queryList(String cameraId, String alertType, String startTime, String endTime, int page, int count); + + void delete(String alertId); + + void deleteBatch(List alertIds); + + Map statistics(String startTime); +} diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlgoTemplateService.java b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlgoTemplateService.java new file mode 100644 index 000000000..00026fdd8 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiAlgoTemplateService.java @@ -0,0 +1,21 @@ +package com.genersoft.iot.vmp.aiot.service; + +import com.genersoft.iot.vmp.aiot.bean.AiAlgoTemplate; + +import java.util.List; + +public interface IAiAlgoTemplateService { + + void save(AiAlgoTemplate template); + + void delete(String templateId); + + AiAlgoTemplate queryByTemplateId(String templateId); + + List queryList(String algoCode); + + /** + * 模板级联更新:更新模板后同步更新所有引用该模板的绑定 + */ + void cascadeUpdate(String templateId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiConfigSnapshotService.java b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiConfigSnapshotService.java new file mode 100644 index 000000000..e15926d59 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiConfigSnapshotService.java @@ -0,0 +1,50 @@ +package com.genersoft.iot.vmp.aiot.service; + +import com.genersoft.iot.vmp.aiot.bean.AiConfigSnapshot; +import com.github.pagehelper.PageInfo; + +import java.util.Map; + +public interface IAiConfigSnapshotService { + + /** + * 生成快照 + */ + AiConfigSnapshot createSnapshot(String scopeType, String scopeId, String cameraId, + String snapshot, String changeType, String changeDesc, String createdBy); + + /** + * 查询版本列表 + */ + PageInfo queryVersions(String scopeType, String scopeId, String cameraId, int page, int count); + + /** + * 查看快照详情 + */ + AiConfigSnapshot queryById(Long id); + + /** + * 摄像头级别回滚 + */ + void rollbackCamera(String cameraId, Integer targetVersion, String operator); + + /** + * ROI级别回滚 + */ + void rollbackRoi(String roiId, Integer targetVersion, String operator); + + /** + * 绑定级别回滚 + */ + void rollbackBind(String bindId, Integer targetVersion, String operator); + + /** + * 版本间比对 + */ + Map diff(String scopeType, String scopeId, Integer versionA, Integer versionB); + + /** + * 推送前预览 - 对比DB配置 vs Redis中的配置 + */ + Map preview(String cameraId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiEdgeDeviceService.java b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiEdgeDeviceService.java new file mode 100644 index 000000000..48aa405e8 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiEdgeDeviceService.java @@ -0,0 +1,16 @@ +package com.genersoft.iot.vmp.aiot.service; + +import com.genersoft.iot.vmp.aiot.bean.AiEdgeDevice; + +import java.util.List; + +public interface IAiEdgeDeviceService { + + void saveOrUpdateHeartbeat(String deviceId, String payload); + + AiEdgeDevice queryByDeviceId(String deviceId); + + List queryAll(); + + void checkOffline(); +} diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiRedisConfigService.java b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiRedisConfigService.java new file mode 100644 index 000000000..135f4db78 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/aiot/service/IAiRedisConfigService.java @@ -0,0 +1,53 @@ +package com.genersoft.iot.vmp.aiot.service; + +import com.genersoft.iot.vmp.aiot.bean.AiRoi; +import com.genersoft.iot.vmp.aiot.bean.AiRoiAlgoBind; + +import java.util.List; +import java.util.Map; + +/** + * AI配置Redis同步服务 - 负责将平台配置写入Redis(对齐ai_edge的key格式) + */ +public interface IAiRedisConfigService { + + /** + * 将ROI配置写入Redis Hash (config:roi:{roi_id}) + */ + void writeRoiToRedis(AiRoi roi); + + /** + * 将算法绑定配置写入Redis Hash (config:bind:{bind_id}) + */ + void writeBindToRedis(AiRoiAlgoBind bind, String algoName, String targetClass, String effectiveParams); + + /** + * 将摄像头配置写入Redis Hash (config:camera:{camera_id}) + */ + void writeCameraToRedis(String cameraId, String rtspUrl, String cameraName, String location); + + /** + * 删除Redis中的ROI配置 + */ + void deleteRoiFromRedis(String roiId); + + /** + * 删除Redis中的绑定配置 + */ + void deleteBindFromRedis(String bindId); + + /** + * 发布config_update通知到Redis Pub/Sub + */ + void publishConfigUpdate(String type, List ids); + + /** + * 从Redis读取指定摄像头下所有ROI和绑定的当前配置 + */ + Map readConfigFromRedis(String cameraId); + + /** + * 全量同步摄像头配置到Redis + */ + void syncCameraConfigToRedis(String cameraId); +}