From 28c7bb7947c56a339f80616a17ddf33359829bb6 Mon Sep 17 00:00:00 2001 From: 16337 <1633794139@qq.com> Date: Mon, 2 Mar 2026 10:27:02 +0800 Subject: [PATCH] =?UTF-8?q?fix(aiot):=20=E4=BF=AE=E5=A4=8D=E5=91=8A?= =?UTF-8?q?=E8=AD=A6=20SQL=20=E5=BC=95=E7=94=A8=E4=B8=8D=E5=AD=98=E5=9C=A8?= =?UTF-8?q?=E7=9A=84=20gb=5Fname=20=E5=88=97?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - queryByAlertId/queryList 的 COALESCE 去掉 sp.gb_name(该列属于 device_channel 表,不在 stream_proxy 表中),改用 sp.name - 新增轻量 countByAlertId 方法,save() 去重改用 COUNT 查询 避免触发带 JOIN 的复杂 SQL Co-Authored-By: Claude Opus 4.6 --- .../java/com/genersoft/iot/vmp/aiot/dao/AiAlertMapper.java | 7 +++++-- .../iot/vmp/aiot/service/impl/AiAlertServiceImpl.java | 5 ++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/aiot/dao/AiAlertMapper.java b/src/main/java/com/genersoft/iot/vmp/aiot/dao/AiAlertMapper.java index cbd830c4e..cbd328d3c 100644 --- a/src/main/java/com/genersoft/iot/vmp/aiot/dao/AiAlertMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/aiot/dao/AiAlertMapper.java @@ -15,8 +15,11 @@ public interface AiAlertMapper { @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") int add(AiAlert alert); + @Select("SELECT COUNT(1) FROM wvp_ai_alert WHERE alert_id=#{alertId}") + int countByAlertId(@Param("alertId") String alertId); + @Select("SELECT a.*, r.name AS roi_name, " + - "COALESCE(SUBSTRING_INDEX(sp.gb_name, '/', 1), sp.name, sp.app) AS camera_name " + + "COALESCE(sp.name, sp.app) AS camera_name " + "FROM wvp_ai_alert a " + "LEFT JOIN wvp_ai_roi r ON a.roi_id = r.roi_id " + "LEFT JOIN wvp_stream_proxy sp ON a.camera_id = sp.camera_code " + @@ -29,7 +32,7 @@ public interface AiAlertMapper { @Select(value = {"