From 09a23bc80e017e73160c3fba89f609fe045f5748 Mon Sep 17 00:00:00 2001
From: 648540858 <648540858@qq.com>
Date: 星期四, 05 一月 2023 17:49:34 +0800
Subject: [PATCH] 修复布防撤防 #717

---
 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java |   35 ++++++++++++++++++++++++++++++++---
 1 files changed, 32 insertions(+), 3 deletions(-)

diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
index 03dba38..048206a 100644
--- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
+++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceMapper.java
@@ -1,6 +1,7 @@
 package com.genersoft.iot.vmp.storager.dao;
 
 import com.genersoft.iot.vmp.gb28181.bean.Device;
+import com.genersoft.iot.vmp.vmanager.bean.ResourceBaceInfo;
 import org.apache.ibatis.annotations.*;
 import org.springframework.stereotype.Repository;
 
@@ -23,6 +24,8 @@
             "transport," +
             "streamMode," +
             "ip," +
+            "sdpIp," +
+            "localIp," +
             "port," +
             "hostAddress," +
             "expires," +
@@ -51,11 +54,14 @@
                 "transport," +
                 "streamMode," +
                 "ip," +
+                "sdpIp," +
+                "localIp," +
                 "port," +
                 "hostAddress," +
                 "expires," +
                 "registerTime," +
                 "keepaliveTime," +
+                "keepaliveIntervalTime," +
                 "createTime," +
                 "updateTime," +
                 "charset," +
@@ -76,11 +82,14 @@
                 "#{transport}," +
                 "#{streamMode}," +
                 "#{ip}," +
+                "#{sdpIp}," +
+                "#{localIp}," +
                 "#{port}," +
                 "#{hostAddress}," +
                 "#{expires}," +
                 "#{registerTime}," +
                 "#{keepaliveTime}," +
+                "#{keepaliveIntervalTime}," +
                 "#{createTime}," +
                 "#{updateTime}," +
                 "#{charset}," +
@@ -104,17 +113,21 @@
                 "<if test=\"firmware != null\">, firmware='${firmware}'</if>" +
                 "<if test=\"transport != null\">, transport='${transport}'</if>" +
                 "<if test=\"ip != null\">, ip='${ip}'</if>" +
+                "<if test=\"localIp != null\">, localIp='${localIp}'</if>" +
                 "<if test=\"port != null\">, port=${port}</if>" +
                 "<if test=\"hostAddress != null\">, hostAddress='${hostAddress}'</if>" +
                 "<if test=\"online != null\">, online=${online}</if>" +
                 "<if test=\"registerTime != null\">, registerTime='${registerTime}'</if>" +
                 "<if test=\"keepaliveTime != null\">, keepaliveTime='${keepaliveTime}'</if>" +
+                "<if test=\"keepaliveIntervalTime != null\">, keepaliveIntervalTime='${keepaliveIntervalTime}'</if>" +
                 "<if test=\"expires != null\">, expires=${expires}</if>" +
                 "WHERE deviceId='${deviceId}'"+
             " </script>"})
     int update(Device device);
 
-    @Select("SELECT " +
+    @Select(
+            " <script>" +
+            "SELECT " +
             "deviceId, " +
             "coalesce(custom_name, name) as name, " +
             "password, " +
@@ -124,6 +137,8 @@
             "transport," +
             "streamMode," +
             "ip," +
+            "sdpIp," +
+            "localIp," +
             "port," +
             "hostAddress," +
             "expires," +
@@ -140,8 +155,11 @@
             "geoCoordSys," +
             "treeType," +
             "online," +
-            "(SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount  FROM device de")
-    List<Device> getDevices();
+            "(SELECT count(0) FROM device_channel WHERE deviceId=de.deviceId) as channelCount  FROM device de" +
+            "<if test=\"online != null\"> where online=${online}</if>"+
+            " </script>"
+    )
+    List<Device> getDevices(Boolean online);
 
     @Delete("DELETE FROM device WHERE deviceId=#{deviceId}")
     int del(String deviceId);
@@ -159,6 +177,8 @@
             "transport," +
             "streamMode," +
             "ip," +
+            "sdpIp," +
+            "localIp," +
             "port," +
             "hostAddress," +
             "expires," +
@@ -187,6 +207,8 @@
             "transport," +
             "streamMode," +
             "ip," +
+            "sdpIp," +
+            "localIp," +
             "port," +
             "hostAddress," +
             "expires," +
@@ -213,6 +235,7 @@
             "<if test=\"password != null\">, password='${password}'</if>" +
             "<if test=\"streamMode != null\">, streamMode='${streamMode}'</if>" +
             "<if test=\"ip != null\">, ip='${ip}'</if>" +
+            "<if test=\"sdpIp != null\">, sdpIp='${sdpIp}'</if>" +
             "<if test=\"port != null\">, port=${port}</if>" +
             "<if test=\"charset != null\">, charset='${charset}'</if>" +
             "<if test=\"subscribeCycleForCatalog != null\">, subscribeCycleForCatalog=${subscribeCycleForCatalog}</if>" +
@@ -231,6 +254,7 @@
             "deviceId, " +
             "custom_name, " +
             "password, " +
+            "sdpIp, " +
             "createTime," +
             "updateTime," +
             "charset," +
@@ -242,6 +266,7 @@
             "#{deviceId}," +
             "#{name}," +
             "#{password}," +
+            "#{sdpIp}," +
             "#{createTime}," +
             "#{updateTime}," +
             "#{charset}," +
@@ -251,4 +276,8 @@
             "#{online}" +
             ")")
     void addCustomDevice(Device device);
+
+    @Select("select count(1) as total, sum(online) as online from device")
+    ResourceBaceInfo getOverview();
+
 }

--
Gitblit v1.8.0