Commit a42dda2bd3cc1cf8c20cc61e7ad9211eadecbaf3
1 parent
2157bb02
规范数据库,添加必要约束,优化通道批量导入功能
Showing
13 changed files
with
204 additions
and
132 deletions
pom.xml
| ... | ... | @@ -231,6 +231,14 @@ |
| 231 | 231 | <!-- <version>1.0.8</version>--> |
| 232 | 232 | <!-- </dependency>--> |
| 233 | 233 | |
| 234 | + <!-- https://mvnrepository.com/artifact/com.google.guava/guava --> | |
| 235 | + <dependency> | |
| 236 | + <groupId>com.google.guava</groupId> | |
| 237 | + <artifactId>guava</artifactId> | |
| 238 | + <version>31.0.1-jre</version> | |
| 239 | + </dependency> | |
| 240 | + | |
| 241 | + | |
| 234 | 242 | <dependency> |
| 235 | 243 | <groupId>org.springframework.boot</groupId> |
| 236 | 244 | <artifactId>spring-boot-starter-test</artifactId> | ... | ... |
sql/mysql.sql
| ... | ... | @@ -53,7 +53,6 @@ CREATE TABLE `device` ( |
| 53 | 53 | |
| 54 | 54 | LOCK TABLES `device` WRITE; |
| 55 | 55 | /*!40000 ALTER TABLE `device` DISABLE KEYS */; |
| 56 | -INSERT INTO `device` VALUES (1,'34020000002000000005','DH-NVR5864-I','Dahua','DH-NVR5864-I','4.001.0000000.3,2020-10-22','UDP','UDP','1','2022-02-22 11:05:10','2022-02-22 11:42:10','192.168.1.19','2022-02-22 10:17:24','2022-02-22 11:42:10',5060,3600,0,'192.168.1.19:5060','gb2312'); | |
| 57 | 56 | /*!40000 ALTER TABLE `device` ENABLE KEYS */; |
| 58 | 57 | UNLOCK TABLES; |
| 59 | 58 | |
| ... | ... | @@ -126,7 +125,8 @@ CREATE TABLE `device_channel` ( |
| 126 | 125 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 127 | 126 | `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 128 | 127 | `subCount` int DEFAULT '0', |
| 129 | - PRIMARY KEY (`channelId`,`deviceId`) USING BTREE | |
| 128 | + PRIMARY KEY (`channelId`,`deviceId`) USING BTREE, | |
| 129 | + UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) | |
| 130 | 130 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; |
| 131 | 131 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 132 | 132 | |
| ... | ... | @@ -136,7 +136,6 @@ CREATE TABLE `device_channel` ( |
| 136 | 136 | |
| 137 | 137 | LOCK TABLES `device_channel` WRITE; |
| 138 | 138 | /*!40000 ALTER TABLE `device_channel` DISABLE KEYS */; |
| 139 | -INSERT INTO `device_channel` VALUES ('34020000001310000001','通道1','Dahua','DH-NVR5864-I','0','340200','','axy','34020000002000000005',0,1,'',0,0,NULL,'0','192.168.1.17',37777,'',0,1,0,0,NULL,'34020000002000000005','0',NULL,'','',0),('34020000001310000065','GB_Chn_065','Dahua','DH-NVR5864-I','0','340200','','axy','34020000002000000005',0,1,'',0,0,NULL,'0','',0,'',0,1,0,0,NULL,'34020000002000000005','0',NULL,'','',0); | |
| 140 | 139 | /*!40000 ALTER TABLE `device_channel` ENABLE KEYS */; |
| 141 | 140 | UNLOCK TABLES; |
| 142 | 141 | |
| ... | ... | @@ -183,7 +182,7 @@ DROP TABLE IF EXISTS `gb_stream`; |
| 183 | 182 | /*!40101 SET @saved_cs_client = @@character_set_client */; |
| 184 | 183 | /*!50503 SET character_set_client = utf8mb4 */; |
| 185 | 184 | CREATE TABLE `gb_stream` ( |
| 186 | - `id` int NOT NULL AUTO_INCREMENT, | |
| 185 | + `gbStreamId` int NOT NULL AUTO_INCREMENT, | |
| 187 | 186 | `app` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 188 | 187 | `stream` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 189 | 188 | `gbId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| ... | ... | @@ -194,10 +193,10 @@ CREATE TABLE `gb_stream` ( |
| 194 | 193 | `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 195 | 194 | `status` int DEFAULT NULL, |
| 196 | 195 | `createStamp` bigint DEFAULT NULL, |
| 197 | - PRIMARY KEY (`id`) USING BTREE, | |
| 196 | + PRIMARY KEY (`gbStreamId`) USING BTREE, | |
| 198 | 197 | UNIQUE KEY `app` (`app`,`stream`) USING BTREE, |
| 199 | 198 | UNIQUE KEY `gbId` (`gbId`) USING BTREE |
| 200 | -) ENGINE=InnoDB AUTO_INCREMENT=77 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 199 | +) ENGINE=InnoDB AUTO_INCREMENT=291 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 201 | 200 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 202 | 201 | |
| 203 | 202 | -- |
| ... | ... | @@ -206,7 +205,6 @@ CREATE TABLE `gb_stream` ( |
| 206 | 205 | |
| 207 | 206 | LOCK TABLES `gb_stream` WRITE; |
| 208 | 207 | /*!40000 ALTER TABLE `gb_stream` DISABLE KEYS */; |
| 209 | -INSERT INTO `gb_stream` VALUES (74,'1000','10000000_000','34020000002000000001','测试1',0,0,'push','FQ3TF8yT83wh5Wvz',0,1645500864142),(75,'1000','10000001_000','34020000012000000002','测试2',0,0,'push','FQ3TF8yT83wh5Wvz',0,1645500864142),(76,'1000','10000002_000','34020000022000000003','测试3',0,0,'push','FQ3TF8yT83wh5Wvz',0,1645500864142); | |
| 210 | 208 | /*!40000 ALTER TABLE `gb_stream` ENABLE KEYS */; |
| 211 | 209 | UNLOCK TABLES; |
| 212 | 210 | |
| ... | ... | @@ -228,7 +226,7 @@ CREATE TABLE `log` ( |
| 228 | 226 | `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 229 | 227 | `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 230 | 228 | PRIMARY KEY (`id`) USING BTREE |
| 231 | -) ENGINE=InnoDB AUTO_INCREMENT=206 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 229 | +) ENGINE=InnoDB AUTO_INCREMENT=245 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 232 | 230 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 233 | 231 | |
| 234 | 232 | -- |
| ... | ... | @@ -237,7 +235,6 @@ CREATE TABLE `log` ( |
| 237 | 235 | |
| 238 | 236 | LOCK TABLES `log` WRITE; |
| 239 | 237 | /*!40000 ALTER TABLE `log` DISABLE KEYS */; |
| 240 | -INSERT INTO `log` VALUES (163,'登录','GET','/api/user/login','127.0.0.1','200 OK',243,'admin','2022-02-22 10:18:15'),(164,'开始点播','GET','/api/play/start/34020000002000000005/34020000001310000001','127.0.0.1','200 OK',77,'admin','2022-02-22 10:18:35'),(165,'[设备查询] 同步设备通道','POST','/api/device/query/devices/34020000002000000005/sync','127.0.0.1','200 OK',10,'admin','2022-02-22 10:18:47'),(166,'开始点播','GET','/api/play/start/34020000002000000005/34020000001310000065','127.0.0.1','200 OK',19,'admin','2022-02-22 10:18:50'),(167,'停止点播','GET','/api/play/stop/34020000002000000005/34020000001310000065','127.0.0.1','200 OK',159,'admin','2022-02-22 10:19:08'),(168,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',305,'admin','2022-02-22 10:22:02'),(169,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',142,'admin','2022-02-22 10:22:28'),(170,'添加上级平台','POST','/api/platform/save','127.0.0.1','200 OK',11,'admin','2022-02-22 10:22:57'),(171,'登录','GET','/api/user/login','127.0.0.1','200 OK',255,'admin','2022-02-22 10:26:31'),(172,'移除代理','DELETE','/api/proxy/del','127.0.0.1','200 OK',40,'admin','2022-02-22 10:26:44'),(173,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',139,'admin','2022-02-22 10:26:51'),(174,'登录','GET','/api/user/login','127.0.0.1','200 OK',657,'admin','2022-02-22 10:28:21'),(175,'登录','GET','/api/user/login','127.0.0.1','200 OK',302,'admin','2022-02-22 11:04:24'),(176,'移除代理','DELETE','/api/proxy/del','127.0.0.1','200 OK',33,'admin','2022-02-22 11:04:34'),(177,'移除代理','DELETE','/api/proxy/del','127.0.0.1','200 OK',17,'admin','2022-02-22 11:04:35'),(178,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',186,'admin','2022-02-22 11:04:44'),(179,'登录','GET','/api/user/login','127.0.0.1','200 OK',258,'admin','2022-02-22 11:05:05'),(180,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',97,'admin','2022-02-22 11:05:51'),(181,'登录','GET','/api/user/login','127.0.0.1','200 OK',300,'admin','2022-02-22 11:11:30'),(182,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',145,'admin','2022-02-22 11:12:00'),(183,'登录','GET','/api/user/login','127.0.0.1','200 OK',264,'admin','2022-02-22 11:12:42'),(184,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',41793,'admin','2022-02-22 11:13:42'),(185,'登录','GET','/api/user/login','127.0.0.1','200 OK',245,'admin','2022-02-22 11:13:58'),(186,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',86,'admin','2022-02-22 11:14:11'),(187,'登录','GET','/api/user/login','127.0.0.1','200 OK',293,'admin','2022-02-22 11:31:52'),(188,'向上级平台添加国标通道','POST','/api/platform/update_channel_for_gb','127.0.0.1','200 OK',14,'admin','2022-02-22 11:34:55'),(189,'向上级平台添加国标通道','POST','/api/platform/update_channel_for_gb','127.0.0.1','200 OK',11,'admin','2022-02-22 11:35:02'),(190,'保存代理','POST','/api/proxy/save','127.0.0.1','200 OK',16,'admin','2022-02-22 11:37:00'),(191,'登录','GET','/api/user/login','127.0.0.1','200 OK',340,'admin','2022-02-22 11:38:15'),(192,'停用代理','GET','/api/proxy/stop','127.0.0.1','200 OK',16,'admin','2022-02-22 11:38:20'),(193,'停用代理','GET','/api/proxy/stop','127.0.0.1','200 OK',10,'admin','2022-02-22 11:38:28'),(194,'登录','GET','/api/user/login','127.0.0.1','200 OK',288,'admin','2022-02-22 11:39:34'),(195,'停用代理','GET','/api/proxy/stop','127.0.0.1','200 OK',29,'admin','2022-02-22 11:39:36'),(196,'启用代理','GET','/api/proxy/start','127.0.0.1','200 OK',594,'admin','2022-02-22 11:39:38'),(197,'停用代理','GET','/api/proxy/stop','127.0.0.1','200 OK',16,'admin','2022-02-22 11:39:43'),(198,'停用代理','GET','/api/proxy/stop','127.0.0.1','200 OK',27,'admin','2022-02-22 11:41:30'),(199,'停用代理','GET','/api/proxy/stop','127.0.0.1','200 OK',17,'admin','2022-02-22 11:41:42'),(200,'启用代理','GET','/api/proxy/start','127.0.0.1','200 OK',9,'admin','2022-02-22 11:41:44'),(201,'启用代理','GET','/api/proxy/start','127.0.0.1','200 OK',6,'admin','2022-02-22 11:41:47'),(202,'启用代理','GET','/api/proxy/start','127.0.0.1','200 OK',67,'admin','2022-02-22 11:41:48'),(203,'移除代理','DELETE','/api/proxy/del','127.0.0.1','200 OK',14,'admin','2022-02-22 11:41:51'),(204,'移除代理','DELETE','/api/proxy/del','127.0.0.1','200 OK',16,'admin','2022-02-22 11:41:52'),(205,'移除代理','DELETE','/api/proxy/del','127.0.0.1','200 OK',14,'admin','2022-02-22 11:41:53'); | |
| 241 | 238 | /*!40000 ALTER TABLE `log` ENABLE KEYS */; |
| 242 | 239 | UNLOCK TABLES; |
| 243 | 240 | |
| ... | ... | @@ -283,7 +280,6 @@ CREATE TABLE `media_server` ( |
| 283 | 280 | |
| 284 | 281 | LOCK TABLES `media_server` WRITE; |
| 285 | 282 | /*!40000 ALTER TABLE `media_server` DISABLE KEYS */; |
| 286 | -INSERT INTO `media_server` VALUES ('FQ3TF8yT83wh5Wvz','192.168.1.3','192.168.1.3','192.168.1.3','192.168.1.3',6080,0,10935,0,10000,10554,0,1,'035c73f7-bb6b-4889-a715-d9eb2d1925cc',18000,1,'30000,30500','30000,30500',18081,1,'2022-02-22 11:39:33','2022-02-22 11:39:33',30); | |
| 287 | 283 | /*!40000 ALTER TABLE `media_server` ENABLE KEYS */; |
| 288 | 284 | UNLOCK TABLES; |
| 289 | 285 | |
| ... | ... | @@ -316,8 +312,10 @@ CREATE TABLE `parent_platform` ( |
| 316 | 312 | `rtcp` int DEFAULT NULL, |
| 317 | 313 | `status` bit(1) DEFAULT NULL, |
| 318 | 314 | `shareAllLiveStream` int DEFAULT NULL, |
| 319 | - PRIMARY KEY (`id`,`serverGBId`) USING BTREE | |
| 320 | -) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 315 | + PRIMARY KEY (`id`), | |
| 316 | + UNIQUE KEY `parent_platform_id_uindex` (`id`), | |
| 317 | + UNIQUE KEY `parent_platform_pk` (`serverGBId`) | |
| 318 | +) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 321 | 319 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 322 | 320 | |
| 323 | 321 | -- |
| ... | ... | @@ -326,7 +324,6 @@ CREATE TABLE `parent_platform` ( |
| 326 | 324 | |
| 327 | 325 | LOCK TABLES `parent_platform` WRITE; |
| 328 | 326 | /*!40000 ALTER TABLE `parent_platform` DISABLE KEYS */; |
| 329 | -INSERT INTO `parent_platform` VALUES (4,0,'11111','111111111111111','1111111111','11.111.11.11',2342,'34020000013000000001','192.168.1.3','15060','34020000013000000001','12345678','300','60','UDP','GB2312','111111111111111',1,0,_binary '\0',0),(5,0,'2222','222222222222222','2222222222','222.22.2.2',2222,'34020000013000000001','192.168.1.3','15060','34020000013000000001','12345678','300','60','UDP','GB2312','222222222222222',1,0,_binary '\0',0); | |
| 330 | 327 | /*!40000 ALTER TABLE `parent_platform` ENABLE KEYS */; |
| 331 | 328 | UNLOCK TABLES; |
| 332 | 329 | |
| ... | ... | @@ -379,7 +376,6 @@ CREATE TABLE `platform_gb_channel` ( |
| 379 | 376 | |
| 380 | 377 | LOCK TABLES `platform_gb_channel` WRITE; |
| 381 | 378 | /*!40000 ALTER TABLE `platform_gb_channel` DISABLE KEYS */; |
| 382 | -INSERT INTO `platform_gb_channel` VALUES (1,'34020000001310000001','34020000002000000005','111111111111111','34020000002000000005_34020000001310000001','111111111111111'),(2,'34020000001310000065','34020000002000000005','222222222222222','34020000002000000005_34020000001310000065','222222222222222'); | |
| 383 | 379 | /*!40000 ALTER TABLE `platform_gb_channel` ENABLE KEYS */; |
| 384 | 380 | UNLOCK TABLES; |
| 385 | 381 | |
| ... | ... | @@ -395,8 +391,9 @@ CREATE TABLE `platform_gb_stream` ( |
| 395 | 391 | `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, |
| 396 | 392 | `gbStreamId` int NOT NULL, |
| 397 | 393 | `id` int NOT NULL AUTO_INCREMENT, |
| 398 | - PRIMARY KEY (`id`) | |
| 399 | -) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; | |
| 394 | + PRIMARY KEY (`id`), | |
| 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; | |
| 400 | 397 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 401 | 398 | |
| 402 | 399 | -- |
| ... | ... | @@ -405,7 +402,6 @@ CREATE TABLE `platform_gb_stream` ( |
| 405 | 402 | |
| 406 | 403 | LOCK TABLES `platform_gb_stream` WRITE; |
| 407 | 404 | /*!40000 ALTER TABLE `platform_gb_stream` DISABLE KEYS */; |
| 408 | -INSERT INTO `platform_gb_stream` VALUES ('111111111111111','111111111111111',70,35),('111111111111111','111111111111111',71,36),('111111111111111','111111111111111',72,37),('222222222222222','222222222222222',73,38),('111111111111111','111111111111111',74,39),('111111111111111','111111111111111',75,40),('111111111111111','111111111111111',76,41); | |
| 409 | 405 | /*!40000 ALTER TABLE `platform_gb_stream` ENABLE KEYS */; |
| 410 | 406 | UNLOCK TABLES; |
| 411 | 407 | |
| ... | ... | @@ -434,7 +430,8 @@ CREATE TABLE `stream_proxy` ( |
| 434 | 430 | `status` bit(1) NOT NULL, |
| 435 | 431 | `enable_remove_none_reader` bit(1) NOT NULL, |
| 436 | 432 | `createTime` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, |
| 437 | - PRIMARY KEY (`id`) | |
| 433 | + PRIMARY KEY (`id`), | |
| 434 | + UNIQUE KEY `stream_proxy_pk` (`app`,`stream`) | |
| 438 | 435 | ) ENGINE=InnoDB AUTO_INCREMENT=7 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; |
| 439 | 436 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 440 | 437 | |
| ... | ... | @@ -466,7 +463,7 @@ CREATE TABLE `stream_push` ( |
| 466 | 463 | `mediaServerId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, |
| 467 | 464 | PRIMARY KEY (`id`), |
| 468 | 465 | UNIQUE KEY `stream_push_pk` (`app`,`stream`) |
| 469 | -) ENGINE=InnoDB AUTO_INCREMENT=16 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 466 | +) ENGINE=InnoDB AUTO_INCREMENT=310 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci; | |
| 470 | 467 | /*!40101 SET character_set_client = @saved_cs_client */; |
| 471 | 468 | |
| 472 | 469 | -- |
| ... | ... | @@ -475,7 +472,6 @@ CREATE TABLE `stream_push` ( |
| 475 | 472 | |
| 476 | 473 | LOCK TABLES `stream_push` WRITE; |
| 477 | 474 | /*!40000 ALTER TABLE `stream_push` DISABLE KEYS */; |
| 478 | -INSERT INTO `stream_push` VALUES (13,'1000','10000000_000','0',2,'rtsp_push',1645500864142,NULL,'FQ3TF8yT83wh5Wvz'),(14,'1000','10000001_000','0',2,'rtsp_push',1645500864142,NULL,'FQ3TF8yT83wh5Wvz'),(15,'1000','10000002_000','0',2,'rtsp_push',1645500864142,NULL,'FQ3TF8yT83wh5Wvz'); | |
| 479 | 475 | /*!40000 ALTER TABLE `stream_push` ENABLE KEYS */; |
| 480 | 476 | UNLOCK TABLES; |
| 481 | 477 | |
| ... | ... | @@ -544,4 +540,4 @@ UNLOCK TABLES; |
| 544 | 540 | /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; |
| 545 | 541 | /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; |
| 546 | 542 | |
| 547 | --- Dump completed on 2022-02-22 11:43:00 | |
| 543 | +-- Dump completed on 2022-02-24 16:52:12 | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/GbStream.java
| ... | ... | @@ -5,7 +5,7 @@ package com.genersoft.iot.vmp.gb28181.bean; |
| 5 | 5 | */ |
| 6 | 6 | public class GbStream extends PlatformGbStream{ |
| 7 | 7 | |
| 8 | - private int id; | |
| 8 | + private Integer gbStreamId; | |
| 9 | 9 | private String app; |
| 10 | 10 | private String stream; |
| 11 | 11 | private String gbId; |
| ... | ... | @@ -20,12 +20,13 @@ public class GbStream extends PlatformGbStream{ |
| 20 | 20 | */ |
| 21 | 21 | public Long createStamp; |
| 22 | 22 | |
| 23 | - public int getId() { | |
| 24 | - return id; | |
| 23 | + @Override | |
| 24 | + public Integer getGbStreamId() { | |
| 25 | + return gbStreamId; | |
| 25 | 26 | } |
| 26 | 27 | |
| 27 | - public void setId(int id) { | |
| 28 | - this.id = id; | |
| 28 | + public void setGbStreamId(Integer gbStreamId) { | |
| 29 | + this.gbStreamId = gbStreamId; | |
| 29 | 30 | } |
| 30 | 31 | |
| 31 | 32 | public String getApp() { | ... | ... |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java
| 1 | 1 | package com.genersoft.iot.vmp.gb28181.bean; |
| 2 | 2 | |
| 3 | 3 | public class PlatformGbStream { |
| 4 | - private String gbStreamId; | |
| 4 | + private Integer gbStreamId; | |
| 5 | 5 | private String platformId; |
| 6 | 6 | private String catalogId; |
| 7 | 7 | |
| 8 | - public String getGbStreamId() { | |
| 8 | + public Integer getGbStreamId() { | |
| 9 | 9 | return gbStreamId; |
| 10 | 10 | } |
| 11 | 11 | |
| 12 | - public void setGbStreamId(String gbStreamId) { | |
| 12 | + public void setGbStreamId(Integer gbStreamId) { | |
| 13 | 13 | this.gbStreamId = gbStreamId; |
| 14 | 14 | } |
| 15 | 15 | ... | ... |
src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java
| ... | ... | @@ -9,6 +9,11 @@ import java.util.List; |
| 9 | 9 | public class StreamPushItem extends GbStream implements Comparable<StreamPushItem>{ |
| 10 | 10 | |
| 11 | 11 | /** |
| 12 | + * id | |
| 13 | + */ | |
| 14 | + private Integer id; | |
| 15 | + | |
| 16 | + /** | |
| 12 | 17 | * 应用名 |
| 13 | 18 | */ |
| 14 | 19 | private String app; |
| ... | ... | @@ -111,6 +116,13 @@ public class StreamPushItem extends GbStream implements Comparable<StreamPushIte |
| 111 | 116 | } |
| 112 | 117 | } |
| 113 | 118 | |
| 119 | + public Integer getId() { | |
| 120 | + return id; | |
| 121 | + } | |
| 122 | + | |
| 123 | + public void setId(Integer id) { | |
| 124 | + this.id = id; | |
| 125 | + } | |
| 114 | 126 | |
| 115 | 127 | public String getApp() { |
| 116 | 128 | return app; | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java
| ... | ... | @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; |
| 9 | 9 | import com.github.pagehelper.PageInfo; |
| 10 | 10 | |
| 11 | 11 | import java.util.List; |
| 12 | +import java.util.Map; | |
| 12 | 13 | |
| 13 | 14 | public interface IStreamPushService { |
| 14 | 15 | |
| ... | ... | @@ -69,5 +70,5 @@ public interface IStreamPushService { |
| 69 | 70 | |
| 70 | 71 | boolean batchStop(List<GbStream> streamPushItems); |
| 71 | 72 | |
| 72 | - void batchAddForUpload(String platformId, String catalogId, List<StreamPushItem> streamPushItems); | |
| 73 | + void batchAddForUpload(List<StreamPushItem> streamPushItems, Map<String, List<String[]>> streamPushItemsForAll); | |
| 73 | 74 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
| ... | ... | @@ -159,7 +159,9 @@ public class GbStreamServiceImpl implements IGbStreamService { |
| 159 | 159 | List<ParentPlatform> parentPlatforms = platformGbStreamMapper.selectByAppAndStream(gs.getApp(), gs.getStream()); |
| 160 | 160 | if (parentPlatforms.size() > 0) { |
| 161 | 161 | for (ParentPlatform parentPlatform : parentPlatforms) { |
| 162 | - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type); | |
| 162 | + if (parentPlatform != null) { | |
| 163 | + eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), gs, type); | |
| 164 | + } | |
| 163 | 165 | } |
| 164 | 166 | } |
| 165 | 167 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
| ... | ... | @@ -28,6 +28,7 @@ import org.springframework.stereotype.Service; |
| 28 | 28 | import org.springframework.util.StringUtils; |
| 29 | 29 | |
| 30 | 30 | import java.util.*; |
| 31 | +import java.util.stream.Collectors; | |
| 31 | 32 | |
| 32 | 33 | @Service |
| 33 | 34 | public class StreamPushServiceImpl implements IStreamPushService { |
| ... | ... | @@ -359,23 +360,63 @@ public class StreamPushServiceImpl implements IStreamPushService { |
| 359 | 360 | } |
| 360 | 361 | |
| 361 | 362 | @Override |
| 362 | - public void batchAddForUpload(String platformId, String catalogId, List<StreamPushItem> streamPushItems) { | |
| 363 | + public void batchAddForUpload(List<StreamPushItem> streamPushItems, Map<String, List<String[]>> streamPushItemsForAll ) { | |
| 364 | + // 存储数据到stream_push表 | |
| 363 | 365 | streamPushMapper.addAll(streamPushItems); |
| 364 | - gbStreamMapper.batchAdd(streamPushItems); | |
| 365 | - if (platformId != null) { | |
| 366 | - ParentPlatform platform = parentPlatformMapper.getParentPlatByServerGBId(platformId); | |
| 367 | - if (platform != null) { | |
| 368 | - if (catalogId == null) { | |
| 369 | - catalogId = platform.getCatalogId(); | |
| 370 | - }else { | |
| 371 | - PlatformCatalog catalog = platformCatalogMapper.select(catalogId); | |
| 372 | - if (catalog == null) { | |
| 373 | - return; | |
| 366 | + List<StreamPushItem> streamPushItemForGbStream = streamPushItems.stream() | |
| 367 | + .filter(streamPushItem-> streamPushItem.getId() != null) | |
| 368 | + .collect(Collectors.toList()); | |
| 369 | + // 存储数据到gb_stream表, id会返回到streamPushItemForGbStream里 | |
| 370 | + if (streamPushItemForGbStream.size() > 0) { | |
| 371 | + gbStreamMapper.batchAdd(streamPushItemForGbStream); | |
| 372 | + } | |
| 373 | + // 去除没有ID也就是没有存储到数据库的数据 | |
| 374 | + List<StreamPushItem> streamPushItemsForPlatform = streamPushItemForGbStream.stream() | |
| 375 | + .filter(streamPushItem-> streamPushItem.getGbStreamId() != null) | |
| 376 | + .collect(Collectors.toList()); | |
| 377 | + | |
| 378 | + if (streamPushItemsForPlatform.size() > 0) { | |
| 379 | + List<StreamPushItem> streamPushItemListFroPlatform = new ArrayList<>(); | |
| 380 | + Map<String, List<StreamPushItem>> platformForEvent = new HashMap<>(); | |
| 381 | + // 遍历存储结果,查找app+Stream->platformId+catalogId的对应关系,然后执行批量写入 | |
| 382 | + for (StreamPushItem streamPushItem : streamPushItemsForPlatform) { | |
| 383 | + List<String[]> platFormInfoList = streamPushItemsForAll.get(streamPushItem.getApp() + streamPushItem.getStream()); | |
| 384 | + if (platFormInfoList != null) { | |
| 385 | + if (platFormInfoList.size() > 0) { | |
| 386 | + for (String[] platFormInfoArray : platFormInfoList) { | |
| 387 | + StreamPushItem streamPushItemForPlatform = new StreamPushItem(); | |
| 388 | + streamPushItemForPlatform.setGbStreamId(streamPushItem.getGbStreamId()); | |
| 389 | + if (platFormInfoArray.length > 0) { | |
| 390 | + // 数组 platFormInfoArray 0 为平台ID。 1为目录ID | |
| 391 | + streamPushItemForPlatform.setPlatformId(platFormInfoArray[0]); | |
| 392 | + | |
| 393 | + List<StreamPushItem> streamPushItemsInPlatform = platformForEvent.get(streamPushItem.getPlatformId()); | |
| 394 | + if (streamPushItemsInPlatform == null) { | |
| 395 | + streamPushItemsInPlatform = new ArrayList<>(); | |
| 396 | + platformForEvent.put(platFormInfoArray[0], streamPushItemsInPlatform); | |
| 397 | + } | |
| 398 | + // 为发送通知整理数据 | |
| 399 | + streamPushItemForPlatform.setApp(streamPushItem.getApp()); | |
| 400 | + streamPushItemForPlatform.setStream(streamPushItem.getStream()); | |
| 401 | + streamPushItemForPlatform.setGbId(streamPushItem.getGbId()); | |
| 402 | + streamPushItemsInPlatform.add(streamPushItemForPlatform); | |
| 403 | + } | |
| 404 | + if (platFormInfoArray.length > 1) { | |
| 405 | + streamPushItemForPlatform.setCatalogId(platFormInfoArray[1]); | |
| 406 | + } | |
| 407 | + streamPushItemListFroPlatform.add(streamPushItemForPlatform); | |
| 408 | + | |
| 409 | + | |
| 410 | + } | |
| 374 | 411 | } |
| 412 | + | |
| 375 | 413 | } |
| 376 | - List<GbStream> gbStreamList = gbStreamMapper.selectAllForAppAndStream(streamPushItems); | |
| 377 | - platformGbStreamMapper.batchAdd(platformId, catalogId, gbStreamList); | |
| 378 | - eventPublisher.catalogEventPublishForStream(platformId, streamPushItems.toArray(new GbStream[0]), CatalogEvent.ADD); | |
| 414 | + } | |
| 415 | + platformGbStreamMapper.batchAdd(streamPushItemListFroPlatform); | |
| 416 | + // 发送通知 | |
| 417 | + for (String platformId : platformForEvent.keySet()) { | |
| 418 | + eventPublisher.catalogEventPublishForStream( | |
| 419 | + platformId, platformForEvent.get(platformId).toArray(new GbStream[0]), CatalogEvent.ADD); | |
| 379 | 420 | } |
| 380 | 421 | } |
| 381 | 422 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
| ... | ... | @@ -5,21 +5,45 @@ import com.alibaba.excel.event.AnalysisEventListener; |
| 5 | 5 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 6 | 6 | import com.genersoft.iot.vmp.service.IStreamPushService; |
| 7 | 7 | import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; |
| 8 | +import com.google.common.collect.BiMap; | |
| 9 | +import com.google.common.collect.HashBiMap; | |
| 8 | 10 | import org.springframework.util.StringUtils; |
| 9 | 11 | |
| 10 | 12 | import java.util.*; |
| 11 | 13 | |
| 12 | 14 | public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> { |
| 13 | 15 | |
| 16 | + // 错误数据的回调,用于将错误数据发送给页面 | |
| 14 | 17 | private ErrorDataHandler errorDataHandler; |
| 18 | + | |
| 19 | + // 推流的业务类用于存储数据 | |
| 15 | 20 | private IStreamPushService pushService; |
| 21 | + | |
| 22 | + // 默认流媒体节点ID | |
| 16 | 23 | private String defaultMediaServerId; |
| 24 | + | |
| 25 | + // 用于存储不加过滤的所有数据 | |
| 17 | 26 | private List<StreamPushItem> streamPushItems = new ArrayList<>(); |
| 18 | - private Map<String, UploadData> streamPushItemsForPlatform = new HashMap<>(); | |
| 27 | + | |
| 28 | + // 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表 | |
| 29 | + private Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>(); | |
| 30 | + | |
| 31 | + // 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表 | |
| 32 | + private Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>(); | |
| 33 | + | |
| 34 | + // 用于判断文件是否存在重复的app+Stream+平台ID | |
| 19 | 35 | private Set<String> streamPushStreamSet = new HashSet<>(); |
| 20 | - private Map<String,String> streamPushGBMap = new HashMap<>(); | |
| 36 | + | |
| 37 | + // 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应,全局判断APP+Stream->国标ID是否存在不对应 | |
| 38 | + private BiMap<String,String> gBMap = HashBiMap.create(); | |
| 39 | + | |
| 40 | + // 记录错误的APP+Stream | |
| 21 | 41 | private List<String> errorStreamList = new ArrayList<>(); |
| 42 | + | |
| 43 | + | |
| 44 | + // 记录错误的国标ID | |
| 22 | 45 | private List<String> errorGBList = new ArrayList<>(); |
| 46 | + | |
| 23 | 47 | // 读取数量计数器 |
| 24 | 48 | private int loadedSize = 0; |
| 25 | 49 | |
| ... | ... | @@ -33,16 +57,6 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 33 | 57 | void handle(List<String> streams, List<String> gbId); |
| 34 | 58 | } |
| 35 | 59 | |
| 36 | - private class UploadData{ | |
| 37 | - public String platformId; | |
| 38 | - public Map<String, List<StreamPushItem>> catalogData = new HashMap<>(); | |
| 39 | - public List<StreamPushItem> streamPushItems = new ArrayList<>(); | |
| 40 | - | |
| 41 | - public UploadData(String platformId) { | |
| 42 | - this.platformId = platformId; | |
| 43 | - } | |
| 44 | - } | |
| 45 | - | |
| 46 | 60 | @Override |
| 47 | 61 | public void invoke(StreamPushExcelDto streamPushExcelDto, AnalysisContext analysisContext) { |
| 48 | 62 | if (StringUtils.isEmpty(streamPushExcelDto.getApp()) |
| ... | ... | @@ -50,18 +64,28 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 50 | 64 | || StringUtils.isEmpty(streamPushExcelDto.getGbId())) { |
| 51 | 65 | return; |
| 52 | 66 | } |
| 53 | - if (streamPushGBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()) == null) { | |
| 54 | - streamPushGBMap.put(streamPushExcelDto.getApp() + streamPushExcelDto.getStream(), streamPushExcelDto.getGbId()); | |
| 55 | 67 | |
| 68 | + if (gBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()) == null) { | |
| 69 | + try { | |
| 70 | + gBMap.put(streamPushExcelDto.getApp() + streamPushExcelDto.getStream(), streamPushExcelDto.getGbId()); | |
| 71 | + }catch (IllegalArgumentException e) { | |
| 72 | + e.printStackTrace(); | |
| 73 | + errorGBList.add(streamPushExcelDto.getGbId() + "(不同的app+stream使用了相同的国标ID)"); | |
| 74 | + return; | |
| 75 | + } | |
| 56 | 76 | }else { |
| 57 | - if (!streamPushGBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()).equals(streamPushExcelDto.getGbId())) { | |
| 58 | - errorGBList.add(streamPushExcelDto.getGbId() + "(同一组app+stream使用了不同国标ID)"); | |
| 77 | + if (!gBMap.get(streamPushExcelDto.getApp() + streamPushExcelDto.getStream()).equals(streamPushExcelDto.getGbId())) { | |
| 78 | + errorGBList.add(streamPushExcelDto.getGbId() + "(同一组app+stream使用了不同的国标ID)"); | |
| 59 | 79 | return; |
| 60 | 80 | } |
| 61 | 81 | } |
| 82 | + | |
| 62 | 83 | if (streamPushStreamSet.contains(streamPushExcelDto.getApp() + streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId())) { |
| 63 | - errorStreamList.add(streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ "/" + streamPushExcelDto.getPlatformId() + "(同一组app+stream添加在了同一个平台下)"); | |
| 84 | + errorStreamList.add(streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream()+ "/" + | |
| 85 | + streamPushExcelDto.getPlatformId() + "(同一组app+stream添加在了同一个平台下)"); | |
| 64 | 86 | return; |
| 87 | + }else { | |
| 88 | + streamPushStreamSet.add(streamPushExcelDto.getApp()+streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId()); | |
| 65 | 89 | } |
| 66 | 90 | |
| 67 | 91 | StreamPushItem streamPushItem = new StreamPushItem(); |
| ... | ... | @@ -78,32 +102,31 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 78 | 102 | streamPushItem.setTotalReaderCount("0"); |
| 79 | 103 | streamPushItem.setPlatformId(streamPushExcelDto.getPlatformId()); |
| 80 | 104 | streamPushItem.setCatalogId(streamPushExcelDto.getCatalogId()); |
| 81 | - if (StringUtils.isEmpty(streamPushExcelDto.getPlatformId())) { | |
| 82 | - streamPushItems.add(streamPushItem); | |
| 83 | - }else { | |
| 84 | - UploadData uploadData = streamPushItemsForPlatform.get(streamPushExcelDto.getPlatformId()); | |
| 85 | - if (uploadData == null) { | |
| 86 | - uploadData = new UploadData(streamPushExcelDto.getPlatformId()); | |
| 87 | - streamPushItemsForPlatform.put(streamPushExcelDto.getPlatformId(), uploadData); | |
| 105 | + | |
| 106 | + // 存入所有的通道信息 | |
| 107 | + streamPushItems.add(streamPushItem); | |
| 108 | + streamPushItemForSave.put(streamPushItem.getApp() + streamPushItem.getStream(), streamPushItem); | |
| 109 | + | |
| 110 | + if (!StringUtils.isEmpty(streamPushExcelDto.getPlatformId())) { | |
| 111 | + List<String[]> platformList = streamPushItemsForPlatform.get(streamPushItem.getApp() + streamPushItem.getStream()); | |
| 112 | + if (platformList == null) { | |
| 113 | + platformList = new ArrayList<>(); | |
| 114 | + streamPushItemsForPlatform.put(streamPushItem.getApp() + streamPushItem.getStream(), platformList); | |
| 88 | 115 | } |
| 89 | - if (!StringUtils.isEmpty(streamPushExcelDto.getCatalogId())) { | |
| 90 | - List<StreamPushItem> streamPushItems = uploadData.catalogData.get(streamPushExcelDto.getCatalogId()); | |
| 91 | - if (streamPushItems == null) { | |
| 92 | - streamPushItems = new ArrayList<>(); | |
| 93 | - uploadData.catalogData.put(streamPushExcelDto.getCatalogId(), streamPushItems); | |
| 94 | - } | |
| 95 | - streamPushItems.add(streamPushItem); | |
| 96 | - }else { | |
| 97 | - uploadData.streamPushItems.add(streamPushItem); | |
| 116 | + String platformId = streamPushExcelDto.getPlatformId(); | |
| 117 | + String catalogId = streamPushExcelDto.getCatalogId(); | |
| 118 | + if (StringUtils.isEmpty(streamPushExcelDto.getCatalogId())) { | |
| 119 | + catalogId = null; | |
| 98 | 120 | } |
| 99 | - | |
| 121 | + String[] platFormInfoArray = new String[]{platformId, catalogId}; | |
| 122 | + platformList.add(platFormInfoArray); | |
| 100 | 123 | } |
| 101 | 124 | |
| 102 | - streamPushStreamSet.add(streamPushExcelDto.getApp()+streamPushExcelDto.getStream() + streamPushExcelDto.getPlatformId()); | |
| 103 | 125 | loadedSize ++; |
| 104 | 126 | if (loadedSize > 1000) { |
| 105 | 127 | saveData(); |
| 106 | 128 | streamPushItems.clear(); |
| 129 | + streamPushItemForSave.clear(); | |
| 107 | 130 | streamPushItemsForPlatform.clear(); |
| 108 | 131 | loadedSize = 0; |
| 109 | 132 | } |
| ... | ... | @@ -114,30 +137,18 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus |
| 114 | 137 | public void doAfterAllAnalysed(AnalysisContext analysisContext) { |
| 115 | 138 | // 这里也要保存数据,确保最后遗留的数据也存储到数据库 |
| 116 | 139 | saveData(); |
| 117 | - streamPushGBMap.clear(); | |
| 140 | + streamPushItems.clear(); | |
| 141 | + streamPushItemForSave.clear(); | |
| 142 | + gBMap.clear(); | |
| 118 | 143 | streamPushStreamSet.clear(); |
| 144 | + streamPushItemsForPlatform.clear(); | |
| 119 | 145 | errorDataHandler.handle(errorStreamList, errorGBList); |
| 120 | 146 | } |
| 121 | 147 | |
| 122 | 148 | private void saveData(){ |
| 123 | - if (streamPushItems.size() > 0) { | |
| 124 | - pushService.batchAddForUpload(null, null, streamPushItems); | |
| 125 | - } | |
| 126 | - // 处理已分配到平台的流 | |
| 127 | - if (streamPushItemsForPlatform.size() > 0){ | |
| 128 | - for (String platformId : streamPushItemsForPlatform.keySet()) { | |
| 129 | - UploadData uploadData = streamPushItemsForPlatform.get(platformId); | |
| 130 | - if (uploadData.streamPushItems.size() > 0) { | |
| 131 | - pushService.batchAddForUpload(platformId, null, uploadData.streamPushItems); | |
| 132 | - } | |
| 133 | - if (uploadData.catalogData.size() > 0) { | |
| 134 | - for (String catalogId : uploadData.catalogData.keySet()) { | |
| 135 | - if (uploadData.catalogData.get(catalogId).size() > 0) { | |
| 136 | - pushService.batchAddForUpload(platformId, catalogId, uploadData.catalogData.get(catalogId)); | |
| 137 | - } | |
| 138 | - } | |
| 139 | - } | |
| 140 | - } | |
| 149 | + if (streamPushItemForSave.size() > 0) { | |
| 150 | + // 向数据库查询是否存在重复的app | |
| 151 | + pushService.batchAddForUpload(new ArrayList<>(streamPushItemForSave.values()), streamPushItemsForPlatform); | |
| 141 | 152 | } |
| 142 | 153 | } |
| 143 | 154 | } | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
| ... | ... | @@ -41,15 +41,15 @@ public interface GbStreamMapper { |
| 41 | 41 | "SELECT gs.* FROM gb_stream gs " + |
| 42 | 42 | "WHERE " + |
| 43 | 43 | "1=1 " + |
| 44 | - " <if test='catalogId != null'> AND gs.id in" + | |
| 44 | + " <if test='catalogId != null'> AND gs.gbStreamId in" + | |
| 45 | 45 | "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId} and pgs.catalogId=#{catalogId})</if> " + |
| 46 | - " <if test='catalogId == null'> AND gs.id not in" + | |
| 46 | + " <if test='catalogId == null'> AND gs.gbStreamId not in" + | |
| 47 | 47 | "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " + |
| 48 | 48 | " <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " + |
| 49 | 49 | " <if test='pushing == true' > AND gs.status=1</if>" + |
| 50 | 50 | " <if test='pushing == false' > AND gs.status=0</if>" + |
| 51 | 51 | " <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" + |
| 52 | - " order by gs.id asc " + | |
| 52 | + " order by gs.gbStreamId asc " + | |
| 53 | 53 | "</script>") |
| 54 | 54 | List<GbStream> selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId); |
| 55 | 55 | |
| ... | ... | @@ -60,18 +60,18 @@ public interface GbStreamMapper { |
| 60 | 60 | List<GbStream> selectByGBId(String gbId); |
| 61 | 61 | |
| 62 | 62 | @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + |
| 63 | - "LEFT JOIN platform_gb_stream pgs ON gs.id = pgs.catalogId " + | |
| 63 | + "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.catalogId " + | |
| 64 | 64 | "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") |
| 65 | 65 | GbStream queryStreamInPlatform(String platformId, String gbId); |
| 66 | 66 | |
| 67 | 67 | @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + |
| 68 | - "LEFT JOIN platform_gb_stream pgs ON gs.id = pgs.gbStreamId " + | |
| 68 | + "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " + | |
| 69 | 69 | "WHERE pgs.platformId = #{platformId}") |
| 70 | 70 | List<GbStream> queryGbStreamListInPlatform(String platformId); |
| 71 | 71 | |
| 72 | 72 | |
| 73 | 73 | @Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " + |
| 74 | - "ON gs.id = pgs.gbStreamId WHERE pgs.gbStreamId is NULL") | |
| 74 | + "ON gs.gbStreamId = pgs.gbStreamId WHERE pgs.gbStreamId is NULL") | |
| 75 | 75 | List<GbStream> queryStreamNotInPlatform(); |
| 76 | 76 | |
| 77 | 77 | @Update("UPDATE gb_stream " + |
| ... | ... | @@ -104,7 +104,7 @@ public interface GbStreamMapper { |
| 104 | 104 | void batchDelForGbStream(List<GbStream> gbStreams); |
| 105 | 105 | |
| 106 | 106 | @Insert("<script> " + |
| 107 | - "REPLACE into gb_stream " + | |
| 107 | + "INSERT IGNORE into gb_stream " + | |
| 108 | 108 | "(app, stream, gbId, name, " + |
| 109 | 109 | "longitude, latitude, streamType, mediaServerId, status, createStamp)" + |
| 110 | 110 | "values " + |
| ... | ... | @@ -114,6 +114,7 @@ public interface GbStreamMapper { |
| 114 | 114 | "'${item.mediaServerId}', ${item.status}, ${item.createStamp}) "+ |
| 115 | 115 | "</foreach> " + |
| 116 | 116 | "</script>") |
| 117 | + @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") | |
| 117 | 118 | void batchAdd(List<StreamPushItem> subList); |
| 118 | 119 | |
| 119 | 120 | @Update({"<script>" + | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java
| ... | ... | @@ -17,21 +17,21 @@ import java.util.List; |
| 17 | 17 | public interface PlatformGbStreamMapper { |
| 18 | 18 | |
| 19 | 19 | @Insert("REPLACE INTO platform_gb_stream (gbStreamId, platformId, catalogId) VALUES" + |
| 20 | - "( #{id}, #{platformId}, #{catalogId})") | |
| 20 | + "( #{gbStreamId}, #{platformId}, #{catalogId})") | |
| 21 | 21 | int add(PlatformGbStream platformGbStream); |
| 22 | 22 | |
| 23 | 23 | |
| 24 | 24 | @Insert("<script> " + |
| 25 | - "REPLACE into platform_gb_stream " + | |
| 25 | + "INSERT into platform_gb_stream " + | |
| 26 | 26 | "(gbStreamId, platformId, catalogId) " + |
| 27 | 27 | "values " + |
| 28 | 28 | "<foreach collection='streamPushItems' index='index' item='item' separator=','> " + |
| 29 | - "(#{item.id}, #{platformId}, #{catalogId})" + | |
| 29 | + "(${item.gbStreamId}, '${item.platformId}', '${item.catalogId}')" + | |
| 30 | 30 | "</foreach> " + |
| 31 | 31 | "</script>") |
| 32 | - int batchAdd(String platformId, String catalogId, List<GbStream> streamPushItems); | |
| 32 | + int batchAdd(List<StreamPushItem> streamPushItems); | |
| 33 | 33 | |
| 34 | - @Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select id from gb_stream where app=#{app} AND stream=#{stream})") | |
| 34 | + @Delete("DELETE FROM platform_gb_stream WHERE gbStreamId = (select gbStreamId from gb_stream where app=#{app} AND stream=#{stream})") | |
| 35 | 35 | int delByAppAndStream(String app, String stream); |
| 36 | 36 | |
| 37 | 37 | @Delete("DELETE FROM platform_gb_stream WHERE platformId=#{platformId}") |
| ... | ... | @@ -42,28 +42,28 @@ public interface PlatformGbStreamMapper { |
| 42 | 42 | "FROM " + |
| 43 | 43 | "platform_gb_stream pgs " + |
| 44 | 44 | "LEFT JOIN parent_platform pp ON pp.serverGBId = pgs.platformId " + |
| 45 | - "LEFT JOIN gb_stream gs ON gs.id = pgs.gbStreamId " + | |
| 45 | + "LEFT JOIN gb_stream gs ON gs.gbStreamId = pgs.gbStreamId " + | |
| 46 | 46 | "WHERE " + |
| 47 | 47 | "gs.app =#{app} " + |
| 48 | 48 | "AND gs.stream =#{stream} ") |
| 49 | 49 | List<ParentPlatform> selectByAppAndStream(String app, String stream); |
| 50 | 50 | |
| 51 | 51 | @Select("SELECT pgs.*, gs.gbId FROM platform_gb_stream pgs " + |
| 52 | - "LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.id " + | |
| 52 | + "LEFT JOIN gb_stream gs ON pgs.gbStreamId = gs.gbStreamId " + | |
| 53 | 53 | "WHERE gs.app=#{app} AND gs.stream=#{stream} AND pgs.platformId=#{serverGBId}") |
| 54 | 54 | StreamProxyItem selectOne(String app, String stream, String serverGBId); |
| 55 | 55 | |
| 56 | 56 | @Select("select gs.* \n" + |
| 57 | 57 | "from gb_stream gs\n" + |
| 58 | 58 | " left join platform_gb_stream pgs\n" + |
| 59 | - " on gs.id = pgs.gbStreamId\n" + | |
| 59 | + " on gs.gbStreamId = pgs.gbStreamId\n" + | |
| 60 | 60 | "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") |
| 61 | 61 | List<GbStream> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); |
| 62 | 62 | |
| 63 | 63 | @Select("select gs.gbId as id, gs.name as name, pgs.platformId as platformId, pgs.catalogId as catalogId , 0 as childrenCount, 2 as type\n" + |
| 64 | 64 | "from gb_stream gs\n" + |
| 65 | 65 | " left join platform_gb_stream pgs\n" + |
| 66 | - " on gs.id = pgs.gbStreamId\n" + | |
| 66 | + " on gs.gbStreamId = pgs.gbStreamId\n" + | |
| 67 | 67 | "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") |
| 68 | 68 | List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatalog(String platformId, String catalogId); |
| 69 | 69 | |
| ... | ... | @@ -78,7 +78,7 @@ public interface PlatformGbStreamMapper { |
| 78 | 78 | "left join platform_gb_stream pgs on " + |
| 79 | 79 | "pp.serverGBId = pgs.platformId " + |
| 80 | 80 | "left join gb_stream gs " + |
| 81 | - "gs.id = pgs.gbStreamId " + | |
| 81 | + "gs.gbStreamId = pgs.gbStreamId " + | |
| 82 | 82 | "WHERE " + |
| 83 | 83 | "gs.app = #{app} " + |
| 84 | 84 | "AND gs.stream = #{stream}" + |
| ... | ... | @@ -93,7 +93,7 @@ public interface PlatformGbStreamMapper { |
| 93 | 93 | @Delete("<script> "+ |
| 94 | 94 | "DELETE FROM platform_gb_stream where gbStreamId in " + |
| 95 | 95 | "<foreach collection='gbStreams' item='item' open='(' separator=',' close=')' >" + |
| 96 | - "#{item.id}" + | |
| 96 | + "#{item.gbStreamId}" + | |
| 97 | 97 | "</foreach>" + |
| 98 | 98 | "</script>") |
| 99 | 99 | void delByGbStreams(List<GbStream> gbStreams); |
| ... | ... | @@ -101,7 +101,7 @@ public interface PlatformGbStreamMapper { |
| 101 | 101 | @Delete("<script> "+ |
| 102 | 102 | "DELETE FROM platform_gb_stream where platformId=#{platformId} and gbStreamId in " + |
| 103 | 103 | "<foreach collection='gbStreams' item='item' open='(' separator=',' close=')'>" + |
| 104 | - "#{item.id} " + | |
| 104 | + "#{item.gbStreamId} " + | |
| 105 | 105 | "</foreach>" + |
| 106 | 106 | "</script>") |
| 107 | 107 | void delByAppAndStreamsByPlatformId(List<GbStream> gbStreams, String platformId); | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
| ... | ... | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.storager.dao; |
| 3 | 3 | import com.genersoft.iot.vmp.gb28181.bean.GbStream; |
| 4 | 4 | import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; |
| 5 | 5 | import org.apache.ibatis.annotations.*; |
| 6 | +import org.omg.PortableInterceptor.INACTIVE; | |
| 6 | 7 | import org.springframework.stereotype.Repository; |
| 7 | 8 | |
| 8 | 9 | import java.util.Collection; |
| ... | ... | @@ -61,39 +62,37 @@ public interface StreamPushMapper { |
| 61 | 62 | @Select(value = {" <script>" + |
| 62 | 63 | "SELECT " + |
| 63 | 64 | "st.*, " + |
| 64 | - "pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude , pgs.id " + | |
| 65 | + "gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude, gs.gbStreamId " + | |
| 65 | 66 | "from " + |
| 66 | 67 | "stream_push st " + |
| 67 | - "LEFT JOIN gb_stream pgs " + | |
| 68 | - "on st.app = pgs.app AND st.stream = pgs.stream " + | |
| 68 | + "LEFT JOIN gb_stream gs " + | |
| 69 | + "on st.app = gs.app AND st.stream = gs.stream " + | |
| 69 | 70 | "WHERE " + |
| 70 | 71 | "1=1 " + |
| 71 | - " <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR pgs.gbId LIKE '%${query}%' OR pgs.name LIKE '%${query}%')</if> " + | |
| 72 | - " <if test='pushing == true' > AND (pgs.gbId is null OR pgs.status=1)</if>" + | |
| 73 | - " <if test='pushing == false' > AND pgs.status=0</if>" + | |
| 72 | + " <if test='query != null'> AND (st.app LIKE '%${query}%' OR st.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " + | |
| 73 | + " <if test='pushing == true' > AND (gs.gbId is null OR gs.status=1)</if>" + | |
| 74 | + " <if test='pushing == false' > AND gs.status=0</if>" + | |
| 74 | 75 | " <if test='mediaServerId != null' > AND st.mediaServerId=#{mediaServerId} </if>" + |
| 75 | 76 | "order by st.createStamp desc" + |
| 76 | 77 | " </script>"}) |
| 77 | 78 | List<StreamPushItem> selectAllForList(String query, Boolean pushing, String mediaServerId); |
| 78 | 79 | |
| 79 | - @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream order by st.createStamp desc") | |
| 80 | + @Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.createStamp desc") | |
| 80 | 81 | List<StreamPushItem> selectAll(); |
| 81 | 82 | |
| 82 | - @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.enable=${enable}") | |
| 83 | - List<StreamPushItem> selectForEnable(boolean enable); | |
| 84 | - | |
| 85 | - @Select("SELECT st.*, pgs.gbId, pgs.status, pgs.name, pgs.longitude, pgs.latitude FROM stream_push st LEFT JOIN gb_stream pgs on st.app = pgs.app AND st.stream = pgs.stream WHERE st.app=#{app} AND st.stream=#{stream}") | |
| 83 | + @Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}") | |
| 86 | 84 | StreamPushItem selectOne(String app, String stream); |
| 87 | 85 | |
| 88 | 86 | @Insert("<script>" + |
| 89 | - "REPLACE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + | |
| 87 | + "Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + | |
| 90 | 88 | "createStamp, aliveSecond, mediaServerId) " + |
| 91 | 89 | "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" + |
| 92 | 90 | "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " + |
| 93 | 91 | "'${item.originTypeStr}',#{item.createStamp}, #{item.aliveSecond}, '${item.mediaServerId}' )" + |
| 94 | 92 | " </foreach>" + |
| 95 | 93 | "</script>") |
| 96 | - void addAll(List<StreamPushItem> streamPushItems); | |
| 94 | + @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") | |
| 95 | + int addAll(List<StreamPushItem> streamPushItems); | |
| 97 | 96 | |
| 98 | 97 | @Delete("DELETE FROM stream_push") |
| 99 | 98 | void clear(); | ... | ... |
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java