Commit 7400ace65d693bb7bcc564b9211d8bab2af3ac01
1 parent
a42dda2b
规范数据库,解决bug
Showing
19 changed files
with
142 additions
and
82 deletions
pom.xml
| ... | ... | @@ -183,6 +183,15 @@ |
| 183 | 183 | <version>4.9.0</version> |
| 184 | 184 | </dependency> |
| 185 | 185 | |
| 186 | + <!-- okhttp 调试日志 --> | |
| 187 | + <dependency> | |
| 188 | + <groupId>com.squareup.okhttp3</groupId> | |
| 189 | + <artifactId>logging-interceptor</artifactId> | |
| 190 | + <version>4.9.0</version> | |
| 191 | + </dependency> | |
| 192 | + | |
| 193 | + | |
| 194 | + | |
| 186 | 195 | <!-- okhttp-digest --> |
| 187 | 196 | <dependency> |
| 188 | 197 | <groupId>com.burgstaller</groupId> | ... | ... |
sql/mysql.sql
| ... | ... | @@ -44,7 +44,7 @@ CREATE TABLE `device` ( |
| 44 | 44 | `charset` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, |
| 45 | 45 | PRIMARY KEY (`id`), |
| 46 | 46 | UNIQUE KEY `device_deviceId_uindex` (`deviceId`) |
| 47 | -) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 47 | +) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 48 | 48 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 49 | 49 | |
| 50 | 50 | -- |
| ... | ... | @@ -95,39 +95,41 @@ DROP TABLE IF EXISTS `device_channel`; |
| 95 | 95 | /*!40101 SET @saved_cs_client = @@character_set_client */; |
| 96 | 96 | /*!50503 SET character_set_client = utf8mb4 */; |
| 97 | 97 | CREATE TABLE `device_channel` ( |
| 98 | - `channelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 99 | - `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 100 | - `manufacture` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 101 | - `model` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 102 | - `owner` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 103 | - `civilCode` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 104 | - `block` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 105 | - `address` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 106 | - `parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 98 | + `id` int NOT NULL AUTO_INCREMENT, | |
| 99 | + `channelId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, | |
| 100 | + `name` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 101 | + `manufacture` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 102 | + `model` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 103 | + `owner` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 104 | + `civilCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 105 | + `block` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 106 | + `address` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 107 | + `parentId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 107 | 108 | `safetyWay` int DEFAULT NULL, |
| 108 | 109 | `registerWay` int DEFAULT NULL, |
| 109 | - `certNum` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 110 | + `certNum` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 110 | 111 | `certifiable` int DEFAULT NULL, |
| 111 | 112 | `errCode` int DEFAULT NULL, |
| 112 | - `endTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 113 | - `secrecy` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 114 | - `ipAddress` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 113 | + `endTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 114 | + `secrecy` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 115 | + `ipAddress` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 115 | 116 | `port` int DEFAULT NULL, |
| 116 | - `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 117 | + `password` varchar(255) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 117 | 118 | `PTZType` int DEFAULT NULL, |
| 118 | 119 | `status` int DEFAULT NULL, |
| 119 | 120 | `longitude` double DEFAULT NULL, |
| 120 | 121 | `latitude` double DEFAULT NULL, |
| 121 | - `streamId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 122 | - `deviceId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 123 | - `parental` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 122 | + `streamId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 123 | + `deviceId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, | |
| 124 | + `parental` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, | |
| 124 | 125 | `hasAudio` bit(1) DEFAULT NULL, |
| 125 | - `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 126 | - `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 126 | + `createTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, | |
| 127 | + `updateTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, | |
| 127 | 128 | `subCount` int DEFAULT '0', |
| 128 | - PRIMARY KEY (`channelId`,`deviceId`) USING BTREE, | |
| 129 | + PRIMARY KEY (`id`), | |
| 130 | + UNIQUE KEY `device_channel_id_uindex` (`id`), | |
| 129 | 131 | UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) |
| 130 | -) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 132 | +) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 131 | 133 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 132 | 134 | |
| 133 | 135 | -- |
| ... | ... | @@ -196,7 +198,7 @@ CREATE TABLE `gb_stream` ( |
| 196 | 198 | PRIMARY KEY (`gbStreamId`) USING BTREE, |
| 197 | 199 | UNIQUE KEY `app` (`app`,`stream`) USING BTREE, |
| 198 | 200 | UNIQUE KEY `gbId` (`gbId`) USING BTREE |
| 199 | -) ENGINE=InnoDB AUTO_INCREMENT=291 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 201 | +) ENGINE=InnoDB AUTO_INCREMENT=375 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 200 | 202 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 201 | 203 | |
| 202 | 204 | -- |
| ... | ... | @@ -226,7 +228,7 @@ CREATE TABLE `log` ( |
| 226 | 228 | `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 227 | 229 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 228 | 230 | PRIMARY KEY (`id`) USING BTREE |
| 229 | -) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 231 | +) ENGINE=InnoDB AUTO_INCREMENT=313 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 230 | 232 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 231 | 233 | |
| 232 | 234 | -- |
| ... | ... | @@ -315,7 +317,7 @@ CREATE TABLE `parent_platform` ( |
| 315 | 317 | PRIMARY KEY (`id`), |
| 316 | 318 | UNIQUE KEY `parent_platform_id_uindex` (`id`), |
| 317 | 319 | UNIQUE KEY `parent_platform_pk` (`serverGBId`) |
| 318 | -) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 320 | +) ENGINE=InnoDB AUTO_INCREMENT=14 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 319 | 321 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 320 | 322 | |
| 321 | 323 | -- |
| ... | ... | @@ -361,13 +363,11 @@ DROP TABLE IF EXISTS `platform_gb_channel`; |
| 361 | 363 | /*!50503 SET character_set_client = utf8mb4 */; |
| 362 | 364 | CREATE TABLE `platform_gb_channel` ( |
| 363 | 365 | `id` int NOT NULL AUTO_INCREMENT, |
| 364 | - `channelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 365 | - `deviceId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 366 | - `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 367 | - `deviceAndChannelId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 368 | - `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, | |
| 366 | + `platformId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, | |
| 367 | + `catalogId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, | |
| 368 | + `deviceChannelId` int NOT NULL, | |
| 369 | 369 | PRIMARY KEY (`id`) |
| 370 | -) ENGINE=InnoDB AUTO_INCREMENT=3 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 370 | +) ENGINE=InnoDB AUTO_INCREMENT=8 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 371 | 371 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 372 | 372 | |
| 373 | 373 | -- |
| ... | ... | @@ -393,7 +393,7 @@ CREATE TABLE `platform_gb_stream` ( |
| 393 | 393 | `id` int NOT NULL AUTO_INCREMENT, |
| 394 | 394 | PRIMARY KEY (`id`), |
| 395 | 395 | UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) |
| 396 | -) ENGINE=InnoDB AUTO_INCREMENT=256 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 396 | +) ENGINE=InnoDB AUTO_INCREMENT=406 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 397 | 397 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 398 | 398 | |
| 399 | 399 | -- |
| ... | ... | @@ -463,7 +463,7 @@ CREATE TABLE `stream_push` ( |
| 463 | 463 | `mediaServerId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 464 | 464 | PRIMARY KEY (`id`), |
| 465 | 465 | UNIQUE KEY `stream_push_pk` (`app`,`stream`) |
| 466 | -) ENGINE=InnoDB AUTO_INCREMENT=310 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 466 | +) ENGINE=InnoDB AUTO_INCREMENT=394 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 467 | 467 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 468 | 468 | |
| 469 | 469 | -- |
| ... | ... | @@ -540,4 +540,4 @@ UNLOCK TABLES; |
| 540 | 540 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
| 541 | 541 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; |
| 542 | 542 | |
| 543 | --- Dump completed on 2022-02-24 16:52:12 | |
| 543 | +-- Dump completed on 2022-02-25 20:32:21 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceChannel.java
| ... | ... | @@ -3,6 +3,10 @@ package com.genersoft.iot.vmp.gb28181.bean; |
| 3 | 3 | public class DeviceChannel { |
| 4 | 4 | |
| 5 | 5 | |
| 6 | + /** | |
| 7 | + * 数据库自赠ID | |
| 8 | + */ | |
| 9 | + private int id; | |
| 6 | 10 | |
| 7 | 11 | /** |
| 8 | 12 | * 通道id |
| ... | ... | @@ -165,6 +169,14 @@ public class DeviceChannel { |
| 165 | 169 | */ |
| 166 | 170 | private boolean hasAudio; |
| 167 | 171 | |
| 172 | + public int getId() { | |
| 173 | + return id; | |
| 174 | + } | |
| 175 | + | |
| 176 | + public void setId(int id) { | |
| 177 | + this.id = id; | |
| 178 | + } | |
| 179 | + | |
| 168 | 180 | public String getDeviceId() { |
| 169 | 181 | return deviceId; |
| 170 | 182 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
| ... | ... | @@ -60,7 +60,7 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> { |
| 60 | 60 | Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); |
| 61 | 61 | if (event.getPlatformId() != null) { |
| 62 | 62 | parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); |
| 63 | - if (!parentPlatform.isStatus())return; | |
| 63 | + if (parentPlatform != null && !parentPlatform.isStatus())return; | |
| 64 | 64 | String key = VideoManagerConstants.SIP_SUBSCRIBE_PREFIX + userSetup.getServerId() + "_Catalog_" + event.getPlatformId(); |
| 65 | 65 | subscribe = redisCatchStorage.getSubscribe(key); |
| 66 | 66 | if (subscribe == null) return; | ... | ... |
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 |
| 98 | 98 | DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); |
| 99 | 99 | deviceChannel.setParental(0); |
| 100 | 100 | deviceChannel.setParentId(channelReduce.getCatalogId()); |
| 101 | - | |
| 102 | 101 | cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); |
| 103 | 102 | // 防止发送过快 |
| 104 | 103 | Thread.sleep(50); | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java
| ... | ... | @@ -122,7 +122,6 @@ public class ZLMMediaListManager { |
| 122 | 122 | transform.setName(thirdPartyGB.getName()); |
| 123 | 123 | } |
| 124 | 124 | } |
| 125 | - storager.updateMedia(transform); | |
| 126 | 125 | if (!StringUtils.isEmpty(transform.getGbId())) { |
| 127 | 126 | // 如果这个国标ID已经给了其他推流且流已离线,则移除其他推流 |
| 128 | 127 | List<GbStream> gbStreams = gbStreamMapper.selectByGBId(transform.getGbId()); |
| ... | ... | @@ -135,13 +134,16 @@ public class ZLMMediaListManager { |
| 135 | 134 | } |
| 136 | 135 | } |
| 137 | 136 | } |
| 138 | - if (gbStreamMapper.selectOne(transform.getApp(), transform.getStream()) != null) { | |
| 137 | + StreamProxyItem streamProxyItem = gbStreamMapper.selectOne(transform.getApp(), transform.getStream()); | |
| 138 | + if (streamProxyItem != null) { | |
| 139 | + transform.setGbStreamId(streamProxyItem.getGbStreamId()); | |
| 139 | 140 | gbStreamMapper.update(transform); |
| 140 | 141 | }else { |
| 141 | 142 | transform.setCreateStamp(System.currentTimeMillis()); |
| 142 | 143 | gbStreamMapper.add(transform); |
| 143 | 144 | } |
| 144 | 145 | } |
| 146 | + storager.updateMedia(transform); | |
| 145 | 147 | return transform; |
| 146 | 148 | } |
| 147 | 149 | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRESTfulUtils.java
| ... | ... | @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSON; |
| 4 | 4 | import com.alibaba.fastjson.JSONObject; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; |
| 6 | 6 | import okhttp3.*; |
| 7 | +import okhttp3.logging.HttpLoggingInterceptor; | |
| 7 | 8 | import org.jetbrains.annotations.NotNull; |
| 8 | 9 | import org.slf4j.Logger; |
| 9 | 10 | import org.slf4j.LoggerFactory; |
| ... | ... | @@ -25,8 +26,23 @@ public class ZLMRESTfulUtils { |
| 25 | 26 | void run(JSONObject response); |
| 26 | 27 | } |
| 27 | 28 | |
| 29 | + private OkHttpClient getClient(){ | |
| 30 | + OkHttpClient.Builder httpClientBuilder = new OkHttpClient.Builder(); | |
| 31 | + if (logger.isDebugEnabled()) { | |
| 32 | + HttpLoggingInterceptor logging = new HttpLoggingInterceptor(message -> { | |
| 33 | + logger.debug("http请求参数:" + message); | |
| 34 | + }); | |
| 35 | + logging.setLevel(HttpLoggingInterceptor.Level.BASIC); | |
| 36 | + // OkHttp進行添加攔截器loggingInterceptor | |
| 37 | + httpClientBuilder.addInterceptor(logging); | |
| 38 | + } | |
| 39 | + return httpClientBuilder.build(); | |
| 40 | + } | |
| 41 | + | |
| 42 | + | |
| 28 | 43 | public JSONObject sendPost(MediaServerItem mediaServerItem, String api, Map<String, Object> param, RequestCallback callback) { |
| 29 | - OkHttpClient client = new OkHttpClient(); | |
| 44 | + OkHttpClient client = getClient(); | |
| 45 | + | |
| 30 | 46 | if (mediaServerItem == null) { |
| 31 | 47 | return null; |
| 32 | 48 | } |
| ... | ... | @@ -56,6 +72,7 @@ public class ZLMRESTfulUtils { |
| 56 | 72 | ResponseBody responseBody = response.body(); |
| 57 | 73 | if (responseBody != null) { |
| 58 | 74 | String responseStr = responseBody.string(); |
| 75 | + System.out.println(responseStr); | |
| 59 | 76 | responseJSON = JSON.parseObject(responseStr); |
| 60 | 77 | } |
| 61 | 78 | }else { | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
| ... | ... | @@ -87,26 +87,27 @@ public interface DeviceChannelMapper { |
| 87 | 87 | void startPlay(String deviceId, String channelId, String streamId); |
| 88 | 88 | |
| 89 | 89 | @Select(value = {" <script>" + |
| 90 | - "SELECT dc.channelId, "+ | |
| 91 | - "dc.deviceId, " + | |
| 92 | - "dc.name, " + | |
| 93 | - "de.manufacturer, " + | |
| 94 | - "de.hostAddress, " + | |
| 95 | - "dc.subCount, " + | |
| 96 | - "pgc.platformId as platformId, " + | |
| 97 | - "pgc.catalogId as catalogId " + | |
| 98 | - "FROM device_channel dc " + | |
| 99 | - "LEFT JOIN device de ON dc.deviceId = de.deviceId " + | |
| 100 | - "LEFT JOIN platform_gb_channel pgc on de.deviceId = pgc.deviceId and pgc.channelId = dc.channelId " + | |
| 101 | - "LEFT JOIN device_channel dc2 ON dc2.deviceId = de.deviceId AND dc2.parentId = dc.channelId " + | |
| 90 | + "SELECT " + | |
| 91 | + " dc.id,\n" + | |
| 92 | + " dc.channelId,\n" + | |
| 93 | + " dc.deviceId,\n" + | |
| 94 | + " dc.name,\n" + | |
| 95 | + " de.manufacturer,\n" + | |
| 96 | + " de.hostAddress,\n" + | |
| 97 | + " dc.subCount,\n" + | |
| 98 | + " pgc.platformId as platformId,\n" + | |
| 99 | + " pgc.catalogId as catalogId " + | |
| 100 | + " FROM device_channel dc " + | |
| 101 | + " LEFT JOIN device de ON dc.deviceId = de.deviceId " + | |
| 102 | + " LEFT JOIN platform_gb_channel pgc on pgc.deviceChannelId = dc.id " + | |
| 102 | 103 | " WHERE 1=1 " + |
| 103 | 104 | " <if test='query != null'> AND (dc.channelId LIKE '%${query}%' OR dc.name LIKE '%${query}%' OR dc.name LIKE '%${query}%')</if> " + |
| 104 | 105 | " <if test='online == true' > AND dc.status=1</if> " + |
| 105 | 106 | " <if test='online == false' > AND dc.status=0</if> " + |
| 106 | - " <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc2.channelId is not null</if> " + | |
| 107 | - " <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc2.channelId is null</if> " + | |
| 108 | - " <if test='catalogId == null ' > AND ((pgc.platformId IS NULL AND pgc.catalogId IS NULL) or (pgc.platformId != #{platformId}))</if> " + | |
| 109 | - " <if test='catalogId != null ' > AND pgc.platformId =#{platformId} AND pgc.catalogId = #{catalogId}</if> " + | |
| 107 | + " <if test='hasSubChannel!= null and hasSubChannel == true' > AND dc.subCount > 0</if> " + | |
| 108 | + " <if test='hasSubChannel!= null and hasSubChannel == false' > AND dc.subCount == 0</if> " + | |
| 109 | + " <if test='catalogId == null ' > AND dc.id not in (select deviceChannelId from platform_gb_channel where platformId=#{platformId} ) </if> " + | |
| 110 | + " <if test='catalogId != null ' > AND pgc.platformId = #{platformId} and pgc.catalogId=#{catalogId} </if> " + | |
| 110 | 111 | " ORDER BY dc.deviceId, dc.channelId ASC" + |
| 111 | 112 | " </script>"}) |
| 112 | 113 | List<ChannelReduce> queryChannelListInAll(String query, Boolean online, Boolean hasSubChannel, String platformId, String catalogId); |
| ... | ... | @@ -196,8 +197,8 @@ public interface DeviceChannelMapper { |
| 196 | 197 | List<DeviceChannel> queryOnlineChannelsByDeviceId(String deviceId); |
| 197 | 198 | |
| 198 | 199 | @Select(" SELECT\n" + |
| 200 | + " id,\n" + | |
| 199 | 201 | " channelId,\n" + |
| 200 | - " channelId as id,\n" + | |
| 201 | 202 | " deviceId,\n" + |
| 202 | 203 | " parentId,\n" + |
| 203 | 204 | " status,\n" + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
| ... | ... | @@ -19,6 +19,7 @@ public interface GbStreamMapper { |
| 19 | 19 | "('${app}', '${stream}', '${gbId}', '${name}', " + |
| 20 | 20 | "'${longitude}', '${latitude}', '${streamType}', " + |
| 21 | 21 | "'${mediaServerId}', ${status}, ${createStamp})") |
| 22 | + @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") | |
| 22 | 23 | int add(GbStream gbStream); |
| 23 | 24 | |
| 24 | 25 | @Update("UPDATE gb_stream " + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| ... | ... | @@ -21,22 +21,22 @@ public interface PlatformChannelMapper { |
| 21 | 21 | * 查询列表里已经关联的 |
| 22 | 22 | */ |
| 23 | 23 | @Select("<script> "+ |
| 24 | - "SELECT deviceAndChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + | |
| 25 | - "<foreach collection='deviceAndChannelIds' open='(' item='id_' separator=',' close=')'> '${id_}'</foreach> ORDER BY deviceAndChannelId ASC" + | |
| 24 | + "SELECT deviceChannelId FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" + | |
| 25 | + "<foreach collection='channelReduces' open='(' item='item' separator=',' close=')'> '${item.id}'</foreach>" + | |
| 26 | 26 | "</script>") |
| 27 | - List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds); | |
| 27 | + List<Integer> findChannelRelatedPlatform(String platformId, List<ChannelReduce> channelReduces); | |
| 28 | 28 | |
| 29 | 29 | @Insert("<script> "+ |
| 30 | - "INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId, catalogId) VALUES" + | |
| 30 | + "INSERT INTO platform_gb_channel (platformId, deviceChannelId, catalogId) VALUES" + | |
| 31 | 31 | "<foreach collection='channelReducesToAdd' item='item' separator=','>" + |
| 32 | - " ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' , '${item.catalogId}' )" + | |
| 32 | + " ('${platformId}', '${item.id}' , '${item.catalogId}' )" + | |
| 33 | 33 | "</foreach>" + |
| 34 | 34 | "</script>") |
| 35 | 35 | int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); |
| 36 | 36 | |
| 37 | 37 | @Delete("<script> "+ |
| 38 | - "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + | |
| 39 | - "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" + | |
| 38 | + "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceChannelId in" + | |
| 39 | + "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.id}'</foreach>" + | |
| 40 | 40 | "</script>") |
| 41 | 41 | int delChannelForGB(String platformId, List<ChannelReduce> channelReducesToDel); |
| 42 | 42 | |
| ... | ... | @@ -79,8 +79,10 @@ public interface PlatformChannelMapper { |
| 79 | 79 | "parent_platform pp " + |
| 80 | 80 | "left join platform_gb_channel pgc on " + |
| 81 | 81 | "pp.serverGBId = pgc.platformId " + |
| 82 | + "left join device_channel dc on " + | |
| 83 | + "dc.id = pgc.deviceChannelId " + | |
| 82 | 84 | "WHERE " + |
| 83 | - "pgc.channelId = #{channelId} and pp.status = true " + | |
| 85 | + "dc.channelId = #{channelId} and pp.status = true " + | |
| 84 | 86 | "AND pp.serverGBId IN" + |
| 85 | 87 | "<foreach collection='platforms' item='item' open='(' separator=',' close=')' > #{item}</foreach>" + |
| 86 | 88 | "</script> ") | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java
| ... | ... | @@ -607,19 +607,19 @@ public class VideoManagerStoragerImpl implements IVideoManagerStorager { |
| 607 | 607 | @Override |
| 608 | 608 | public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) { |
| 609 | 609 | |
| 610 | - Map<String, ChannelReduce> deviceAndChannels = new HashMap<>(); | |
| 610 | + Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>(); | |
| 611 | 611 | for (ChannelReduce channelReduce : channelReduces) { |
| 612 | 612 | channelReduce.setCatalogId(catalogId); |
| 613 | - deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce); | |
| 613 | + deviceAndChannels.put(channelReduce.getId(), channelReduce); | |
| 614 | 614 | } |
| 615 | - List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); | |
| 615 | + List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); | |
| 616 | 616 | // 查询当前已经存在的 |
| 617 | - List<String> relatedPlatformchannels = platformChannelMapper.findChannelRelatedPlatform(platformId, deviceAndChannelList); | |
| 618 | - if (relatedPlatformchannels != null) { | |
| 619 | - deviceAndChannelList.removeAll(relatedPlatformchannels); | |
| 617 | + List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces); | |
| 618 | + if (deviceAndChannelList != null) { | |
| 619 | + deviceAndChannelList.removeAll(channelIds); | |
| 620 | 620 | } |
| 621 | - for (String relatedPlatformchannel : relatedPlatformchannels) { | |
| 622 | - deviceAndChannels.remove(relatedPlatformchannel); | |
| 621 | + for (Integer channelId : channelIds) { | |
| 622 | + deviceAndChannels.remove(channelId); | |
| 623 | 623 | } |
| 624 | 624 | List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); |
| 625 | 625 | // 对剩下的数据进行存储 | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/node/BaseNode.java
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNode.java
| ... | ... | @@ -19,7 +19,7 @@ public class ForestNode extends BaseNode<ForestNode> { |
| 19 | 19 | */ |
| 20 | 20 | private Object content; |
| 21 | 21 | |
| 22 | - public ForestNode(String id, String parentId, Object content) { | |
| 22 | + public ForestNode(int id, String parentId, Object content) { | |
| 23 | 23 | this.id = id; |
| 24 | 24 | this.parentId = parentId; |
| 25 | 25 | this.content = content; | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/node/ForestNodeManager.java
| ... | ... | @@ -17,12 +17,12 @@ public class ForestNodeManager<T extends INode<T>> { |
| 17 | 17 | /** |
| 18 | 18 | * 森林的所有节点 |
| 19 | 19 | */ |
| 20 | - private final ImmutableMap<String, T> nodeMap; | |
| 20 | + private final ImmutableMap<Integer, T> nodeMap; | |
| 21 | 21 | |
| 22 | 22 | /** |
| 23 | 23 | * 森林的父节点ID |
| 24 | 24 | */ |
| 25 | - private final Map<String, Object> parentIdMap = Maps.newHashMap(); | |
| 25 | + private final Map<Integer, Object> parentIdMap = Maps.newHashMap(); | |
| 26 | 26 | |
| 27 | 27 | public ForestNodeManager(List<T> nodes) { |
| 28 | 28 | nodeMap = Maps.uniqueIndex(nodes, INode::getId); |
| ... | ... | @@ -46,7 +46,7 @@ public class ForestNodeManager<T extends INode<T>> { |
| 46 | 46 | * |
| 47 | 47 | * @param parentId 父节点ID |
| 48 | 48 | */ |
| 49 | - public void addParentId(String parentId) { | |
| 49 | + public void addParentId(int parentId) { | |
| 50 | 50 | parentIdMap.put(parentId, ""); |
| 51 | 51 | } |
| 52 | 52 | ... | ... |
src/main/java/com/genersoft/iot/vmp/utils/node/INode.java
src/main/java/com/genersoft/iot/vmp/vmanager/bean/DeviceChannelTree.java
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.media; |
| 2 | 2 | |
| 3 | 3 | import com.genersoft.iot.vmp.common.StreamInfo; |
| 4 | +import com.genersoft.iot.vmp.service.IMediaServerService; | |
| 4 | 5 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| 5 | 6 | import com.genersoft.iot.vmp.service.IMediaService; |
| 6 | 7 | import com.genersoft.iot.vmp.storager.IVideoManagerStorager; |
| ... | ... | @@ -9,6 +10,7 @@ import io.swagger.annotations.Api; |
| 9 | 10 | import io.swagger.annotations.ApiImplicitParam; |
| 10 | 11 | import io.swagger.annotations.ApiImplicitParams; |
| 11 | 12 | import io.swagger.annotations.ApiOperation; |
| 13 | +import org.apache.commons.lang3.StringUtils; | |
| 12 | 14 | import org.slf4j.Logger; |
| 13 | 15 | import org.slf4j.LoggerFactory; |
| 14 | 16 | import org.springframework.beans.factory.annotation.Autowired; |
| ... | ... | @@ -33,6 +35,9 @@ public class MediaController { |
| 33 | 35 | @Autowired |
| 34 | 36 | private IMediaService mediaService; |
| 35 | 37 | |
| 38 | + @Autowired | |
| 39 | + private IMediaServerService mediaServerService; | |
| 40 | + | |
| 36 | 41 | |
| 37 | 42 | /** |
| 38 | 43 | * 根据应用名和流id获取播放地址 | ... | ... |
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java
| 1 | 1 | package com.genersoft.iot.vmp.vmanager.gb28181.platform.bean; |
| 2 | 2 | |
| 3 | +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | |
| 4 | + | |
| 3 | 5 | /** |
| 4 | 6 | * 精简的channel信息展示,主要是选择通道的时候展示列表使用 |
| 5 | 7 | */ |
| 6 | 8 | public class ChannelReduce { |
| 7 | 9 | |
| 8 | 10 | /** |
| 11 | + * deviceChannel的数据库自增ID | |
| 12 | + */ | |
| 13 | + private int id; | |
| 14 | + | |
| 15 | + /** | |
| 9 | 16 | * 通道id |
| 10 | 17 | */ |
| 11 | 18 | private String channelId; |
| ... | ... | @@ -45,6 +52,13 @@ public class ChannelReduce { |
| 45 | 52 | */ |
| 46 | 53 | private String catalogId; |
| 47 | 54 | |
| 55 | + public int getId() { | |
| 56 | + return id; | |
| 57 | + } | |
| 58 | + | |
| 59 | + public void setId(int id) { | |
| 60 | + this.id = id; | |
| 61 | + } | |
| 48 | 62 | |
| 49 | 63 | public String getChannelId() { |
| 50 | 64 | return channelId; | ... | ... |
web_src/src/components/channelList.vue
| ... | ... | @@ -28,9 +28,7 @@ |
| 28 | 28 | <devicePlayer ref="devicePlayer" v-loading="isLoging"></devicePlayer> |
| 29 | 29 | <!--设备列表--> |
| 30 | 30 | <el-table ref="channelListTable" :data="deviceChannelList" :height="winHeight" border style="width: 100%"> |
| 31 | - <el-table-column prop="channelId" label="通道编号" width="210"> | |
| 32 | - </el-table-column> | |
| 33 | - <el-table-column prop="deviceId" label="设备编号" width="210"> | |
| 31 | + <el-table-column prop="channelId" label="通道编号" width="200"> | |
| 34 | 32 | </el-table-column> |
| 35 | 33 | <el-table-column prop="name" label="通道名称"> |
| 36 | 34 | </el-table-column> | ... | ... |