Browse Source

规范数据库,解决bug

pull/360/head
648540858 3 years ago
parent
commit
7400ace65d
  1. 9
      pom.xml
  2. 68
      sql/mysql.sql
  3. 12
      src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
  4. 2
      src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
  5. 1
      src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java
  6. 6
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
  7. 19
      src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
  8. 35
      src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
  9. 1
      src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
  10. 18
      src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
  11. 16
      src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
  12. 2
      src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java
  13. 2
      src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java
  14. 6
      src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java
  15. 2
      src/main/java/com/genersoft/iot/vmp/utils/node/INode.java
  16. 2
      src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeviceChannelTree.java
  17. 5
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
  18. 14
      src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java
  19. 4
      web_src/src/components/channelList.vue

9
pom.xml

@ -183,6 +183,15 @@
<version>4.9.0</version> <version>4.9.0</version>
</dependency> </dependency>
<!-- okhttp 调试日志 -->
<dependency>
<groupId>com.squareup.okhttp3</groupId>
<artifactId>logging-interceptor</artifactId>
<version>4.9.0</version>
</dependency>
<!-- okhttp-digest --> <!-- okhttp-digest -->
<dependency> <dependency>
<groupId>com.burgstaller</groupId> <groupId>com.burgstaller</groupId>

68
sql/mysql.sql

