From 6e0f7fae6eda7ffa18c4289d19a705f272174911 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: 星期三, 05 一月 2022 15:23:14 +0800 Subject: [PATCH] 为级联平台增加虚拟目录功能 --- src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java | 2 src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java | 21 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java | 15 web_src/src/components/dialog/chooseChannelForCatalog.vue | 311 +++++++++ src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java | 43 + web_src/package-lock.json | 11 web_src/src/main.js | 2 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java | 14 sql/mysql.sql | 12 src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java | 2 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java | 9 src/main/resources/application-dev.yml | 2 web_src/src/components/dialog/platformEdit.vue | 1 src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java | 71 ++ src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java | 21 web_src/package.json | 1 src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java | 95 ++ README.md | 4 web_src/src/components/dialog/chooseChannelForStream.vue | 11 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java | 6 web_src/src/components/dialog/chooseChannel.vue | 83 ++ src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java | 201 ++++++ src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java | 12 sql/dump-wvp-202201051515.sql | 539 ++++++++++++++++ src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java | 1 web_src/src/components/dialog/catalogEdit.vue | 101 +++ src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java | 13 web_src/src/components/dialog/chooseChannelForGb.vue | 55 + src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java | 6 src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java | 42 + src/main/resources/application-docker.yml | 2 src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java | 2 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java | 41 + src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java | 10 src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java | 13 src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java | 8 src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java | 3 src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java | 8 web_src/src/components/ParentPlatformList.vue | 2 web_src/static/css/iconfont.css | 26 src/main/resources/wvp.sqlite | 0 src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java | 14 src/main/resources/all-application.yml | 2 src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java | 27 src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java | 24 web_src/static/css/iconfont.woff2 | 0 src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java | 7 src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java | 4 src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java | 3 src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java | 3 50 files changed, 1,802 insertions(+), 104 deletions(-) diff --git a/README.md b/README.md index e7645c6..d399874 100644 --- a/README.md +++ b/README.md @@ -95,15 +95,13 @@ - [X] 骞冲彴鐘舵�佹煡璇� - [X] 骞冲彴淇℃伅鏌ヨ - [X] 骞冲彴杩滅▼鍚姩 + - [X] 姣忎釜绾ц仈骞冲彴鍙嚜瀹氫箟鐨勮櫄鎷熺洰褰� - [X] 娣诲姞RTSP瑙嗛 - [X] 娣诲姞鎺ュ彛閴存潈 -- [ ] 娣诲姞ONVIF鎺㈡祴灞�鍩熺綉鍐呯殑璁惧 - [X] 娣诲姞RTMP瑙嗛 - [X] 浜戠褰曞儚锛堥渶瑕侀儴缃插崟鐙湇鍔¢厤鍚堜娇鐢級 - [X] 澶氭祦濯掍綋鑺傜偣锛岃嚜鍔ㄩ�夋嫨璐熻浇鏈�浣庣殑鑺傜偣浣跨敤銆� - [X] 鏀寔浣跨敤mysql浣滀负鏁版嵁搴擄紝榛樿sqlite3,寮�绠卞嵆鐢ㄣ�� -- [ ] 娣诲姞绯荤粺閰嶇疆 -- [ ] 娣诲姞鐢ㄦ埛绠$悊 - [X] WEB绔敮鎸佹挱鏀綡264涓嶩265锛岄煶棰戞敮鎸丟.711A/G.711U/AAC,瑕嗙洊鍥芥爣甯哥敤缂栫爜鏍煎紡銆� # docker蹇�熶綋楠� diff --git a/sql/dump-wvp-202201051515.sql b/sql/dump-wvp-202201051515.sql new file mode 100644 index 0000000..1b3b84f --- /dev/null +++ b/sql/dump-wvp-202201051515.sql @@ -0,0 +1,539 @@ +-- MySQL dump 10.13 Distrib 8.0.27, for Linux (x86_64) +-- +-- Host: localhost Database: wvp +-- ------------------------------------------------------ +-- Server version 8.0.27-0ubuntu0.20.04.1 + +/*!40101 SET @OLD_CHARACTER_SET_CLIENT=@@CHARACTER_SET_CLIENT */; +/*!40101 SET @OLD_CHARACTER_SET_RESULTS=@@CHARACTER_SET_RESULTS */; +/*!40101 SET @OLD_COLLATION_CONNECTION=@@COLLATION_CONNECTION */; +/*!50503 SET NAMES utf8mb4 */; +/*!40103 SET @OLD_TIME_ZONE=@@TIME_ZONE */; +/*!40103 SET TIME_ZONE='+00:00' */; +/*!40014 SET @OLD_UNIQUE_CHECKS=@@UNIQUE_CHECKS, UNIQUE_CHECKS=0 */; +/*!40014 SET @OLD_FOREIGN_KEY_CHECKS=@@FOREIGN_KEY_CHECKS, FOREIGN_KEY_CHECKS=0 */; +/*!40101 SET @OLD_SQL_MODE=@@SQL_MODE, SQL_MODE='NO_AUTO_VALUE_ON_ZERO' */; +/*!40111 SET @OLD_SQL_NOTES=@@SQL_NOTES, SQL_NOTES=0 */; + +-- +-- Table structure for table `device` +-- + +DROP TABLE IF EXISTS `device`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `device` ( + `deviceId` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `manufacturer` varchar(255) DEFAULT NULL, + `model` varchar(255) DEFAULT NULL, + `firmware` varchar(255) DEFAULT NULL, + `transport` varchar(50) DEFAULT NULL, + `streamMode` varchar(50) DEFAULT NULL, + `online` varchar(50) DEFAULT NULL, + `registerTime` varchar(50) DEFAULT NULL, + `keepaliveTime` varchar(50) DEFAULT NULL, + `ip` varchar(50) NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + `port` int NOT NULL, + `expires` int NOT NULL, + `subscribeCycleForCatalog` int NOT NULL, + `hostAddress` varchar(50) NOT NULL, + `charset` varchar(50) NOT NULL, + PRIMARY KEY (`deviceId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `device` +-- + +LOCK TABLES `device` WRITE; +/*!40000 ALTER TABLE `device` DISABLE KEYS */; +INSERT INTO `device` VALUES ('34020000001320000005','IPC-HFW4433M-I2','Dahua','IPC-HFW4433M-I2','2.622.0000000.31.R,2017-12-14','UDP','UDP','1','2022-01-05 15:08:26','2022-01-05 15:15:26','192.168.1.100','2022-01-05 15:08:26','2022-01-05 15:15:26',5060,3600,0,'192.168.1.100:5060','gb2312'),('34020000002000000005','DH-NVR5864-I','Dahua','DH-NVR5864-I','4.001.0000000.3,2020-10-22','UDP','UDP','1','2022-01-05 14:07:36','2022-01-05 15:15:25','192.168.1.19','2022-01-05 15:08:25','2022-01-05 15:15:25',5060,3600,0,'192.168.1.19:5060','gb2312'),('44010000001110008008',NULL,'Mercury','MIPC368(P)W-4','1.0.1 Build 210304 Rel.60784n','UDP','UDP','1','2022-01-05 15:08:35','2022-01-05 15:14:35','192.168.1.17','2022-01-05 15:08:35','2022-01-05 15:14:35',5060,36000,0,'192.168.1.17:5060','gb2312'); +/*!40000 ALTER TABLE `device` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `device_alarm` +-- + +DROP TABLE IF EXISTS `device_alarm`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `device_alarm` ( + `id` int NOT NULL AUTO_INCREMENT, + `deviceId` varchar(50) NOT NULL, + `channelId` varchar(50) NOT NULL, + `alarmPriority` varchar(50) NOT NULL, + `alarmMethod` varchar(50) DEFAULT NULL, + `alarmTime` varchar(50) NOT NULL, + `alarmDescription` varchar(255) DEFAULT NULL, + `longitude` double DEFAULT NULL, + `latitude` double DEFAULT NULL, + `alarmType` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `device_alarm` +-- + +LOCK TABLES `device_alarm` WRITE; +/*!40000 ALTER TABLE `device_alarm` DISABLE KEYS */; +/*!40000 ALTER TABLE `device_alarm` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `device_channel` +-- + +DROP TABLE IF EXISTS `device_channel`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `device_channel` ( + `channelId` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `manufacture` varchar(50) DEFAULT NULL, + `model` varchar(50) DEFAULT NULL, + `owner` varchar(50) DEFAULT NULL, + `civilCode` varchar(50) DEFAULT NULL, + `block` varchar(50) DEFAULT NULL, + `address` varchar(50) DEFAULT NULL, + `parentId` varchar(50) DEFAULT NULL, + `safetyWay` int DEFAULT NULL, + `registerWay` int DEFAULT NULL, + `certNum` varchar(50) DEFAULT NULL, + `certifiable` int DEFAULT NULL, + `errCode` int DEFAULT NULL, + `endTime` varchar(50) DEFAULT NULL, + `secrecy` varchar(50) DEFAULT NULL, + `ipAddress` varchar(50) DEFAULT NULL, + `port` int DEFAULT NULL, + `password` varchar(255) DEFAULT NULL, + `PTZType` int DEFAULT NULL, + `status` int DEFAULT NULL, + `longitude` double DEFAULT NULL, + `latitude` double DEFAULT NULL, + `streamId` varchar(50) DEFAULT NULL, + `deviceId` varchar(50) NOT NULL, + `parental` varchar(50) DEFAULT NULL, + `hasAudio` bit(1) DEFAULT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + PRIMARY KEY (`channelId`,`deviceId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `device_channel` +-- + +LOCK TABLES `device_channel` WRITE; +/*!40000 ALTER TABLE `device_channel` DISABLE KEYS */; +INSERT INTO `device_channel` VALUES ('34020000001310000001','IPC','Dahua','IPC-HFW4433M-I2','0','340200','','axy','34020000001320000005',0,1,'',0,0,NULL,'0','',0,'',0,1,0,0,'','34020000001320000005','0',NULL,'2022-01-05 15:11:21','2022-01-05 15:11:21'),('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,'','34020000002000000005','0',NULL,'2022-01-05 15:11:25','2022-01-05 15:11:25'),('34020000001310000065','GB_Chn_065','Dahua','DH-NVR5864-I','0','340200','','axy','34020000002000000005',0,1,'',0,0,NULL,'0','',0,'',0,1,0,0,'','34020000002000000005','0',NULL,'2022-01-05 15:11:25','2022-01-05 15:11:25'),('34020000001320000001','IPCamera 01','Mercury','MIPC368(P)W-4','Owner','CivilCode','','Address','',0,1,'',0,0,NULL,'0','',0,'',0,1,0,0,'','44010000001110008008','0',NULL,'2022-01-05 15:11:26','2022-01-05 15:11:26'); +/*!40000 ALTER TABLE `device_channel` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `device_mobile_position` +-- + +DROP TABLE IF EXISTS `device_mobile_position`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `device_mobile_position` ( + `deviceId` varchar(50) NOT NULL, + `channelId` varchar(50) NOT NULL, + `deviceName` varchar(255) DEFAULT NULL, + `time` varchar(50) NOT NULL, + `longitude` double NOT NULL, + `latitude` double NOT NULL, + `altitude` double DEFAULT NULL, + `speed` double DEFAULT NULL, + `direction` double DEFAULT NULL, + `reportSource` varchar(50) DEFAULT NULL, + `geodeticSystem` varchar(50) DEFAULT NULL, + `cnLng` varchar(50) DEFAULT NULL, + `cnLat` varchar(50) DEFAULT NULL, + PRIMARY KEY (`deviceId`,`time`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `device_mobile_position` +-- + +LOCK TABLES `device_mobile_position` WRITE; +/*!40000 ALTER TABLE `device_mobile_position` DISABLE KEYS */; +/*!40000 ALTER TABLE `device_mobile_position` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `gb_stream` +-- + +DROP TABLE IF EXISTS `gb_stream`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `gb_stream` ( + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `gbId` varchar(50) NOT NULL, + `name` varchar(255) DEFAULT NULL, + `longitude` double DEFAULT NULL, + `latitude` double DEFAULT NULL, + `streamType` varchar(50) DEFAULT NULL, + `mediaServerId` varchar(50) DEFAULT NULL, + `status` int DEFAULT NULL, + PRIMARY KEY (`app`,`stream`,`gbId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `gb_stream` +-- + +LOCK TABLES `gb_stream` WRITE; +/*!40000 ALTER TABLE `gb_stream` DISABLE KEYS */; +INSERT INTO `gb_stream` VALUES ('1000','10000001_52869999','77777777777777777777','shoulei1111',0,0,'push','XR1LEpKlfQtSg9Z1',1); +/*!40000 ALTER TABLE `gb_stream` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `log` +-- + +DROP TABLE IF EXISTS `log`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `log` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` varchar(50) NOT NULL, + `type` varchar(50) NOT NULL, + `uri` varchar(200) NOT NULL, + `address` varchar(50) NOT NULL, + `result` varchar(50) NOT NULL, + `timing` bigint NOT NULL, + `username` varchar(50) NOT NULL, + `createTime` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=21 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `log` +-- + +LOCK TABLES `log` WRITE; +/*!40000 ALTER TABLE `log` DISABLE KEYS */; +INSERT INTO `log` VALUES (1,'鐧诲綍','GET','/api/user/login','127.0.0.1','200 OK',245,'admin','2022-01-05 15:09:06'),(2,'娣诲姞涓婄骇骞冲彴','POST','/api/platform/save','127.0.0.1','200 OK',88,'admin','2022-01-05 15:09:24'),(3,'[璁惧鏌ヨ] 鍚屾璁惧閫氶亾','POST','/api/device/query/devices/34020000001320000005/sync','127.0.0.1','200 OK',17,'admin','2022-01-05 15:11:21'),(4,'[璁惧鏌ヨ] 鍚屾璁惧閫氶亾','POST','/api/device/query/devices/34020000002000000005/sync','127.0.0.1','200 OK',4,'admin','2022-01-05 15:11:25'),(5,'[璁惧鏌ヨ] 鍚屾璁惧閫氶亾','POST','/api/device/query/devices/44010000001110008008/sync','127.0.0.1','200 OK',4,'admin','2022-01-05 15:11:26'),(6,'鍚戜笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾','POST','/api/platform/update_channel_for_gb','127.0.0.1','200 OK',52,'admin','2022-01-05 15:11:32'),(7,'浠庝笂绾у钩鍙扮Щ闄ゅ浗鏍囬�氶亾','DELETE','/api/platform/del_channel_for_gb','127.0.0.1','200 OK',35,'admin','2022-01-05 15:11:34'),(8,'鍚戜笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾','POST','/api/platform/update_channel_for_gb','127.0.0.1','200 OK',39,'admin','2022-01-05 15:11:35'),(9,'浠庝笂绾у钩鍙扮Щ闄ゅ浗鏍囬�氶亾','DELETE','/api/platform/del_channel_for_gb','127.0.0.1','200 OK',46,'admin','2022-01-05 15:14:00'),(10,'鍚戜笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾','POST','/api/platform/update_channel_for_gb','127.0.0.1','200 OK',59,'admin','2022-01-05 15:14:01'),(11,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',12,'admin','2022-01-05 15:14:16'),(12,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',8,'admin','2022-01-05 15:14:17'),(13,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',6,'admin','2022-01-05 15:14:19'),(14,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',8,'admin','2022-01-05 15:14:19'),(15,'绉婚櫎閫氶亾涓庡浗鏍囩殑鍏宠仈','DELETE','/api/gbStream/del','127.0.0.1','200 OK',11,'admin','2022-01-05 15:14:21'),(16,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',42,'admin','2022-01-05 15:14:24'),(17,'绉婚櫎閫氶亾涓庡浗鏍囩殑鍏宠仈','DELETE','/api/gbStream/del','127.0.0.1','200 OK',43,'admin','2022-01-05 15:14:25'),(18,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',9,'admin','2022-01-05 15:14:27'),(19,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',9,'admin','2022-01-05 15:14:37'),(20,'娣诲姞閫氶亾涓庡浗鏍囩殑鍏宠仈','POST','/api/gbStream/add','127.0.0.1','200 OK',10,'admin','2022-01-05 15:14:38'); +/*!40000 ALTER TABLE `log` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `media_server` +-- + +DROP TABLE IF EXISTS `media_server`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `media_server` ( + `id` varchar(255) NOT NULL, + `ip` varchar(50) NOT NULL, + `hookIp` varchar(50) NOT NULL, + `sdpIp` varchar(50) NOT NULL, + `streamIp` varchar(50) NOT NULL, + `httpPort` int NOT NULL, + `httpSSlPort` int NOT NULL, + `rtmpPort` int NOT NULL, + `rtmpSSlPort` int NOT NULL, + `rtpProxyPort` int NOT NULL, + `rtspPort` int NOT NULL, + `rtspSSLPort` int NOT NULL, + `autoConfig` int NOT NULL, + `secret` varchar(50) NOT NULL, + `streamNoneReaderDelayMS` int NOT NULL, + `rtpEnable` int NOT NULL, + `rtpPortRange` varchar(50) NOT NULL, + `sendRtpPortRange` varchar(50) NOT NULL, + `recordAssistPort` int NOT NULL, + `defaultServer` int NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + `hookAliveInterval` int NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `media_server_i` (`ip`,`httpPort`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `media_server` +-- + +LOCK TABLES `media_server` WRITE; +/*!40000 ALTER TABLE `media_server` DISABLE KEYS */; +INSERT INTO `media_server` VALUES ('XR1LEpKlfQtSg9Z1','192.168.1.3','127.0.0.1','192.168.1.3','192.168.1.3',6080,0,10935,0,10000,10554,0,1,'035c73f7-bb6b-4889-a715-d9eb2d1925cc',100000,1,'30000,30500','30000,30500',18081,1,'2022-01-05 15:08:27','2022-01-05 15:08:27',10); +/*!40000 ALTER TABLE `media_server` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `parent_platform` +-- + +DROP TABLE IF EXISTS `parent_platform`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `parent_platform` ( + `id` int NOT NULL AUTO_INCREMENT, + `enable` int DEFAULT NULL, + `name` varchar(255) DEFAULT NULL, + `serverGBId` varchar(50) NOT NULL, + `serverGBDomain` varchar(50) DEFAULT NULL, + `serverIP` varchar(50) DEFAULT NULL, + `serverPort` int DEFAULT NULL, + `deviceGBId` varchar(50) NOT NULL, + `deviceIp` varchar(50) DEFAULT NULL, + `devicePort` varchar(50) DEFAULT NULL, + `username` varchar(255) DEFAULT NULL, + `password` varchar(50) DEFAULT NULL, + `expires` varchar(50) DEFAULT NULL, + `keepTimeout` varchar(50) DEFAULT NULL, + `transport` varchar(50) DEFAULT NULL, + `characterSet` varchar(50) DEFAULT NULL, + `catalogId` varchar(50) NOT NULL, + `ptz` int DEFAULT NULL, + `rtcp` int DEFAULT NULL, + `status` bit(1) DEFAULT NULL, + `shareAllLiveStream` int DEFAULT NULL, + PRIMARY KEY (`id`,`serverGBId`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `parent_platform` +-- + +LOCK TABLES `parent_platform` WRITE; +/*!40000 ALTER TABLE `parent_platform` DISABLE KEYS */; +INSERT INTO `parent_platform` VALUES (1,1,'1112','1111111111111','1111111111','11.11.11.11',111111,'34020000002110000015','192.168.1.3','5060','34020000002110000015','12345678','300','60','UDP','GB2312','1111111111111',1,0,_binary '\0',1); +/*!40000 ALTER TABLE `parent_platform` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `platform_catalog` +-- + +DROP TABLE IF EXISTS `platform_catalog`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `platform_catalog` ( + `id` varchar(50) NOT NULL, + `platformId` varchar(50) NOT NULL, + `name` varchar(255) NOT NULL, + `parentId` varchar(50) DEFAULT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `platform_catalog` +-- + +LOCK TABLES `platform_catalog` WRITE; +/*!40000 ALTER TABLE `platform_catalog` DISABLE KEYS */; +INSERT INTO `platform_catalog` VALUES ('1111111111','1111111111111','11122','1111111111111'); +/*!40000 ALTER TABLE `platform_catalog` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `platform_gb_channel` +-- + +DROP TABLE IF EXISTS `platform_gb_channel`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `platform_gb_channel` ( + `channelId` varchar(50) NOT NULL, + `deviceId` varchar(50) NOT NULL, + `platformId` varchar(50) NOT NULL, + `deviceAndChannelId` varchar(50) NOT NULL, + `catalogId` varchar(50) NOT NULL, + PRIMARY KEY (`deviceAndChannelId`,`platformId`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `platform_gb_channel` +-- + +LOCK TABLES `platform_gb_channel` WRITE; +/*!40000 ALTER TABLE `platform_gb_channel` DISABLE KEYS */; +INSERT INTO `platform_gb_channel` VALUES ('34020000001310000001','34020000001320000005','1111111111111','34020000001320000005_34020000001310000001','1111111111'),('34020000001310000001','34020000002000000005','1111111111111','34020000002000000005_34020000001310000001','1111111111'),('34020000001310000065','34020000002000000005','1111111111111','34020000002000000005_34020000001310000065','1111111111'),('34020000001320000001','44010000001110008008','1111111111111','44010000001110008008_34020000001320000001','1111111111'); +/*!40000 ALTER TABLE `platform_gb_channel` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `platform_gb_stream` +-- + +DROP TABLE IF EXISTS `platform_gb_stream`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `platform_gb_stream` ( + `platformId` varchar(50) NOT NULL, + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `catalogId` varchar(50) NOT NULL, + PRIMARY KEY (`platformId`,`app`,`stream`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `platform_gb_stream` +-- + +LOCK TABLES `platform_gb_stream` WRITE; +/*!40000 ALTER TABLE `platform_gb_stream` DISABLE KEYS */; +INSERT INTO `platform_gb_stream` VALUES ('1111111111111','1000','10000001_52869999','1111111111'); +/*!40000 ALTER TABLE `platform_gb_stream` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `role` +-- + +DROP TABLE IF EXISTS `role`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `role` ( + `id` int NOT NULL AUTO_INCREMENT, + `name` text NOT NULL, + `authority` text NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + PRIMARY KEY (`id`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `role` +-- + +LOCK TABLES `role` WRITE; +/*!40000 ALTER TABLE `role` DISABLE KEYS */; +INSERT INTO `role` VALUES (1,'admin','0','2021-04-13 14:14:57','2021-04-13 14:14:57'); +/*!40000 ALTER TABLE `role` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `stream_proxy` +-- + +DROP TABLE IF EXISTS `stream_proxy`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `stream_proxy` ( + `type` varchar(50) NOT NULL, + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `url` varchar(255) DEFAULT NULL, + `src_url` varchar(255) DEFAULT NULL, + `dst_url` varchar(255) DEFAULT NULL, + `timeout_ms` int DEFAULT NULL, + `ffmpeg_cmd_key` varchar(255) DEFAULT NULL, + `rtp_type` varchar(50) DEFAULT NULL, + `mediaServerId` varchar(50) DEFAULT NULL, + `enable_hls` bit(1) DEFAULT NULL, + `enable_mp4` bit(1) DEFAULT NULL, + `enable` bit(1) NOT NULL, + `enable_remove_none_reader` bit(1) NOT NULL, + `createTime` varchar(50) NOT NULL, + PRIMARY KEY (`app`,`stream`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `stream_proxy` +-- + +LOCK TABLES `stream_proxy` WRITE; +/*!40000 ALTER TABLE `stream_proxy` DISABLE KEYS */; +/*!40000 ALTER TABLE `stream_proxy` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `stream_push` +-- + +DROP TABLE IF EXISTS `stream_push`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `stream_push` ( + `app` varchar(255) NOT NULL, + `stream` varchar(255) NOT NULL, + `totalReaderCount` varchar(50) DEFAULT NULL, + `originType` int DEFAULT NULL, + `originTypeStr` varchar(50) DEFAULT NULL, + `createStamp` int DEFAULT NULL, + `aliveSecond` int DEFAULT NULL, + `mediaServerId` varchar(50) DEFAULT NULL, + PRIMARY KEY (`app`,`stream`) +) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `stream_push` +-- + +LOCK TABLES `stream_push` WRITE; +/*!40000 ALTER TABLE `stream_push` DISABLE KEYS */; +INSERT INTO `stream_push` VALUES ('1000','10000001_52869999','0',2,'rtsp_push',1641366850,0,'XR1LEpKlfQtSg9Z1'); +/*!40000 ALTER TABLE `stream_push` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Table structure for table `user` +-- + +DROP TABLE IF EXISTS `user`; +/*!40101 SET @saved_cs_client = @@character_set_client */; +/*!50503 SET character_set_client = utf8mb4 */; +CREATE TABLE `user` ( + `id` int NOT NULL AUTO_INCREMENT, + `username` varchar(255) NOT NULL, + `password` varchar(255) NOT NULL, + `roleId` int NOT NULL, + `createTime` varchar(50) NOT NULL, + `updateTime` varchar(50) NOT NULL, + PRIMARY KEY (`id`), + UNIQUE KEY `user_username_uindex` (`username`) +) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_0900_ai_ci; +/*!40101 SET character_set_client = @saved_cs_client */; + +-- +-- Dumping data for table `user` +-- + +LOCK TABLES `user` WRITE; +/*!40000 ALTER TABLE `user` DISABLE KEYS */; +INSERT INTO `user` VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',1,'2021-04-13 14:14:57','2021-04-13 14:14:57'); +/*!40000 ALTER TABLE `user` ENABLE KEYS */; +UNLOCK TABLES; + +-- +-- Dumping routines for database 'wvp' +-- +/*!40103 SET TIME_ZONE=@OLD_TIME_ZONE */; + +/*!40101 SET SQL_MODE=@OLD_SQL_MODE */; +/*!40014 SET FOREIGN_KEY_CHECKS=@OLD_FOREIGN_KEY_CHECKS */; +/*!40014 SET UNIQUE_CHECKS=@OLD_UNIQUE_CHECKS */; +/*!40101 SET CHARACTER_SET_CLIENT=@OLD_CHARACTER_SET_CLIENT */; +/*!40101 SET CHARACTER_SET_RESULTS=@OLD_CHARACTER_SET_RESULTS */; +/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; +/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; + +-- Dump completed on 2022-01-05 15:15:35 diff --git a/sql/mysql.sql b/sql/mysql.sql index 5724342..8cbd493 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -171,11 +171,21 @@ keepTimeout varchar(50) null, transport varchar(50) null, characterSet varchar(50) null, + catalogId varchar(50) not null, ptz int null, rtcp int null, status bit null, shareAllLiveStream int null, primary key (id, serverGBId) +); + + +create table platform_catalog +( + id varchar(50) primary key, + platformId varchar(50) not null, + name varchar(255) not null, + parentId varchar(50) ); create table platform_gb_channel @@ -184,6 +194,7 @@ deviceId varchar(50) not null, platformId varchar(50) not null, deviceAndChannelId varchar(50) not null, + catalogId varchar(50) not null, primary key (deviceAndChannelId, platformId) ); @@ -192,6 +203,7 @@ platformId varchar(50) not null, app varchar(255) not null, stream varchar(255) not null, + catalogId varchar(50) not null, primary key (platformId, app, stream) ); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java new file mode 100644 index 0000000..4e55011 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/DeviceNotFoundEvent.java @@ -0,0 +1,21 @@ +package com.genersoft.iot.vmp.gb28181.bean; + +import javax.sip.Dialog; +import java.util.EventObject; + +public class DeviceNotFoundEvent extends EventObject { + /** + * Constructs a prototypical Event. + * + * @param dialog + * @throws IllegalArgumentException if source is null. + */ + public DeviceNotFoundEvent(Dialog dialog) { + super(dialog); + } + + + public Dialog getDialog() { + return (Dialog)super.getSource(); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java index fabae8a..0c06145 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java @@ -109,6 +109,11 @@ */ private boolean shareAllLiveStream; + /** + * 榛樿鐩綍Id,鑷姩娣诲姞鐨勯�氶亾澶氭斁鍦ㄨ繖涓洰褰曚笅 + */ + private String catalogId; + public Integer getId() { return id; } @@ -277,4 +282,12 @@ public void setShareAllLiveStream(boolean shareAllLiveStream) { this.shareAllLiveStream = shareAllLiveStream; } + + public String getCatalogId() { + return catalogId; + } + + public void setCatalogId(String catalogId) { + this.catalogId = catalogId; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java new file mode 100644 index 0000000..065971d --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java @@ -0,0 +1,71 @@ +package com.genersoft.iot.vmp.gb28181.bean; + +public class PlatformCatalog { + private String id; + private String name; + private String platformId; + private String parentId; + private int childrenCount; // 瀛愯妭鐐规暟 + private int type; // 0 鐩綍, 1 鍥芥爣閫氶亾, 2 鐩存挱娴� + + public String getId() { + return id; + } + + public void setId(String id) { + this.id = id; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public String getPlatformId() { + return platformId; + } + + public void setPlatformId(String platformId) { + this.platformId = platformId; + } + + public String getParentId() { + return parentId; + } + + public void setParentId(String parentId) { + this.parentId = parentId; + } + + public int getChildrenCount() { + return childrenCount; + } + + public void setChildrenCount(int childrenCount) { + this.childrenCount = childrenCount; + } + + public int getType() { + return type; + } + + public void setType(int type) { + this.type = type; + } + + public void setTypeForCatalog() { + this.type = 0; + } + + public void setTypeForGb() { + this.type = 1; + } + + public void setTypeForStream() { + this.type = 2; + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java index a4f7730..1ab3814 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformGbStream.java @@ -4,6 +4,7 @@ private String app; private String stream; private String platformId; + private String catalogId; public String getApp() { return app; @@ -29,4 +30,11 @@ this.platformId = platformId; } + public String getCatalogId() { + return catalogId; + } + + public void setCatalogId(String catalogId) { + this.catalogId = catalogId; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java index f341548..a00ac63 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/SipSubscribe.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.gb28181.event; +import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.scheduling.annotation.Scheduled; @@ -91,6 +92,13 @@ this.statusCode = -1024; this.callId = dialogTerminatedEvent.getDialog().getCallId().getCallId(); this.dialog = dialogTerminatedEvent.getDialog(); + }else if (event instanceof DeviceNotFoundEvent) { + DeviceNotFoundEvent deviceNotFoundEvent = (DeviceNotFoundEvent)event; + this.type = "deviceNotFoundEvent"; + this.msg = "璁惧鏈壘鍒�"; + this.statusCode = -1024; + this.callId = deviceNotFoundEvent.getDialog().getCallId().getCallId(); + this.dialog = deviceNotFoundEvent.getDialog(); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java index 116236f..be369ae 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/SIPProcessorObserver.java @@ -94,7 +94,6 @@ logger.debug(responseEvent.getResponse().toString()); int status = response.getStatusCode(); if (((status >= 200) && (status < 300)) || status == 401) { // Success! -// ISIPResponseProcessor processor = processorFactory.createResponseProcessor(evt); CSeqHeader cseqHeader = (CSeqHeader) responseEvent.getResponse().getHeader(CSeqHeader.NAME); String method = cseqHeader.getMethod(); ISIPResponseProcessor sipRequestProcessor = responseProcessorMap.get(method); @@ -108,6 +107,7 @@ if (subscribe != null) { SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent); subscribe.response(eventResult); + sipSubscribe.removeOkSubscribe(callIdHeader.getCallId()); } } } @@ -122,6 +122,7 @@ if (subscribe != null) { SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(responseEvent); subscribe.response(eventResult); + sipSubscribe.removeErrorSubscribe(callIdHeader.getCallId()); } } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java index aee414f..203d58b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/InviteRequestProcessor.java @@ -107,6 +107,7 @@ // 鏌ヨ骞冲彴涓嬫槸鍚︽湁璇ラ�氶亾 DeviceChannel channel = storager.queryChannelInParentPlatform(requesterId, channelId); List<GbStream> gbStreams = storager.queryStreamInParentPlatform(requesterId, channelId); + PlatformCatalog catalog = storager.getCatalog(channelId); GbStream gbStream = gbStreams.size() > 0? gbStreams.get(0):null; MediaServerItem mediaServerItem = null; // 涓嶆槸閫氶亾鍙兘鏄洿鎾祦 @@ -132,7 +133,10 @@ return; } responseAck(evt, Response.CALL_IS_BEING_FORWARDED); // 閫氶亾瀛樺湪锛屽彂181锛屽懠鍙浆鎺ヤ腑 - }else { + }else if (catalog != null) { + responseAck(evt, Response.BAD_REQUEST, "catalog channel can not play"); // 鐩綍涓嶆敮鎸佺偣鎾� + return; + } else { logger.info("閫氶亾涓嶅瓨鍦紝杩斿洖404"); responseAck(evt, Response.NOT_FOUND); // 閫氶亾涓嶅瓨鍦紝鍙�404锛岃祫婧愪笉瀛樺湪 return; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java index 0aab871..bd05344 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/MessageRequestProcessor.java @@ -1,7 +1,9 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message; import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceNotFoundEvent; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; import com.genersoft.iot.vmp.gb28181.transmit.SIPProcessorObserver; import com.genersoft.iot.vmp.gb28181.transmit.event.request.ISIPRequestProcessor; import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent; @@ -19,6 +21,7 @@ import javax.sip.InvalidArgumentException; import javax.sip.RequestEvent; import javax.sip.SipException; +import javax.sip.header.CallIdHeader; import javax.sip.message.Response; import java.text.ParseException; import java.util.Map; @@ -40,6 +43,9 @@ private IVideoManagerStorager storage; @Autowired + private SipSubscribe sipSubscribe; + + @Autowired private IRedisCatchStorage redisCatchStorage; @Override @@ -56,6 +62,7 @@ public void process(RequestEvent evt) { logger.debug("鎺ユ敹鍒版秷鎭細" + evt.getRequest()); String deviceId = SipUtils.getUserIdFromFromHeader(evt.getRequest()); + CallIdHeader callIdHeader = (CallIdHeader)evt.getRequest().getHeader(CallIdHeader.NAME); // 鏌ヨ璁惧鏄惁瀛樺湪 Device device = redisCatchStorage.getDevice(deviceId); // 鏌ヨ涓婄骇骞冲彴鏄惁瀛樺湪 @@ -63,7 +70,12 @@ try { if (device == null && parentPlatform == null) { // 涓嶅瓨鍦ㄥ垯鍥炲404 - responseAck(evt, Response.NOT_FOUND, "device id not found"); + responseAck(evt, Response.NOT_FOUND, "device "+ deviceId +" not found"); + logger.warn("[璁惧鏈壘鍒� ]锛� {}", deviceId); + if (sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()) != null){ + SipSubscribe.EventResult eventResult = new SipSubscribe.EventResult(new DeviceNotFoundEvent(evt.getDialog())); + sipSubscribe.getErrorSubscribe(callIdHeader.getCallId()).response(eventResult); + }; }else { Element rootElement = getRootElement(evt); String name = rootElement.getName(); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java index c6c1ab9..0b1a572 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/CatalogNotifyMessageHandler.java @@ -1,10 +1,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.cmd; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; @@ -71,11 +68,41 @@ // 鏌ヨ鍏宠仈鐨勭洿鎾�氶亾 List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); int size = channelReduces.size() + gbStreams.size(); + // 鍥炲鐩綍淇℃伅 + List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + if (catalogs.size() > 0) { + for (PlatformCatalog catalog : catalogs) { + DeviceChannel deviceChannel = new DeviceChannel(); + deviceChannel.setChannelId(catalog.getId()); + deviceChannel.setName(catalog.getName()); + deviceChannel.setLongitude(0.0); + deviceChannel.setLatitude(0.0); + deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); + deviceChannel.setManufacture("wvp-pro"); + deviceChannel.setStatus(1); + deviceChannel.setParental(1); + deviceChannel.setParentId(catalog.getParentId()); + deviceChannel.setRegisterWay(1); + deviceChannel.setCivilCode(config.getDomain()); + deviceChannel.setModel("live"); + deviceChannel.setOwner("wvp-pro"); + deviceChannel.setSecrecy("0"); + cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); + // 闃叉鍙戦�佽繃蹇� + Thread.sleep(10); + } + } // 鍥炲绾ц仈鐨勯�氶亾 if (channelReduces.size() > 0) { for (ChannelReduce channelReduce : channelReduces) { DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); + // TODO 鐩墠鏆傛椂璁や负杩欓噷鍙敤閫氶亾娌℃湁鐩綍 + deviceChannel.setParental(0); + deviceChannel.setParentId(channelReduce.getCatalogId()); + cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); + // 闃叉鍙戦�佽繃蹇� + Thread.sleep(10); } } // 鍥炲鐩存挱鐨勯�氶亾 @@ -89,16 +116,16 @@ deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); deviceChannel.setManufacture("wvp-pro"); deviceChannel.setStatus(gbStream.isStatus()?1:0); - // deviceChannel.setParentId(parentPlatform.getDeviceGBId()); + deviceChannel.setParentId(gbStream.getCatalogId()); deviceChannel.setRegisterWay(1); deviceChannel.setCivilCode(config.getDomain()); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); deviceChannel.setSecrecy("0"); - deviceChannel.setSecrecy("0"); - cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); + // 闃叉鍙戦�佽繃蹇� + Thread.sleep(10); } } if (size == 0) { @@ -111,6 +138,8 @@ e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java index 98ed2dc..6ca608c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java @@ -1,10 +1,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd; import com.genersoft.iot.vmp.conf.SipConfig; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; -import com.genersoft.iot.vmp.gb28181.bean.GbStream; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; @@ -73,12 +70,41 @@ List<ChannelReduce> channelReduces = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); // 鏌ヨ鍏宠仈鐨勭洿鎾�氶亾 List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); - int size = channelReduces.size() + gbStreams.size(); + // 鍥炲鐩綍淇℃伅 + List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + int size = catalogs.size() + channelReduces.size() + gbStreams.size(); + if (catalogs.size() > 0) { + for (PlatformCatalog catalog : catalogs) { + DeviceChannel deviceChannel = new DeviceChannel(); + deviceChannel.setChannelId(catalog.getId()); + deviceChannel.setName(catalog.getName()); + deviceChannel.setLongitude(0.0); + deviceChannel.setLatitude(0.0); + deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); + deviceChannel.setManufacture("wvp-pro"); + deviceChannel.setStatus(1); + deviceChannel.setParental(1); + deviceChannel.setParentId(catalog.getParentId()); + deviceChannel.setRegisterWay(1); + deviceChannel.setCivilCode(config.getDomain()); + deviceChannel.setModel("live"); + deviceChannel.setOwner("wvp-pro"); + deviceChannel.setSecrecy("0"); + cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); + // 闃叉鍙戦�佽繃蹇� + Thread.sleep(10); + } + } // 鍥炲绾ц仈鐨勯�氶亾 if (channelReduces.size() > 0) { for (ChannelReduce channelReduce : channelReduces) { DeviceChannel deviceChannel = storager.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); + // TODO 鐩墠鏆傛椂璁や负杩欓噷鍙敤閫氶亾娌℃湁鐩綍 + deviceChannel.setParental(0); + deviceChannel.setParentId(channelReduce.getCatalogId()); cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); + // 闃叉鍙戦�佽繃蹇� + Thread.sleep(10); } } // 鍥炲鐩存挱鐨勯�氶亾 @@ -92,13 +118,12 @@ deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); deviceChannel.setManufacture("wvp-pro"); deviceChannel.setStatus(gbStream.isStatus()?1:0); - // deviceChannel.setParentId(parentPlatform.getDeviceGBId()); + deviceChannel.setParentId(gbStream.getCatalogId()); deviceChannel.setRegisterWay(1); deviceChannel.setCivilCode(config.getDomain()); deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); - deviceChannel.setSecrecy("0"); deviceChannel.setSecrecy("0"); cmderFroPlatform.catalogQuery(deviceChannel, parentPlatform, sn, fromHeader.getTag(), size); @@ -114,6 +139,8 @@ e.printStackTrace(); } catch (ParseException e) { e.printStackTrace(); + } catch (InterruptedException e) { + e.printStackTrace(); } } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java index b6af955..118b2af 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java @@ -4,7 +4,6 @@ import java.util.UUID; import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONArray; import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.conf.MediaConfig; import com.genersoft.iot.vmp.conf.UserSetup; @@ -302,7 +301,7 @@ @ResponseBody @PostMapping(value = "/on_stream_changed", produces = "application/json;charset=UTF-8") public ResponseEntity<String> onStreamChanged(@RequestBody MediaItem item){ - + if (logger.isDebugEnabled()) { logger.debug("[ ZLM HOOK ]on_stream_changed API璋冪敤锛屽弬鏁帮細" + JSONObject.toJSONString(item)); } @@ -322,10 +321,8 @@ String schema = item.getSchema(); List<MediaItem.MediaTrack> tracks = item.getTracks(); boolean regist = item.isRegist(); - if (tracks != null) { - logger.info("[stream: " + streamId + "] on_stream_changed->>" + schema); - } if ("rtmp".equals(schema)){ + logger.info("on_stream_changed锛氭敞鍐�->{}, app->{}, stream->{}", regist, app, streamId); if (regist) { mediaServerService.addCount(mediaServerId); }else { diff --git a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java index 49ba7b7..9c5c32f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java @@ -30,7 +30,7 @@ * 淇濆瓨鍥芥爣鍏宠仈 * @param gbStreams */ - boolean addPlatformInfo(List<GbStream> gbStreams, String platformId); + boolean addPlatformInfo(List<GbStream> gbStreams, String platformId, String catalogId); /** * 绉婚櫎鍥芥爣鍏宠仈 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java index 5002d29..21c666f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java @@ -47,13 +47,15 @@ @Override - public boolean addPlatformInfo(List<GbStream> gbStreams, String platformId) { + public boolean addPlatformInfo(List<GbStream> gbStreams, String platformId, String catalogId) { // 鏀惧湪浜嬪姟鍐呮墽琛� boolean result = false; TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); try { for (GbStream gbStream : gbStreams) { + gbStream.setCatalogId(catalogId); gbStream.setPlatformId(platformId); + // TODO 淇敼涓烘壒閲忔彁浜� platformGbStreamMapper.add(gbStream); } dataSourceTransactionManager.commit(transactionStatus); //鎵嬪姩鎻愪氦 diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java index a972585..8ec9474 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java @@ -130,7 +130,7 @@ if ( !StringUtils.isEmpty(param.getPlatformGbId()) && streamLive) { List<GbStream> gbStreams = new ArrayList<>(); gbStreams.add(param); - if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId())){ + if (gbStreamService.addPlatformInfo(gbStreams, param.getPlatformGbId(), param.getCatalogId())){ result.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]鎴愬姛"); }else { result.append(", 鍏宠仈鍥芥爣骞冲彴[ " + param.getPlatformGbId() + " ]澶辫触"); @@ -141,6 +141,7 @@ if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { param.setPlatformId(parentPlatform.getServerGBId()); + param.setCatalogId(parentPlatform.getCatalogId()); String stream = param.getStream(); StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId()); if (streamProxyItems == null) { diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java index 5fef8cf..2a70754 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java @@ -119,6 +119,7 @@ List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { + stream.setCatalogId(parentPlatform.getCatalogId()); stream.setPlatformId(parentPlatform.getServerGBId()); String streamId = stream.getStream(); StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId()); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java index 68a772e..c890b05 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -185,6 +185,8 @@ */ void updateDevice(Device device); + void removeDevice(String deviceId); + /** * 鑾峰彇Device */ diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java index 9118d76..96a487c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorager.java @@ -243,7 +243,7 @@ * @param channelReduces * @return */ - int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces); + int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId); /** * 绉婚櫎涓婄骇骞冲彴鐨勯�氶亾淇℃伅 @@ -255,6 +255,9 @@ DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); + + List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); + List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId); Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); @@ -431,4 +434,26 @@ * @param deviceChannelList */ boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList); + + /** + * 鑾峰彇鐩綍淇℃伅 + * @param platformId + * @param parentId + * @return + */ + List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId); + + int addCatalog(PlatformCatalog platformCatalog); + + PlatformCatalog getCatalog(String id); + + int delCatalog(String id); + + int updateCatalog(PlatformCatalog platformCatalog); + + int setDefaultCatalog(String platformId, String catalogId); + + List<PlatformCatalog> queryCatalogInPlatform(String serverGBId); + + int delRelation(PlatformCatalog platformCatalog); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java index 8377ccb..3a4f466 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java @@ -91,7 +91,8 @@ "SELECT * FROM ( "+ " SELECT dc.channelId, dc.deviceId, dc.name, de.manufacturer, de.hostAddress, " + "(SELECT count(0) FROM device_channel WHERE parentId=dc.channelId) as subCount, " + - "(SELECT pc.platformId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as platformId " + + "(SELECT pc.platformId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as platformId, " + + "(SELECT pc.catalogId FROM platform_gb_channel pc WHERE pc.deviceId=dc.deviceId AND pc.channelId = dc.channelId ) as catalogId " + "FROM device_channel dc " + "LEFT JOIN device de ON dc.deviceId = de.deviceId " + " WHERE 1=1 " + diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java index ffbca9c..fa6b51c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java @@ -35,7 +35,7 @@ @Delete("DELETE FROM gb_stream WHERE app=#{app} AND stream=#{stream}") int del(String app, String stream); - @Select("SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream") + @Select("SELECT gs.*, pgs.platformId AS platformId, pgs.catalogId AS catalogId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream") List<GbStream> selectAll(); @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}") @@ -44,12 +44,12 @@ @Select("SELECT * FROM gb_stream WHERE gbId=#{gbId}") List<GbStream> selectByGBId(String gbId); - @Select("SELECT gs.*, pgs.platformId FROM gb_stream gs " + + @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") List<GbStream> queryStreamInPlatform(String platformId, String gbId); - @Select("SELECT gs.*, pgs.platformId FROM gb_stream gs " + + @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + "LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream " + "WHERE pgs.platformId = '${platformId}'") List<GbStream> queryGbStreamListInPlatform(String platformId); @@ -59,16 +59,10 @@ "WHERE app=#{app} AND stream=#{stream}") int setStatus(String app, String stream, boolean status); - @Select("SELECT gs.*, pgs.platformId FROM gb_stream gs LEFT JOIN platform_gb_stream pgs ON gs.app = pgs.app AND gs.stream = pgs.stream WHERE mediaServerId=#{mediaServerId} ") - List<GbStream> selectAllByMediaServerId(String mediaServerId); - @Update("UPDATE gb_stream " + "SET status=${status} " + "WHERE mediaServerId=#{mediaServerId} ") void updateStatusByMediaServerId(String mediaServerId, boolean status); - - @Select("SELECT * FROM gb_stream WHERE mediaServerId=#{mediaServerId}") - void delByMediaServerId(String mediaServerId); @Delete("DELETE FROM gb_stream WHERE streamType=#{type} AND gbId=NULL AND mediaServerId=#{mediaServerId}") void deleteWithoutGBId(String type, String mediaServerId); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java index c92711a..4f0cbea 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java @@ -15,10 +15,10 @@ @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + - " status, shareAllLiveStream) " + + " status, shareAllLiveStream, catalogId) " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + - " ${status}, ${shareAllLiveStream})") + " ${status}, ${shareAllLiveStream}, #{catalogId})") int addParentPlatform(ParentPlatform parentPlatform); @Update("UPDATE parent_platform " + @@ -40,7 +40,8 @@ "ptz=#{ptz}, " + "rtcp=#{rtcp}, " + "status=#{status}, " + - "shareAllLiveStream=#{shareAllLiveStream} " + + "shareAllLiveStream=#{shareAllLiveStream}, " + + "catalogId=#{catalogId} " + "WHERE id=#{id}") int updateParentPlatform(ParentPlatform parentPlatform); @@ -74,4 +75,11 @@ @Select("SELECT * FROM parent_platform WHERE shareAllLiveStream=true") List<ParentPlatform> selectAllAhareAllLiveStream(); + + @Update(value = {" <script>" + + "UPDATE parent_platform " + + "SET catalogId=#{catalogId}" + + "WHERE serverGBId=#{platformId}"+ + "</script>"}) + int setDefaultCatalog(String platformId, String catalogId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java new file mode 100644 index 0000000..03c66d4 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java @@ -0,0 +1,42 @@ +package com.genersoft.iot.vmp.storager.dao; + +import com.genersoft.iot.vmp.gb28181.bean.GbStream; +import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; +import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; +import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; +import org.apache.ibatis.annotations.*; +import org.springframework.stereotype.Repository; + +import java.util.List; + + +@Mapper +@Repository +public interface PlatformCatalogMapper { + + @Insert("INSERT INTO platform_catalog (id, name, platformId, parentId) VALUES" + + "(#{id}, #{name}, #{platformId}, #{parentId})") + int add(PlatformCatalog platformCatalog); + + @Delete("DELETE FROM platform_catalog WHERE id=#{id}") + int del(String id); + + @Delete("DELETE FROM platform_catalog WHERE platformId=#{platformId}") + int delByPlatformId(String platformId); + + @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id AND platformId=#{platformId}) as childrenCount FROM platform_catalog pc WHERE parentId=#{parentId} AND platformId=#{platformId}") + List<PlatformCatalog> selectByParentId(String platformId, String parentId); + + @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.id=#{id}") + PlatformCatalog select(String id); + + @Update(value = {" <script>" + + "UPDATE platform_catalog " + + "SET name=#{name}" + + "WHERE id=#{id}"+ + "</script>"}) + int update(PlatformCatalog platformCatalog); + + @Select("SELECT *, (SELECT COUNT(1) from platform_catalog where parentId = pc.id) as childrenCount FROM platform_catalog pc WHERE pc.platformId=#{platformId}") + List<PlatformCatalog> selectByPlatForm(String platformId); +} diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java index c8130c3..da38cb0 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java @@ -2,6 +2,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import org.apache.ibatis.annotations.Delete; import org.apache.ibatis.annotations.Insert; @@ -25,9 +26,9 @@ List<String> findChannelRelatedPlatform(String platformId, List<String> deviceAndChannelIds); @Insert("<script> "+ - "INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId) VALUES" + + "INSERT INTO platform_gb_channel (channelId, deviceId, platformId, deviceAndChannelId, catalogId) VALUES" + "<foreach collection='channelReducesToAdd' item='item' separator=','>" + - " ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' )" + + " ('${item.channelId}','${item.deviceId}', '${platformId}', '${item.deviceId}_${item.channelId}' , '${item.catalogId}' )" + "</foreach>" + "</script>") int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); @@ -54,6 +55,22 @@ "platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'") DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); + + @Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " + + "from device_channel dc left join platform_gb_channel pgc on dc.deviceId = pgc.deviceId and dc.channelId = pgc.channelId " + + "where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}") + List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); + @Select("SELECT * FROM device WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE platformId='${platformId}' AND channelId='${channelId}')") Device queryVideoDeviceByPlatformIdAndChannelId(String platformId, String channelId); + + @Delete("<script> "+ + "DELETE FROM platform_gb_channel WHERE catalogId=#{id}" + + "</script>") + int delByCatalogId(String id); + + @Delete("<script> "+ + "DELETE FROM platform_gb_channel WHERE catalogId=#{parentId} AND platformId=#{platformId} AND channelId=#{id}" + + "</script>") + int delByCatalogIdAndChannelIdAndPlatformId(PlatformCatalog platformCatalog); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java index a51eda2..06486c9 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformGbStreamMapper.java @@ -1,5 +1,7 @@ package com.genersoft.iot.vmp.storager.dao; +import com.genersoft.iot.vmp.gb28181.bean.GbStream; +import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import org.apache.ibatis.annotations.*; @@ -12,8 +14,8 @@ @Repository public interface PlatformGbStreamMapper { - @Insert("INSERT INTO platform_gb_stream (app, stream, platformId) VALUES" + - "('${app}', '${stream}', '${platformId}')") + @Insert("INSERT INTO platform_gb_stream (app, stream, platformId, catalogId) VALUES" + + "('${app}', '${stream}', '${platformId}', '${catalogId}')") int add(PlatformGbStream platformGbStream); @Delete("DELETE FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream}") @@ -27,4 +29,22 @@ @Select("SELECT * FROM platform_gb_stream WHERE app=#{app} AND stream=#{stream} AND platformId=#{serverGBId}") StreamProxyItem selectOne(String app, String stream, String serverGBId); + + @Select("select gs.* \n" + + "from gb_stream gs\n" + + " left join platform_gb_stream pgs\n" + + " on gs.app = pgs.app and gs.stream = pgs.stream\n" + + "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") + List<GbStream> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId); + + @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" + + "from gb_stream gs\n" + + " left join platform_gb_stream pgs\n" + + " on gs.app = pgs.app and gs.stream = pgs.stream\n" + + "where pgs.platformId=#{platformId} and pgs.catalogId=#{catalogId}") + List<PlatformCatalog> queryChannelInParentPlatformAndCatalogForCatlog(String platformId, String catalogId); + + @Delete("DELETE FROM platform_gb_stream WHERE catalogId=#{id}") + int delByCatalogId(String id); + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java index 3ded416..309db20 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/RedisCatchStorageImpl.java @@ -407,6 +407,12 @@ } @Override + public void removeDevice(String deviceId) { + String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId; + redis.del(key); + } + + @Override public Device getDevice(String deviceId) { String key = VideoManagerConstants.DEVICE_PREFIX + userSetup.getServerId() + "_" + deviceId; return (Device)redis.get(key); diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java index 1d8d83a..7f0efcd 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStoragerImpl.java @@ -71,6 +71,9 @@ @Autowired private GbStreamMapper gbStreamMapper; + + @Autowired + private PlatformCatalogMapper catalogMapper; ; @Autowired @@ -449,6 +452,9 @@ @Override public boolean addParentPlatform(ParentPlatform parentPlatform) { + if (parentPlatform.getCatalogId() == null) { + parentPlatform.setCatalogId(parentPlatform.getServerGBId()); + } int result = platformMapper.addParentPlatform(parentPlatform); return result > 0; } @@ -458,6 +464,9 @@ int result = 0; ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); if (parentPlatform.getId() == null ) { + if (parentPlatform.getCatalogId() == null) { + parentPlatform.setCatalogId(parentPlatform.getServerGBId()); + } result = platformMapper.addParentPlatform(parentPlatform); if (parentPlatformCatch == null) { parentPlatformCatch = new ParentPlatformCatch(); @@ -480,8 +489,11 @@ // 鍏变韩鎵�鏈夎棰戞祦锛岄渶瑕佸皢鐜版湁瑙嗛娴佹坊鍔犲埌姝ゅ钩鍙� List<GbStream> gbStreams = gbStreamMapper.selectAll(); if (gbStreams.size() > 0) { + for (GbStream gbStream : gbStreams) { + gbStream.setCatalogId(parentPlatform.getCatalogId()); + } if (parentPlatform.isShareAllLiveStream()) { - gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId()); + gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId()); }else { gbStreamService.delPlatformInfo(gbStreams); } @@ -536,10 +548,11 @@ } @Override - public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces) { + public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) { Map<String, ChannelReduce> deviceAndChannels = new HashMap<>(); for (ChannelReduce channelReduce : channelReduces) { + channelReduce.setCatalogId(catalogId); deviceAndChannels.put(channelReduce.getDeviceId() + "_" + channelReduce.getChannelId(), channelReduce); } List<String> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); @@ -574,6 +587,18 @@ public DeviceChannel queryChannelInParentPlatform(String platformId, String channelId) { DeviceChannel channel = platformChannelMapper.queryChannelInParentPlatform(platformId, channelId); return channel; + } + + @Override + public List<PlatformCatalog> queryChannelInParentPlatformAndCatalog(String platformId, String catalogId) { + List<PlatformCatalog> catalogs = platformChannelMapper.queryChannelInParentPlatformAndCatalog(platformId, catalogId); + return catalogs; + } + + @Override + public List<PlatformCatalog> queryStreamInParentPlatformAndCatalog(String platformId, String catalogId) { + List<PlatformCatalog> catalogs = platformGbStreamMapper.queryChannelInParentPlatformAndCatalogForCatlog(platformId, catalogId); + return catalogs; } @Override @@ -739,6 +764,7 @@ List<ParentPlatform> parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); if (parentPlatforms.size() > 0) { for (ParentPlatform parentPlatform : parentPlatforms) { + streamPushItem.setCatalogId(parentPlatform.getCatalogId()); streamPushItem.setPlatformId(parentPlatform.getServerGBId()); String stream = streamPushItem.getStream(); StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(streamPushItem.getApp(), stream, parentPlatform.getServerGBId()); @@ -804,4 +830,69 @@ return streamProxyMapper.selectOne(app, streamId); } + @Override + public List<PlatformCatalog> getChildrenCatalogByPlatform(String platformId, String parentId) { + return catalogMapper.selectByParentId(platformId, parentId); + } + + @Override + public int addCatalog(PlatformCatalog platformCatalog) { + return catalogMapper.add(platformCatalog); + } + + @Override + public PlatformCatalog getCatalog(String id) { + return catalogMapper.select(id); + } + + @Override + public int delCatalog(String id) { + PlatformCatalog platformCatalog = catalogMapper.select(id); + if (platformCatalog.getChildrenCount() > 0) { + List<PlatformCatalog> platformCatalogList = catalogMapper.selectByParentId(platformCatalog.getPlatformId(), platformCatalog.getId()); + for (PlatformCatalog catalog : platformCatalogList) { + if (catalog.getChildrenCount() == 0) { + catalogMapper.del(catalog.getId()); + platformGbStreamMapper.delByCatalogId(catalog.getId()); + platformChannelMapper.delByCatalogId(catalog.getId()); + }else { + delCatalog(catalog.getId()); + } + } + } + int delresult = catalogMapper.del(id); + int delStreamresult = platformGbStreamMapper.delByCatalogId(id); + int delChanneresult = platformChannelMapper.delByCatalogId(id); + return delresult + delChanneresult + delStreamresult; + } + + @Override + public int updateCatalog(PlatformCatalog platformCatalog) { + return catalogMapper.update(platformCatalog); + } + + @Override + public int setDefaultCatalog(String platformId, String catalogId) { + return platformMapper.setDefaultCatalog(platformId, catalogId); + } + + @Override + public List<PlatformCatalog> queryCatalogInPlatform(String platformId) { + return catalogMapper.selectByPlatForm(platformId); + } + + @Override + public int delRelation(PlatformCatalog platformCatalog) { + if (platformCatalog.getType() == 1) { + return platformChannelMapper.delByCatalogIdAndChannelIdAndPlatformId(platformCatalog); + }else if (platformCatalog.getType() == 2) { + List<GbStream> gbStreams = platformGbStreamMapper.queryChannelInParentPlatformAndCatalog(platformCatalog.getPlatformId(), platformCatalog.getParentId()); + for (GbStream gbStream : gbStreams) { + if (gbStream.getGbId().equals(platformCatalog.getId())) { + return platformGbStreamMapper.delByAppAndStream(gbStream.getApp(), gbStream.getStream()); + } + } + } + return 0; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java index 729eca2..959ac21 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/device/DeviceQuery.java @@ -152,12 +152,16 @@ String uuid = UUID.randomUUID().toString(); DeferredResult<ResponseEntity<Device>> result = new DeferredResult<ResponseEntity<Device>>(15*1000L); result.onTimeout(()->{ - logger.warn(String.format("璁惧閫氶亾淇℃伅鍚屾瓒呮椂")); + logger.warn("璁惧[{}]閫氶亾淇℃伅鍚屾瓒呮椂", deviceId); // 閲婃斁rtpserver RequestMessage msg = new RequestMessage(); msg.setKey(key); msg.setId(uuid); - msg.setData("Timeout"); + WVPResult<Object> wvpResult = new WVPResult<>(); + wvpResult.setCode(-1); + wvpResult.setData(device); + wvpResult.setMsg("鏇存柊瓒呮椂"); + msg.setData(wvpResult); resultHolder.invokeAllResult(msg); }); // 绛夊緟鍏朵粬鐩稿悓璇锋眰杩斿洖鏃朵竴璧疯繑鍥� @@ -168,7 +172,11 @@ RequestMessage msg = new RequestMessage(); msg.setKey(key); msg.setId(uuid); - msg.setData(String.format("鍚屾閫氶亾澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg)); + WVPResult<Object> wvpResult = new WVPResult<>(); + wvpResult.setCode(-1); + wvpResult.setData(device); + wvpResult.setMsg(String.format("鍚屾閫氶亾澶辫触锛岄敊璇爜锛� %s, %s", event.statusCode, event.msg)); + msg.setData(wvpResult); resultHolder.invokeAllResult(msg); }); @@ -199,6 +207,7 @@ boolean isSuccess = storager.delete(deviceId); if (isSuccess) { redisCatchStorage.clearCatchByDeviceId(deviceId); + redisCatchStorage.removeDevice(deviceId); JSONObject json = new JSONObject(); json.put("deviceId", deviceId); return new ResponseEntity<>(json.toString(),HttpStatus.OK); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java index fcfc847..69492a7 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java @@ -82,7 +82,7 @@ @PostMapping(value = "/add") @ResponseBody public Object add(@RequestBody GbStreamParam gbStreamParam){ - if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId())) { + if (gbStreamService.addPlatformInfo(gbStreamParam.getGbStreams(), gbStreamParam.getPlatformId(), gbStreamParam.getCatalogId())) { return "success"; }else { return "fail"; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java index 40456a8..a377c1c 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/bean/GbStreamParam.java @@ -8,12 +8,22 @@ private String platformId; + private String catalogId; + private List<GbStream> gbStreams; public String getPlatformId() { return platformId; } + public String getCatalogId() { + return catalogId; + } + + public void setCatalogId(String catalogId) { + this.catalogId = catalogId; + } + public void setPlatformId(String platformId) { this.platformId = platformId; } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java index 5af0837..0dc172f 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java @@ -1,10 +1,15 @@ package com.genersoft.iot.vmp.vmanager.gb28181.platform; +import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; +import com.genersoft.iot.vmp.gb28181.bean.CatalogData; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorager; +import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.UpdateChannelParam; import com.github.pagehelper.PageInfo; @@ -20,6 +25,8 @@ import org.springframework.util.StringUtils; import org.springframework.web.bind.annotation.*; import com.genersoft.iot.vmp.conf.SipConfig; + +import java.util.List; /** * 绾ц仈骞冲彴绠$悊 @@ -253,7 +260,7 @@ if (logger.isDebugEnabled()) { logger.debug("缁欎笂绾у钩鍙版坊鍔犲浗鏍囬�氶亾API璋冪敤"); } - int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces()); + int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); } @@ -279,5 +286,197 @@ return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); } + /** + * 鑾峰彇鐩綍 + * @param platformId 骞冲彴ID + * @param parentId 鐩綍鐖禝D + * @return + */ + @ApiOperation("鑾峰彇鐩綍") + @ApiImplicitParams({ + @ApiImplicitParam(name = "platformId", value = "骞冲彴ID", dataTypeClass = String.class, required = true), + @ApiImplicitParam(name = "parentId", value = "鐩綍鐖禝D", dataTypeClass = String.class, required = true), + }) + @GetMapping("/catalog") + @ResponseBody + public ResponseEntity<WVPResult<List<PlatformCatalog>>> getCatalogByPlatform(String platformId, String parentId){ + + if (logger.isDebugEnabled()) { + logger.debug("鏌ヨ鐩綍,platformId: {}, parentId: {}", platformId, parentId); + } + List<PlatformCatalog> platformCatalogList = storager.getChildrenCatalogByPlatform(platformId, parentId); + // 鏌ヨ涓嬪睘鐨勫浗鏍囬�氶亾 + List<PlatformCatalog> catalogsForChannel = storager.queryChannelInParentPlatformAndCatalog(platformId, parentId); + List<PlatformCatalog> catalogsForStream = storager.queryStreamInParentPlatformAndCatalog(platformId, parentId); + platformCatalogList.addAll(catalogsForChannel); + platformCatalogList.addAll(catalogsForStream); + WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); + result.setCode(0); + result.setMsg("success"); + result.setData(platformCatalogList); + return new ResponseEntity<>(result, HttpStatus.OK); + } + + /** + * 娣诲姞鐩綍 + * @param platformCatalog 鐩綍 + * @return + */ + @ApiOperation("娣诲姞鐩綍") + @ApiImplicitParams({ + @ApiImplicitParam(name = "platformCatalog", value = "鐩綍淇℃伅", dataTypeClass = PlatformCatalog.class, required = true), + }) + @PostMapping("/catalog/add") + @ResponseBody + public ResponseEntity<WVPResult<List<PlatformCatalog>>> addCatalog(@RequestBody PlatformCatalog platformCatalog){ + + if (logger.isDebugEnabled()) { + logger.debug("娣诲姞鐩綍,{}", JSON.toJSONString(platformCatalog)); + } + PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); + WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); + + + if (platformCatalogInStore != null) { + result.setCode(-1); + result.setMsg( platformCatalog.getId() + " already exists"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + int addResult = storager.addCatalog(platformCatalog); + if (addResult > 0) { + result.setCode(0); + result.setMsg("success"); + return new ResponseEntity<>(result, HttpStatus.OK); + }else { + result.setCode(-500); + result.setMsg("save error"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + } + + /** + * 缂栬緫鐩綍 + * @param platformCatalog 鐩綍 + * @return + */ + @ApiOperation("缂栬緫鐩綍") + @ApiImplicitParams({ + @ApiImplicitParam(name = "platformCatalog", value = "鐩綍淇℃伅", dataTypeClass = PlatformCatalog.class, required = true), + }) + @PostMapping("/catalog/edit") + @ResponseBody + public ResponseEntity<WVPResult<List<PlatformCatalog>>> editCatalog(@RequestBody PlatformCatalog platformCatalog){ + + if (logger.isDebugEnabled()) { + logger.debug("缂栬緫鐩綍,{}", JSON.toJSONString(platformCatalog)); + } + PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); + WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); + result.setCode(0); + + if (platformCatalogInStore == null) { + result.setMsg( platformCatalog.getId() + " not exists"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + int addResult = storager.updateCatalog(platformCatalog); + if (addResult > 0) { + result.setMsg("success"); + return new ResponseEntity<>(result, HttpStatus.OK); + }else { + result.setMsg("save error"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + } + + /** + * 鍒犻櫎鐩綍 + * @param id 鐩綍Id + * @return + */ + @ApiOperation("鍒犻櫎鐩綍") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", value = "鐩綍Id", dataTypeClass = String.class, required = true), + }) + @DeleteMapping("/catalog/del") + @ResponseBody + public ResponseEntity<WVPResult<List<PlatformCatalog>>> delCatalog(String id){ + + if (logger.isDebugEnabled()) { + logger.debug("鍒犻櫎鐩綍,{}", id); + } + int delResult = storager.delCatalog(id); + WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); + result.setCode(0); + + if (delResult > 0) { + result.setMsg("success"); + return new ResponseEntity<>(result, HttpStatus.OK); + }else { + result.setMsg("save error"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + } + + /** + * 鍒犻櫎鍏宠仈 + * @param platformCatalog 鍏宠仈鐨勪俊鎭� + * @return + */ + @ApiOperation("鍒犻櫎鍏宠仈") + @ApiImplicitParams({ + @ApiImplicitParam(name = "platformCatalog", value = "鍏宠仈鐨勪俊鎭�", dataTypeClass = PlatformCatalog.class, required = true), + }) + @DeleteMapping("/catalog/relation/del") + @ResponseBody + public ResponseEntity<WVPResult<List<PlatformCatalog>>> delRelation(@RequestBody PlatformCatalog platformCatalog){ + + if (logger.isDebugEnabled()) { + logger.debug("鍒犻櫎鍏宠仈,{}", JSON.toJSONString(platformCatalog)); + } + int delResult = storager.delRelation(platformCatalog); + WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); + result.setCode(0); + + if (delResult > 0) { + result.setMsg("success"); + return new ResponseEntity<>(result, HttpStatus.OK); + }else { + result.setMsg("save error"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + } + + + /** + * 淇敼榛樿鐩綍 + * @param platformId 骞冲彴Id + * @param catalogId 鐩綍Id + * @return + */ + @ApiOperation("淇敼榛樿鐩綍") + @ApiImplicitParams({ + @ApiImplicitParam(name = "platformId", value = "骞冲彴Id", dataTypeClass = String.class, required = true), + @ApiImplicitParam(name = "catalogId", value = "鐩綍Id", dataTypeClass = String.class, required = true), + }) + @PostMapping("/catalog/default/update") + @ResponseBody + public ResponseEntity<WVPResult<String>> setDefaultCatalog(String platformId, String catalogId){ + + if (logger.isDebugEnabled()) { + logger.debug("淇敼榛樿鐩綍,{},{}", platformId, catalogId); + } + int updateResult = storager.setDefaultCatalog(platformId, catalogId); + WVPResult<String> result = new WVPResult<>(); + result.setCode(0); + + if (updateResult > 0) { + result.setMsg("success"); + return new ResponseEntity<>(result, HttpStatus.OK); + }else { + result.setMsg("save error"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + } + } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java index d4ef0bc..fc13e05 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/ChannelReduce.java @@ -40,6 +40,11 @@ */ private String platformId; + /** + * 鐩綍Id + */ + private String catalogId; + public String getChannelId() { return channelId; @@ -96,4 +101,12 @@ public void setPlatformId(String platformId) { this.platformId = platformId; } + + public String getCatalogId() { + return catalogId; + } + + public void setCatalogId(String catalogId) { + this.catalogId = catalogId; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java index 445b08b..5b97f18 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/bean/UpdateChannelParam.java @@ -4,6 +4,7 @@ public class UpdateChannelParam { private String platformId; + private String catalogId; private List<ChannelReduce> channelReduces; public String getPlatformId() { @@ -21,4 +22,12 @@ public void setChannelReduces(List<ChannelReduce> channelReduces) { this.channelReduces = channelReduces; } + + public String getCatalogId() { + return catalogId; + } + + public void setCatalogId(String catalogId) { + this.catalogId = catalogId; + } } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index a9d7a08..c0b2919 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -27,7 +27,7 @@ datasource: # 浣跨敤mysql 鎵撳紑23-28琛屾敞閲婏紝 鍒犻櫎29-36琛� # name: wvp - # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true + # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true # username: # password: # type: com.alibaba.druid.pool.DruidDataSource diff --git a/src/main/resources/application-dev.yml b/src/main/resources/application-dev.yml index 066702a..0246161 100644 --- a/src/main/resources/application-dev.yml +++ b/src/main/resources/application-dev.yml @@ -15,7 +15,7 @@ datasource: # 浣跨敤mysql 鎵撳紑23-28琛屾敞閲婏紝 鍒犻櫎29-36琛� # name: wvp - # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true + # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true # username: # password: # type: com.alibaba.druid.pool.DruidDataSource diff --git a/src/main/resources/application-docker.yml b/src/main/resources/application-docker.yml index 7eefe88..9e48bc5 100644 --- a/src/main/resources/application-docker.yml +++ b/src/main/resources/application-docker.yml @@ -15,7 +15,7 @@ datasource: # 浣跨敤mysql 鎵撳紑23-28琛屾敞閲婏紝 鍒犻櫎29-36琛� # name: wvp - # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true + # url: jdbc:mysql://127.0.0.1:3306/wvp?useUnicode=true&characterEncoding=UTF8&rewriteBatchedStatements=true&allowMultiQueries=true # username: # password: # type: com.alibaba.druid.pool.DruidDataSource diff --git a/src/main/resources/wvp.sqlite b/src/main/resources/wvp.sqlite index e6140f4..37eefca 100644 --- a/src/main/resources/wvp.sqlite +++ b/src/main/resources/wvp.sqlite Binary files differ diff --git a/web_src/package-lock.json b/web_src/package-lock.json index c4862ca..a1bc6f8 100644 --- a/web_src/package-lock.json +++ b/web_src/package-lock.json @@ -19,6 +19,7 @@ "vue-baidu-map": "^0.21.22", "vue-clipboard2": "^0.3.1", "vue-clipboards": "^1.3.0", + "vue-contextmenujs": "^1.3.13", "vue-cookies": "^1.7.4", "vue-router": "^3.1.6" }, @@ -12920,6 +12921,11 @@ "tiny-emitter": "^2.0.0" } }, + "node_modules/vue-contextmenujs": { + "version": "1.3.13", + "resolved": "https://registry.npmmirror.com/vue-contextmenujs/download/vue-contextmenujs-1.3.13.tgz", + "integrity": "sha1-O9rgI8e9QgleeNpCWAACUNUKuO8=" + }, "node_modules/vue-cookies": { "version": "1.7.4", "resolved": "https://registry.npm.taobao.org/vue-cookies/download/vue-cookies-1.7.4.tgz?cache=0&sync_timestamp=1598941352058&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-cookies%2Fdownload%2Fvue-cookies-1.7.4.tgz", @@ -25077,6 +25083,11 @@ } } }, + "vue-contextmenujs": { + "version": "1.3.13", + "resolved": "https://registry.npmmirror.com/vue-contextmenujs/download/vue-contextmenujs-1.3.13.tgz", + "integrity": "sha1-O9rgI8e9QgleeNpCWAACUNUKuO8=" + }, "vue-cookies": { "version": "1.7.4", "resolved": "https://registry.npm.taobao.org/vue-cookies/download/vue-cookies-1.7.4.tgz?cache=0&sync_timestamp=1598941352058&other_urls=https%3A%2F%2Fregistry.npm.taobao.org%2Fvue-cookies%2Fdownload%2Fvue-cookies-1.7.4.tgz", diff --git a/web_src/package.json b/web_src/package.json index 69d8b6a..3c682a1 100644 --- a/web_src/package.json +++ b/web_src/package.json @@ -21,6 +21,7 @@ "vue-baidu-map": "^0.21.22", "vue-clipboard2": "^0.3.1", "vue-clipboards": "^1.3.0", + "vue-contextmenujs": "^1.3.13", "vue-cookies": "^1.7.4", "vue-router": "^3.1.6" }, diff --git a/web_src/src/components/ParentPlatformList.vue b/web_src/src/components/ParentPlatformList.vue index 6960c6a..a3f1120 100644 --- a/web_src/src/components/ParentPlatformList.vue +++ b/web_src/src/components/ParentPlatformList.vue @@ -138,7 +138,7 @@ }); }, chooseChannel: function(platform) { - this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, this.initData) + this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, this.initData) }, initData: function() { this.getPlatformList(); diff --git a/web_src/src/components/dialog/catalogEdit.vue b/web_src/src/components/dialog/catalogEdit.vue new file mode 100644 index 0000000..5b59494 --- /dev/null +++ b/web_src/src/components/dialog/catalogEdit.vue @@ -0,0 +1,101 @@ +<template> + <div id="catalogEdit" v-loading="isLoging"> + <el-dialog + title="鑺傜偣缂栬緫" + width="40%" + top="2rem" + :append-to-body="true" + :close-on-click-modal="false" + :visible.sync="showDialog" + :destroy-on-close="true" + @close="close()" + > + <div id="shared" style="margin-top: 1rem;margin-right: 100px;"> + <el-form ref="form" :rules="rules" :model="form" label-width="140px" > + <el-form-item label="鑺傜偣缂栧彿" prop="id" > + <el-input v-model="form.id" :disabled="isEdit"></el-input> + </el-form-item> + <el-form-item label="鑺傜偣鍚嶇О" prop="name"> + <el-input v-model="form.name" clearable></el-input> + </el-form-item> + <el-form-item> + <div style="float: right;"> + <el-button type="primary" @click="onSubmit" >纭</el-button> + <el-button @click="close">鍙栨秷</el-button> + </div> + + </el-form-item> + </el-form> + </div> + </el-dialog> + </div> +</template> + +<script> + +export default { + name: "catalogEdit", + computed: {}, + props: ['platformId'], + created() {}, + data() { + return { + submitCallback: null, + showDialog: false, + isLoging: false, + isEdit: false, + form: { + id: null, + name: null, + platformId: null, + parentId: null, + }, + rules: { + name: [{ required: true, message: "璇疯緭鍏ュ悕绉�", trigger: "blur" }], + id: [{ required: true, message: "璇疯緭鍏d", trigger: "blur" }] + }, + }; + }, + methods: { + openDialog: function (isEdit, id, name, parentId, callback) { + console.log("parentId: " + parentId) + this.isEdit = isEdit; + this.form.id = id; + this.form.name = name; + this.form.platformId = this.platformId; + this.form.parentId = parentId; + this.showDialog = true; + this.submitCallback = callback; + }, + onSubmit: function () { + console.log("onSubmit"); + console.log(this.form); + this.$axios({ + method:"post", + url:`/api/platform/catalog/${!this.isEdit? "add":"edit"}`, + data: this.form + }) + .then((res)=> { + if (res.data.code === 0) { + console.log("娣诲姞/淇敼鎴愬姛") + if (this.submitCallback)this.submitCallback() + }else { + this.$message({ + showClose: true, + message: res.data.msg, + type: "error", + }); + } + this.close(); + }) + .catch((error)=> { + console.log(error); + }); + }, + close: function () { + this.showDialog = false; + this.$refs.form.resetFields(); + }, + }, +}; +</script> diff --git a/web_src/src/components/dialog/chooseChannel.vue b/web_src/src/components/dialog/chooseChannel.vue index 87fc62e..85755e8 100644 --- a/web_src/src/components/dialog/chooseChannel.vue +++ b/web_src/src/components/dialog/chooseChannel.vue @@ -1,25 +1,40 @@ <template> <div id="chooseChannel" v-loading="isLoging"> - <el-dialog title="閫夋嫨閫氶亾" v-if="showDialog" top="2rem" width="70%" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()"> - <el-tabs v-model="tabActiveName" > + <el-dialog title="閫夋嫨閫氶亾" v-if="showDialog" top="2rem" width="90%" :close-on-click-modal="false" :visible.sync="showDialog" :destroy-on-close="true" @close="close()"> + <el-row> + <el-col :span="10"> + <el-tabs v-model="catalogTabActiveName" > + <el-tab-pane label="鐩綍缁撴瀯" name="catalog"> + <el-container> + <el-main style="background-color: #FFF;"> + <chooseChannelForCatalog ref="chooseChannelForCatalog" :platformId=platformId :platformName=platformName :defaultCatalogId=defaultCatalogId :catalogIdChange="catalogIdChange"></chooseChannelForCatalog> + </el-main> + </el-container> + </el-tab-pane> + </el-tabs> + + </el-col> + <el-col :span="14"> + <el-tabs v-model="tabActiveName" @tab-click="tabClick"> <el-tab-pane label="鍥芥爣閫氶亾" name="gbChannel"> - <el-container> - <el-main style="background-color: #FFF;"> - <chooseChannelForGb :platformId=platformId ></chooseChannelForGb> - </el-main> - </el-container> - - + <el-container> + <el-main style="background-color: #FFF;"> + <chooseChannelForGb ref="chooseChannelForGb" :platformId=platformId :updateChoosedCallback="updateChooseChannelCallback"></chooseChannelForGb> + </el-main> + </el-container> </el-tab-pane> <el-tab-pane label="鐩存挱娴侀�氶亾" name="streamchannel"> - <el-container> - <el-main style="background-color: #FFF;"> - <chooseChannelFoStream :platformId=platformId ></chooseChannelFoStream> - </el-main> - </el-container> + <el-container> + <el-main style="background-color: #FFF;"> + <chooseChannelFoStream ref="chooseChannelFoStream" :platformId=platformId :updateChoosedCallback="updateChooseChannelCallback"></chooseChannelFoStream> + </el-main> + </el-container> </el-tab-pane> - </el-tabs> + </el-tabs> + </el-col> + </el-row> + </el-dialog> </div> </template> @@ -27,12 +42,14 @@ <script> import chooseChannelForGb from '../dialog/chooseChannelForGb.vue' import chooseChannelFoStream from '../dialog/chooseChannelForStream.vue' +import chooseChannelForCatalog from '../dialog/chooseChannelForCatalog.vue' export default { name: 'chooseChannel', props: {}, components: { chooseChannelForGb, chooseChannelFoStream, + chooseChannelForCatalog, }, computed: { // getPlayerShared: function () { @@ -47,19 +64,34 @@ return { isLoging: false, tabActiveName: "gbChannel", + catalogTabActiveName: "catalog", platformId: "", - isLoging: false, + catalogId: "", + platformName: "", + defaultCatalogId: "", showDialog: false, chooseData: {} }; }, methods: { - openDialog: function (platformId, closeCallback) { - console.log(platformId) + openDialog(platformId, platformName, defaultCatalogId, closeCallback) { this.platformId = platformId + this.platformName = platformName + this.defaultCatalogId = defaultCatalogId this.showDialog = true this.closeCallback = closeCallback + }, + tabClick (tab, event){ + console.log(tab.label) + if (tab.label === "gbChannel") { + this.$refs.chooseChannelForGb.catalogIdChange(this.catalogId); + this.$refs.chooseChannelForGb.initData(); + }else { + this.$refs.chooseChannelFoStream.catalogIdChange(this.catalogId); + this.$refs.chooseChannelFoStream.initData(); + } + }, close: function() { this.closeCallback() @@ -88,6 +120,21 @@ }).catch(function (error) { console.log(error); }); + }, + catalogIdChange: function (id) { + console.log("涓棿妯″潡鏀跺埌锛� " + id) + this.catalogId = id; + if (this.tabActiveName === "gbChannel") { + this.$refs.chooseChannelForGb.catalogIdChange(id); + }else { + this.$refs.chooseChannelFoStream.catalogIdChange(id); + } + }, + updateChooseChannelCallback (id, nodeIds){ + console.log("涓棿妯″潡鏀跺埌閫夋嫨閫氶亾鍙樺寲锛� " + id) + console.log("涓棿妯″潡鏀跺埌閫夋嫨閫氶亾鍙樺寲锛� " + nodeIds) + console.log("涓棿妯″潡鏀跺埌閫夋嫨閫氶亾鍙樺寲锛� " + typeof (nodeIds)) + this.$refs.chooseChannelForCatalog.refreshCatalogById(id, nodeIds) } } }; diff --git a/web_src/src/components/dialog/chooseChannelForCatalog.vue b/web_src/src/components/dialog/chooseChannelForCatalog.vue new file mode 100644 index 0000000..89fa32b --- /dev/null +++ b/web_src/src/components/dialog/chooseChannelForCatalog.vue @@ -0,0 +1,311 @@ +<template> +<div id="chooseChannelForCatalog" > + <div style="background-color: #FFFFFF; margin-bottom: 1rem; position: relative; padding: 0.5rem; text-align: left;font-size: 14px;"> + <el-tree class="el-scrollbar" + ref="tree" + id="catalogTree" + empty-text="鏈煡鑺傜偣" + node-key="id" + default-expand-all + :highlight-current="true" + :expand-on-click-node="false" + :props="props" + :load="loadNode" + @node-contextmenu="contextmenuEventHandler" + lazy> + <span class="custom-tree-node" slot-scope="{ node, data }" style="width: 100%"> + <el-radio v-if="node.data.type === 0" style="margin-right: 0" v-model="chooseId" :label="node.data.id">{{''}}</el-radio> + <span v-if="node.data.type === 0 && node.level === 1" class="el-icon-s-home"></span> + <span v-if="node.data.type === 0 && node.level > 1" class="el-icon-folder-opened"></span> + <span v-if="node.data.type === 1" class="iconfont icon-shexiangtou"></span> + <span v-if="node.data.type === 2" class="iconfont icon-zhibo"></span> + <span style="padding-left: 1px">{{ node.label }}</span> + <span> + <i style="margin-left: 5rem; color: #9d9d9d; padding-right: 20px" v-if="node.data.id === defaultCatalogId">榛樿</i> + </span> + </span> + </el-tree> + </div> + <catalogEdit ref="catalogEdit" :platformId="platformId"></catalogEdit> +</div> +</template> + + +<script> + +import catalogEdit from './catalogEdit.vue' +export default { + name: 'chooseChannelForCatalog', + props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'], + created() { + this.initData(); + setTimeout(()=>{ + if (this.catalogIdChange)this.catalogIdChange(this.defaultCatalogId); + }, 100) + + }, + components: { + catalogEdit, + }, + data() { + return { + props: { + label: 'name', + children: 'children', + isLeaf: 'leaf' + }, + chooseNode: null, + chooseId: this.defaultCatalogId, + catalogTree: null, + contextmenuShow: false + + }; + }, + watch:{ + platformId(newData, oldData){ + console.log(newData) + this.initData() + }, + chooseId(newData, oldData){ + console.log("鍙戦�侊細 " + newData) + if (this.catalogIdChange)this.catalogIdChange(newData); + }, + }, + methods: { + initData: function () { + this.getCatalog(); + }, + + getCatalog: function(parentId, callback) { + let that = this; + this.$axios({ + method:"get", + url:`/api/platform/catalog`, + params: { + platformId: that.platformId, + parentId: parentId + } + }) + .then((res)=> { + if (res.data.code === 0) { + if (typeof(callback) === 'function') { + callback(res.data.data) + } + // + + // if (typeof (this.$refs.tree.setCurrentKey) == "undefined") { + // this.$refs.tree.setCurrentKey(this.defaultCatalogId) + // let data = this.$refs.tree.getCurrentNode() + // if (data != null && data.id === this.defaultCatalogId) { + // this.currentCatalogChange(data, this.$refs.tree.getNode(data.id)) + // } + // } + + } + }) + .catch(function (error) { + console.log(error); + }); + + }, + addCatalog: function (parentId, node){ + let that = this; + // 鎵撳紑娣诲姞寮圭獥 + that.$refs.catalogEdit.openDialog(false, null, null, parentId, ()=>{ + node.loaded = false + node.expand(); + }); + + }, + refreshCatalog: function (node){ + node.loaded = false + node.expand(); + }, + refreshCatalogById: function (id, nodeIds) { + if (id) { + console.log("refreshCatalogById: " + id) + let node = this.$refs.tree.getNode(id); + console.log(node) + this.refreshCatalog(node); + } + if (nodeIds !== null) { + let refreshNode = {} + for (let i = 0; i < nodeIds.length; i++) { + let node = this.$refs.tree.getNode(nodeIds[i]); + refreshNode[node.parent.data.id] = node.parent + } + if (Object.values(refreshNode).length > 0) { + for (let j = 0; j < Object.values(refreshNode).length; j++) { + this.refreshCatalog(Object.values(refreshNode)[j]); + } + } + } + }, + editCatalog: function (data, node){ + let that = this; + // 鎵撳紑娣诲姞寮圭獥 + that.$refs.catalogEdit.openDialog(true, data.id, data.name, data.parentId, (data)=>{ + node.parent.loaded = false + node.parent.expand(); + }); + + }, + removeCatalog: function (id, node){ + this.$axios({ + method:"delete", + url:`/api/platform/catalog/del`, + params: { + id: id, + } + }) + .then((res) => { + if (res.data.code === 0) { + console.log("绉婚櫎鎴愬姛") + node.parent.loaded = false + node.parent.expand(); + } + }) + .catch(function (error) { + console.log(error); + }); + }, + setDefaultCatalog: function (id){ + this.$axios({ + method:"post", + url:`/api/platform/catalog/default/update`, + params: { + platformId: this.platformId, + catalogId: id, + } + }) + .then((res)=> { + if (res.data.code === 0) { + this.defaultCatalogId = id; + } + }) + .catch(function (error) { + console.log(error); + }); + }, + loadNode: function(node, resolve){ + if (node.level === 0) { + resolve([{ + name: this.platformName, + id: this.platformId, + type: 0 + }]); + } + if (node.level >= 1){ + this.getCatalog(node.data.id, resolve) + } + }, + contextmenuEventHandler: function (event,data,node,element){ + if (node.data.type !== 0) { + data.parentId = node.parent.data.id; + this.$contextmenu({ + items: [ + { + label: "绉婚櫎閫氶亾", + icon: "el-icon-delete", + disabled: false, + onClick: () => { + this.$axios({ + method:"delete", + url:"/api/platform/catalog/relation/del", + data: data + }).then((res)=>{ + console.log("绉婚櫎鎴愬姛") + node.parent.loaded = false + node.parent.expand(); + }).catch(function (error) { + console.log(error); + }); + } + } + ], + event, // 榧犳爣浜嬩欢淇℃伅 + customClass: "custom-class", // 鑷畾涔夎彍鍗� class + zIndex: 3000, // 鑿滃崟鏍峰紡 z-index + }); + }else { + this.$contextmenu({ + items: [ + { + label: "鍒锋柊鑺傜偣", + icon: "el-icon-refresh", + disabled: false, + onClick: () => { + this.refreshCatalog(node); + } + }, + { + label: "鏂板缓鑺傜偣", + icon: "el-icon-plus", + disabled: false, + onClick: () => { + this.addCatalog(data.id, node); + } + }, + { + label: "淇敼鑺傜偣", + icon: "el-icon-edit", + disabled: node.level === 1, + onClick: () => { + this.editCatalog(data, node); + } + }, + { + label: "鍒犻櫎鑺傜偣", + icon: "el-icon-delete", + disabled: node.level === 1, + divided: true, + onClick: () => { + this.removeCatalog(data.id, node) + } + }, + { + label: "璁句负榛樿", + icon: "el-icon-folder-checked", + disabled: node.data.id === this.defaultCatalogId, + onClick: () => { + this.setDefaultCatalog(data.id) + }, + }, + // { + // label: "瀵煎嚭", + // icon: "el-icon-download", + // disabled: false, + // children: [ + // { + // label: "瀵煎嚭鍒版枃浠�", + // onClick: () => { + // + // }, + // }, + // { + // label: "瀵煎嚭鍒板叾浠栧钩鍙�", + // onClick: () => { + // + // }, + // } + // ] + // }, + + ], + event, // 榧犳爣浜嬩欢淇℃伅 + customClass: "custom-class", // 鑷畾涔夎彍鍗� class + zIndex: 3000, // 鑿滃崟鏍峰紡 z-index + }); + } + + return false; + }, + } +}; +</script> + +<style> +#catalogTree{ + display: inline-block; +} +</style> diff --git a/web_src/src/components/dialog/chooseChannelForGb.vue b/web_src/src/components/dialog/chooseChannelForGb.vue index f5c66d2..4b2be34 100644 --- a/web_src/src/components/dialog/chooseChannelForGb.vue +++ b/web_src/src/components/dialog/chooseChannelForGb.vue @@ -21,9 +21,9 @@ <el-option label="绂荤嚎" value="false"></el-option> </el-select> - <el-checkbox @change="shareAllCheckedChanage">鍏ㄩ儴鍏变韩</el-checkbox> + <el-checkbox @change="shareAllCheckedChange">鍏ㄩ儴鍏变韩</el-checkbox> </div> - <el-table ref="gbChannelsTable" :data="gbChannels" border style="width: 100%" @selection-change="checkedChanage" > + <el-table ref="gbChannelsTable" :data="gbChannels" border style="width: 100%" @selection-change="checkedChange" > <el-table-column type="selection" width="55" align="center" fixed > </el-table-column> <el-table-column prop="channelId" label="閫氶亾缂栧彿" width="210"> </el-table-column> @@ -49,7 +49,6 @@ <script> export default { name: 'chooseChannelForGb', - props: {}, computed: { // getPlayerShared: function () { // return { @@ -59,7 +58,7 @@ // }; // } }, - props: ['platformId'], + props: ['platformId', 'updateChoosedCallback'], created() { this.initData(); }, @@ -71,6 +70,7 @@ channelType: "", online: "", choosed: "", + catalogId: null, currentPage: 1, count: 10, total: 0, @@ -97,28 +97,28 @@ this.count = val; console.log(val) this.initData(); - }, - rowcheckedChanage: function (val, row) { + rowcheckedChange: function (val, row) { console.log(val) console.log(row) }, - checkedChanage: function (val) { - var that = this; + // selectDisable: function (){ + // if (this.catalogId == null) { + // return false; + // } + // }, + checkedChange: function (val) { + let that = this; if (!that.eventEnanle) { return; } - var tabelData = JSON.parse(JSON.stringify(this.$refs.gbChannelsTable.data)); - console.log("checkedChanage") - console.log(val) - - var newData = {}; - var addData = []; - var delData = []; + let newData = {}; + let addData = []; + let delData = []; if (val.length > 0) { for (let i = 0; i < val.length; i++) { const element = val[i]; - var key = element.deviceId + "_" + element.channelId; + let key = element.deviceId + "_" + element.channelId; newData[key] = element; if (!!!that.gbChoosechannel[key]){ addData.push(element) @@ -127,7 +127,7 @@ } } - var oldKeys = Object.keys(that.gbChoosechannel); + let oldKeys = Object.keys(that.gbChoosechannel); if (oldKeys.length > 0) { for (let i = 0; i < oldKeys.length; i++) { const key = oldKeys[i]; @@ -136,7 +136,7 @@ } }else{ - var oldKeys = Object.keys(that.gbChoosechannel); + let oldKeys = Object.keys(that.gbChoosechannel); if (oldKeys.length > 0) { for (let i = 0; i < oldKeys.length; i++) { const key = oldKeys[i]; @@ -152,15 +152,17 @@ url:"/api/platform/update_channel_for_gb", data:{ platformId: that.platformId, - channelReduces: addData + channelReduces: addData, + catalogId: that.catalogId } }).then((res)=>{ console.log("淇濆瓨鎴愬姛") + if(that.updateChoosedCallback)that.updateChoosedCallback(that.catalogId) }).catch(function (error) { console.log(error); }); } - if (Object.keys(delData).length >0) { + if (delData.length >0) { that.$axios({ method:"delete", url:"/api/platform/del_channel_for_gb", @@ -170,13 +172,18 @@ } }).then((res)=>{ console.log("绉婚櫎鎴愬姛") + let nodeIds = new Array(); + for (let i = 0; i < delData.length; i++) { + nodeIds.push(delData[i].channelId) + } + if(that.updateChoosedCallback)that.updateChoosedCallback(null, nodeIds) }).catch(function (error) { console.log(error); }); } }, - shareAllCheckedChanage: function (val) { + shareAllCheckedChange: function (val) { this.chooseChanage(null, val) }, getChannelList: function () { @@ -215,7 +222,7 @@ } } that.eventEnanle = true; - // that.checkedChanage(chooseGBS) + // that.checkedChange(chooseGBS) }) console.log(that.gbChoosechannel) }) @@ -230,6 +237,10 @@ handleGBSelectionChange: function() { this.initData(); }, + catalogIdChange: function(id) { + this.catalogId = id; + console.log("閫氶亾閫夋嫨妯″潡鏀跺埌锛� " + id) + }, } }; </script> diff --git a/web_src/src/components/dialog/chooseChannelForStream.vue b/web_src/src/components/dialog/chooseChannelForStream.vue index 8fa5d46..341c22f 100644 --- a/web_src/src/components/dialog/chooseChannelForStream.vue +++ b/web_src/src/components/dialog/chooseChannelForStream.vue @@ -27,7 +27,6 @@ <script> export default { name: 'chooseChannelFoStream', - props: {}, computed: { // getPlayerShared: function () { // return { @@ -37,7 +36,7 @@ // }; // } }, - props: ['platformId'], + props: ['platformId', 'updateChoosedCallback'], created() { this.initData(); }, @@ -49,6 +48,7 @@ channelType: "", online: "", choosed: "", + catalogId: null, currentPage: 1, count: 10, total: 0, @@ -131,10 +131,12 @@ url:"/api/gbStream/add", data:{ platformId: that.platformId, + catalogId: that.catalogId, gbStreams: addData, } }).then((res)=>{ console.log("淇濆瓨鎴愬姛") + if(this.updateChoosedCallback)this.updateChoosedCallback(this.catalogId) }).catch(function (error) { console.log(error); }); @@ -149,6 +151,7 @@ } }).then((res)=>{ console.log("绉婚櫎鎴愬姛") + if(this.updateChoosedCallback)this.updateChoosedCallback(this.catalogId) }).catch(function (error) { console.log(error); }); @@ -207,6 +210,10 @@ handleGBSelectionChange: function() { this.initData(); }, + catalogIdChange: function(id) { + this.catalogId = id; + console.log("鐩存挱閫氶亾閫夋嫨妯″潡鏀跺埌锛� " + id) + }, } }; </script> diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index fad0444..62a6957 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -196,6 +196,7 @@ this.platform.transport = platform.transport; this.platform.characterSet = platform.characterSet; this.platform.shareAllLiveStream = platform.shareAllLiveStream; + this.platform.catalogId = platform.catalogId; this.onSubmit_text = "淇濆瓨"; } this.showDialog = true; diff --git a/web_src/src/main.js b/web_src/src/main.js index ffd7fde..d534d5f 100644 --- a/web_src/src/main.js +++ b/web_src/src/main.js @@ -12,6 +12,7 @@ import { Notification } from 'element-ui'; import Fingerprint2 from 'fingerprintjs2'; import VueClipboards from 'vue-clipboards'; +import Contextmenu from "vue-contextmenujs" // 鐢熸垚鍞竴ID @@ -37,6 +38,7 @@ Vue.use(VueClipboards); Vue.prototype.$axios = axios; Vue.prototype.$notify = Notification; +Vue.use(Contextmenu); axios.defaults.baseURL = (process.env.NODE_ENV === 'development') ? process.env.BASE_API : ""; diff --git a/web_src/static/css/iconfont.css b/web_src/static/css/iconfont.css index 4c7b608..b13982d 100644 --- a/web_src/static/css/iconfont.css +++ b/web_src/static/css/iconfont.css @@ -1,8 +1,8 @@ @font-face { font-family: "iconfont"; /* Project id 1291092 */ - src: url('iconfont.woff2?t=1637741914969') format('woff2'), - url('iconfont.woff?t=1637741914969') format('woff'), - url('iconfont.ttf?t=1637741914969') format('truetype'); + src: url('iconfont.woff2?t=1640922722742') format('woff2'), + url('iconfont.woff?t=1640922722742') format('woff'), + url('iconfont.ttf?t=1640922722742') format('truetype'); } .iconfont { @@ -11,6 +11,22 @@ font-style: normal; -webkit-font-smoothing: antialiased; -moz-osx-font-smoothing: grayscale; +} + +.icon-wxbzhuye:before { + content: "\e7d1"; +} + +.icon-mulu:before { + content: "\e7d2"; +} + +.icon-zhibo:before { + content: "\e8c1"; +} + +.icon-shexiangtou:before { + content: "\e7d3"; } .icon-suoxiao:before { @@ -49,7 +65,7 @@ content: "\e7a2"; } -.icon-kuaijin:before { +.icon-houtui:before { content: "\e7a3"; } @@ -57,7 +73,7 @@ content: "\e7a4"; } -.icon-kuaitui:before { +.icon-kuaijin:before { content: "\e7a5"; } diff --git a/web_src/static/css/iconfont.woff2 b/web_src/static/css/iconfont.woff2 index dea6728..8b2d400 100644 --- a/web_src/static/css/iconfont.woff2 +++ b/web_src/static/css/iconfont.woff2 Binary files differ -- Gitblit v1.8.0