From af885ca4d9f2836567505bb41a3f677ef4827aca Mon Sep 17 00:00:00 2001
From: chenjialing <595168663@qq.com>
Date: 星期四, 03 三月 2022 15:40:12 +0800
Subject: [PATCH] 节点管理--某个zlm节点删除之后,数据库中仍有数据,导致再次添加该zlm节点
---
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java | 17 ++++++++++++-----
1 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
index 6d3be95..190a7b1 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
@@ -41,7 +41,11 @@
int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel);
@Delete("<script> "+
- "DELETE FROM platform_gb_channel WHERE deviceId='${deviceId}' " +
+ "DELETE FROM platform_gb_channel WHERE deviceChannelId in " +
+ "( select temp.deviceChannelId from " +
+ "(select pgc.deviceChannelId from platform_gb_channel pgc " +
+ "left join device_channel dc on dc.id = pgc.deviceChannelId where dc.deviceId =#{deviceId} " +
+ ") temp)" +
"</script>")
int delChannelForDeviceId(String deviceId);
@@ -50,16 +54,19 @@
"</script>")
int cleanChannelForGB(String platformId);
- @Select("SELECT * FROM device_channel WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE " +
- "platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'")
+ @Select("SELECT dc.* FROM platform_gb_channel pgc left join device_channel dc on dc.id = pgc.deviceChannelId WHERE dc.channelId='${channelId}' and pgc.platformId='${platformId}'")
DeviceChannel queryChannelInParentPlatform(String platformId, String channelId);
@Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " +
- "from device_channel dc left join platform_gb_channel pgc on dc.deviceId = pgc.deviceId and dc.channelId = pgc.channelId " +
+ "from device_channel dc left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId" +
"where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}")
List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId);
- @Select("SELECT * FROM device WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE platformId='${platformId}' AND channelId='${channelId}')")
+ @Select("select d.*\n" +
+ "from platform_gb_channel pgc\n" +
+ " left join device_channel dc on dc.id = pgc.deviceChannelId\n" +
+ " left join device d on dc.deviceId = d.deviceId\n" +
+ "where dc.channelId = #{channelId} and pgc.platformId=#{platformId}")
Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId);
@Delete("<script> "+
--
Gitblit v1.8.0