@ -44,7 +44,7 @@ CREATE TABLE `device` (
`charset` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, `charset` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `device_deviceId_uindex` (`deviceId`) UNIQUE KEY `device_deviceId_uindex` (`deviceId`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -95,39 +95,41 @@ DROP TABLE IF EXISTS `device_channel`;
/*!40101 SET @saved_cs_client = @@character_set_client */; /*!40101 SET @saved_cs_client = @@character_set_client */;
/*!50503 SET character_set_client = utf8mb4 */; /*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `device_channel` ( CREATE TABLE `device_channel` (
`channelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `id` int NOT NULL AUTO_INCREMENT,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `channelId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
`manufacture` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
`model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `manufacture` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`owner` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `model` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`civilCode` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `owner` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`block` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `civilCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `block` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `address` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`parentId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`safetyWay` int DEFAULT NULL, `safetyWay` int DEFAULT NULL,
`registerWay` int DEFAULT NULL, `registerWay` int DEFAULT NULL,
`certNum` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `certNum` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`certifiable` int DEFAULT NULL, `certifiable` int DEFAULT NULL,
`errCode` int DEFAULT NULL, `errCode` int DEFAULT NULL,
`endTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `endTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`secrecy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `secrecy` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`ipAddress` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `ipAddress` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`port` int DEFAULT NULL, `port` int DEFAULT NULL,
`password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `password` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL,
`PTZType` int DEFAULT NULL, `PTZType` int DEFAULT NULL,
`status` int DEFAULT NULL, `status` int DEFAULT NULL,
`longitude` double DEFAULT NULL, `longitude` double DEFAULT NULL,
`latitude` double DEFAULT NULL, `latitude` double DEFAULT NULL,
`streamId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `streamId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`deviceId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `deviceId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
`parental` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `parental` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`hasAudio` bit(1) DEFAULT NULL, `hasAudio` bit(1) DEFAULT NULL,
`createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `createTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
`updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `updateTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
`subCount` int DEFAULT '0', `subCount` int DEFAULT '0',
PRIMARY KEY (`channelId`,`deviceId`) USING BTREE, PRIMARY KEY (`id`),
UNIQUE KEY `device_channel_id_uindex` (`id`),
UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -196,7 +198,7 @@ CREATE TABLE `gb_stream` (
PRIMARY KEY (`gbStreamId`) USING BTREE, PRIMARY KEY (`gbStreamId`) USING BTREE,
UNIQUE KEY `app` (`app`,`stream`) USING BTREE, UNIQUE KEY `app` (`app`,`stream`) USING BTREE,
UNIQUE KEY `gbId` (`gbId`) USING BTREE UNIQUE KEY `gbId` (`gbId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=291 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=375 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -226,7 +228,7 @@ CREATE TABLE `log` (
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=313 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -315,7 +317,7 @@ CREATE TABLE `parent_platform` (
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `parent_platform_id_uindex` (`id`), UNIQUE KEY `parent_platform_id_uindex` (`id`),
UNIQUE KEY `parent_platform_pk` (`serverGBId`) UNIQUE KEY `parent_platform_pk` (`serverGBId`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -361,13 +363,11 @@ DROP TABLE IF EXISTS `platform_gb_channel`;
/*!50503 SET character_set_client = utf8mb4 */; /*!50503 SET character_set_client = utf8mb4 */;
CREATE TABLE `platform_gb_channel` ( CREATE TABLE `platform_gb_channel` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
`channelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `platformId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
`deviceId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `catalogId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
`platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `deviceChannelId` int NOT NULL,
`deviceAndChannelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -393,7 +393,7 @@ CREATE TABLE `platform_gb_stream` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`)
) ENGINE=InnoDB AUTO_INCREMENT=256 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=406 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -463,7 +463,7 @@ CREATE TABLE `stream_push` (
`mediaServerId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, `mediaServerId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`id`), PRIMARY KEY (`id`),
UNIQUE KEY `stream_push_pk` (`app`,`stream`) UNIQUE KEY `stream_push_pk` (`app`,`stream`)
) ENGINE=InnoDB AUTO_INCREMENT=310 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; ) ENGINE=InnoDB AUTO_INCREMENT=394 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -540,4 +540,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-02-24 16:52:12 -- Dump completed on 2022-02-25 20:32:21

12
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java

@ -3,6 +3,10 @@ package com.genersoft.iot.vmp.gb28181.bean;
public class DeviceChannel { public class DeviceChannel {
/**
* 数据库自赠ID
*/
private int id;
/** /**
* 通道id * 通道id
@ -165,6 +169,14 @@ public class DeviceChannel {
*/ */
private boolean hasAudio; private boolean hasAudio;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getDeviceId() { public String getDeviceId() {
return deviceId; return deviceId;
} }

2
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java

@ -60,7 +60,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
if (event.getPlatformId() != null) { if (event.getPlatformId() != null) {
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
if (!parentPlatform.isStatus())return; if (parentPlatform != null && !parentPlatform.isStatus())return;
String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId();
subscribe = redisCatchStorage.getSubscribe(key); subscribe = redisCatchStorage.getSubscribe(key);
if (subscribe == null) return; if (subscribe == null) return;

1
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java

@ -98,7 +98,6 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
deviceChannel.setParental(0); deviceChannel.setParental(0);
deviceChannel.setParentId(channelReduce.getCatalogId()); deviceChannel.setParentId(channelReduce.getCatalogId());
cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size);
// 防止发送过快 // 防止发送过快
Thread.sleep(50); Thread.sleep(50);

6
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java

@ -122,7 +122,6 @@ public class ZLMMediaListManager {
transform.setName(thirdPartyGB.getName()); transform.setName(thirdPartyGB.getName());
} }
} }
storager.updateMedia(transform);
if (!StringUtils.isEmpty(transform.getGbId())) { if (!StringUtils.isEmpty(transform.getGbId())) {
// 如果这个国标ID已经给了其他推流且流已离线,则移除其他推流 // 如果这个国标ID已经给了其他推流且流已离线,则移除其他推流
List<GbStream> gbStreams = gbStreamMapper.selectByGBId(transform.getGbId()); List<GbStream> gbStreams = gbStreamMapper.selectByGBId(transform.getGbId());
@ -135,13 +134,16 @@ public class ZLMMediaListManager {
} }
} }
} }
if (gbStreamMapper.selectOne(transform.getApp(), transform.getStream()) != null) { StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(transform.getApp(), transform.getStream());
if (streamProxyItem != null) {
transform.setGbStreamId(streamProxyItem.getGbStreamId());
gbStreamMapper.update(transform); gbStreamMapper.update(transform);
}else { }else {
transform.setCreateStamp(System.currentTimeMillis()); transform.setCreateStamp(System.currentTimeMillis());
gbStreamMapper.add(transform); gbStreamMapper.add(transform);
} }
} }
storager.updateMedia(transform);
return transform; return transform;
} }

19
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java

@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem;
import okhttp3.*; import okhttp3.*;
import okhttp3.logging.HttpLoggingInterceptor;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
@ -25,8 +26,23 @@ public class ZLMRESTfulUtils {
void run(JSONObject response); void run(JSONObject response);
} }
private OkHttpClient getClient(){
OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder();
if (logger.isDebugEnabled()) {
HttpLoggingInterceptor logging = new HttpLoggingInterceptor(message -> {
logger.debug("http请求参数:" + message);
});
logging.setLevel(HttpLoggingInterceptor.Level.BASIC);
// OkHttp進行添加攔截器loggingInterceptor
httpClientBuilder.addInterceptor(logging);
}
return httpClientBuilder.build();
}
public JSONObject sendPost(MediaServerItem mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) { public JSONObject sendPost(MediaServerItem mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) {
OkHttpClient client = new OkHttpClient(); OkHttpClient client = getClient();
if (mediaServerItem == null) { if (mediaServerItem == null) {
return null; return null;
} }
@ -56,6 +72,7 @@ public class ZLMRESTfulUtils {
ResponseBody responseBody = response.body(); ResponseBody responseBody = response.body();
if (responseBody != null) { if (responseBody != null) {
String responseStr = responseBody.string(); String responseStr = responseBody.string();
System.out.println(responseStr);
responseJSON = JSON.parseObject(responseStr); responseJSON = JSON.parseObject(responseStr);
} }
}else { }else {

35
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java

@ -87,26 +87,27 @@ public interface DeviceChannelMapper {
void startPlay(String deviceId, String channelId, String streamId); void startPlay(String deviceId, String channelId, String streamId);
@Select(value = {" <script>" + @Select(value = {" <script>" +
"SELECT dc.channelId, "+ "SELECT " +
"dc.deviceId, " + " dc.id,\n" +
"dc.name, " + " dc.channelId,\n" +
"de.manufacturer, " + " dc.deviceId,\n" +
"de.hostAddress, " + " dc.name,\n" +
"dc.subCount, " + " de.manufacturer,\n" +
"pgc.platformId as platformId, " + " de.hostAddress,\n" +
"pgc.catalogId as catalogId " + " dc.subCount,\n" +
"FROM device_channel dc " + " pgc.platformId as platformId,\n" +
"LEFT JOIN device de ON dc.deviceId = de.deviceId " + " pgc.catalogId as catalogId " +
"LEFT JOIN platform_gb_channel pgc on de.deviceId = pgc.deviceId and pgc.channelId = dc.channelId " + " FROM device_channel dc " +
"LEFT JOIN device_channel dc2 ON dc2.deviceId = de.deviceId AND dc2.parentId = dc.channelId " + " LEFT JOIN device de ON dc.deviceId = de.deviceId " +
" LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " +
" WHERE 1=1 " + " 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='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 == true' > AND dc.status=1</if> " +
" <if test='online == false' > AND dc.status=0</if> " + " <if test='online == false' > AND dc.status=0</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc2.channelId is not null</if> " + " <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.subCount > 0</if> " +
" <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc2.channelId is null</if> " + " <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.subCount == 0</if> " +
" <if test='catalogId == null ' > AND ((pgc.platformId IS NULL AND pgc.catalogId IS NULL) or (pgc.platformId != #{platformId}))</if> " + " <if test='catalogId == null ' > AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) </if> " +
" <if test='catalogId != null ' > AND pgc.platformId =#{platformId} AND pgc.catalogId = #{catalogId}</if> " + " <if test='catalogId != null ' > AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " +
" ORDER BY dc.deviceId, dc.channelId ASC" + " ORDER BY dc.deviceId, dc.channelId ASC" +
" </script>"}) " </script>"})
List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId); List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId);
@ -196,8 +197,8 @@ public interface DeviceChannelMapper {
List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId);
@Select(" SELECT\n" + @Select(" SELECT\n" +
" id,\n" +
" channelId,\n" + " channelId,\n" +
" channelId as id,\n" +
" deviceId,\n" + " deviceId,\n" +
" parentId,\n" + " parentId,\n" +
" status,\n" + " status,\n" +

1
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java

@ -19,6 +19,7 @@ public interface GbStreamMapper {
"('${app}', '${stream}', '${gbId}', '${name}', " + "('${app}', '${stream}', '${gbId}', '${name}', " +
"'${longitude}', '${latitude}', '${streamType}', " + "'${longitude}', '${latitude}', '${streamType}', " +
"'${mediaServerId}', ${status}, ${createStamp})") "'${mediaServerId}', ${status}, ${createStamp})")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
int add(GbStream gbStream); int add(GbStream gbStream);
@Update("UPDATE gb_stream " + @Update("UPDATE gb_stream " +

18
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java

@ -21,22 +21,22 @@ public interface PlatformChannelMapper {
* 查询列表里已经关联的 * 查询列表里已经关联的
*/ */
@Select("<script> "+ @Select("<script> "+
"SELECT deviceAndChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + "SELECT deviceChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
"<foreach collection='deviceAndChannelIds' open='(' item='id_' separator=',' close=')'> '${id_}'</foreach> ORDER BY deviceAndChannelId ASC" + "<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> '${item.id}'</foreach>" +
"</script>") "</script>")
List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds); List<Integer> findChannelRelatedPlatform(String platformId, List<ChannelReduce> channelReduces);
@Insert("<script> "+ @Insert("<script> "+
"INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId, catalogId) VALUES" + "INSERT INTO platform_gb_channel (platformId, deviceChannelId, catalogId) VALUES" +
"<foreach collection='channelReducesToAdd' item='item' separator=','>" + "<foreach collection='channelReducesToAdd' item='item' separator=','>" +
" ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' , '${item.catalogId}' )" + " ('${platformId}', '${item.id}' , '${item.catalogId}' )" +
"</foreach>" + "</foreach>" +
"</script>") "</script>")
int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd);
@Delete("<script> "+ @Delete("<script> "+
"DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" +
"<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" + "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.id}'</foreach>" +
"</script>") "</script>")
int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel); int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel);
@ -79,8 +79,10 @@ public interface PlatformChannelMapper {
"parent_platform pp " + "parent_platform pp " +
"left join platform_gb_channel pgc on " + "left join platform_gb_channel pgc on " +
"pp.serverGBId = pgc.platformId " + "pp.serverGBId = pgc.platformId " +
"left join device_channel dc on " +
"dc.id = pgc.deviceChannelId " +
"WHERE " + "WHERE " +
"pgc.channelId = #{channelId} and pp.status = true " + "dc.channelId = #{channelId} and pp.status = true " +
"AND pp.serverGBId IN" + "AND pp.serverGBId IN" +
"<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" +
"</script> ") "</script> ")

16
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java

@ -607,19 +607,19 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager {
@Override @Override
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) { public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
Map<String, ChannelReduce> deviceAndChannels = new HashMap<>(); Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
for (ChannelReduce channelReduce : channelReduces) { for (ChannelReduce channelReduce : channelReduces) {
channelReduce.setCatalogId(catalogId); channelReduce.setCatalogId(catalogId);
deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce); deviceAndChannels.put(channelReduce.getId(), channelReduce);
} }
List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
// 查询当前已经存在的 // 查询当前已经存在的
List<String> relatedPlatformchannels = platformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList); List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
if (relatedPlatformchannels != null) { if (deviceAndChannelList != null) {
deviceAndChannelList.removeAll(relatedPlatformchannels); deviceAndChannelList.removeAll(channelIds);
} }
for (String relatedPlatformchannel : relatedPlatformchannels) { for (Integer channelId : channelIds) {
deviceAndChannels.remove(relatedPlatformchannel); deviceAndChannels.remove(channelId);
} }
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
// 对剩下的数据进行存储 // 对剩下的数据进行存储

2
src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java

@ -18,7 +18,7 @@ public class BaseNode<T> implements INode<T> {
/** /**
* 主键ID * 主键ID
*/ */
protected String id; protected int id;
/** /**
* 父节点ID * 父节点ID

2
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java

@ -19,7 +19,7 @@ public class ForestNode extends BaseNode<ForestNode> {
*/ */
private Object content; private Object content;
public ForestNode(String id, String parentId, Object content) { public ForestNode(int id, String parentId, Object content) {
this.id = id; this.id = id;
this.parentId = parentId; this.parentId = parentId;
this.content = content; this.content = content;

6
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java

@ -17,12 +17,12 @@ public class ForestNodeManager<T extends INode<T>> {
/** /**
* 森林的所有节点 * 森林的所有节点
*/ */
private final ImmutableMap<String, T> nodeMap; private final ImmutableMap<Integer, T> nodeMap;
/** /**
* 森林的父节点ID * 森林的父节点ID
*/ */
private final Map<String, Object> parentIdMap = Maps.newHashMap(); private final Map<Integer, Object> parentIdMap = Maps.newHashMap();
public ForestNodeManager(List<T> nodes) { public ForestNodeManager(List<T> nodes) {
nodeMap = Maps.uniqueIndex(nodes, INode::getId); nodeMap = Maps.uniqueIndex(nodes, INode::getId);
@ -46,7 +46,7 @@ public class ForestNodeManager<T extends INode<T>> {
* *
* @param parentId 父节点ID * @param parentId 父节点ID
*/ */
public void addParentId(String parentId) { public void addParentId(int parentId) {
parentIdMap.put(parentId, ""); parentIdMap.put(parentId, "");
} }

2
src/main/java/com/genersoft/iot/vmp/utils/node/INode.java

@ -14,7 +14,7 @@ public interface INode<T> extends Serializable {
* *
* @return String * @return String
*/ */
String getId(); int getId();
/** /**
* 父主键 * 父主键

2
src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeviceChannelTree.java

@ -19,7 +19,7 @@ public class DeviceChannelTree extends DeviceChannel implements INode<DeviceChan
/** /**
* 主键ID * 主键ID
*/ */
private String id; private int id;
/** /**
* 父节点ID * 父节点ID

5
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java

@ -1,6 +1,7 @@
package com.genersoft.iot.vmp.vmanager.gb28181.media; package com.genersoft.iot.vmp.vmanager.gb28181.media;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.service.IMediaServerService;
import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IMediaService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorager; import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
@ -9,6 +10,7 @@ import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
@ -33,6 +35,9 @@ public class MediaController {
@Autowired @Autowired
private IMediaService mediaService; private IMediaService mediaService;
@Autowired
private IMediaServerService mediaServerService;
/** /**
* 根据应用名和流id获取播放地址 * 根据应用名和流id获取播放地址

14
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java

@ -1,10 +1,17 @@
package com.genersoft.iot.vmp.vmanager.gb28181.platform.bean; package com.genersoft.iot.vmp.vmanager.gb28181.platform.bean;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
/** /**
* 精简的channel信息展示主要是选择通道的时候展示列表使用 * 精简的channel信息展示主要是选择通道的时候展示列表使用
*/ */
public class ChannelReduce { public class ChannelReduce {
/**
* deviceChannel的数据库自增ID
*/
private int id;
/** /**
* 通道id * 通道id
*/ */
@ -45,6 +52,13 @@ public class ChannelReduce {
*/ */
private String catalogId; private String catalogId;
public int getId() {
return id;
}
public void setId(int id) {
this.id = id;
}
public String getChannelId() { public String getChannelId() {
return channelId; return channelId;

4
web_src/src/components/channelList.vue

@ -28,9 +28,7 @@
<devicePlayer ref="devicePlayer" v-loading="isLoging"></devicePlayer> <devicePlayer ref="devicePlayer" v-loading="isLoging"></devicePlayer>
<!--设备列表--> <!--设备列表-->
<el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%"> <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%">
<el-table-column prop="channelId" label="通道编号" width="210"> <el-table-column prop="channelId" label="通道编号" width="200">
</el-table-column>
<el-table-column prop="deviceId" label="设备编号" width="210">
</el-table-column> </el-table-column>
<el-table-column prop="name" label="通道名称"> <el-table-column prop="name" label="通道名称">
</el-table-column> </el-table-column>

Loading…
Cancel
Save