From f082797d9bf323084ebc6216c84eb00f05da868f Mon Sep 17 00:00:00 2001
From: panlinlin <648540858@qq.com>
Date: 星期三, 13 一月 2021 17:08:26 +0800
Subject: [PATCH] 完成向上级联->选择通道-003

---
 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java |   28 +++++++++++++++++-----------
 1 files changed, 17 insertions(+), 11 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
index ff1a7e1..5b04222 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
@@ -4,6 +4,7 @@
 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
 import com.genersoft.iot.vmp.vmanager.platform.bean.ChannelReduce;
 import org.apache.ibatis.annotations.*;
+import org.springframework.stereotype.Repository;
 
 import java.util.List;
 
@@ -11,6 +12,7 @@
  * 鐢ㄤ簬瀛樺偍璁惧閫氶亾淇℃伅
  */
 @Mapper
+@Repository
 public interface DeviceChannelMapper {
 
     @Insert("INSERT INTO device_channel (channelId, deviceId, name, manufacture, model, owner, civilCode, block, " +
@@ -79,18 +81,22 @@
 
     @Select(value = {" <script>" +
             "SELECT * FROM ( "+
-            " SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " +
-            "(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount " +
-            "FROM device_channel dc LEFT JOIN device de ON dc.deviceId = de.deviceId" +
+                " SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " +
+                "(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount, " +
+                "pc.platformId " +
+                "FROM device_channel dc " +
+                "LEFT JOIN device de ON dc.deviceId = de.deviceId " +
+                "LEFT JOIN platform_gb_channel pc on pc.deviceId = dc.deviceId AND pc.channelId = dc.channelId " +
+                " WHERE 1=1 " +
+                " <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
+                " <if test=\"online == true\" > AND dc.status=1</if> " +
+                " <if test=\"online == false\" > AND dc.status=0</if> " +
+                " <if test=\"platformId != null and inPlatform == true\"> AND pc.platformId=#{platformId} </if> " +
+            ") dcr" +
             " WHERE 1=1 " +
-            " <if test=\"query != null\"> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " +
-            " <if test=\"parentChannelId != null\"> AND dc.parentId=#{parentChannelId} </if> " +
-            " <if test=\"online == true\" > AND dc.status=1</if>" +
-            " <if test=\"online == false\" > AND dc.status=0</if>) dcr" +
-            " WHERE 1=1 " +
-            " <if test=\"hasSubChannel == true\" >  AND subCount >0</if>" +
-            " <if test=\"hasSubChannel == false\" >  AND subCount=0</if>" +
+            " <if test=\"hasSubChannel!= null and hasSubChannel == true\" >  AND subCount >0</if> " +
+            " <if test=\"hasSubChannel!= null and hasSubChannel == false\" >  AND subCount=0</if> " +
             " </script>"})
 
-    List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String parentChannelId);
+    List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, Boolean inPlatform);
 }

--
Gitblit v1.8.0