From 99ab7874688dae125439bcbae01e1c8ccf46f725 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Fri, 8 Jul 2022 11:20:29 +0800 Subject: [PATCH 01/20] =?UTF-8?q?=E7=94=A8=E6=88=B7=E8=A1=A8=E5=A2=9E?= =?UTF-8?q?=E5=8A=A0=E6=8E=A8=E6=B5=81=E9=89=B4=E6=9D=83KEY?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql.sql | 1 + sql/update.sql | 4 ++++ .../com/genersoft/iot/vmp/storager/dao/UserMapper.java | 5 +++-- .../com/genersoft/iot/vmp/storager/dao/dto/User.java | 9 +++++++++ 4 files changed, 17 insertions(+), 2 deletions(-) diff --git a/sql/mysql.sql b/sql/mysql.sql index ffe39c3f..8a7c1bfb 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -513,6 +513,7 @@ CREATE TABLE `user` ( `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `roleId` int NOT NULL, + `pushKey` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci default null, `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, diff --git a/sql/update.sql b/sql/update.sql index 43413552..b575f0f1 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -57,4 +57,8 @@ alter table stream_push change createStamp createTime varchar(50) default null; +alter table user + add pushKey varchar(50) default null; + + diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index addb27d0..cc35789c 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -10,13 +10,14 @@ import java.util.List; @Repository public interface UserMapper { - @Insert("INSERT INTO user (username, password, roleId, createTime, updateTime) VALUES" + - "('${username}', '${password}', '${role.id}', '${createTime}', '${updateTime}')") + @Insert("INSERT INTO user (username, password, roleId, pushKey, createTime, updateTime) VALUES" + + "('${username}', '${password}', '${role.id}', '${pushKey}', '${createTime}', '${updateTime}')") int add(User user); @Update(value = {" "}) int update(StreamPushItem streamPushItem); @Delete("DELETE FROM stream_push WHERE app=#{app} AND stream=#{stream}") @@ -62,7 +64,7 @@ public interface StreamPushMapper { @Select(value = {" "}) List selectAllForList(String query, Boolean pushing, String mediaServerId); - @Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.createStamp desc") + @Select("SELECT st.*, gs.gbId, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream order by st.createTime desc") List selectAll(); - @Select("SELECT st.*, gs.gbId, gs.status, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}") + @Select("SELECT st.*, gs.gbId, gs.name, gs.longitude, gs.latitude FROM stream_push st LEFT JOIN gb_stream gs on st.app = gs.app AND st.stream = gs.stream WHERE st.app=#{app} AND st.stream=#{stream}") StreamPushItem selectOne(String app, String stream); @Insert("") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -106,4 +108,13 @@ public interface StreamPushMapper { @Select("SELECT sp.* FROM stream_push sp left join gb_stream gs on gs.app = sp.app and gs.stream= sp.stream WHERE sp.mediaServerId=#{mediaServerId} and gs.gbId is null") List selectAllByMediaServerIdWithOutGbID(String mediaServerId); + @Update("UPDATE stream_push " + + "SET status=${status} " + + "WHERE app=#{app} AND stream=#{stream}") + int updateStatus(String app, String stream, boolean status); + + @Update("UPDATE stream_push " + + "SET status=#{status} " + + "WHERE mediaServerId=#{mediaServerId}") + void updateStatusByMediaServerId(String mediaServerId, boolean status); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index cc35789c..5ed0a57d 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -49,4 +49,10 @@ public interface UserMapper { @Select("select u.*, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u, user_role r WHERE u.roleId=r.id") @ResultMap(value="roleMap") List selectAll(); + + @Select("select * from (select user.*, concat('${callId}_', pushKey) as str1 from user) as u where md5(u.str1) = '${sign}'") + List checkPushAuthorityByCallIdAndSign(String callId, String sign); + + @Select("select * from user where md5(pushKey) = '${sign}'") + List checkPushAuthorityByCallId(String sign); } 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 5377e23f..d2798479 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 @@ -9,6 +9,8 @@ import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; +import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam; +import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; import com.genersoft.iot.vmp.service.bean.MessageForPushChannel; import com.genersoft.iot.vmp.service.bean.ThirdPartyGB; @@ -20,6 +22,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Component; +import org.springframework.util.StringUtils; import java.util.*; @@ -598,6 +601,26 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { return result; } + @Override + public void updateStreamAuthorityInfo(String app, String stream, StreamAuthorityInfo streamAuthorityInfo) { + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream; + redis.set(key, streamAuthorityInfo); + } + + @Override + public void removeStreamAuthorityInfo(String app, String stream) { + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ; + redis.del(key); + } + + @Override + public StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream) { + String key = VideoManagerConstants.MEDIA_STREAM_AUTHORITY + userSetting.getServerId() + "_" + app+ "_" + stream ; + return (StreamAuthorityInfo) redis.get(key); + + } + + @Override public MediaItem getStreamInfo(String app, String streamId, String mediaServerId) { String scanKey = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_*_" + app + "_" + streamId + "_" + mediaServerId; @@ -682,4 +705,6 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { public boolean deviceIsOnline(String deviceId) { return getDevice(deviceId).getOnline() == 1; } + + } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index 9a5be6e0..c4d1c9e6 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -848,7 +848,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { streamPushMapper.addAll(streamPushItems); // TODO 待优化 for (int i = 0; i < streamPushItems.size(); i++) { - int onlineResult = gbStreamMapper.setStatus(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream(), true); + int onlineResult = mediaOnline(streamPushItems.get(i).getApp(), streamPushItems.get(i).getStream()); if (onlineResult > 0) { // 发送上线通知 eventPublisher.catalogEventPublishForStream(null, streamPushItems.get(i), CatalogEvent.ON); @@ -856,11 +856,13 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } } + + @Override public void updateMedia(StreamPushItem streamPushItem) { streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); streamPushMapper.add(streamPushItem); - gbStreamMapper.setStatus(streamPushItem.getApp(), streamPushItem.getStream(), true); + mediaOffline(streamPushItem.getApp(), streamPushItem.getStream()); if(!StringUtils.isEmpty(streamPushItem.getGbId() )){ // 查找开启了全部直播流共享的上级平台 @@ -897,8 +899,26 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } @Override - public int mediaOutline(String app, String streamId) { - return gbStreamMapper.setStatus(app, streamId, false); + public int mediaOffline(String app, String stream) { + GbStream gbStream = gbStreamMapper.selectOne(app, stream); + int result; + if ("proxy".equals(gbStream.getStreamType())) { + result = streamProxyMapper.updateStatus(app, stream, false); + }else { + result = streamPushMapper.updateStatus(app, stream, false); + } + return result; + } + + public int mediaOnline(String app, String stream) { + GbStream gbStream = gbStreamMapper.selectOne(app, stream); + int result; + if ("proxy".equals(gbStream.getStreamType())) { + result = streamProxyMapper.updateStatus(app, stream, true); + }else { + result = streamPushMapper.updateStatus(app, stream, true); + } + return result; } @Override diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java index d4995a01..54bd3f6a 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java @@ -1,9 +1,14 @@ package com.genersoft.iot.vmp.vmanager.gb28181.media; import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.security.SecurityUtils; +import com.genersoft.iot.vmp.conf.security.dto.LoginUser; +import com.genersoft.iot.vmp.media.zlm.dto.OnPublishHookParam; +import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.IMediaService; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import io.swagger.annotations.Api; @@ -16,6 +21,8 @@ import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Controller; import org.springframework.web.bind.annotation.*; +import javax.servlet.http.HttpServletRequest; + @Api(tags = "媒体流相关") @Controller @@ -26,7 +33,7 @@ public class MediaController { private final static Logger logger = LoggerFactory.getLogger(MediaController.class); @Autowired - private IVideoManagerStorage storager; + private IRedisCatchStorage redisCatchStorage; @Autowired private IStreamPushService streamPushService; @@ -52,13 +59,47 @@ public class MediaController { }) @GetMapping(value = "/stream_info_by_app_and_stream") @ResponseBody - public WVPResult getStreamInfoByAppAndStream(@RequestParam String app, @RequestParam String stream, @RequestParam(required = false) String mediaServerId){ - StreamInfo streamInfoByAppAndStreamWithCheck = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId); + public WVPResult getStreamInfoByAppAndStream(HttpServletRequest request, @RequestParam String app, + @RequestParam String stream, + @RequestParam(required = false) String mediaServerId, + @RequestParam(required = false) String callId, + @RequestParam(required = false) Boolean useSourceIpAsStreamIp){ + boolean authority = false; + if (callId != null) { + // 权限校验 + StreamAuthorityInfo streamAuthorityInfo = redisCatchStorage.getStreamAuthorityInfo(app, stream); + if (streamAuthorityInfo.getCallId().equals(callId)) { + authority = true; + }else { + WVPResult result = new WVPResult<>(); + result.setCode(401); + result.setMsg("fail"); + return result; + } + }else { + // 是否登陆用户, 登陆用户返回完整信息 + LoginUser userInfo = SecurityUtils.getUserInfo(); + if (userInfo!= null) { + authority = true; + } + } + + StreamInfo streamInfo; + + if (useSourceIpAsStreamIp != null && useSourceIpAsStreamIp) { + String host = request.getHeader("Host"); + String localAddr = host.split(":")[0]; + logger.info("使用{}作为返回流的ip", localAddr); + streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, localAddr, authority); + }else { + streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); + } + WVPResult result = new WVPResult<>(); - if (streamInfoByAppAndStreamWithCheck != null){ + if (streamInfo != null){ result.setCode(0); result.setMsg("scccess"); - result.setData(streamInfoByAppAndStreamWithCheck); + result.setData(streamInfo); }else { result.setCode(-1); result.setMsg("fail"); diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java index 20ffc000..db7f8fdc 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/play/PlayController.java @@ -193,7 +193,7 @@ public class PlayController { JSONObject data = jsonObject.getJSONObject("data"); if (data != null) { result.put("key", data.getString("key")); - StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId()); + StreamInfo streamInfoResult = mediaService.getStreamInfoByAppAndStreamWithCheck("convert", streamId, mediaInfo.getId(), false); result.put("data", streamInfoResult); } }else { diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index 8e104bd9..3c933f14 100644 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -23,12 +23,12 @@ - 修改密码 - 注销 在线文档 + 修改密码 + 注销 From 56265c2f40026ab26b98f5d59d51d9a64787c245 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 11 Jul 2022 16:41:32 +0800 Subject: [PATCH 04/20] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E5=A4=B1=E6=95=88?= =?UTF-8?q?=E7=9A=84=E9=85=8D=E7=BD=AE=EF=BC=8C=E5=A2=9E=E5=8A=A0=E4=BA=BA?= =?UTF-8?q?=E7=89=A9=E7=BB=93=E6=9D=9F=E6=97=B6=E7=A7=BB=E9=99=A4=E4=BA=BA?= =?UTF-8?q?=E7=89=A9=E7=BC=93=E5=AD=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java | 7 ++----- src/main/resources/all-application.yml | 2 -- 2 files changed, 2 insertions(+), 7 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java index ade2e622..1f18338b 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java @@ -103,12 +103,9 @@ public class DynamicTask { public void stop(String key) { if (futureMap.get(key) != null && !futureMap.get(key).isCancelled()) { -// Runnable runnable = runnableMap.get(key); -// if (runnable instanceof ISubscribeTask) { -// ISubscribeTask subscribeTask = (ISubscribeTask) runnable; -// subscribeTask.stop(); -// } futureMap.get(key).cancel(false); + futureMap.remove(key); + runnableMap.remove(key); } } diff --git a/src/main/resources/all-application.yml b/src/main/resources/all-application.yml index 9dedcb14..ef14c242 100644 --- a/src/main/resources/all-application.yml +++ b/src/main/resources/all-application.yml @@ -185,8 +185,6 @@ user-settings: record-sip: true # 是否将日志存储进数据库 logInDatebase: true - # 第三方匹配,用于从stream钟获取有效信息 - thirdPartyGBIdReg: "[\\s\\S]*" # 在线文档: swagger-ui(生产环境建议关闭) swagger-ui: From 0f945910f35795ef76ee3860072cb6c52a40f5fc Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 11 Jul 2022 17:34:22 +0800 Subject: [PATCH 05/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=8E=B7=E5=8F=96?= =?UTF-8?q?=E6=8E=A8=E6=B5=81=E6=92=AD=E6=94=BE=E5=9C=B0=E5=9D=80=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql.sql | 20 ++++---- .../streamPush/StreamPushController.java | 47 +++++++++++++++++++ web_src/src/components/PushVideoList.vue | 2 +- 3 files changed, 58 insertions(+), 11 deletions(-) diff --git a/sql/mysql.sql b/sql/mysql.sql index 77bfb532..9d2e1174 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -50,7 +50,7 @@ CREATE TABLE `device` ( `treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `device_deviceId_uindex` (`deviceId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=37 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -142,7 +142,7 @@ CREATE TABLE `device_channel` ( PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `device_channel_id_uindex` (`id`) USING BTREE, UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=19324 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=19331 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -179,7 +179,7 @@ CREATE TABLE `device_mobile_position` ( `latitudeWgs84` double DEFAULT NULL, `createTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=5649 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=6751 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -208,7 +208,6 @@ CREATE TABLE `gb_stream` ( `latitude` double DEFAULT NULL, `streamType` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `mediaServerId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, - `status` int DEFAULT NULL, `createTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, `gpsTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, PRIMARY KEY (`gbStreamId`) USING BTREE, @@ -244,7 +243,7 @@ CREATE TABLE `log` ( `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=29943 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=34997 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -455,7 +454,7 @@ CREATE TABLE `stream_proxy` ( `updateTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `stream_proxy_pk` (`app`,`stream`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=65 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=66 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -487,9 +486,10 @@ CREATE TABLE `stream_push` ( `serverId` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, `pushTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, `updateTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `status` int DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `stream_push_pk` (`app`,`stream`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=305304 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=305315 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -513,9 +513,9 @@ CREATE TABLE `user` ( `username` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `password` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `roleId` int NOT NULL, - `pushKey` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci default null, `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `updateTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, + `pushKey` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `user_username_uindex` (`username`) USING BTREE ) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; @@ -527,7 +527,7 @@ CREATE TABLE `user` ( LOCK TABLES `user` WRITE; /*!40000 ALTER TABLE `user` DISABLE KEYS */; -INSERT INTO `user` VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',1,'453df297a57a5a7438934sda801fc3','2021 - 04 - 13 14:14:57','2021 - 04 - 13 14:14:57'); +INSERT INTO `user` VALUES (1,'admin','21232f297a57a5a743894a0e4a801fc3',1,'2021 - 04 - 13 14:14:57','2021 - 04 - 13 14:14:57','453df297a57a5a7438934sda801fc3'); /*!40000 ALTER TABLE `user` ENABLE KEYS */; UNLOCK TABLES; @@ -567,4 +567,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-07-06 9:43:54 +-- Dump completed on 2022-07-11 17:32:51 diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java index cf0fed8a..300f9521 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/streamPush/StreamPushController.java @@ -3,11 +3,16 @@ package com.genersoft.iot.vmp.vmanager.streamPush; import com.alibaba.excel.EasyExcel; import com.alibaba.excel.ExcelReader; import com.alibaba.excel.read.metadata.ReadSheet; +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.conf.security.SecurityUtils; +import com.genersoft.iot.vmp.conf.security.dto.LoginUser; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; +import com.genersoft.iot.vmp.media.zlm.dto.StreamAuthorityInfo; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IMediaServerService; +import com.genersoft.iot.vmp.service.IMediaService; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.impl.StreamPushUploadFileHandler; import com.genersoft.iot.vmp.vmanager.bean.BatchGBStreamParam; @@ -30,6 +35,7 @@ import org.springframework.web.bind.annotation.*; import org.springframework.web.context.request.async.DeferredResult; import org.springframework.web.multipart.MultipartFile; +import javax.servlet.http.HttpServletRequest; import java.io.IOException; import java.io.InputStream; import java.util.HashMap; @@ -54,6 +60,9 @@ public class StreamPushController { @Autowired private DeferredResultHolder resultHolder; + @Autowired + private IMediaService mediaService; + @ApiOperation("推流列表查询") @ApiImplicitParams({ @ApiImplicitParam(name="page", value = "当前页", required = true, dataTypeClass = Integer.class), @@ -237,5 +246,43 @@ public class StreamPushController { return result; } + /** + * 获取推流播放地址 + * @param app 应用名 + * @param stream 流id + * @return + */ + @ApiOperation("获取推流播放地址") + @ApiImplicitParams({ + @ApiImplicitParam(name = "app", value = "应用名", dataTypeClass = String.class), + @ApiImplicitParam(name = "stream", value = "流id", dataTypeClass = String.class), + @ApiImplicitParam(name = "mediaServerId", value = "媒体服务器id", dataTypeClass = String.class, required = false), + }) + @GetMapping(value = "/getPlayUrl") + @ResponseBody + public WVPResult getPlayUrl(HttpServletRequest request, @RequestParam String app, + @RequestParam String stream, + @RequestParam(required = false) String mediaServerId){ + boolean authority = false; + // 是否登陆用户, 登陆用户返回完整信息 + LoginUser userInfo = SecurityUtils.getUserInfo(); + if (userInfo!= null) { + authority = true; + } + + StreamInfo streamInfo = mediaService.getStreamInfoByAppAndStreamWithCheck(app, stream, mediaServerId, authority); + + WVPResult result = new WVPResult<>(); + if (streamInfo != null){ + result.setCode(0); + result.setMsg("scccess"); + result.setData(streamInfo); + }else { + result.setCode(-1); + result.setMsg("fail"); + } + return result; + } + } diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue index 678d13f5..0253c1e3 100644 --- a/web_src/src/components/PushVideoList.vue +++ b/web_src/src/components/PushVideoList.vue @@ -187,7 +187,7 @@ export default { this.getListLoading = true; this.$axios({ method: 'get', - url: '/api/media/stream_info_by_app_and_stream', + url: '/api/push/getPlayUrl', params: { app: row.app, stream: row.stream, From 6d8569f340c42f511d633b5d8699e4845e071bb6 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 12 Jul 2022 10:32:45 +0800 Subject: [PATCH 06/20] =?UTF-8?q?=E5=8A=A8=E6=80=81=E4=BA=BA=E7=89=A9?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=A2=9E=E5=8A=A0=E8=87=AA=E6=A3=80=E6=9C=BA?= =?UTF-8?q?=E5=88=B6=E3=80=82=E9=98=B2=E6=AD=A2=E5=86=85=E5=AD=98=E6=BA=A2?= =?UTF-8?q?=E5=87=BA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/genersoft/iot/vmp/conf/DynamicTask.java | 16 ++++++++++++++++ .../req => gb28181/bean}/PresetQuerySipReq.java | 2 +- .../cmd/PresetQueryResponseMessageHandler.java | 2 +- .../vmanager/gb28181/media/MediaController.java | 6 ------ src/main/resources/8042900_www.wvp-pro.cn.jks | Bin 0 -> 5676 bytes 5 files changed, 18 insertions(+), 8 deletions(-) rename src/main/java/com/genersoft/iot/vmp/{domain/req => gb28181/bean}/PresetQuerySipReq.java (91%) create mode 100644 src/main/resources/8042900_www.wvp-pro.cn.jks diff --git a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java index 1f18338b..1885632a 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/DynamicTask.java @@ -5,6 +5,7 @@ import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.context.annotation.Bean; +import org.springframework.scheduling.annotation.Scheduled; import org.springframework.scheduling.concurrent.ThreadPoolTaskScheduler; import org.springframework.stereotype.Component; @@ -120,4 +121,19 @@ public class DynamicTask { public Runnable get(String key) { return runnableMap.get(key); } + + /** + * 每五分钟检查失效的任务,并移除 + */ + @Scheduled(cron="0 0/5 * * * ?") + public void execute(){ + if (futureMap.size() > 0) { + for (String key : futureMap.keySet()) { + if (futureMap.get(key).isDone()) { + futureMap.remove(key); + runnableMap.remove(key); + } + } + } + } } diff --git a/src/main/java/com/genersoft/iot/vmp/domain/req/PresetQuerySipReq.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java similarity index 91% rename from src/main/java/com/genersoft/iot/vmp/domain/req/PresetQuerySipReq.java rename to src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java index e2f3ec62..d1971a2e 100644 --- a/src/main/java/com/genersoft/iot/vmp/domain/req/PresetQuerySipReq.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PresetQuerySipReq.java @@ -1,4 +1,4 @@ -package com.genersoft.iot.vmp.domain.req; +package com.genersoft.iot.vmp.gb28181.bean; /** diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java index 36626004..45265c5b 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/PresetQueryResponseMessageHandler.java @@ -1,6 +1,6 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd; -import com.genersoft.iot.vmp.domain.req.PresetQuerySipReq; +import com.genersoft.iot.vmp.gb28181.bean.PresetQuerySipReq; import com.genersoft.iot.vmp.gb28181.bean.*; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java index 54bd3f6a..94fe8df2 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/media/MediaController.java @@ -35,15 +35,9 @@ public class MediaController { @Autowired private IRedisCatchStorage redisCatchStorage; - @Autowired - private IStreamPushService streamPushService; - @Autowired private IMediaService mediaService; - @Autowired - private IMediaServerService mediaServerService; - /** * 根据应用名和流id获取播放地址 diff --git a/src/main/resources/8042900_www.wvp-pro.cn.jks b/src/main/resources/8042900_www.wvp-pro.cn.jks new file mode 100644 index 0000000000000000000000000000000000000000..3e5120652595d9e6480232fc0d0329a02552548d GIT binary patch literal 5676 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 literal 0 HcmV?d00001 From 86340fa1a2c9cfe39f543ff90e59a367ef3b79b9 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 12 Jul 2022 17:33:17 +0800 Subject: [PATCH 07/20] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8Eredis=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=9B=B4=E6=96=B0=E6=8E=A8=E6=B5=81=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/common/VideoManagerConstants.java | 4 + .../genersoft/iot/vmp/conf/RedisConfig.java | 9 +- .../subscribe/catalog/CatalogEventLister.java | 2 +- .../vmp/media/zlm/ZLMRTPServerFactory.java | 2 +- .../iot/vmp/service/IStreamPushService.java | 35 ++++++-- .../RedisPushStreamStatusMsgListener.java | 89 +++++++++++++++++++ .../service/impl/RedisStreamMsgListener.java | 7 +- .../service/impl/StreamPushServiceImpl.java | 32 ++++++- .../iot/vmp/storager/IRedisCatchStorage.java | 5 ++ .../vmp/storager/dao/StreamPushMapper.java | 42 +++++++++ 10 files changed, 210 insertions(+), 17 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java diff --git a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java index 702e3579..40a73521 100644 --- a/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java +++ b/src/main/java/com/genersoft/iot/vmp/common/VideoManagerConstants.java @@ -104,6 +104,10 @@ public class VideoManagerConstants { // 设备状态订阅的通知 public static final String VM_MSG_SUBSCRIBE_DEVICE_STATUS = "device"; + + + + //************************** 第三方 **************************************** public static final String WVP_STREAM_GB_ID_PREFIX = "memberNo_"; public static final String WVP_STREAM_GPS_MSG_PREFIX = "WVP_STREAM_GPS_MSG_"; diff --git a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java index ec1f9bac..6a862ae3 100644 --- a/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java +++ b/src/main/java/com/genersoft/iot/vmp/conf/RedisConfig.java @@ -1,10 +1,7 @@ package com.genersoft.iot.vmp.conf; import com.genersoft.iot.vmp.common.VideoManagerConstants; -import com.genersoft.iot.vmp.service.impl.RedisAlarmMsgListener; -import com.genersoft.iot.vmp.service.impl.RedisGpsMsgListener; -import com.genersoft.iot.vmp.service.impl.RedisGbPlayMsgListener; -import com.genersoft.iot.vmp.service.impl.RedisStreamMsgListener; +import com.genersoft.iot.vmp.service.impl.*; import org.apache.commons.lang3.StringUtils; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Value; @@ -60,6 +57,9 @@ public class RedisConfig extends CachingConfigurerSupport { @Autowired private RedisGbPlayMsgListener redisGbPlayMsgListener; + @Autowired + private RedisPushStreamStatusMsgListener redisPushStreamStatusMsgListener; + @Bean public JedisPool jedisPool() { if (StringUtils.isBlank(password)) { @@ -108,6 +108,7 @@ public class RedisConfig extends CachingConfigurerSupport { container.addMessageListener(redisAlarmMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_SUBSCRIBE_ALARM_RECEIVE)); container.addMessageListener(redisStreamMsgListener, new PatternTopic(VideoManagerConstants.WVP_MSG_STREAM_CHANGE_PREFIX + "PUSH")); container.addMessageListener(redisGbPlayMsgListener, new PatternTopic(RedisGbPlayMsgListener.WVP_PUSH_STREAM_KEY)); + container.addMessageListener(redisPushStreamStatusMsgListener, new PatternTopic(VideoManagerConstants.VM_MSG_PUSH_STREAM_STATUS_CHANGE)); return container; } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index e38733d5..ac304504 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -58,7 +58,7 @@ public class CatalogEventLister implements ApplicationListener { ParentPlatform parentPlatform = null; Map> parentPlatformMap = new HashMap<>(); - if (event.getPlatformId() != null) { + if (!StringUtils.isEmpty(event.getPlatformId())) { parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); if (parentPlatform != null && !parentPlatform.isStatus()) { return; diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java index 366ed220..cbef9ce2 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMRTPServerFactory.java @@ -292,7 +292,7 @@ public class ZLMRTPServerFactory { logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg")); return -1; } - if ( code == 0 && ! mediaInfo.getBoolean("online")) { + if ( code == 0 && mediaInfo.getBoolean("online") != null && !mediaInfo.getBoolean("online")) { logger.warn("查询流({}/{})是否有其它观看者时得到: {}", app, streamId, mediaInfo.getString("msg")); return -1; } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java index acf0d274..5dd45ef9 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamPushService.java @@ -5,6 +5,7 @@ import com.genersoft.iot.vmp.media.zlm.ZLMServerConfig; import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.MediaServerItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; +import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import com.genersoft.iot.vmp.vmanager.bean.StreamPushExcelDto; import com.github.pagehelper.PageInfo; @@ -44,31 +45,55 @@ public interface IStreamPushService { * 停止一路推流 * @param app 应用名 * @param streamId 流ID - * @return */ boolean stop(String app, String streamId); /** * 新的节点加入 - * @param mediaServerId - * @return */ void zlmServerOnline(String mediaServerId); /** * 节点离线 - * @param mediaServerId - * @return */ void zlmServerOffline(String mediaServerId); + /** + * 清空 + */ void clean(); + boolean saveToRandomGB(); + /** + * 批量添加 + */ void batchAdd(List streamPushExcelDtoList); + /** + * 中止多个推流 + */ boolean batchStop(List streamPushItems); + /** + * 导入时批量增加 + */ void batchAddForUpload(List streamPushItems, Map> streamPushItemsForAll); + + /** + * 全部离线 + */ + void allStreamOffline(); + + /** + * 推流离线 + */ + void offline(List offlineStreams); + + /** + * 推流上线 + */ + void online(List onlineStreams); + } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java new file mode 100644 index 00000000..a34315bc --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java @@ -0,0 +1,89 @@ +package com.genersoft.iot.vmp.service.impl; + +import com.alibaba.fastjson.JSON; +import com.alibaba.fastjson.JSONObject; +import com.genersoft.iot.vmp.common.VideoManagerConstants; +import com.genersoft.iot.vmp.conf.DynamicTask; +import com.genersoft.iot.vmp.conf.UserSetting; +import com.genersoft.iot.vmp.gb28181.bean.GbStream; +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; +import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; +import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; +import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; +import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; +import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; +import com.genersoft.iot.vmp.storager.IVideoManagerStorage; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.boot.ApplicationArguments; +import org.springframework.boot.ApplicationRunner; +import org.springframework.data.redis.connection.Message; +import org.springframework.data.redis.connection.MessageListener; +import org.springframework.stereotype.Component; + +import java.util.List; + + +/** + * 接收redis发送的推流设备上线下线通知 + * @author lin + */ +@Component +public class RedisPushStreamStatusMsgListener implements MessageListener, ApplicationRunner { + + private final static Logger logger = LoggerFactory.getLogger(RedisPushStreamStatusMsgListener.class); + + @Autowired + private IRedisCatchStorage redisCatchStorage; + + @Autowired + private IStreamPushService streamPushService; + + @Autowired + private EventPublisher eventPublisher; + + @Autowired + private UserSetting userSetting; + + @Autowired + private DynamicTask dynamicTask; + + @Override + public void onMessage(Message message, byte[] bytes) { + + PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(message.getBody(), PushStreamStatusChangeFromRedisDto.class); + if (statusChangeFromPushStream == null) { + logger.warn("[REDIS 消息]推流设备状态变化消息解析失败"); + return; + } + if (statusChangeFromPushStream.isSetAllOffline()) { + // 所有设备离线 + streamPushService.allStreamOffline(); + } + if (statusChangeFromPushStream.getOfflineStreams().size() > 0) { + // 更新部分设备离线 + streamPushService.offline(statusChangeFromPushStream.getOfflineStreams()); + } + if (statusChangeFromPushStream.getOnlineStreams().size() > 0) { + // 更新部分设备上线 + streamPushService.online(statusChangeFromPushStream.getOnlineStreams()); + } + } + + @Override + public void run(ApplicationArguments args) throws Exception { + // 启动时设置所有推流通道离线,发起查询请求 + redisCatchStorage.sendStreamPushRequestedMsgForStatus(); + dynamicTask.startDelay(VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED, ()->{ + logger.info("[REDIS 消息]未收到redis回复推流设备状态,执行推流设备离线"); + // 五秒收不到请求就设置通道离线,然后通知上级离线 + streamPushService.allStreamOffline(); + }, 5000); + } + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisStreamMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisStreamMsgListener.java index 07fffdcc..83116f3a 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisStreamMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisStreamMsgListener.java @@ -3,16 +3,12 @@ package com.genersoft.iot.vmp.service.impl; import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.conf.UserSetting; -import com.genersoft.iot.vmp.gb28181.bean.AlarmChannelMessage; -import com.genersoft.iot.vmp.gb28181.bean.Device; -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; + import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.media.zlm.ZLMMediaListManager; import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; -import com.genersoft.iot.vmp.utils.DateUtil; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; @@ -22,6 +18,7 @@ import org.springframework.stereotype.Component; /** + * 接收其他wvp发送流变化通知 * @author lin */ @Component 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 837e135c..646d287d 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 @@ -13,6 +13,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.*; import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.IMediaServerService; import com.genersoft.iot.vmp.service.IStreamPushService; +import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.dao.*; import com.genersoft.iot.vmp.utils.DateUtil; @@ -181,7 +182,6 @@ public class StreamPushServiceImpl implements IStreamPushService { @Override public StreamPushItem getPush(String app, String streamId) { - return streamPushMapper.selectOne(app, streamId); } @@ -481,4 +481,34 @@ public class StreamPushServiceImpl implements IStreamPushService { } return true; } + + @Override + public void allStreamOffline() { + List onlinePushers = streamPushMapper.getOnlinePusherForGb(); + if (onlinePushers.size() == 0) { + return; + } + streamPushMapper.allStreamOffline(); + + // 发送通知 + eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF); + } + + @Override + public void offline(List offlineStreams) { + // 更新部分设备离线 + List onlinePushers = streamPushMapper.getOnlinePusherForGbInList(offlineStreams); + streamPushMapper.offline(offlineStreams); + // 发送通知 + eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF); + } + + @Override + public void online(List onlineStreams) { + // 更新部分设备上线streamPushService + List onlinePushers = streamPushMapper.getOfflinePusherForGbInList(onlineStreams); + streamPushMapper.online(onlineStreams); + // 发送通知 + eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.ON); + } } 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 79e6b26a..b9811da1 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IRedisCatchStorage.java @@ -233,4 +233,9 @@ public interface IRedisCatchStorage { * @return */ StreamAuthorityInfo getStreamAuthorityInfo(String app, String stream); + + /** + * 发送redis消息 查询所有推流设备的状态 + */ + void sendStreamPushRequestedMsgForStatus(); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 6c1e72d2..bcf57a6f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.storager.dao; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; +import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import org.apache.ibatis.annotations.*; // import org.omg.PortableInterceptor.INACTIVE; import org.springframework.stereotype.Repository; @@ -117,4 +118,45 @@ public interface StreamPushMapper { "SET status=#{status} " + "WHERE mediaServerId=#{mediaServerId}") void updateStatusByMediaServerId(String mediaServerId, boolean status); + + + @Select("") + List getOnlinePusherForGbInList(List offlineStreams); + + @Update("") + void offline(List offlineStreams); + + @Select("") + List getOfflinePusherForGbInList(List onlineStreams); + + @Update("") + void online(List onlineStreams); + + @Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream") + List getOnlinePusherForGb(); + + @Update("UPDATE stream_push SET status=0") + void allStreamOffline(); } From 24fba85c38d69c3074414e182b1e82fe34dac7fe Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 12 Jul 2022 17:33:32 +0800 Subject: [PATCH 08/20] =?UTF-8?q?=E6=94=AF=E6=8C=81=E4=BB=8Eredis=E6=B6=88?= =?UTF-8?q?=E6=81=AF=E6=9B=B4=E6=96=B0=E6=8E=A8=E6=B5=81=E8=AE=BE=E5=A4=87?= =?UTF-8?q?=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/storager/impl/RedisCatchStorageImpl.java | 8 ++++++++ 1 file changed, 8 insertions(+) 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 d2798479..8e98059c 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 @@ -707,4 +707,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { } + @Override + public void sendStreamPushRequestedMsgForStatus() { + String key = VideoManagerConstants.VM_MSG_GET_ALL_ONLINE_REQUESTED; + logger.info("[redis 通知]获取所有推流设备的状态"); + JSONObject jsonObject = new JSONObject(); + jsonObject.put(key, key); + redis.convertAndSend(key, jsonObject); + } } From 9fec9dc93aa97b55106308809e3dad04b8e8d2b7 Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: Wed, 13 Jul 2022 11:29:46 +0800 Subject: [PATCH 09/20] =?UTF-8?q?=E6=B5=8B=E8=AF=95=E6=8F=90=E4=BA=A4?= =?UTF-8?q?=E6=9D=83=E9=99=90?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java index 8ff2efb8..3bac82d6 100644 --- a/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java +++ b/src/main/java/com/genersoft/iot/vmp/VManageBootstrap.java @@ -11,7 +11,7 @@ import org.springframework.scheduling.annotation.EnableScheduling; import springfox.documentation.oas.annotations.EnableOpenApi; /** - * + * 启动类 */ @ServletComponentScan("com.genersoft.iot.vmp.conf") @SpringBootApplication From 1a285ba00f97150da4fb3e8b61807747f19bbba9 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 17 Jul 2022 23:17:36 +0800 Subject: [PATCH 10/20] =?UTF-8?q?=E4=BC=98=E5=8C=96=E5=9B=BD=E6=A0=87?= =?UTF-8?q?=E7=BA=A7=E8=81=94=E7=9B=AE=E5=BD=95=E8=AE=A2=E9=98=85=E9=80=9A?= =?UTF-8?q?=E7=9F=A5=E4=BB=A5=E5=8F=8A=E7=9B=AE=E5=BD=95=E6=9F=A5=E8=AF=A2?= =?UTF-8?q?=E5=9B=9E=E5=A4=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql.sql | 21 +- sql/update.sql | 10 + .../iot/vmp/gb28181/bean/ParentPlatform.java | 13 + .../iot/vmp/gb28181/bean/PlatformCatalog.java | 35 ++- .../iot/vmp/gb28181/bean/TreeType.java | 10 + .../event/subscribe/catalog/CatalogEvent.java | 41 ++- .../subscribe/catalog/CatalogEventLister.java | 16 +- .../MobilePositionSubscribeHandlerTask.java | 10 +- .../cmd/impl/SIPCommanderFroPlatform.java | 72 ++--- .../request/impl/NotifyRequestProcessor.java | 88 +++--- .../notify/cmd/AlarmNotifyMessageHandler.java | 42 ++- .../cmd/CatalogNotifyMessageHandler.java | 76 +---- .../MobilePositionNotifyMessageHandler.java | 42 ++- .../query/cmd/CatalogQueryMessageHandler.java | 76 +---- .../cmd/CatalogResponseMessageHandler.java | 6 +- .../cmd/DeviceInfoResponseMessageHandler.java | 1 - .../MobilePositionResponseMessageHandler.java | 41 ++- .../iot/vmp/gb28181/utils/XmlUtil.java | 227 +++++++++------ .../iot/vmp/media/zlm/AssistRESTfulUtils.java | 8 + .../vmp/media/zlm/ZLMHttpHookListener.java | 14 +- .../vmp/service/IDeviceChannelService.java | 35 +++ .../iot/vmp/service/IGbStreamService.java | 2 +- .../vmp/service/IPlatformChannelService.java | 22 ++ .../iot/vmp/service/IStreamProxyService.java | 5 + .../service/impl/DeviceAlarmServiceImpl.java | 1 - .../impl/DeviceChannelServiceImpl.java | 165 +++++++++++ .../vmp/service/impl/DeviceServiceImpl.java | 33 +-- .../vmp/service/impl/GbStreamServiceImpl.java | 34 ++- .../impl/PlatformChannelServiceImpl.java | 110 ++++++++ .../RedisPushStreamStatusMsgListener.java | 9 +- .../service/impl/StreamProxyServiceImpl.java | 101 ++++++- .../service/impl/StreamPushServiceImpl.java | 2 +- .../impl/StreamPushUploadFileHandler.java | 44 ++- .../vmp/storager/IVideoManagerStorage.java | 45 +-- .../vmp/storager/dao/DeviceChannelMapper.java | 10 +- .../iot/vmp/storager/dao/GbStreamMapper.java | 35 ++- .../storager/dao/ParentPlatformMapper.java | 5 +- .../storager/dao/PlatformCatalogMapper.java | 13 +- .../vmp/storager/dao/StreamPushMapper.java | 36 +-- .../impl/VideoManagerStorageImpl.java | 265 +++++------------- .../vmanager/gb28181/device/DeviceQuery.java | 6 +- .../gb28181/gbStream/GbStreamController.java | 4 +- .../gb28181/platform/PlatformController.java | 15 +- web_src/src/components/ParentPlatformList.vue | 2 +- web_src/src/components/PushVideoList.vue | 15 +- web_src/src/components/dialog/catalogEdit.vue | 38 ++- .../src/components/dialog/chooseChannel.vue | 6 +- .../dialog/chooseChannelForCatalog.vue | 5 +- .../dialog/chooseChannelForStream.vue | 1 - .../src/components/dialog/platformEdit.vue | 65 +++-- 50 files changed, 1159 insertions(+), 819 deletions(-) create mode 100644 src/main/java/com/genersoft/iot/vmp/gb28181/bean/TreeType.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java create mode 100644 src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java diff --git a/sql/mysql.sql b/sql/mysql.sql index 9d2e1174..71d4ac5d 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -50,7 +50,7 @@ CREATE TABLE `device` ( `treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `device_deviceId_uindex` (`deviceId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -142,7 +142,7 @@ CREATE TABLE `device_channel` ( PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `device_channel_id_uindex` (`id`) USING BTREE, UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=19331 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=19336 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -213,7 +213,7 @@ CREATE TABLE `gb_stream` ( PRIMARY KEY (`gbStreamId`) USING BTREE, UNIQUE KEY `app` (`app`,`stream`) USING BTREE, UNIQUE KEY `gbId` (`gbId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=301681 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=301740 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -243,7 +243,7 @@ CREATE TABLE `log` ( `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=34997 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=37760 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -334,10 +334,11 @@ CREATE TABLE `parent_platform` ( `catalogGroup` int DEFAULT '1', `createTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, `updateTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `parent_platform_id_uindex` (`id`) USING BTREE, UNIQUE KEY `parent_platform_pk` (`serverGBId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -361,6 +362,8 @@ CREATE TABLE `platform_catalog` ( `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, + `civilCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, + `businessGroupId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; @@ -387,7 +390,7 @@ CREATE TABLE `platform_gb_channel` ( `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `deviceChannelId` int NOT NULL, PRIMARY KEY (`id`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=4889 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=4912 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -413,7 +416,7 @@ CREATE TABLE `platform_gb_stream` ( `id` int NOT NULL AUTO_INCREMENT, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=302077 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=302134 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -489,7 +492,7 @@ CREATE TABLE `stream_push` ( `status` int DEFAULT NULL, PRIMARY KEY (`id`) USING BTREE, UNIQUE KEY `stream_push_pk` (`app`,`stream`) USING BTREE -) ENGINE=InnoDB AUTO_INCREMENT=305315 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; +) ENGINE=InnoDB AUTO_INCREMENT=305390 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; /*!40101 SET character_set_client = @saved_cs_client */; -- @@ -567,4 +570,4 @@ UNLOCK TABLES; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; --- Dump completed on 2022-07-11 17:32:51 +-- Dump completed on 2022-07-17 23:15:09 diff --git a/sql/update.sql b/sql/update.sql index 89d0e8a0..c5fb671b 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -65,4 +65,14 @@ alter table user add pushKey varchar(50) default null; +alter table parent_platform + add treeType varchar(50) not null; +update parent_platform set parent_platform.treeType='BusinessGroup'; + +alter table platform_catalog + add civilCode varchar(50) default null; +alter table platform_catalog + add businessGroupId varchar(50) default null; + + 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 4377282d..6dcf0dfc 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 @@ -154,6 +154,11 @@ public class ParentPlatform { */ private String createTime; + /** + * 树类型 国标规定了两种树的展现方式 行政区划 CivilCode 和业务分组:BusinessGroup + */ + private String treeType; + public Integer getId() { return id; } @@ -394,4 +399,12 @@ public class ParentPlatform { public void setCreateTime(String createTime) { this.createTime = createTime; } + + public String getTreeType() { + return treeType; + } + + public void setTreeType(String treeType) { + this.treeType = treeType; + } } 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 index 065971dd..58a9cbb0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java @@ -1,12 +1,28 @@ package com.genersoft.iot.vmp.gb28181.bean; +/** + * 国标级联-目录 + * @author lin + */ public class PlatformCatalog { private String id; private String name; private String platformId; private String parentId; - private int childrenCount; // 子节点数 - private int type; // 0 目录, 1 国标通道, 2 直播流 + + private String civilCode; + + private String businessGroupId; + + /** + * 子节点数 + */ + private int childrenCount; + + /** + * 0 目录, 1 国标通道, 2 直播流 + */ + private int type; public String getId() { return id; @@ -68,4 +84,19 @@ public class PlatformCatalog { this.type = 2; } + public String getCivilCode() { + return civilCode; + } + + public void setCivilCode(String civilCode) { + this.civilCode = civilCode; + } + + public String getBusinessGroupId() { + return businessGroupId; + } + + public void setBusinessGroupId(String businessGroupId) { + this.businessGroupId = businessGroupId; + } } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/bean/TreeType.java b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/TreeType.java new file mode 100644 index 00000000..bb684e1a --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/bean/TreeType.java @@ -0,0 +1,10 @@ +package com.genersoft.iot.vmp.gb28181.bean; + +/** + * 目录结构类型 + * @author lin + */ +public class TreeType { + public static final String BUSINESS_GROUP = "BusinessGroup"; + public static final String CIVIL_CODE = "CivilCode"; +} diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java index c035b808..5c064f75 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java @@ -11,13 +11,40 @@ public class CatalogEvent extends ApplicationEvent { super(source); } - public static final String ON = "ON"; // 上线 - public static final String OFF = "OFF"; // 离线 - public static final String VLOST = "VLOST"; // 视频丢失 - public static final String DEFECT = "DEFECT"; // 故障 - public static final String ADD = "ADD"; // 增加 - public static final String DEL = "DEL"; // 删除 - public static final String UPDATE = "UPDATE"; // 更新 + /** + * 上线 + */ + public static final String ON = "ON"; + + /** + * 离线 + */ + public static final String OFF = "OFF"; + + /** + * 视频丢失 + */ + public static final String VLOST = "VLOST"; + + /** + * 故障 + */ + public static final String DEFECT = "DEFECT"; + + /** + * 增加 + */ + public static final String ADD = "ADD"; + + /** + * 删除 + */ + public static final String DEL = "DEL"; + + /** + * 更新 + */ + public static final String UPDATE = "UPDATE"; private List deviceChannels; private List gbStreams; diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java index ac304504..224fa1e6 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java @@ -59,16 +59,15 @@ public class CatalogEventLister implements ApplicationListener { Map> parentPlatformMap = new HashMap<>(); if (!StringUtils.isEmpty(event.getPlatformId())) { + subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); + if (subscribe == null) { + return; + } parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); if (parentPlatform != null && !parentPlatform.isStatus()) { return; } - subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId()); - if (subscribe == null) { - logger.info("发送订阅消息时发现订阅信息已经不存在: {}", event.getPlatformId()); - return; - } }else { // 获取所用订阅 List platforms = subscribeHolder.getAllCatalogSubscribePlatform(); @@ -144,11 +143,8 @@ public class CatalogEventLister implements ApplicationListener { } if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ for (GbStream gbStream : event.getGbStreams()) { - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform); - if (deviceChannelByStream.getParentId().length() <= 10) { // 父节点是行政区划,则设置CivilCode使用此行政区划 - deviceChannelByStream.setCivilCode(deviceChannelByStream.getParentId()); - } - deviceChannelList.add(deviceChannelByStream); + deviceChannelList.add( + gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform)); } } if (deviceChannelList.size() > 0) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java index 66b57fec..0bad048a 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java @@ -57,18 +57,14 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); if (subscribe != null) { -// if (!parentPlatform.isStatus()) { -// logger.info("发送订阅时发现平台已经离线:{}", platformId); -// return; -// } // TODO 暂时只处理视频流的回复,后续增加对国标设备的支持 - List gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId()); + List gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId()); if (gbStreams.size() == 0) { logger.info("发送订阅时发现平台已经没有关联的直播流:{}", platform.getServerGBId()); return; } - for (GbStream gbStream : gbStreams) { - String gbId = gbStream.getGbId(); + for (DeviceChannel deviceChannel : gbStreams) { + String gbId = deviceChannel.getChannelId(); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); if (gpsMsgInfo != null) { // 无最新位置不发送 if (logger.isDebugEnabled()) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java index 73f9c4f7..10f428b0 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java @@ -257,37 +257,37 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { catalogXml.append("\r\n"); if (channels.size() > 0) { for (DeviceChannel channel : channels) { + if (parentPlatform.getServerGBId().equals(channel.getParentId())) { + channel.setParentId(parentPlatform.getDeviceGBId()); + } catalogXml.append("\r\n"); + // 行政区划分组只需要这两项就可以 catalogXml.append("" + channel.getChannelId() + "\r\n"); catalogXml.append("" + channel.getName() + "\r\n"); - catalogXml.append("" + channel.getParental() + "\r\n"); if (channel.getParentId() != null) { + // 业务分组加上这一项即可,提高兼容性, catalogXml.append("" + channel.getParentId() + "\r\n"); } - if (channel.getChannelId().length() == 20) { - if (Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段 - catalogXml.append("" + channel.getParentId() + "\r\n"); - } + if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { + // 虚拟组织增加BusinessGroupID字段 + catalogXml.append("" + channel.getParentId() + "\r\n"); + } + catalogXml.append("" + channel.getParental() + "\r\n"); + if (channel.getParental() == 0) { + // 通道项 catalogXml.append("" + channel.getManufacture() + "\r\n"); + catalogXml.append("" + channel.getSecrecy() + "\r\n"); catalogXml.append("" + channel.getRegisterWay() + "\r\n"); - catalogXml.append("" + (channel.getStatus() == 0?"OFF":"ON") + "\r\n"); - if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下字段 - catalogXml.append("" + channel.getSecrecy() + "\r\n"); + catalogXml.append("" + (channel.getStatus() == 0 ? "OFF" : "ON") + "\r\n"); + + if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 catalogXml.append("" + channel.getModel() + "\r\n"); - catalogXml.append("" + channel.getOwner() + "\r\n"); + catalogXml.append(" " + channel.getOwner()+ "\r\n"); catalogXml.append("" + channel.getCivilCode() + "\r\n"); catalogXml.append("
" + channel.getAddress() + "
\r\n"); - catalogXml.append("" + channel.getLongitudeWgs84() + "\r\n"); - catalogXml.append("" + channel.getLatitudeWgs84() + "\r\n"); - catalogXml.append("" + channel.getIpAddress() + "\r\n"); - catalogXml.append("" + channel.getPort() + "\r\n"); - catalogXml.append("\r\n"); - catalogXml.append("" + channel.getPTZType() + "\r\n"); - catalogXml.append("\r\n"); } + } - - catalogXml.append("
\r\n"); } } @@ -592,27 +592,35 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { channel.setParentId(parentPlatform.getDeviceGBId()); } catalogXml.append("\r\n"); + // 行政区划分组只需要这两项就可以 catalogXml.append("" + channel.getChannelId() + "\r\n"); catalogXml.append("" + channel.getName() + "\r\n"); - catalogXml.append("" + channel.getManufacture() + "\r\n"); - catalogXml.append("" + channel.getParental() + "\r\n"); if (channel.getParentId() != null) { + // 业务分组加上这一项即可,提高兼容性, catalogXml.append("" + channel.getParentId() + "\r\n"); } - catalogXml.append("" + channel.getSecrecy() + "\r\n"); - catalogXml.append("" + channel.getRegisterWay() + "\r\n"); - catalogXml.append("" + (channel.getStatus() == 0 ? "OFF" : "ON") + "\r\n"); - if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段 + if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { + // 虚拟组织增加BusinessGroupID字段 catalogXml.append("" + channel.getParentId() + "\r\n"); } - if (channel.getChannelType() == 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 - catalogXml.append("" + channel.getModel() + "\r\n"); - catalogXml.append("0\r\n"); - catalogXml.append("CivilCode\r\n"); - catalogXml.append("
" + channel.getAddress() + "
\r\n"); - } - if (!"presence".equals(subscribeInfo.getEventType())) { - catalogXml.append("" + type + "\r\n"); + catalogXml.append("" + channel.getParental() + "\r\n"); + if (channel.getParental() == 0) { + // 通道项 + catalogXml.append("" + channel.getManufacture() + "\r\n"); + catalogXml.append("" + channel.getSecrecy() + "\r\n"); + catalogXml.append("" + channel.getRegisterWay() + "\r\n"); + catalogXml.append("" + (channel.getStatus() == 0 ? "OFF" : "ON") + "\r\n"); + + if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性 + catalogXml.append("" + channel.getModel() + "\r\n"); + catalogXml.append(" " + channel.getOwner()+ "\r\n"); + catalogXml.append("" + channel.getCivilCode() + "\r\n"); + catalogXml.append("
" + channel.getAddress() + "
\r\n"); + } + if (!"presence".equals(subscribeInfo.getEventType())) { + catalogXml.append("" + type + "\r\n"); + } + } catalogXml.append("
\r\n"); } diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java index 376d74b0..c8a221bd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/NotifyRequestProcessor.java @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; @@ -71,6 +72,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements @Autowired private SIPProcessorObserver sipProcessorObserver; + @Autowired + private IDeviceChannelService deviceChannelService; + private boolean taskQueueHandlerRun = false; private final ConcurrentLinkedQueue taskQueue = new ConcurrentLinkedQueue<>(); @@ -173,28 +177,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements logger.info("[收到 移动位置订阅]:{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), mobilePosition.getLongitude(), mobilePosition.getLatitude()); mobilePosition.setReportSource("Mobile Position"); - // 默认来源坐标系为WGS-84处理 - if ("WGS84".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude()); - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeGcj02(position[0]); - mobilePosition.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude()); - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeWgs84(position[0]); - mobilePosition.setLatitudeWgs84(position[1]); - }else { - mobilePosition.setLongitudeGcj02(0.00); - mobilePosition.setLatitudeGcj02(0.00); - mobilePosition.setLongitudeWgs84(0.00); - mobilePosition.setLatitudeWgs84(0.00); - } - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } + // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); @@ -202,11 +185,18 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements deviceChannel.setChannelId(channelId); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84()); - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84()); - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02()); - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02()); deviceChannel.setGpsTime(mobilePosition.getTime()); + deviceChannel = deviceChannelService.updateGps(deviceChannel, device); + + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); + + if (userSetting.getSavePositionHistory()) { + storager.insertMobilePosition(mobilePosition); + } + storager.updateChannelPosition(deviceChannel); // 发送redis消息。 通知位置信息的变化 JSONObject jsonObject = new JSONObject(); @@ -281,38 +271,28 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements mobilePosition.setLongitude(deviceAlarm.getLongitude()); mobilePosition.setLatitude(deviceAlarm.getLatitude()); mobilePosition.setReportSource("GPS Alarm"); - if ("WGS84".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude()); - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeGcj02(position[0]); - mobilePosition.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude()); - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeWgs84(position[0]); - mobilePosition.setLatitudeWgs84(position[1]); - }else { - mobilePosition.setLongitudeGcj02(0.00); - mobilePosition.setLatitudeGcj02(0.00); - mobilePosition.setLongitudeWgs84(0.00); - mobilePosition.setLatitudeWgs84(0.00); - } - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } + + + // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setChannelId(channelId); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84()); - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84()); - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02()); - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02()); deviceChannel.setGpsTime(mobilePosition.getTime()); + + deviceChannel = deviceChannelService.updateGps(deviceChannel, device); + + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); + + if (userSetting.getSavePositionHistory()) { + storager.insertMobilePosition(mobilePosition); + } + storager.updateChannelPosition(deviceChannel); } // TODO: 需要实现存储报警信息、报警分类 @@ -364,7 +344,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements }else { event = eventElement.getText().toUpperCase(); } - DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device); + DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event); channel.setDeviceId(device.getDeviceId()); logger.info("[收到 目录订阅]:{}/{}", device.getDeviceId(), channel.getChannelId()); switch (event) { @@ -389,7 +369,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements case CatalogEvent.ADD: // 增加 logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channel.getChannelId()); - storager.updateChannel(deviceId, channel); + deviceChannelService.updateChannel(deviceId, channel); break; case CatalogEvent.DEL: // 删除 @@ -399,7 +379,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements case CatalogEvent.UPDATE: // 更新 logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channel.getChannelId()); - storager.updateChannel(deviceId, channel); + deviceChannelService.updateChannel(deviceId, channel); break; default: logger.warn("[ NotifyCatalog ] event not found : {}", event ); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java index 8dfd2331..265694ae 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/AlarmNotifyMessageHandler.java @@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.service.IDeviceAlarmService; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; @@ -58,6 +59,9 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme @Autowired private IDeviceAlarmService deviceAlarmService; + @Autowired + private IDeviceChannelService deviceChannelService; + @Override public void afterPropertiesSet() throws Exception { notifyMessageHandler.addHandler(cmdType, this); @@ -119,38 +123,26 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme mobilePosition.setLongitude(deviceAlarm.getLongitude()); mobilePosition.setLatitude(deviceAlarm.getLatitude()); mobilePosition.setReportSource("GPS Alarm"); - if ("WGS84".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude()); - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeGcj02(position[0]); - mobilePosition.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude()); - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeWgs84(position[0]); - mobilePosition.setLatitudeWgs84(position[1]); - }else { - mobilePosition.setLongitudeGcj02(0.00); - mobilePosition.setLatitudeGcj02(0.00); - mobilePosition.setLongitudeWgs84(0.00); - mobilePosition.setLatitudeWgs84(0.00); - } - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } + + // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setChannelId(channelId); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84()); - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84()); - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02()); - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02()); deviceChannel.setGpsTime(mobilePosition.getTime()); + + deviceChannel = deviceChannelService.updateGps(deviceChannel, device); + + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); + + if (userSetting.getSavePositionHistory()) { + storager.insertMobilePosition(mobilePosition); + } storager.updateChannelPosition(deviceChannel); } } 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 d714ee4f..0b27855f 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 @@ -58,85 +58,21 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple // 准备回复通道信息 List deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); // 查询关联的直播通道 - List gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); + List gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); + // 回复目录信息 + List catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId()); List allChannels = new ArrayList<>(); - // 回复目录信息 - List catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId()); if (catalogs.size() > 0) { - for (PlatformCatalog catalog : catalogs) { - if (catalog.getParentId().equals(catalog.getPlatformId())) { - catalog.setParentId(parentPlatform.getDeviceGBId()); - } - 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); - if (catalog.getParentId() != null && catalog.getParentId().length() <= 10) { - deviceChannel.setCivilCode(catalog.getParentId()); - }else { - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - } - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setSecrecy("0"); - allChannels.add(deviceChannel); - } + allChannels.addAll(catalogs); } // 回复级联的通道 if (deviceChannels.size() > 0) { - for (DeviceChannelInPlatform channel : deviceChannels) { - if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) { - channel.setCatalogId(parentPlatform.getDeviceGBId()); - } - DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId()); - deviceChannel.setParental(0); - deviceChannel.setParentId(channel.getCatalogId()); - if (channel.getCatalogId() != null && channel.getCatalogId().length() <= 10) { - channel.setCivilCode(channel.getCatalogId()); - }else { - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - } - - allChannels.add(deviceChannel); - } + allChannels.addAll(deviceChannels); } // 回复直播的通道 if (gbStreams.size() > 0) { - for (GbStream gbStream : gbStreams) { - if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) { - gbStream.setCatalogId(null); - } - DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannel.setName(gbStream.getName()); - deviceChannel.setLongitude(gbStream.getLongitude()); - deviceChannel.setLatitude(gbStream.getLatitude()); - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); -// deviceChannel.setStatus(gbStream.isStatus()?1:0); - deviceChannel.setStatus(1); - deviceChannel.setParentId(gbStream.getCatalogId()); - deviceChannel.setRegisterWay(1); - if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() <= 10) { - deviceChannel.setCivilCode(gbStream.getCatalogId()); - }else { - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - } - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setParental(0); - deviceChannel.setSecrecy("0"); - allChannels.add(deviceChannel); - } + allChannels.addAll(gbStreams); } if (allChannels.size() > 0) { cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java index aa91556f..2402494c 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/notify/cmd/MobilePositionNotifyMessageHandler.java @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.GpsUtil; @@ -42,6 +43,9 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceChannelService deviceChannelService; + @Override public void afterPropertiesSet() throws Exception { notifyMessageHandler.addHandler(cmdType, this); @@ -79,38 +83,26 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen mobilePosition.setAltitude(0.0); } mobilePosition.setReportSource("Mobile Position"); - if ("WGS84".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude()); - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeGcj02(position[0]); - mobilePosition.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude()); - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeWgs84(position[0]); - mobilePosition.setLatitudeWgs84(position[1]); - }else { - mobilePosition.setLongitudeGcj02(0.00); - mobilePosition.setLatitudeGcj02(0.00); - mobilePosition.setLongitudeWgs84(0.00); - mobilePosition.setLatitudeWgs84(0.00); - } - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } + + // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setChannelId(mobilePosition.getChannelId()); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84()); - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84()); - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02()); - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02()); deviceChannel.setGpsTime(mobilePosition.getTime()); + + deviceChannel = deviceChannelService.updateGps(deviceChannel, device); + + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); + + if (userSetting.getSavePositionHistory()) { + storager.insertMobilePosition(mobilePosition); + } storager.updateChannelPosition(deviceChannel); //回复 200 OK responseAck(evt, Response.OK); 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 0e979619..7f6f8177 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 @@ -70,86 +70,24 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem Element snElement = rootElement.element("SN"); String sn = snElement.getText(); // 准备回复通道信息 - List deviceChannelInPlatforms = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); + List deviceChannelInPlatforms = storager.queryChannelWithCatalog(parentPlatform.getServerGBId()); // 查询关联的直播通道 - List gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); + List gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); // 回复目录信息 - List catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); + List catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); List allChannels = new ArrayList<>(); + if (catalogs.size() > 0) { - for (PlatformCatalog catalog : catalogs) { - if (catalog.getParentId().equals(catalog.getPlatformId())) { - catalog.setParentId(parentPlatform.getDeviceGBId()); - } - DeviceChannel deviceChannel = new DeviceChannel(); - // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 - deviceChannel.setChannelType(2); - deviceChannel.setChannelId(catalog.getId()); - deviceChannel.setName(catalog.getName()); - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); - deviceChannel.setStatus(1); - deviceChannel.setParental(1); - deviceChannel.setParentId(catalog.getParentId()); - deviceChannel.setRegisterWay(1); - if (catalog.getParentId() != null && catalog.getParentId().length() < 10) { - deviceChannel.setCivilCode(catalog.getParentId()); - }else { - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - } - allChannels.add(deviceChannel); - } + allChannels.addAll(catalogs); } // 回复级联的通道 if (deviceChannelInPlatforms.size() > 0) { - for (DeviceChannelInPlatform channel : deviceChannelInPlatforms) { - if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) { - channel.setCatalogId(parentPlatform.getDeviceGBId()); - } - DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId()); - // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 - deviceChannel.setChannelType(0); - deviceChannel.setParental(0); - deviceChannel.setParentId(channel.getCatalogId()); - if (channel.getCatalogId() != null && channel.getCatalogId().length() < 10) { - deviceChannel.setCivilCode(channel.getCatalogId()); - }else { - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - } - allChannels.add(deviceChannel); - } + allChannels.addAll(deviceChannelInPlatforms); } // 回复直播的通道 if (gbStreams.size() > 0) { - for (GbStream gbStream : gbStreams) { - if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) { - gbStream.setCatalogId(null); - } - DeviceChannel deviceChannel = new DeviceChannel(); - // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划 - deviceChannel.setChannelType(1); - deviceChannel.setChannelId(gbStream.getGbId()); - deviceChannel.setName(gbStream.getName()); - deviceChannel.setLongitude(gbStream.getLongitude()); - deviceChannel.setLatitude(gbStream.getLatitude()); - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId()); - deviceChannel.setManufacture("wvp-pro"); -// deviceChannel.setStatus(gbStream.isStatus()?1:0); - deviceChannel.setStatus(1); - deviceChannel.setParentId(gbStream.getCatalogId()); - deviceChannel.setRegisterWay(1); - if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() < 10) { - deviceChannel.setCivilCode(gbStream.getCatalogId()); - }else { - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision()); - } - deviceChannel.setModel("live"); - deviceChannel.setOwner("wvp-pro"); - deviceChannel.setParental(0); - deviceChannel.setSecrecy("0"); - allChannels.add(deviceChannel); - } + allChannels.addAll(gbStreams); } if (allChannels.size() > 0) { cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag()); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java index 2766474e..66e92c52 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/CatalogResponseMessageHandler.java @@ -125,11 +125,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp if (channelDeviceElement == null) { continue; } - //by brewswang - // if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置 - // processNotifyMobilePosition(evt, itemDevice); - // } - DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device); + DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device, null); deviceChannel.setDeviceId(take.getDevice().getDeviceId()); channelList.add(deviceChannel); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java index eb2c7b8f..f5d04be9 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/DeviceInfoResponseMessageHandler.java @@ -87,7 +87,6 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent device.setStreamMode("UDP"); } deviceService.updateDevice(device); -// storager.updateDevice(device); RequestMessage msg = new RequestMessage(); msg.setKey(key); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java index e562fa45..4c723abd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/MobilePositionResponseMessageHandler.java @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.GpsUtil; @@ -42,6 +43,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceChannelService deviceChannelService; + @Override public void afterPropertiesSet() throws Exception { responseMessageHandler.addHandler(cmdType, this); @@ -79,38 +83,25 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar mobilePosition.setAltitude(0.0); } mobilePosition.setReportSource("Mobile Position"); - if ("WGS84".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude()); - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeGcj02(position[0]); - mobilePosition.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude()); - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude()); - mobilePosition.setLongitudeWgs84(position[0]); - mobilePosition.setLatitudeWgs84(position[1]); - }else { - mobilePosition.setLongitudeGcj02(0.00); - mobilePosition.setLatitudeGcj02(0.00); - mobilePosition.setLongitudeWgs84(0.00); - mobilePosition.setLatitudeWgs84(0.00); - } - if (userSetting.getSavePositionHistory()) { - storager.insertMobilePosition(mobilePosition); - } + // 更新device channel 的经纬度 DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setChannelId(mobilePosition.getChannelId()); deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLatitude(mobilePosition.getLatitude()); - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84()); - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84()); - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02()); - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02()); deviceChannel.setGpsTime(mobilePosition.getTime()); + + deviceChannel = deviceChannelService.updateGps(deviceChannel, device); + + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84()); + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84()); + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02()); + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02()); + + if (userSetting.getSavePositionHistory()) { + storager.insertMobilePosition(mobilePosition); + } storager.updateChannelPosition(deviceChannel); //回复 200 OK responseAck(evt, Response.OK); diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java index 72206d87..ced97efe 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.gb28181.bean.TreeType; +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.utils.DateUtil; import org.dom4j.Attribute; import org.dom4j.Document; @@ -29,7 +31,7 @@ public class XmlUtil { /** * 日志服务 */ - private static Logger LOG = LoggerFactory.getLogger(XmlUtil.class); + private static Logger logger = LoggerFactory.getLogger(XmlUtil.class); /** * 解析XML为Document对象 @@ -46,7 +48,7 @@ public class XmlUtil { try { document = saxReader.read(sr); } catch (DocumentException e) { - LOG.error("解析失败", e); + logger.error("解析失败", e); } return null == document ? null : document.getRootElement(); } @@ -182,47 +184,69 @@ public class XmlUtil { return xml.getRootElement(); } - public static DeviceChannel channelContentHander(Element itemDevice, Device device){ - Element channdelNameElement = itemDevice.element("Name"); - String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : ""; - Element statusElement = itemDevice.element("Status"); - String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON"; + private enum ChannelType{ + CivilCode, BusinessGroup,VirtualOrganization,Other + } + + public static DeviceChannel channelContentHander(Element itemDevice, Device device, String event){ DeviceChannel deviceChannel = new DeviceChannel(); - deviceChannel.setName(channelName); + deviceChannel.setDeviceId(device.getDeviceId()); Element channdelIdElement = itemDevice.element("DeviceID"); - String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : ""; - deviceChannel.setChannelId(channelId); - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) { - deviceChannel.setStatus(1); + if (channdelIdElement == null) { + logger.warn("解析Catalog消息时发现缺少 DeviceID"); + return null; } - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { - deviceChannel.setStatus(0); + String channelId = channdelIdElement.getTextTrim(); + if (StringUtils.isEmpty(channelId)) { + logger.warn("解析Catalog消息时发现缺少 DeviceID"); + return null; + } + deviceChannel.setChannelId(channelId); + if (event != null && !event.equals(CatalogEvent.ADD) && !event.equals(CatalogEvent.UPDATE)) { + // 除了ADD和update情况下需要识别全部内容, + return deviceChannel; } - deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); - deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); - deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); - deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); - deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); - deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); - String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID"); - if (XmlUtil.getText(itemDevice, "Parental") == null - || XmlUtil.getText(itemDevice, "Parental").equals("")) { - if (deviceChannel.getChannelId().length() <= 10 - || (deviceChannel.getChannelId().length() == 20 && ( - Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 215 - || Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216 - ) - ) - ) { - deviceChannel.setParental(1); - }else { - deviceChannel.setParental(0); + ChannelType channelType = ChannelType.Other; + if (channelId.length() <= 8) { + channelType = ChannelType.CivilCode; + }else { + if (channelId.length() == 20) { + int code = Integer.parseInt(channelId.substring(10, 13)); + switch (code){ + case 215: + channelType = ChannelType.BusinessGroup; + break; + case 216: + channelType = ChannelType.VirtualOrganization; + break; + default: + break; + + } } - } else { - // 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1 - deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")) == 1?1:0); + } + + Element channdelNameElement = itemDevice.element("Name"); + String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim() : ""; + deviceChannel.setName(channelName); + + String civilCode = XmlUtil.getText(itemDevice, "CivilCode"); + deviceChannel.setCivilCode(civilCode); + if (channelType == ChannelType.CivilCode && civilCode == null) { + deviceChannel.setParental(1); + // 行政区划如果没有传递具体值,则推测一个 + if (channelId.length() > 2) { + deviceChannel.setCivilCode(channelId.substring(0, channelId.length() - 2)); + } + } + if (channelType.equals(ChannelType.CivilCode)) { + // 行政区划其他字段没必要识别了,默认在线即可 + deviceChannel.setStatus(1); + deviceChannel.setParental(1); + deviceChannel.setCreateTime(DateUtil.getNow()); + deviceChannel.setUpdateTime(DateUtil.getNow()); + return deviceChannel; } /** * 行政区划展示设备树与业务分组展示设备树是两种不同的模式 @@ -230,7 +254,17 @@ public class XmlUtil { * 河北省 * --> 石家庄市 * --> 摄像头 - * --> 正定县 + *String parentId = XmlUtil.getText(itemDevice, "ParentID"); + if (parentId != null) { + if (parentId.contains("/")) { + String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); + String businessGroup = parentId.substring(0, parentId.indexOf("/")); + deviceChannel.setParentId(lastParentId); + }else { + deviceChannel.setParentId(parentId); + } + } + deviceCh --> 正定县 * --> 摄像头 * --> 摄像头 * @@ -243,59 +277,88 @@ public class XmlUtil { * --> 摄像头 */ String parentId = XmlUtil.getText(itemDevice, "ParentID"); + String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID"); if (parentId != null) { if (parentId.contains("/")) { String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); + if (businessGroupID == null) { + businessGroupID = parentId.substring(0, parentId.indexOf("/")); + } deviceChannel.setParentId(lastParentId); }else { deviceChannel.setParentId(parentId); } } deviceChannel.setBusinessGroupId(businessGroupID); + if (channelType.equals(ChannelType.BusinessGroup) || channelType.equals(ChannelType.VirtualOrganization)) { + // 业务分组和虚拟组织 其他字段没必要识别了,默认在线即可 + deviceChannel.setStatus(1); + deviceChannel.setParental(1); + deviceChannel.setCreateTime(DateUtil.getNow()); + deviceChannel.setUpdateTime(DateUtil.getNow()); + return deviceChannel; + } -// else { -// if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联 -// deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2)); -// }else if (deviceChannel.getChannelId().length() == 20) { -// if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织 -// deviceChannel.setBusinessGroupId(businessGroupID); -// }else if (Integer.parseInt(device.getDeviceId().substring(10, 13) )== 118) {//NVR 如果上级设备编号是NVR则直接将NVR的编号设置给通道的上级编号 -// deviceChannel.setParentId(device.getDeviceId()); -// }else if (deviceChannel.getCivilCode() != null) { -// // 设备, 无parentId的20位是使用CivilCode表示上级的设备, -// // 注:215 业务分组是需要有parentId的 -// deviceChannel.setParentId(deviceChannel.getCivilCode()); -// } -// }else { -// deviceChannel.setParentId(deviceChannel.getDeviceId()); -// } -// } + Element statusElement = itemDevice.element("Status"); - if (XmlUtil.getText(itemDevice, "SafetyWay") == null - || XmlUtil.getText(itemDevice, "SafetyWay") == "") { + if (statusElement != null) { + String status = statusElement.getTextTrim().trim(); + // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理 + if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) { + deviceChannel.setStatus(1); + } + if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) { + deviceChannel.setStatus(0); + } + }else { + deviceChannel.setStatus(1); + } + // 识别自带的目录标识 + String parental = XmlUtil.getText(itemDevice, "Parental"); + // 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1 + if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) { + deviceChannel.setParental(0); + }else { + deviceChannel.setParental(1); + } + + + deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); + deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); + deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); + deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); + deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); + deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); + deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); + + String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay"); + if (StringUtils.isEmpty(safetyWay)) { deviceChannel.setSafetyWay(0); } else { - deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); + deviceChannel.setSafetyWay(Integer.parseInt(safetyWay)); } - if (XmlUtil.getText(itemDevice, "RegisterWay") == null - || XmlUtil.getText(itemDevice, "RegisterWay") == "") { + + String registerWay = XmlUtil.getText(itemDevice, "RegisterWay"); + if (StringUtils.isEmpty(registerWay)) { deviceChannel.setRegisterWay(1); } else { - deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); + deviceChannel.setRegisterWay(Integer.parseInt(registerWay)); } - deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum")); + if (XmlUtil.getText(itemDevice, "Certifiable") == null || XmlUtil.getText(itemDevice, "Certifiable") == "") { deviceChannel.setCertifiable(0); } else { deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); } + if (XmlUtil.getText(itemDevice, "ErrCode") == null || XmlUtil.getText(itemDevice, "ErrCode") == "") { deviceChannel.setErrCode(0); } else { deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); } + deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); @@ -304,43 +367,23 @@ public class XmlUtil { } else { deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); } - deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password")); - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) { - deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); + + + String longitude = XmlUtil.getText(itemDevice, "Longitude"); + if (NumericUtil.isDouble(longitude)) { + deviceChannel.setLongitude(Double.parseDouble(longitude)); } else { deviceChannel.setLongitude(0.00); } - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) { - deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); + String latitude = XmlUtil.getText(itemDevice, "Latitude"); + if (NumericUtil.isDouble(latitude)) { + deviceChannel.setLatitude(Double.parseDouble(latitude)); } else { deviceChannel.setLatitude(0.00); } deviceChannel.setGpsTime(DateUtil.getNow()); - if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) { - if ("WGS84".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeGcj02(position[0]); - deviceChannel.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(position[0]); - deviceChannel.setLatitudeWgs84(position[1]); - }else { - deviceChannel.setLongitudeGcj02(0.00); - deviceChannel.setLatitudeGcj02(0.00); - deviceChannel.setLongitudeWgs84(0.00); - deviceChannel.setLatitudeWgs84(0.00); - } - }else { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - } + + if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) { //兼容INFO中的信息 Element info = itemDevice.element("Info"); diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java index 249ec03c..c8f90402 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java @@ -136,4 +136,12 @@ public class AssistRESTfulUtils { return sendGet(mediaServerItem, "api/record/file/duration",param, callback); } + public JSONObject addStreamCallInfo(MediaServerItem mediaServerItem, String app, String stream, String callId, RequestCallback callback){ + Map param = new HashMap<>(); + param.put("app",app); + param.put("stream",stream); + param.put("callId",callId); + return sendGet(mediaServerItem, "api/record/addStreamCallInfo",param, callback); + } + } 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 f4a27443..4b51d7ce 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 @@ -87,6 +87,9 @@ public class ZLMHttpHookListener { @Autowired private VideoStreamSessionManager sessionManager; + @Autowired + private AssistRESTfulUtils assistRESTfulUtils; + /** * 服务器定时上报时间,上报间隔可配置,默认10s上报一次 * @@ -200,6 +203,8 @@ public class ZLMHttpHookListener { logger.info("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString()); JSONObject ret = new JSONObject(); + String mediaServerId = json.getString("mediaServerId"); + MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); if (!"rtp".equals(param.getApp())) { // 推流鉴权 if (param.getParams() == null) { @@ -231,6 +236,10 @@ public class ZLMHttpHookListener { streamAuthorityInfo.setSign(sign); // 鉴权通过 redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); + // 通知assist新的callId + if (mediaInfo != null) { + assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null); + } } ret.put("code", 0); @@ -240,10 +249,9 @@ public class ZLMHttpHookListener { ret.put("enable_audio", true); } - String mediaServerId = json.getString("mediaServerId"); + ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json); if (subscribe != null) { - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId); if (mediaInfo != null) { subscribe.response(mediaInfo, json); }else { @@ -270,10 +278,12 @@ public class ZLMHttpHookListener { ret.put("mp4_max_second", 10); ret.put("enable_mp4", true); ret.put("enable_audio", true); + } } + return new ResponseEntity(ret.toString(), HttpStatus.OK); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java new file mode 100644 index 00000000..9629e3a8 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java @@ -0,0 +1,35 @@ +package com.genersoft.iot.vmp.service; + +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; + +import java.util.List; + +/** + * 国标通道业务类 + * @author lin + */ +public interface IDeviceChannelService { + + /** + * 更新gps信息 + */ + DeviceChannel updateGps(DeviceChannel deviceChannel, Device device); + + /** + * 添加设备通道 + * + * @param deviceId 设备id + * @param channel 通道 + */ + void updateChannel(String deviceId, DeviceChannel channel); + + /** + * 批量添加设备通道 + * + * @param deviceId 设备id + * @param channels 多个通道 + */ + int updateChannels(String deviceId, List channels); + +} 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 abdde6de..0a392060 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java @@ -18,7 +18,7 @@ public interface IGbStreamService { * @param count * @return */ - PageInfo getAll(Integer page, Integer count, String platFormId, String catalogId,String query,Boolean pushing,String mediaServerId); + PageInfo getAll(Integer page, Integer count, String platFormId, String catalogId,String query,String mediaServerId); /** diff --git a/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java b/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java new file mode 100644 index 00000000..739e6b86 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java @@ -0,0 +1,22 @@ +package com.genersoft.iot.vmp.service; + +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; + +import java.util.List; + +/** + * 平台关联通道管理 + * @author lin + */ +public interface IPlatformChannelService { + + /** + * 更新目录下的通道 + * @param platformId 平台编号 + * @param channelReduces 通道信息 + * @param catalogId 目录编号 + * @return + */ + int updateChannelForGB(String platformId, List channelReduces, String catalogId); + +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java index ac100006..1dd74ee2 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java @@ -101,4 +101,9 @@ public interface IStreamProxyService { void zlmServerOffline(String mediaServerId); void clean(); + + /** + * 更新代理流 + */ + boolean updateStreamProxy(StreamProxyItem streamProxyItem); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java index ead291c0..8c55986e 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java @@ -17,7 +17,6 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService { @Autowired private DeviceAlarmMapper deviceAlarmMapper; - @Override public PageInfo getAllAlarm(int page, int count, String deviceId, String alarmPriority, String alarmMethod, String alarmType, String startTime, String endTime) { PageHelper.startPage(page, count); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java new file mode 100644 index 00000000..99ad3dee --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java @@ -0,0 +1,165 @@ +package com.genersoft.iot.vmp.service.impl; + +import com.genersoft.iot.vmp.common.StreamInfo; +import com.genersoft.iot.vmp.gb28181.bean.Device; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; +import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; +import com.genersoft.iot.vmp.service.IDeviceChannelService; +import com.genersoft.iot.vmp.storager.IRedisCatchStorage; +import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; +import com.genersoft.iot.vmp.storager.dao.DeviceMapper; +import com.genersoft.iot.vmp.utils.DateUtil; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; + +/** + * @author lin + */ +@Service +public class DeviceChannelServiceImpl implements IDeviceChannelService { + + private final static Logger logger = LoggerFactory.getLogger(DeviceChannelServiceImpl.class); + + @Autowired + private IRedisCatchStorage redisCatchStorage; + + @Autowired + private DeviceChannelMapper channelMapper; + + @Autowired + private DeviceMapper deviceMapper; + + @Override + public DeviceChannel updateGps(DeviceChannel deviceChannel, Device device) { + if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) { + if (device == null) { + device = deviceMapper.getDeviceByDeviceId(deviceChannel.getDeviceId()); + } + + if ("WGS84".equals(device.getGeoCoordSys())) { + deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); + deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); + Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude()); + deviceChannel.setLongitudeGcj02(position[0]); + deviceChannel.setLatitudeGcj02(position[1]); + }else if ("GCJ02".equals(device.getGeoCoordSys())) { + deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); + deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); + Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); + deviceChannel.setLongitudeWgs84(position[0]); + deviceChannel.setLatitudeWgs84(position[1]); + }else { + deviceChannel.setLongitudeGcj02(0.00); + deviceChannel.setLatitudeGcj02(0.00); + deviceChannel.setLongitudeWgs84(0.00); + deviceChannel.setLatitudeWgs84(0.00); + } + }else { + deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); + deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); + deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); + deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); + } + return deviceChannel; + } + + @Override + public void updateChannel(String deviceId, DeviceChannel channel) { + String channelId = channel.getChannelId(); + channel.setDeviceId(deviceId); + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); + if (streamInfo != null) { + channel.setStreamId(streamInfo.getStream()); + } + String now = DateUtil.getNow(); + channel.setUpdateTime(now); + DeviceChannel deviceChannel = channelMapper.queryChannel(deviceId, channelId); + channel = updateGps(channel, null); + if (deviceChannel == null) { + channel.setCreateTime(now); + channelMapper.add(channel); + }else { + channelMapper.update(channel); + } + channelMapper.updateChannelSubCount(deviceId,channel.getParentId()); + } + + @Override + public int updateChannels(String deviceId, List channels) { + List addChannels = new ArrayList<>(); + List updateChannels = new ArrayList<>(); + HashMap channelsInStore = new HashMap<>(); + Device device = deviceMapper.getDeviceByDeviceId(deviceId); + if (channels != null && channels.size() > 0) { + List channelList = channelMapper.queryChannels(deviceId, null, null, null, null); + if (channelList.size() == 0) { + for (DeviceChannel channel : channels) { + channel.setDeviceId(deviceId); + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId()); + if (streamInfo != null) { + channel.setStreamId(streamInfo.getStream()); + } + String now = DateUtil.getNow(); + channel.setUpdateTime(now); + channel.setCreateTime(now); + channel = updateGps(channel, device); + addChannels.add(channel); + } + }else { + for (DeviceChannel deviceChannel : channelList) { + channelsInStore.put(deviceChannel.getChannelId(), deviceChannel); + } + for (DeviceChannel channel : channels) { + channel.setDeviceId(deviceId); + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId()); + if (streamInfo != null) { + channel.setStreamId(streamInfo.getStream()); + } + String now = DateUtil.getNow(); + channel.setUpdateTime(now); + channel = updateGps(channel, device); + if (channelsInStore.get(channel.getChannelId()) != null) { + updateChannels.add(channel); + }else { + addChannels.add(channel); + channel.setCreateTime(now); + } + } + } + int limitCount = 300; + if (addChannels.size() > 0) { + if (addChannels.size() > limitCount) { + for (int i = 0; i < addChannels.size(); i += limitCount) { + int toIndex = i + limitCount; + if (i + limitCount > addChannels.size()) { + toIndex = addChannels.size(); + } + channelMapper.batchAdd(addChannels.subList(i, toIndex)); + } + }else { + channelMapper.batchAdd(addChannels); + } + } + if (updateChannels.size() > 0) { + if (updateChannels.size() > limitCount) { + for (int i = 0; i < updateChannels.size(); i += limitCount) { + int toIndex = i + limitCount; + if (i + limitCount > updateChannels.size()) { + toIndex = updateChannels.size(); + } + channelMapper.batchUpdate(updateChannels.subList(i, toIndex)); + } + }else { + channelMapper.batchUpdate(updateChannels); + } + } + } + return addChannels.size() + updateChannels.size(); + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java index 9d376fb0..579184c9 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; @@ -55,6 +56,9 @@ public class DeviceServiceImpl implements IDeviceService { @Autowired private DeviceMapper deviceMapper; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private DeviceChannelMapper deviceChannelMapper; @@ -324,23 +328,12 @@ public class DeviceServiceImpl implements IDeviceService { private void updateDeviceChannelGeoCoordSys(Device device) { List deviceChannels = deviceChannelMapper.getAllChannelWithCoordinate(device.getDeviceId()); if (deviceChannels.size() > 0) { + List deviceChannelsForStore = new ArrayList<>(); for (DeviceChannel deviceChannel : deviceChannels) { - if ("WGS84".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude()); - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude()); - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeGcj02(position[0]); - deviceChannel.setLatitudeGcj02(position[1]); - }else if ("GCJ02".equals(device.getGeoCoordSys())) { - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude()); - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude()); - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude()); - deviceChannel.setLongitudeWgs84(position[0]); - deviceChannel.setLatitudeWgs84(position[1]); - } + deviceChannelsForStore.add(deviceChannelService.updateGps(deviceChannel, device)); } + deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore); } - storage.updateChannels(device.getDeviceId(), deviceChannels); } @@ -352,11 +345,11 @@ public class DeviceServiceImpl implements IDeviceService { } if (parentId == null || parentId.equals(deviceId)) { // 字根节点开始查询 - List rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), true, !onlyCatalog); + List rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), true, !onlyCatalog); return transportChannelsToTree(rootNodes, ""); } - if ("CivilCode".equals(device.getTreeType())) { + if (TreeType.CIVIL_CODE.equals(device.getTreeType())) { if (parentId.length()%2 != 0) { return null; } @@ -386,7 +379,7 @@ public class DeviceServiceImpl implements IDeviceService { } // 使用业务分组展示树 - if ("BusinessGroup".equals(device.getTreeType())) { + if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) { if (parentId.length() < 14 ) { return null; } @@ -406,11 +399,11 @@ public class DeviceServiceImpl implements IDeviceService { } if (parentId == null || parentId.equals(deviceId)) { // 字根节点开始查询 - List rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), false, true); + List rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), false, true); return rootNodes; } - if ("CivilCode".equals(device.getTreeType())) { + if (TreeType.CIVIL_CODE.equals(device.getTreeType())) { if (parentId.length()%2 != 0) { return null; } @@ -431,7 +424,7 @@ public class DeviceServiceImpl implements IDeviceService { } // 使用业务分组展示树 - if ("BusinessGroup".equals(device.getTreeType())) { + if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) { if (parentId.length() < 14 ) { return null; } 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 4a965a0b..8734882f 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 @@ -1,14 +1,13 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.conf.SipConfig; -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.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; +import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.service.IGbStreamService; import com.github.pagehelper.PageHelper; @@ -46,15 +45,15 @@ public class GbStreamServiceImpl implements IGbStreamService { private ParentPlatformMapper platformMapper; @Autowired - private SipConfig sipConfig; + private PlatformCatalogMapper catalogMapper; @Autowired private EventPublisher eventPublisher; @Override - public PageInfo getAll(Integer page, Integer count, String platFormId, String catalogId, String query, Boolean pushing, String mediaServerId) { + public PageInfo getAll(Integer page, Integer count, String platFormId, String catalogId, String query, String mediaServerId) { PageHelper.startPage(page, count); - List all = gbStreamMapper.selectAll(platFormId, catalogId, query, pushing, mediaServerId); + List all = gbStreamMapper.selectAll(platFormId, catalogId, query, mediaServerId); return new PageInfo<>(all); } @@ -102,16 +101,25 @@ public class GbStreamServiceImpl implements IGbStreamService { deviceChannel.setLatitude(gbStream.getLatitude()); deviceChannel.setDeviceId(platform.getDeviceGBId()); deviceChannel.setManufacture("wvp-pro"); -// deviceChannel.setStatus(gbStream.isStatus()?1:0); - deviceChannel.setStatus(1); - deviceChannel.setParentId(catalogId ==null?gbStream.getCatalogId():catalogId); + deviceChannel.setStatus(gbStream.isStatus()?1:0); + deviceChannel.setRegisterWay(1); - if (catalogId.length() > 0 && catalogId.length() <= 10) { - // 父节点是行政区划,则设置CivilCode使用此行政区划 + deviceChannel.setCivilCode(platform.getAdministrativeDivision()); + + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){ deviceChannel.setCivilCode(catalogId); - }else { - deviceChannel.setCivilCode(platform.getAdministrativeDivision()); + }else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){ + PlatformCatalog catalog = catalogMapper.select(catalogId); + if (catalog == null) { + deviceChannel.setParentId(platform.getDeviceGBId()); + deviceChannel.setBusinessGroupId(null); + }else { + deviceChannel.setParentId(catalog.getId()); + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); + } + } + deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setParental(0); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java new file mode 100644 index 00000000..dda87b56 --- /dev/null +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -0,0 +1,110 @@ +package com.genersoft.iot.vmp.service.impl; + +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.bean.TreeType; +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; +import com.genersoft.iot.vmp.service.IPlatformChannelService; +import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; +import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; +import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; +import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; +import com.genersoft.iot.vmp.vmanager.gb28181.platform.PlatformController; +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; +import com.sun.org.apache.xml.internal.resolver.CatalogManager; +import javafx.application.Platform; +import org.apache.ibatis.annotations.Mapper; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; +import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.stereotype.Service; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +/** + * @author lin + */ +@Service +public class PlatformChannelServiceImpl implements IPlatformChannelService { + + private final static Logger logger = LoggerFactory.getLogger(PlatformChannelServiceImpl.class); + + @Autowired + private PlatformChannelMapper platformChannelMapper; + + @Autowired + private DeviceChannelMapper deviceChannelMapper; + + @Autowired + private PlatformCatalogMapper catalogManager; + + @Autowired + private ParentPlatformMapper platformMapper; + + @Autowired + EventPublisher eventPublisher; + + @Override + public int updateChannelForGB(String platformId, List channelReduces, String catalogId) { + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId); + if (platform == null) { + logger.warn("更新级联通道信息时未找到平台{}的信息", platformId); + return 0; + } + Map deviceAndChannels = new HashMap<>(); + for (ChannelReduce channelReduce : channelReduces) { + channelReduce.setCatalogId(catalogId); + deviceAndChannels.put(channelReduce.getId(), channelReduce); + } + List deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); + // 查询当前已经存在的 + List channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces); + if (deviceAndChannelList != null) { + deviceAndChannelList.removeAll(channelIds); + } + for (Integer channelId : channelIds) { + deviceAndChannels.remove(channelId); + } + List channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); + // 对剩下的数据进行存储 + int result = 0; + if (channelReducesToAdd.size() > 0) { + result = platformChannelMapper.addChannels(platformId, channelReducesToAdd); + // TODO 后续给平台增加控制开关以控制是否响应目录订阅 + List deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform); + eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD); + } + + return result; + } + + private List getDeviceChannelListByChannelReduceList(List channelReduces, String catalogId, ParentPlatform platform) { + List deviceChannelList = new ArrayList<>(); + if (channelReduces.size() > 0){ + PlatformCatalog catalog = catalogManager.select(catalogId); + if (catalog == null && !catalogId.equals(platform.getServerGBId())) { + logger.warn("未查询到目录{}的信息", catalogId); + return null; + } + for (ChannelReduce channelReduce : channelReduces) { + DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId()); + deviceChannel.setParental(0); + deviceChannelList.add(deviceChannel); + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){ + deviceChannel.setCivilCode(catalogId); + }else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){ + deviceChannel.setParentId(catalogId); + if (catalog != null) { + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); + } + } + } + } + return deviceChannelList; + } +} diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java index a34315bc..27e4a7d1 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto; +import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import org.slf4j.Logger; @@ -26,6 +27,7 @@ import org.springframework.data.redis.connection.Message; import org.springframework.data.redis.connection.MessageListener; import org.springframework.stereotype.Component; +import java.util.ArrayList; import java.util.List; @@ -55,7 +57,6 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic @Override public void onMessage(Message message, byte[] bytes) { - PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(message.getBody(), PushStreamStatusChangeFromRedisDto.class); if (statusChangeFromPushStream == null) { logger.warn("[REDIS 消息]推流设备状态变化消息解析失败"); @@ -65,11 +66,13 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic // 所有设备离线 streamPushService.allStreamOffline(); } - if (statusChangeFromPushStream.getOfflineStreams().size() > 0) { + if (statusChangeFromPushStream.getOfflineStreams() != null + && statusChangeFromPushStream.getOfflineStreams().size() > 0) { // 更新部分设备离线 streamPushService.offline(statusChangeFromPushStream.getOfflineStreams()); } - if (statusChangeFromPushStream.getOnlineStreams().size() > 0) { + if (statusChangeFromPushStream.getOnlineStreams() != null && + statusChangeFromPushStream.getOnlineStreams().size() > 0) { // 更新部分设备上线 streamPushService.online(statusChangeFromPushStream.getOnlineStreams()); } 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 b9bb96b1..6d699cfa 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 @@ -3,10 +3,10 @@ package com.genersoft.iot.vmp.service.impl; import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONObject; import com.genersoft.iot.vmp.common.StreamInfo; -import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; +import com.genersoft.iot.vmp.gb28181.bean.TreeType; import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; @@ -23,14 +23,19 @@ import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; import com.genersoft.iot.vmp.service.IStreamProxyService; +import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.github.pagehelper.PageInfo; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; +import org.springframework.jdbc.datasource.DataSourceTransactionManager; import org.springframework.stereotype.Service; +import org.springframework.transaction.TransactionDefinition; +import org.springframework.transaction.TransactionStatus; import org.springframework.util.StringUtils; +import java.net.InetAddress; import java.util.*; /** @@ -48,7 +53,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { private IMediaService mediaService; @Autowired - private ZLMRESTfulUtils zlmresTfulUtils;; + private ZLMRESTfulUtils zlmresTfulUtils; @Autowired private StreamProxyMapper streamProxyMapper; @@ -62,9 +67,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @Autowired private UserSetting userSetting; - @Autowired - private SipConfig sipConfig; - @Autowired private GbStreamMapper gbStreamMapper; @@ -83,6 +85,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService { @Autowired private IMediaServerService mediaServerService; + @Autowired + DataSourceTransactionManager dataSourceTransactionManager; + + @Autowired + TransactionDefinition transactionDefinition; + @Override public WVPResult save(StreamProxyItem param) { @@ -99,6 +107,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { wvpResult.setMsg("保存失败"); return wvpResult; } + String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), param.getStream() ); param.setDst_url(dstUrl); @@ -108,9 +117,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService { boolean saveResult; // 更新 if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) { - saveResult = videoManagerStorager.updateStreamProxy(param); + saveResult = updateStreamProxy(param); }else { // 新增 - saveResult = videoManagerStorager.addStreamProxy(param); + saveResult = addStreamProxy(param); } if (saveResult) { result.append("保存成功"); @@ -124,7 +133,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { if (param.isEnable_remove_none_reader()) { del(param.getApp(), param.getStream()); }else { - videoManagerStorager.updateStreamProxy(param); + updateStreamProxy(param); } }else { @@ -154,6 +163,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { 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) { @@ -168,6 +178,77 @@ public class StreamProxyServiceImpl implements IStreamProxyService { return wvpResult; } + /** + * 新增代理流 + * @param streamProxyItem + * @return + */ + private boolean addStreamProxy(StreamProxyItem streamProxyItem) { + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); + boolean result = false; + streamProxyItem.setStreamType("proxy"); + streamProxyItem.setStatus(true); + String now = DateUtil.getNow(); + streamProxyItem.setCreateTime(now); + try { + if (streamProxyMapper.add(streamProxyItem) > 0) { + if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { + if (gbStreamMapper.add(streamProxyItem) < 0) { + //事务回滚 + dataSourceTransactionManager.rollback(transactionStatus); + return false; + } + } + }else { + //事务回滚 + dataSourceTransactionManager.rollback(transactionStatus); + return false; + } + result = true; + dataSourceTransactionManager.commit(transactionStatus); //手动提交 + }catch (Exception e) { + logger.error("向数据库添加流代理失败:", e); + dataSourceTransactionManager.rollback(transactionStatus); + } + + + return result; + } + + /** + * 更新代理流 + * @param streamProxyItem + * @return + */ + @Override + public boolean updateStreamProxy(StreamProxyItem streamProxyItem) { + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); + boolean result = false; + streamProxyItem.setStreamType("proxy"); + try { + if (streamProxyMapper.update(streamProxyItem) > 0) { + if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { + if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) { + //事务回滚 + dataSourceTransactionManager.rollback(transactionStatus); + return false; + } + } + } else { + //事务回滚 + dataSourceTransactionManager.rollback(transactionStatus); + return false; + } + + dataSourceTransactionManager.commit(transactionStatus); //手动提交 + result = true; + }catch (Exception e) { + e.printStackTrace(); + dataSourceTransactionManager.rollback(transactionStatus); + } + return result; + } + @Override public JSONObject addStreamProxyToZlm(StreamProxyItem param) { JSONObject result = null; @@ -239,7 +320,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { if (jsonObject.getInteger("code") == 0) { result = true; streamProxy.setEnable(true); - videoManagerStorager.updateStreamProxy(streamProxy); + updateStreamProxy(streamProxy); } } return result; @@ -253,7 +334,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService { JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto); if (jsonObject != null && jsonObject.getInteger("code") == 0) { streamProxyDto.setEnable(false); - result = videoManagerStorager.updateStreamProxy(streamProxyDto); + result = updateStreamProxy(streamProxyDto); } } return result; 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 646d287d..faac5c92 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 @@ -488,7 +488,7 @@ public class StreamPushServiceImpl implements IStreamPushService { if (onlinePushers.size() == 0) { return; } - streamPushMapper.allStreamOffline(); + streamPushMapper.setAllStreamOffline(); // 发送通知 eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF); diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java index 45cbcf6e..0baad966 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java @@ -14,38 +14,60 @@ import java.util.*; public class StreamPushUploadFileHandler extends AnalysisEventListener { - // 错误数据的回调,用于将错误数据发送给页面 + /** + * 错误数据的回调,用于将错误数据发送给页面 + */ private ErrorDataHandler errorDataHandler; - // 推流的业务类用于存储数据 + /** + * 推流的业务类用于存储数据 + */ private IStreamPushService pushService; - // 默认流媒体节点ID + /** + * 默认流媒体节点ID + */ private String defaultMediaServerId; - // 用于存储不加过滤的所有数据 + /** + * 用于存储不加过滤的所有数据 + */ private List streamPushItems = new ArrayList<>(); - // 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表 + /** + * 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表 + */ private Map streamPushItemForSave = new HashMap<>(); - // 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表 + /** + * 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表 + */ private Map> streamPushItemsForPlatform = new HashMap<>(); - // 用于判断文件是否存在重复的app+Stream+平台ID + /** + * 用于判断文件是否存在重复的app+Stream+平台ID + */ private Set streamPushStreamSet = new HashSet<>(); - // 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应,全局判断APP+Stream->国标ID是否存在不对应 + /** + * 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应,全局判断APP+Stream->国标ID是否存在不对应 + */ private BiMap gBMap = HashBiMap.create(); - // 记录错误的APP+Stream + /** + * 记录错误的APP+Stream + */ private List errorStreamList = new ArrayList<>(); - // 记录错误的国标ID + /** + * 记录错误的国标ID + */ private List errorGBList = new ArrayList<>(); - // 读取数量计数器 + /** + * 读取数量计数器 + */ private int loadedSize = 0; public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId, ErrorDataHandler errorDataHandler) { diff --git a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java index 96d4d958..543d8c16 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java @@ -26,22 +26,6 @@ public interface IVideoManagerStorage { */ public boolean exists(String deviceId); - /** - * 添加设备通道 - * - * @param deviceId 设备id - * @param channel 通道 - */ - public void updateChannel(String deviceId, DeviceChannel channel); - - /** - * 批量添加设备通道 - * - * @param deviceId 设备id - * @param channels 多个通道 - */ - public int updateChannels(String deviceId, List channels); - /** * 开始播放 * @param deviceId 设备id @@ -224,13 +208,6 @@ public interface IVideoManagerStorage { List queryChannelListInParentPlatform(String platformId); - /** - * 更新上级平台的通道信息 - * @param platformId - * @param channelReduces - * @return - */ - int updateChannelForGB(String platformId, List channelReduces, String catalogId); /** * 移除上级平台的通道信息 @@ -276,20 +253,6 @@ public interface IVideoManagerStorage { */ public int clearMobilePositionsByDeviceId(String deviceId); - /** - * 新增代理流 - * @param streamProxyDto - * @return - */ - public boolean addStreamProxy(StreamProxyItem streamProxyDto); - - /** - * 更新代理流 - * @param streamProxyDto - * @return - */ - public boolean updateStreamProxy(StreamProxyItem streamProxyDto); - /** * 移除代理流 * @param app @@ -334,7 +297,7 @@ public interface IVideoManagerStorage { * @param platformId * @return */ - List queryGbStreamListInPlatform(String platformId); + List queryGbStreamListInPlatform(String platformId); /** * 批量更新推流列表 @@ -445,7 +408,7 @@ public interface IVideoManagerStorage { int setDefaultCatalog(String platformId, String catalogId); - List queryCatalogInPlatform(String serverGBId); + List queryCatalogInPlatform(String serverGBId); int delRelation(PlatformCatalog platformCatalog); @@ -466,4 +429,8 @@ public interface IVideoManagerStorage { List getChannelSource(String platformId, String gbId); void updateChannelPosition(DeviceChannel deviceChannel); + + void cleanContentForPlatform(String serverGBId); + + List queryChannelWithCatalog(String serverGBId); } 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 ffa5cf15..653e39da 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 @@ -329,5 +329,13 @@ public interface DeviceChannelMapper { @Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}") List getBusinessGroups(String deviceId, String typeCode); - + @Select("select dc.id, dc.channelId, dc.deviceId, dc.name, dc.manufacture,dc.model,dc.owner, pc.civilCode,dc.block, " + + " dc.address, '0' as parental,'0' as channelType, pc.id as parentId, dc.safetyWay, dc.registerWay,dc.certNum, dc.certifiable, " + + " dc.errCode,dc.endTime, dc.secrecy, dc.ipAddress, dc.port, dc.PTZType, dc.password, dc.status, " + + " dc.longitudeWgs84 as longitude, dc.latitudeWgs84 as latitude, pc.businessGroupId " + + " from device_channel dc" + + " left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId" + + " left join platform_catalog pc on pgc.catalogId = pc.id and pgc.platformId = pc.platformId" + + " where pgc.platformId=#{serverGBId}") + List queryChannelWithCatalog(String serverGBId); } 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 e8d23a8b..73fff576 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 @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.storager.dao; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; @@ -15,10 +16,10 @@ import java.util.List; public interface GbStreamMapper { @Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " + - "longitude, latitude, streamType, mediaServerId, status, createTime) VALUES" + + "longitude, latitude, streamType, mediaServerId, createTime) VALUES" + "('${app}', '${stream}', '${gbId}', '${name}', " + "'${longitude}', '${latitude}', '${streamType}', " + - "'${mediaServerId}', ${status}, '${createTime}')") + "'${mediaServerId}', '${createTime}')") @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") int add(GbStream gbStream); @@ -30,8 +31,7 @@ public interface GbStreamMapper { "streamType=#{streamType}," + "longitude=#{longitude}, " + "latitude=#{latitude}," + - "mediaServerId=#{mediaServerId}," + - "status=${status} " + + "mediaServerId=#{mediaServerId}" + "WHERE app=#{app} AND stream=#{stream}") int updateByAppAndStream(GbStream gbStream); @@ -43,8 +43,7 @@ public interface GbStreamMapper { "streamType=#{streamType}," + "longitude=#{longitude}, " + "latitude=#{latitude}," + - "mediaServerId=#{mediaServerId}," + - "status=${status} " + + "mediaServerId=#{mediaServerId}" + "WHERE gbStreamId=#{gbStreamId}") int update(GbStream gbStream); @@ -60,12 +59,10 @@ public interface GbStreamMapper { " AND gs.gbStreamId not in" + "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) " + " AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%') " + - " AND gs.status=1" + - " AND gs.status=0" + " AND gs.mediaServerId=#{mediaServerId} " + " order by gs.gbStreamId asc " + "") - List selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId); + List selectAll(String platformId, String catalogId, String query, String mediaServerId); @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}") GbStream selectOne(String app, String stream); @@ -78,10 +75,18 @@ public interface GbStreamMapper { "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") GbStream queryStreamInPlatform(String platformId, String gbId); - @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + - "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " + - "WHERE pgs.platformId = #{platformId}") - List queryGbStreamListInPlatform(String platformId); + @Select("select gt.gbId as channelId, gt.name, 'wvp-pro' as manufacture, st.status, gt.longitude, gt.latitude, pc.id as parentId," + + " '1' as registerWay, pc.civilCode, 'live' as model, 'wvp-pro' as owner, '0' as parental,'0' as secrecy" + + " from gb_stream gt " + + " left join (" + + " select sp.status, sp.app, sp.stream from stream_push sp" + + " union all" + + " select spxy.status, spxy.app, spxy.stream from stream_proxy spxy" + + " ) st on st.app = gt.app and st.stream = gt.stream" + + " left join platform_gb_stream pgs on gt.gbStreamId = pgs.gbStreamId" + + " left join platform_catalog pc on pgs.catalogId = pc.id and pgs.platformId = pc.platformId" + + " where pgs.platformId=#{platformId}") + List queryGbStreamListInPlatform(String platformId); @Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " + @@ -110,12 +115,12 @@ public interface GbStreamMapper { @Insert("") @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") 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 b57e103c..0db6498a 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 @@ -16,10 +16,10 @@ public interface ParentPlatformMapper { @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + - " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime) " + + " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + - " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})") + " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})") int addParentPlatform(ParentPlatform parentPlatform); @Update("UPDATE parent_platform " + @@ -47,6 +47,7 @@ public interface ParentPlatformMapper { "administrativeDivision=#{administrativeDivision}, " + "createTime=#{createTime}, " + "updateTime=#{updateTime}, " + + "treeType=#{treeType}, " + "catalogId=#{catalogId} " + "WHERE id=#{id}") int updateParentPlatform(ParentPlatform parentPlatform); 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 index 95015bda..4ed0f32f 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java @@ -1,5 +1,6 @@ package com.genersoft.iot.vmp.storager.dao; +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; @@ -14,8 +15,8 @@ import java.util.List; @Repository public interface PlatformCatalogMapper { - @Insert("INSERT INTO platform_catalog (id, name, platformId, parentId) VALUES" + - "(#{id}, #{name}, #{platformId}, #{parentId})") + @Insert("INSERT INTO platform_catalog (id, name, platformId, parentId, civilCode, businessGroupId) VALUES" + + "(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})") int add(PlatformCatalog platformCatalog); @Delete("DELETE FROM platform_catalog WHERE id=#{id}") @@ -44,4 +45,12 @@ public interface PlatformCatalogMapper { @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})") PlatformCatalog selectDefaultByPlatFormId(String platformId); + + + @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = #{id}") + PlatformCatalog selectParentCatalog(String id); + + @Select("SELECT pc.id as channelId, pc.name, pc.civilCode, pc.businessGroupId,'0' as parental, pc.parentId " + + " FROM platform_catalog pc WHERE pc.platformId=#{platformId}") + List queryCatalogInPlatform(String platformId); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index bcf57a6f..895316d1 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -88,10 +88,10 @@ public interface StreamPushMapper { @Insert("") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -122,41 +122,41 @@ public interface StreamPushMapper { @Select("") List getOnlinePusherForGbInList(List offlineStreams); @Update("") void offline(List offlineStreams); @Select("") + ") ") List getOfflinePusherForGbInList(List onlineStreams); @Update("") void online(List onlineStreams); - @Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream") + @Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where sp.status = 1") List getOnlinePusherForGb(); @Update("UPDATE stream_push SET status=0") - void allStreamOffline(); + void setAllStreamOffline(); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index c4d1c9e6..a839f729 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -48,12 +48,13 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @Autowired SipConfig sipConfig; - @Autowired - DataSourceTransactionManager dataSourceTransactionManager; @Autowired TransactionDefinition transactionDefinition; + @Autowired + DataSourceTransactionManager dataSourceTransactionManager; + @Autowired private DeviceMapper deviceMapper; @@ -104,96 +105,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceMapper.getDeviceByDeviceId(deviceId) != null; } - @Override - public synchronized void updateChannel(String deviceId, DeviceChannel channel) { - String channelId = channel.getChannelId(); - channel.setDeviceId(deviceId); - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId); - if (streamInfo != null) { - channel.setStreamId(streamInfo.getStream()); - } - String now = DateUtil.getNow(); - channel.setUpdateTime(now); - DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId); - if (deviceChannel == null) { - channel.setCreateTime(now); - deviceChannelMapper.add(channel); - }else { - deviceChannelMapper.update(channel); - } - deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId()); - } - - @Override - public int updateChannels(String deviceId, List channels) { - List addChannels = new ArrayList<>(); - List updateChannels = new ArrayList<>(); - HashMap channelsInStore = new HashMap<>(); - if (channels != null && channels.size() > 0) { - List channelList = deviceChannelMapper.queryChannels(deviceId, null, null, null, null); - if (channelList.size() == 0) { - for (DeviceChannel channel : channels) { - channel.setDeviceId(deviceId); - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId()); - if (streamInfo != null) { - channel.setStreamId(streamInfo.getStream()); - } - String now = DateUtil.getNow(); - channel.setUpdateTime(now); - channel.setCreateTime(now); - addChannels.add(channel); - } - }else { - for (DeviceChannel deviceChannel : channelList) { - channelsInStore.put(deviceChannel.getChannelId(), deviceChannel); - } - for (DeviceChannel channel : channels) { - channel.setDeviceId(deviceId); - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId()); - if (streamInfo != null) { - channel.setStreamId(streamInfo.getStream()); - } - String now = DateUtil.getNow(); - channel.setUpdateTime(now); - if (channelsInStore.get(channel.getChannelId()) != null) { - updateChannels.add(channel); - }else { - addChannels.add(channel); - channel.setCreateTime(now); - } - } - } - int limitCount = 300; - if (addChannels.size() > 0) { - if (addChannels.size() > limitCount) { - for (int i = 0; i < addChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > addChannels.size()) { - toIndex = addChannels.size(); - } - deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex)); - } - }else { - deviceChannelMapper.batchAdd(addChannels); - } - } - if (updateChannels.size() > 0) { - if (updateChannels.size() > limitCount) { - for (int i = 0; i < updateChannels.size(); i += limitCount) { - int toIndex = i + limitCount; - if (i + limitCount > updateChannels.size()) { - toIndex = updateChannels.size(); - } - deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex)); - } - }else { - deviceChannelMapper.batchUpdate(updateChannels); - } - } - } - return addChannels.size() + updateChannels.size(); - } - @Override public boolean resetChannels(String deviceId, List deviceChannelList) { if (CollectionUtils.isEmpty(deviceChannelList)) { @@ -596,36 +507,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceChannelMapper.queryChannelByPlatformId(platformId); } - @Override - public int updateChannelForGB(String platformId, List channelReduces, String catalogId) { - - Map deviceAndChannels = new HashMap<>(); - for (ChannelReduce channelReduce : channelReduces) { - channelReduce.setCatalogId(catalogId); - deviceAndChannels.put(channelReduce.getId(), channelReduce); - } - List deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet()); - // 查询当前已经存在的 - List channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces); - if (deviceAndChannelList != null) { - deviceAndChannelList.removeAll(channelIds); - } - for (Integer channelId : channelIds) { - deviceAndChannels.remove(channelId); - } - List channelReducesToAdd = new ArrayList<>(deviceAndChannels.values()); - // 对剩下的数据进行存储 - int result = 0; - if (channelReducesToAdd.size() > 0) { - result = platformChannelMapper.addChannels(platformId, channelReducesToAdd); - // TODO 后续给平台增加控制开关以控制是否响应目录订阅 - List deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId); - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD); - } - - return result; - } - @Override public int delChannelForGB(String platformId, List channelReduces) { @@ -701,77 +582,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId); } - /** - * 新增代理流 - * @param streamProxyItem - * @return - */ - @Override - public boolean addStreamProxy(StreamProxyItem streamProxyItem) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - boolean result = false; - streamProxyItem.setStreamType("proxy"); - streamProxyItem.setStatus(true); - String now = DateUtil.getNow(); - streamProxyItem.setCreateTime(now); - try { - if (streamProxyMapper.add(streamProxyItem) > 0) { - if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.add(streamProxyItem) < 0) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - } - }else { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - result = true; - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - }catch (Exception e) { - logger.error("向数据库添加流代理失败:", e); - dataSourceTransactionManager.rollback(transactionStatus); - } - - - return result; - } - - /** - * 更新代理流 - * @param streamProxyItem - * @return - */ - @Override - public boolean updateStreamProxy(StreamProxyItem streamProxyItem) { - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition); - boolean result = false; - streamProxyItem.setStreamType("proxy"); - try { - if (streamProxyMapper.update(streamProxyItem) > 0) { - if (!StringUtils.isEmpty(streamProxyItem.getGbId())) { - if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - } - } else { - //事务回滚 - dataSourceTransactionManager.rollback(transactionStatus); - return false; - } - - dataSourceTransactionManager.commit(transactionStatus); //手动提交 - result = true; - }catch (Exception e) { - e.printStackTrace(); - dataSourceTransactionManager.rollback(transactionStatus); - } - return result; - } /** * 移除代理流 @@ -824,7 +634,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { * @return */ @Override - public List queryGbStreamListInPlatform(String platformId) { + public List queryGbStreamListInPlatform(String platformId) { return gbStreamMapper.queryGbStreamListInPlatform(platformId); } @@ -910,6 +720,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return result; } + @Override public int mediaOnline(String app, String stream) { GbStream gbStream = gbStreamMapper.selectOne(app, stream); int result; @@ -954,6 +765,24 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @Override public int addCatalog(PlatformCatalog platformCatalog) { + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformCatalog.getPlatformId()); + if (platform == null) { + return 0; + } + if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) { + if (platformCatalog.getPlatformId().equals(platformCatalog.getParentId())) { + // 第一层节点 + platformCatalog.setBusinessGroupId(platformCatalog.getId()); + }else { + // 获取顶层的 + PlatformCatalog topCatalog = getTopCatalog(platformCatalog.getParentId(), platformCatalog.getPlatformId()); + platformCatalog.setBusinessGroupId(topCatalog.getId()); + } + } + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)) { + platformCatalog.setCivilCode(platformCatalog.getId()); + } + int result = catalogMapper.add(platformCatalog); if (result > 0) { DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog); @@ -962,6 +791,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { return result; } + private PlatformCatalog getTopCatalog(String id, String platformId) { + PlatformCatalog catalog = catalogMapper.selectParentCatalog(id); + if (catalog.getParentId().equals(platformId)) { + return catalog; + }else { + return getTopCatalog(catalog.getParentId(), platformId); + } + } + @Override public PlatformCatalog getCatalog(String id) { return catalogMapper.select(id); @@ -1032,8 +870,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } @Override - public List queryCatalogInPlatform(String platformId) { - return catalogMapper.selectByPlatForm(platformId); + public List queryCatalogInPlatform(String platformId) { + return catalogMapper.queryCatalogInPlatform(platformId); } @Override @@ -1076,20 +914,24 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { } private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) { - ParentPlatform parentPlatByServerGBId = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); DeviceChannel deviceChannel = new DeviceChannel(); deviceChannel.setChannelId(catalog.getId()); deviceChannel.setName(catalog.getName()); deviceChannel.setLongitude(0.0); deviceChannel.setLatitude(0.0); - deviceChannel.setDeviceId(parentPlatByServerGBId.getDeviceGBId()); + deviceChannel.setDeviceId(platform.getDeviceGBId()); deviceChannel.setManufacture("wvp-pro"); deviceChannel.setStatus(1); deviceChannel.setParental(1); - deviceChannel.setParentId(catalog.getParentId()); + deviceChannel.setRegisterWay(1); // 行政区划应该是Domain的前八位 - deviceChannel.setCivilCode(parentPlatByServerGBId.getAdministrativeDivision()); + if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) { + deviceChannel.setParentId(catalog.getParentId()); + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId()); + } + deviceChannel.setModel("live"); deviceChannel.setOwner("wvp-pro"); deviceChannel.setSecrecy("0"); @@ -1151,4 +993,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { deviceChannelMapper.updatePosition(deviceChannel); } + + @Override + public void cleanContentForPlatform(String serverGBId) { +// List catalogList = catalogMapper.selectByPlatForm(serverGBId); +// if (catalogList.size() > 0) { +// int result = catalogMapper.delByPlatformId(serverGBId); +// if (result > 0) { +// List deviceChannels = new ArrayList<>(); +// for (PlatformCatalog catalog : catalogList) { +// deviceChannels.add(getDeviceChannelByCatalog(catalog)); +// } +// eventPublisher.catalogEventPublish(serverGBId, deviceChannels, CatalogEvent.DEL); +// } +// } + catalogMapper.delByPlatformId(serverGBId); + platformChannelMapper.delByPlatformId(serverGBId); + platformGbStreamMapper.delByPlatformId(serverGBId); + } + + @Override + public List queryChannelWithCatalog(String serverGBId) { + return deviceChannelMapper.queryChannelWithCatalog(serverGBId); + } } 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 767e9c40..29f9d884 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 @@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; +import com.genersoft.iot.vmp.service.IDeviceChannelService; import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; @@ -52,6 +53,9 @@ public class DeviceQuery { @Autowired private IVideoManagerStorage storager; + @Autowired + private IDeviceChannelService deviceChannelService; + @Autowired private IRedisCatchStorage redisCatchStorage; @@ -280,7 +284,7 @@ public class DeviceQuery { }) @PostMapping("/channel/update/{deviceId}") public ResponseEntity updateChannel(@PathVariable String deviceId,DeviceChannel channel){ - storager.updateChannel(deviceId, channel); + deviceChannelService.updateChannel(deviceId, channel); return new ResponseEntity<>(null,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 300546f9..fba050b0 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 @@ -44,7 +44,6 @@ public class GbStreamController { @ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = String.class), @ApiImplicitParam(name = "catalogId", value = "目录ID", required = false , dataTypeClass = String.class), @ApiImplicitParam(name="query", value = "查询内容", required = false , dataTypeClass = String.class), - @ApiImplicitParam(name="pushing", value = "是否正在推流", required = false , dataTypeClass = Boolean.class), @ApiImplicitParam(name="mediaServerId", value = "流媒体ID", required = false , dataTypeClass = String.class), }) @@ -55,7 +54,6 @@ public class GbStreamController { @RequestParam(required = true)String platformId, @RequestParam(required = false)String catalogId, @RequestParam(required = false)String query, - @RequestParam(required = false)Boolean pushing, @RequestParam(required = false)String mediaServerId){ if (StringUtils.isEmpty(catalogId)) { catalogId = null; @@ -69,7 +67,7 @@ public class GbStreamController { // catalogId 为null 查询未在平台下分配的数据 // catalogId 不为null 查询平台下这个,目录下的通道 - return gbStreamService.getAll(page, count, platformId, catalogId, query, pushing, mediaServerId); + return gbStreamService.getAll(page, count, platformId, catalogId, query, mediaServerId); } 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 44de6c9e..8d2278e6 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 @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; +import com.genersoft.iot.vmp.service.IPlatformChannelService; import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.utils.DateUtil; @@ -48,6 +49,9 @@ public class PlatformController { @Autowired private IVideoManagerStorage storager; + @Autowired + private IPlatformChannelService platformChannelService; + @Autowired private IRedisCatchStorage redisCatchStorage; @@ -236,6 +240,12 @@ public class PlatformController { parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase()); ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); parentPlatform.setUpdateTime(DateUtil.getNow()); + if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) { + // 目录结构发生变化,清空之前的关联关系 + logger.info("保存平台{}时发现目录结构变化,清空关联关系", parentPlatform.getDeviceGBId()); + storager.cleanContentForPlatform(parentPlatform.getServerGBId()); + + } boolean updateResult = storager.updateParentPlatform(parentPlatform); if (updateResult) { @@ -256,6 +266,8 @@ public class PlatformController { } } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 关闭启用时注销 commanderForPlatform.unregister(parentPlatformOld, null, null); + // 停止订阅相关的定时任务 + subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId()); } wvpResult.setCode(0); wvpResult.setMsg("success"); @@ -405,7 +417,7 @@ public class PlatformController { if (logger.isDebugEnabled()) { logger.debug("给上级平台添加国标通道API调用"); } - int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); + int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); } @@ -485,7 +497,6 @@ public class PlatformController { PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); WVPResult> result = new WVPResult<>(); - if (platformCatalogInStore != null) { result.setCode(-1); result.setMsg(platformCatalog.getId() + " already exists"); diff --git a/web_src/src/components/ParentPlatformList.vue b/web_src/src/components/ParentPlatformList.vue index 3ae0b657..23bebdbd 100644 --- a/web_src/src/components/ParentPlatformList.vue +++ b/web_src/src/components/ParentPlatformList.vue @@ -143,7 +143,7 @@ export default { }); }, chooseChannel: function(platform) { - this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, this.initData) + this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, platform.treeType, this.initData) }, initData: function() { this.getPlatformList(); diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue index 0253c1e3..fc645cf6 100644 --- a/web_src/src/components/PushVideoList.vue +++ b/web_src/src/components/PushVideoList.vue @@ -56,7 +56,7 @@ @@ -242,19 +242,6 @@ export default { console.error(error); }); }, - dateFormat: function (/** timestamp=0 **/) { - let ts = arguments[0] || 0; - let t, y, m, d, h, i, s; - t = ts ? new Date(ts) : new Date(); - y = t.getFullYear(); - m = t.getMonth() + 1; - d = t.getDate(); - h = t.getHours(); - i = t.getMinutes(); - s = t.getSeconds(); - // 可根据需要在这里定义时间格式 - return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s); - }, importChannel: function () { this.$refs.importChannel.openDialog(() => { diff --git a/web_src/src/components/dialog/catalogEdit.vue b/web_src/src/components/dialog/catalogEdit.vue index 13cabfb5..22ff1816 100644 --- a/web_src/src/components/dialog/catalogEdit.vue +++ b/web_src/src/components/dialog/catalogEdit.vue @@ -49,11 +49,43 @@ export default { props: ['platformId'], created() {}, data() { + let checkId = (rule, value, callback) => { + console.log("checkId") + console.log(this.treeType) + console.log(rule) + console.log(value) + console.log(value.length) + console.log(this.level) + if (!value) { + return callback(new Error('编号不能为空')); + } + if (this.treeType === "BusinessGroup" && value.length !== 20) { + return callback(new Error('编号必须由20位数字组成')); + } + if (this.treeType === "CivilCode" && value.length <= 8 && value.length%2 !== 0) { + return callback(new Error('行政区划必须是八位以下的偶数个数字组成')); + } + if (this.treeType === "BusinessGroup") { + let catalogType = value.substring(10, 13); + console.log(catalogType) + // 216 为虚拟组织 215 为业务分组;目录第一级必须为业务分组, 业务分组下为虚拟组织,虚拟组织下可以有其他虚拟组织 + if (this.level === 1 && catalogType !== "215") { + return callback(new Error('业务分组模式下第一层目录的编号10到13位必须为215')); + } + if (this.level > 1 && catalogType !== "216") { + return callback(new Error('业务分组模式下第一层以下目录的编号10到13位必须为216')); + } + + } + callback(); + } return { submitCallback: null, showDialog: false, isLoging: false, isEdit: false, + treeType: null, + level: 0, form: { id: null, name: null, @@ -62,12 +94,12 @@ export default { }, rules: { name: [{ required: true, message: "请输入名称", trigger: "blur" }], - id: [{ required: true, message: "请输入ID", trigger: "blur" }] + id: [{ trigger: "blur",validator: checkId }] }, }; }, methods: { - openDialog: function (isEdit, id, name, parentId, callback) { + openDialog: function (isEdit, id, name, parentId, treeType, level, callback) { console.log("parentId: " + parentId) console.log(this.form) this.isEdit = isEdit; @@ -77,6 +109,8 @@ export default { this.form.parentId = parentId; this.showDialog = true; this.submitCallback = callback; + this.treeType = treeType; + this.level = level; }, onSubmit: function () { console.log("onSubmit"); diff --git a/web_src/src/components/dialog/chooseChannel.vue b/web_src/src/components/dialog/chooseChannel.vue index 599921ec..cd8132a4 100644 --- a/web_src/src/components/dialog/chooseChannel.vue +++ b/web_src/src/components/dialog/chooseChannel.vue @@ -8,7 +8,7 @@ - + @@ -66,18 +66,20 @@ export default { platformName: "", defaultCatalogId: "", showDialog: false, + treeType: null, chooseData: {}, winHeight: window.innerHeight - 250, }; }, methods: { - openDialog(platformId, platformName, defaultCatalogId, closeCallback) { + openDialog(platformId, platformName, defaultCatalogId, treeType, closeCallback) { this.platformId = platformId this.platformName = platformName this.defaultCatalogId = defaultCatalogId this.showDialog = true this.closeCallback = closeCallback + this.treeType = treeType }, tabClick (tab, event){ diff --git a/web_src/src/components/dialog/chooseChannelForCatalog.vue b/web_src/src/components/dialog/chooseChannelForCatalog.vue index a0cb98c8..86fb48d9 100644 --- a/web_src/src/components/dialog/chooseChannelForCatalog.vue +++ b/web_src/src/components/dialog/chooseChannelForCatalog.vue @@ -38,7 +38,7 @@ import catalogEdit from './catalogEdit.vue' export default { name: 'chooseChannelForCatalog', - props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'], + props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange', 'treeType'], created() { this.chooseId = this.defaultCatalogId; this.defaultCatalogIdSign = this.defaultCatalogId; @@ -102,8 +102,9 @@ export default { }, addCatalog: function (parentId, node){ let that = this; + console.log(this.treeType) // 打开添加弹窗 - that.$refs.catalogEdit.openDialog(false, null, null, parentId, ()=>{ + that.$refs.catalogEdit.openDialog(false, null, null, parentId, this.treeType, node.level, ()=>{ node.loaded = false node.expand(); }); diff --git a/web_src/src/components/dialog/chooseChannelForStream.vue b/web_src/src/components/dialog/chooseChannelForStream.vue index d5e5ac38..1eec0b25 100644 --- a/web_src/src/components/dialog/chooseChannelForStream.vue +++ b/web_src/src/components/dialog/chooseChannelForStream.vue @@ -174,7 +174,6 @@ export default { page: that.currentPage, count: that.count, query: that.searchSrt, - pushing: that.pushing, platformId: that.platformId, catalogId: that.catalogId, mediaServerId: that.mediaServerId diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index 0caec322..c1292813 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -78,6 +78,12 @@ + + + + + + { + this.saveForm() + }).catch(() => { + + }); + }else { + this.saveForm() + } + }, + saveForm: function (){ var that = this; that.$axios({ method: 'post', url: this.saveUrl, data: that.platform }).then(function (res) { - if (res.data.code === 0) { - that.$message({ - showClose: true, - message: "保存成功", - type: "success", - }); - that.showDialog = false; - if (that.listChangeCallback != null) { - that.listChangeCallback(); - } - }else { - that.$message({ - showClose: true, - message: res.data.msg, - type: "error", - }); + if (res.data.code === 0) { + that.$message({ + showClose: true, + message: "保存成功", + type: "success", + }); + that.showDialog = false; + if (that.listChangeCallback != null) { + that.listChangeCallback(); } - }).catch(function (error) { - console.log(error); - }); + }else { + that.$message({ + showClose: true, + message: res.data.msg, + type: "error", + }); + } + }).catch(function (error) { + console.log(error); + }); }, close: function () { this.showDialog = false; @@ -293,6 +319,7 @@ export default { keepTimeout: 60, transport: "UDP", characterSet: "GB2312", + treeType: "BusinessGroup", shareAllLiveStream: false, startOfflinePush: false, catalogGroup: 1, From 11c47b139fb0d98c9db3bb8cbb20d0c09955ffe6 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Sun, 17 Jul 2022 23:19:59 +0800 Subject: [PATCH 11/20] =?UTF-8?q?=E5=8E=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E5=BC=95=E7=94=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/impl/PlatformChannelServiceImpl.java | 4 ---- 1 file changed, 4 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java index dda87b56..d0245502 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java @@ -11,11 +11,7 @@ import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper; import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper; -import com.genersoft.iot.vmp.vmanager.gb28181.platform.PlatformController; import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce; -import com.sun.org.apache.xml.internal.resolver.CatalogManager; -import javafx.application.Platform; -import org.apache.ibatis.annotations.Mapper; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Autowired; From 9dcc315dbdc53378229869252001c71823a44d7c Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: Mon, 18 Jul 2022 17:09:35 +0800 Subject: [PATCH 12/20] =?UTF-8?q?=E5=A2=9E=E5=8A=A0=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E7=AE=A1=E7=90=86=E5=8A=9F=E8=83=BD=E3=80=82=E7=AE=A1=E7=90=86?= =?UTF-8?q?=E5=91=98=E5=8F=AF=E4=BB=A5=E6=B7=BB=E5=8A=A0=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E3=80=81=E4=BF=AE=E6=94=B9=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E5=AF=86=E7=A0=81=E3=80=81=E9=87=8D=E7=BD=AEpushkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/IUserService.java | 5 + .../iot/vmp/service/impl/UserServiceImpl.java | 16 +- .../iot/vmp/storager/dao/UserMapper.java | 7 + .../iot/vmp/vmanager/user/UserController.java | 64 +++++ web_src/src/components/Login.vue | 2 +- web_src/src/components/UserManager.vue | 236 ++++++++++++++++++ web_src/src/components/dialog/addUser.vue | 159 ++++++++++++ .../dialog/changePasswordForAdmin.vue | 121 +++++++++ web_src/src/layout/UiHeader.vue | 3 + web_src/src/router/index.js | 6 + 10 files changed, 617 insertions(+), 2 deletions(-) create mode 100644 web_src/src/components/UserManager.vue create mode 100644 web_src/src/components/dialog/addUser.vue create mode 100644 web_src/src/components/dialog/changePasswordForAdmin.vue diff --git a/src/main/java/com/genersoft/iot/vmp/service/IUserService.java b/src/main/java/com/genersoft/iot/vmp/service/IUserService.java index e362605b..616fd1a3 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IUserService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IUserService.java @@ -1,6 +1,7 @@ package com.genersoft.iot.vmp.service; import com.genersoft.iot.vmp.storager.dao.dto.User; +import com.github.pagehelper.PageInfo; import java.util.List; @@ -21,4 +22,8 @@ public interface IUserService { int updateUsers(User user); boolean checkPushAuthority(String callId, String sign); + + PageInfo getUsers(int page, int count); + + int resetPushKey(int id); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java index 01d91a55..46d9ad5d 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java @@ -3,6 +3,8 @@ package com.genersoft.iot.vmp.service.impl; import com.genersoft.iot.vmp.service.IUserService; import com.genersoft.iot.vmp.storager.dao.UserMapper; import com.genersoft.iot.vmp.storager.dao.dto.User; +import com.github.pagehelper.PageHelper; +import com.github.pagehelper.PageInfo; import org.springframework.beans.factory.annotation.Autowired; import org.springframework.stereotype.Service; import org.springframework.util.StringUtils; @@ -11,7 +13,7 @@ import java.util.List; @Service public class UserServiceImpl implements IUserService { - + @Autowired private UserMapper userMapper; @@ -64,4 +66,16 @@ public class UserServiceImpl implements IUserService { return userMapper.checkPushAuthorityByCallIdAndSign(callId, sign).size() > 0; } } + + @Override + public PageInfo getUsers(int page, int count) { + PageHelper.startPage(page, count); + List users = userMapper.getUsers(); + return new PageInfo<>(users); + } + + @Override + public int resetPushKey(int id) { + return userMapper.resetPushKey(id); + } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index 5ed0a57d..850e4d44 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -55,4 +55,11 @@ public interface UserMapper { @Select("select * from user where md5(pushKey) = '${sign}'") List checkPushAuthorityByCallId(String sign); + + @Select("select u.idu.username,u.pushKey,u.roleId, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u join user_role r on u.roleId=r.id") + @ResultMap(value="roleMap") + List getUsers(); + + @Delete("update user set pushKey=MD5(NOW()+#{id}) where id=#{id}") + int resetPushKey(int id); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index 152122d2..ca6fc84e 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -8,6 +8,7 @@ import com.genersoft.iot.vmp.storager.dao.dto.Role; import com.genersoft.iot.vmp.storager.dao.dto.User; import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.vmanager.bean.WVPResult; +import com.github.pagehelper.PageInfo; import io.swagger.annotations.Api; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; @@ -177,4 +178,67 @@ public class UserController { result.setData(allUsers); return new ResponseEntity<>(result, HttpStatus.OK); } + + /** + * 分页查询用户 + * + * @param page 当前页 + * @param count 每页查询数量 + * @return 分页用户列表 + */ + @ApiOperation("分页查询用户") + @ApiImplicitParams({ + @ApiImplicitParam(name = "page", value = "当前页", required = true, dataTypeClass = Integer.class), + @ApiImplicitParam(name = "count", value = "每页查询数量", required = true, dataTypeClass = Integer.class), + }) + @GetMapping("/users") + public PageInfo users(int page, int count) { + return userService.getUsers(page, count); + } + + @ApiOperation("重置pushkey") + @ApiImplicitParams({ + @ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class), + }) + @RequestMapping("/resetPushKey") + public ResponseEntity> resetPushKey(@RequestParam Integer id) { + // 获取当前登录用户id + int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); + WVPResult result = new WVPResult<>(); + if (currenRoleId != 1) { + // 只用角色id为0才可以删除和添加用户 + result.setCode(-1); + result.setMsg("用户无权限"); + return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); + } + int resetPushKeyResult = userService.resetPushKey(id); + + result.setCode(resetPushKeyResult > 0 ? 0 : -1); + result.setMsg(resetPushKeyResult > 0 ? "success" : "fail"); + return new ResponseEntity<>(result, HttpStatus.OK); + } + + @ApiOperation("管理员修改普通用户密码") + @ApiImplicitParams({ + @ApiImplicitParam(name = "adminId", required = true, value = "管理员id", dataTypeClass = String.class), + @ApiImplicitParam(name = "userId", required = true, value = "用户id", dataTypeClass = String.class), + @ApiImplicitParam(name = "password", required = true, value = "新密码(未md5加密的密码)", dataTypeClass = String.class), + }) + @PostMapping("/changePasswordForAdmin") + public String changePasswordForAdmin(@RequestParam int userId, @RequestParam String password) { + // 获取当前登录用户id + LoginUser userInfo = SecurityUtils.getUserInfo(); + if (userInfo == null) { + return "fail"; + } + Role role = userInfo.getRole(); + if (role != null && role.getId() == 1) { + boolean result = userService.changePassword(userId, DigestUtils.md5DigestAsHex(password.getBytes())); + if (result) { + return "success"; + } + } + + return "fail"; + } } diff --git a/web_src/src/components/Login.vue b/web_src/src/components/Login.vue index d823659b..4ade7444 100644 --- a/web_src/src/components/Login.vue +++ b/web_src/src/components/Login.vue @@ -86,7 +86,7 @@ export default { }).then(function (res) { console.log(JSON.stringify(res)); if (res.data.code == 0 && res.data.msg == "success") { - that.$cookies.set("session", {"username": that.username}) ; + that.$cookies.set("session", {"username": that.username,"roleId":res.data.data.role.id}) ; //登录成功后 that.cancelEnterkeyDefaultAction(); that.$router.push('/'); diff --git a/web_src/src/components/UserManager.vue b/web_src/src/components/UserManager.vue new file mode 100644 index 00000000..10faf6d3 --- /dev/null +++ b/web_src/src/components/UserManager.vue @@ -0,0 +1,236 @@ + + + + diff --git a/web_src/src/components/dialog/addUser.vue b/web_src/src/components/dialog/addUser.vue new file mode 100644 index 00000000..403ecebe --- /dev/null +++ b/web_src/src/components/dialog/addUser.vue @@ -0,0 +1,159 @@ + + + diff --git a/web_src/src/components/dialog/changePasswordForAdmin.vue b/web_src/src/components/dialog/changePasswordForAdmin.vue new file mode 100644 index 00000000..0e0ae229 --- /dev/null +++ b/web_src/src/components/dialog/changePasswordForAdmin.vue @@ -0,0 +1,121 @@ + + + diff --git a/web_src/src/layout/UiHeader.vue b/web_src/src/layout/UiHeader.vue index 3c933f14..42d617e9 100644 --- a/web_src/src/layout/UiHeader.vue +++ b/web_src/src/layout/UiHeader.vue @@ -13,6 +13,7 @@ 云端录像 节点管理 国标级联 + 用户管理 @@ -47,9 +48,11 @@ export default { alarmNotify: false, sseSource: null, activeIndex: this.$route.path, + editUser: this.$cookies.get("session").roleId==1 }; }, created() { + console.log(this.$cookies.get("session")) if (this.$route.path.startsWith("/channelList")) { this.activeIndex = "/deviceList" } diff --git a/web_src/src/router/index.js b/web_src/src/router/index.js index 2c9c6f37..7651a725 100644 --- a/web_src/src/router/index.js +++ b/web_src/src/router/index.js @@ -17,6 +17,7 @@ import sip from '../components/setting/Sip.vue' import media from '../components/setting/Media.vue' import live from '../components/live.vue' import deviceTree from '../components/common/DeviceTree.vue' +import userManager from '../components/UserManager.vue' import wasmPlayer from '../components/common/jessibuca.vue' import rtcPlayer from '../components/dialog/rtcPlayer.vue' @@ -103,6 +104,11 @@ export default new VueRouter({ name: 'map', component: map, }, + { + path: '/userManager', + name: 'userManager', + component: userManager, + } ] }, { From 7e1b19e75fb1b2520fbd6a628c5920ef55170195 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 18 Jul 2022 20:33:47 +0800 Subject: [PATCH 13/20] =?UTF-8?q?MediaItem=E5=A2=9E=E5=8A=A0callId?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/media/zlm/ZLMHttpHookListener.java | 2 +- .../iot/vmp/media/zlm/dto/MediaItem.java | 16 ++++++++++++++++ .../vmp/storager/impl/RedisCatchStorageImpl.java | 5 +++++ 3 files changed, 22 insertions(+), 1 deletion(-) 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 4b51d7ce..055cccbd 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 @@ -461,7 +461,7 @@ public class ZLMHttpHookListener { StreamInfo streamInfoByAppAndStream = mediaService.getStreamInfoByAppAndStream(mediaServerItem, app, stream, tracks, streamAuthorityInfo.getCallId()); item.setStreamInfo(streamInfoByAppAndStream); - + item.setSeverId(userSetting.getServerId()); redisCatchStorage.addStream(mediaServerItem, type, app, stream, item); if (item.getOriginType() == OriginType.RTSP_PUSH.ordinal() || item.getOriginType() == OriginType.RTMP_PUSH.ordinal() diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaItem.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaItem.java index 8abac5b0..96cbfbd8 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaItem.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/MediaItem.java @@ -4,6 +4,9 @@ import com.genersoft.iot.vmp.common.StreamInfo; import java.util.List; +/** + * @author lin + */ public class MediaItem { /** @@ -21,6 +24,11 @@ public class MediaItem { */ private String stream; + /** + * 推流鉴权Id + */ + private String callId; + /** * 观看总人数,包括hls/rtsp/rtmp/http-flv/ws-flv */ @@ -427,4 +435,12 @@ public class MediaItem { public void setSeverId(String severId) { this.severId = severId; } + + public String getCallId() { + return callId; + } + + public void setCallId(String callId) { + this.callId = callId; + } } 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 8e98059c..b8b97cee 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 @@ -485,7 +485,12 @@ public class RedisCatchStorageImpl implements IRedisCatchStorage { @Override public void addStream(MediaServerItem mediaServerItem, String type, String app, String streamId, MediaItem mediaItem) { + // 查找是否使用了callID + StreamAuthorityInfo streamAuthorityInfo = getStreamAuthorityInfo(app, streamId); String key = VideoManagerConstants.WVP_SERVER_STREAM_PREFIX + userSetting.getServerId() + "_" + type + "_" + app + "_" + streamId + "_" + mediaServerItem.getId(); + if (streamAuthorityInfo != null) { + mediaItem.setCallId(streamAuthorityInfo.getCallId()); + } redis.set(key, mediaItem); } From bf189cb11bc8c8e45c13751cdc6d8e99d6887fe1 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Mon, 18 Jul 2022 20:38:47 +0800 Subject: [PATCH 14/20] =?UTF-8?q?=E4=B8=BApushKey=E5=A2=9E=E5=8A=A0?= =?UTF-8?q?=E9=BB=98=E8=AE=A4=E5=80=BC?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/update.sql | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/sql/update.sql b/sql/update.sql index c5fb671b..dd41e978 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -63,7 +63,7 @@ alter table gb_stream alter table user add pushKey varchar(50) default null; - +update user set pushKey='453df297a57a5a7438934sda801fc3' where id=1; alter table parent_platform add treeType varchar(50) not null; From 86deeedf857289e5a7fd54c8a51d5cdc143491fb Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Jul 2022 11:13:46 +0800 Subject: [PATCH 15/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=94=A8=E6=88=B7?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2sql=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/genersoft/iot/vmp/storager/dao/UserMapper.java | 2 +- web_src/src/components/dialog/platformEdit.vue | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index 850e4d44..57d2fdc3 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -56,7 +56,7 @@ public interface UserMapper { @Select("select * from user where md5(pushKey) = '${sign}'") List checkPushAuthorityByCallId(String sign); - @Select("select u.idu.username,u.pushKey,u.roleId, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u join user_role r on u.roleId=r.id") + @Select("select u.id, u.username,u.pushKey,u.roleId, r.id as roleID, r.name as roleName, r.authority as roleAuthority , r.createTime as roleCreateTime , r.updateTime as roleUpdateTime FROM user u join user_role r on u.roleId=r.id") @ResultMap(value="roleMap") List getUsers(); diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index c1292813..512f00ad 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -201,7 +201,7 @@ export default { that.platform.devicePort = res.data.devicePort; that.platform.username = res.data.username; that.platform.password = res.data.password; - that.platform.treeType = res.data.treeType; + that.platform.treeType = "BusinessGroup"; that.platform.administrativeDivision = res.data.username.substr(0, 6); }).catch(function (error) { console.log(error); From f69f1bcb5f6d210e4751404b103961b2e42d3e17 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Jul 2022 14:27:30 +0800 Subject: [PATCH 16/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=9B=B4=E6=96=B0?= =?UTF-8?q?=E6=8E=A8=E6=B5=81=E7=8A=B6=E6=80=81sql=E9=94=99=E8=AF=AF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../PlatformNotRegisterEventLister.java | 1 - .../impl/MobilePositionSubscribeHandlerTask.java | 6 ++---- .../iot/vmp/service/impl/RedisGpsMsgListener.java | 1 + .../iot/vmp/storager/dao/StreamPushMapper.java | 12 ++++++------ 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java index 14ed76a2..56bdeb58 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/event/platformNotRegister/PlatformNotRegisterEventLister.java @@ -65,7 +65,6 @@ public class PlatformNotRegisterEventLister implements ApplicationListener sendRtpItems = redisCatchStorage.querySendRTPServer(event.getPlatformGbID()); - logger.info("[ 平台未注册事件 ] 停止[ {} ]的所有推流size", sendRtpItems.size()); if (sendRtpItems != null && sendRtpItems.size() > 0) { logger.info("[ 平台未注册事件 ] 停止[ {} ]的所有推流", event.getPlatformGbID()); for (SendRtpItem sendRtpItem : sendRtpItems) { diff --git a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java index 0bad048a..7edee4dd 100644 --- a/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java +++ b/src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java @@ -66,10 +66,8 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask { for (DeviceChannel deviceChannel : gbStreams) { String gbId = deviceChannel.getChannelId(); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); - if (gpsMsgInfo != null) { // 无最新位置不发送 - if (logger.isDebugEnabled()) { - logger.debug("无最新位置不发送"); - } + // 无最新位置不发送 + if (gpsMsgInfo != null) { // 经纬度都为0不发送 if (gpsMsgInfo.getLng() == 0 && gpsMsgInfo.getLat() == 0) { continue; diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGpsMsgListener.java b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGpsMsgListener.java index be214010..74828334 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGpsMsgListener.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/RedisGpsMsgListener.java @@ -25,6 +25,7 @@ public class RedisGpsMsgListener implements MessageListener { @Override public void onMessage(@NotNull Message message, byte[] bytes) { + // TODO 加消息队列 GPSMsgInfo gpsMsgInfo = JSON.parseObject(message.getBody(), GPSMsgInfo.class); redisCatchStorage.updateGpsMsgInfo(gpsMsgInfo); } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java index 895316d1..4f2fbe24 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java @@ -125,16 +125,16 @@ public interface StreamPushMapper { "where sp.status = 1 and (gs.app, gs.stream) in (" + "" + "(#{item.app}, #{item.stream}) " + - ")" + - "") + "" + + ")") List getOnlinePusherForGbInList(List offlineStreams); @Update("") + "" + + ")") void offline(List offlineStreams); @Select("") + "" + + ")") void online(List onlineStreams); @Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where sp.status = 1") From a9fcd4502c35358c1335a2901ebf41dd797daadf Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Jul 2022 15:27:33 +0800 Subject: [PATCH 17/20] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E6=8E=A8=E6=B5=81?= =?UTF-8?q?=E5=AF=BC=E5=85=A5=E6=A8=A1=E6=9D=BF?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/static/file/推流通道导入.zip | Bin 16434 -> 13599 bytes 1 file changed, 0 insertions(+), 0 deletions(-) diff --git a/web_src/static/file/推流通道导入.zip b/web_src/static/file/推流通道导入.zip index c5ab3ab733c78f5a545934c737b18e5220ae9e8e..fb95c613dbe6ab761dfe26ea37dd160ad153867f 100644 GIT binary patch delta 5359 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 K0MR}G0001MIvV`| From fe6ca0c571558aa5c60124fbfbacab68c3ee0d02 Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Jul 2022 16:37:34 +0800 Subject: [PATCH 18/20] =?UTF-8?q?=E4=BC=98=E5=8C=96=E6=8E=A8=E6=B5=81?= =?UTF-8?q?=E5=88=97=E8=A1=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- web_src/src/components/PushVideoList.vue | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue index fc645cf6..d8d3aca7 100644 --- a/web_src/src/components/PushVideoList.vue +++ b/web_src/src/components/PushVideoList.vue @@ -62,7 +62,7 @@ From 64f6d596f4ab0a1fffd5f3d0b98eecf132b6ba2f Mon Sep 17 00:00:00 2001 From: 648540858 <648540858@qq.com> Date: Tue, 19 Jul 2022 17:46:16 +0800 Subject: [PATCH 19/20] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E5=85=B1=E4=BA=AB?= =?UTF-8?q?=E6=89=80=E6=9C=89=E7=9B=B4=E6=92=AD=E6=B5=81=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sql/mysql.sql | 1 - sql/update.sql | 3 ++ .../iot/vmp/gb28181/bean/ParentPlatform.java | 14 ------ .../vmp/media/zlm/ZLMMediaListManager.java | 28 +---------- .../iot/vmp/media/zlm/dto/StreamPushItem.java | 13 +++++ .../service/impl/StreamProxyServiceImpl.java | 18 ------- .../service/impl/StreamPushServiceImpl.java | 48 ------------------- .../storager/dao/ParentPlatformMapper.java | 8 +--- .../vmp/storager/dao/StreamPushMapper.java | 15 ++++-- .../impl/VideoManagerStorageImpl.java | 32 ------------- web_src/src/components/PushVideoList.vue | 7 ++- .../src/components/dialog/platformEdit.vue | 4 -- 12 files changed, 36 insertions(+), 155 deletions(-) diff --git a/sql/mysql.sql b/sql/mysql.sql index 71d4ac5d..7d0996f6 100644 --- a/sql/mysql.sql +++ b/sql/mysql.sql @@ -328,7 +328,6 @@ CREATE TABLE `parent_platform` ( `ptz` int DEFAULT NULL, `rtcp` int DEFAULT NULL, `status` bit(1) DEFAULT NULL, - `shareAllLiveStream` int DEFAULT NULL, `startOfflinePush` int DEFAULT '0', `administrativeDivision` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `catalogGroup` int DEFAULT '1', diff --git a/sql/update.sql b/sql/update.sql index dd41e978..91f725ec 100644 --- a/sql/update.sql +++ b/sql/update.sql @@ -55,6 +55,8 @@ alter table stream_push add status int DEFAULT NULL; alter table stream_push add updateTime varchar(50) default null; +alter table stream_push + add pushIng int DEFAULT NULL; alter table stream_push change createStamp createTime varchar(50) default null; @@ -68,6 +70,7 @@ update user set pushKey='453df297a57a5a7438934sda801fc3' where id=1; alter table parent_platform add treeType varchar(50) not null; update parent_platform set parent_platform.treeType='BusinessGroup'; +alter table parent_platform drop shareAllLiveStream; alter table platform_catalog add civilCode varchar(50) default null; 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 6dcf0dfc..61e777ad 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 @@ -104,11 +104,6 @@ public class ParentPlatform { */ private int channelCount; - /** - * 共享所有的直播流 - */ - private boolean shareAllLiveStream; - /** * 默认目录Id,自动添加的通道多放在这个目录下 */ @@ -319,15 +314,6 @@ public class ParentPlatform { this.channelCount = channelCount; } - - public boolean isShareAllLiveStream() { - return shareAllLiveStream; - } - - public void setShareAllLiveStream(boolean shareAllLiveStream) { - this.shareAllLiveStream = shareAllLiveStream; - } - public String getCatalogId() { return catalogId; } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java index 693dda16..3d9b7cbf 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMMediaListManager.java @@ -116,6 +116,7 @@ public class ZLMMediaListManager { // 查找此直播流是否存在redis预设gbId StreamPushItem transform = streamPushService.transform(mediaItem); StreamPushItem pushInDb = streamPushService.getPush(mediaItem.getApp(), mediaItem.getStream()); + transform.setPushIng(true); transform.setUpdateTime(DateUtil.getNow()); transform.setPushTime(DateUtil.getNow()); if (pushInDb == null) { @@ -123,34 +124,7 @@ public class ZLMMediaListManager { streamPushMapper.add(transform); }else { streamPushMapper.update(transform); - - -// if (!StringUtils.isEmpty(pushInDb.getGbId())) { -// List gbStreamList = gbStreamMapper.selectByGBId(transform.getGbId()); -// if (gbStreamList != null && gbStreamList.size() == 1) { -// transform.setGbStreamId(gbStreamList.get(0).getGbStreamId()); -// transform.setPlatformId(gbStreamList.get(0).getPlatformId()); -// transform.setCatalogId(gbStreamList.get(0).getCatalogId()); -// transform.setGbId(gbStreamList.get(0).getGbId()); -// gbStreamMapper.update(transform); -// streamPushMapper.del(gbStreamList.get(0).getApp(), gbStreamList.get(0).getStream()); -// }else { -// transform.setCreateTime(DateUtil.getNow()); -// transform.setUpdateTime(DateUtil.getNow()); -// gbStreamMapper.add(transform); -// } - // 通知通道上线 -// if (transform != null) { -// if (channelOnlineEvents.get(transform.getGbId()) != null) { -// channelOnlineEvents.get(transform.getGbId()).run(transform.getApp(), transform.getStream(), transform.getServerId()); -// channelOnlineEvents.remove(transform.getGbId()); -// } -// } -// } } - - - return transform; } diff --git a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java index 91fa6198..d5830060 100644 --- a/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java +++ b/src/main/java/com/genersoft/iot/vmp/media/zlm/dto/StreamPushItem.java @@ -103,6 +103,11 @@ public class StreamPushItem extends GbStream implements Comparable parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); - 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) { - platformGbStreamMapper.add(param); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), param, CatalogEvent.ADD); - } - } - } - } - wvpResult.setMsg(result.toString()); return wvpResult; } 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 faac5c92..62cf20fa 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 @@ -134,29 +134,6 @@ public class StreamPushServiceImpl implements IStreamPushService { stream.setStatus(true); stream.setCreateTime(DateUtil.getNow()); int add = gbStreamMapper.add(stream); - - // 查找开启了全部直播流共享的上级平台 - List parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); - if (parentPlatforms.size() > 0) { - for (ParentPlatform parentPlatform : parentPlatforms) { - stream.setCatalogId(parentPlatform.getCatalogId()); - stream.setPlatformId(parentPlatform.getServerGBId()); - String streamId = stream.getStream(); - StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId()); - if (streamProxyItem == null) { - platformGbStreamMapper.add(stream); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD); - }else { - if (!streamProxyItem.getGbId().equals(stream.getGbId())) { - // 此流使用另一个国标Id已经与该平台关联,移除此记录 - platformGbStreamMapper.delByAppAndStreamAndPlatform(stream.getApp(), streamId, parentPlatform.getServerGBId()); - platformGbStreamMapper.add(stream); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD); - } - } - } - } - return add > 0; } @@ -345,31 +322,6 @@ public class StreamPushServiceImpl implements IStreamPushService { public void batchAdd(List streamPushItems) { streamPushMapper.addAll(streamPushItems); gbStreamMapper.batchAdd(streamPushItems); - // 查找开启了全部直播流共享的上级平台 - List parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); - if (parentPlatforms.size() > 0) { - for (StreamPushItem stream : streamPushItems) { - for (ParentPlatform parentPlatform : parentPlatforms) { - stream.setCatalogId(parentPlatform.getCatalogId()); - stream.setPlatformId(parentPlatform.getServerGBId()); - String streamId = stream.getStream(); - StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(stream.getApp(), streamId, parentPlatform.getServerGBId()); - if (streamProxyItem == null) { - platformGbStreamMapper.add(stream); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD); - }else { - if (!streamProxyItem.getGbId().equals(stream.getGbId())) { - // 此流使用另一个国标Id已经与该平台关联,移除此记录 - platformGbStreamMapper.delByAppAndStreamAndPlatform(stream.getApp(), streamId, parentPlatform.getServerGBId()); - platformGbStreamMapper.add(stream); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.ADD); - stream.setGbId(streamProxyItem.getGbId()); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), stream, CatalogEvent.DEL); - } - } - } - } - } } @Override 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 0db6498a..554354a8 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 @@ -16,10 +16,10 @@ public interface ParentPlatformMapper { @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + - " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " + + " status, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + - " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})") + " ${status}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})") int addParentPlatform(ParentPlatform parentPlatform); @Update("UPDATE parent_platform " + @@ -41,7 +41,6 @@ public interface ParentPlatformMapper { "ptz=#{ptz}, " + "rtcp=#{rtcp}, " + "status=#{status}, " + - "shareAllLiveStream=#{shareAllLiveStream}, " + "startOfflinePush=${startOfflinePush}, " + "catalogGroup=#{catalogGroup}, " + "administrativeDivision=#{administrativeDivision}, " + @@ -84,9 +83,6 @@ public interface ParentPlatformMapper { @Update("UPDATE parent_platform SET status=#{online} WHERE serverGBId=#{platformGbID}" ) int updateParentPlatformStatus(String platformGbID, boolean online); - @Select("SELECT * FROM parent_platform WHERE shareAllLiveStream=true") - List selectAllAhareAllLiveStream(); - @Update(value = {" "}) int update(StreamPushItem streamPushItem); @@ -88,10 +89,11 @@ public interface StreamPushMapper { @Insert("") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @@ -114,6 +116,11 @@ public interface StreamPushMapper { "WHERE app=#{app} AND stream=#{stream}") int updateStatus(String app, String stream, boolean status); + @Update("UPDATE stream_push " + + "SET pushIng=${pushIng} " + + "WHERE app=#{app} AND stream=#{stream}") + int updatePushStatus(String app, String stream, boolean status); + @Update("UPDATE stream_push " + "SET status=#{status} " + "WHERE mediaServerId=#{mediaServerId}") diff --git a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java index a839f729..c18c5d2e 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java @@ -443,20 +443,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { // 更新缓存 parentPlatformCatch.setParentPlatform(parentPlatform); redisCatchStorage.updatePlatformCatchInfo(parentPlatformCatch); - if (parentPlatform.isEnable()) { - // 共享所有视频流,需要将现有视频流添加到此平台 - List gbStreams = gbStreamMapper.queryStreamNotInPlatform(); - if (gbStreams.size() > 0) { - for (GbStream gbStream : gbStreams) { - gbStream.setCatalogId(parentPlatform.getCatalogId()); - } - if (parentPlatform.isShareAllLiveStream()) { - gbStreamService.addPlatformInfo(gbStreams, parentPlatform.getServerGBId(), parentPlatform.getCatalogId()); - }else { - gbStreamService.delPlatformInfo(parentPlatform.getServerGBId(), gbStreams); - } - } - } return result > 0; } @@ -673,24 +659,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { streamPushMapper.del(streamPushItem.getApp(), streamPushItem.getStream()); streamPushMapper.add(streamPushItem); mediaOffline(streamPushItem.getApp(), streamPushItem.getStream()); - - if(!StringUtils.isEmpty(streamPushItem.getGbId() )){ - // 查找开启了全部直播流共享的上级平台 - List parentPlatforms = parentPlatformMapper.selectAllAhareAllLiveStream(); - if (parentPlatforms.size() > 0) { - for (ParentPlatform parentPlatform : parentPlatforms) { - StreamProxyItem streamProxyItem = platformGbStreamMapper.selectOne(streamPushItem.getApp(), streamPushItem.getStream(), - parentPlatform.getServerGBId()); - if (streamProxyItem == null) { - streamPushItem.setCatalogId(parentPlatform.getCatalogId()); - streamPushItem.setPlatformId(parentPlatform.getServerGBId()); - platformGbStreamMapper.add(streamPushItem); - eventPublisher.catalogEventPublishForStream(parentPlatform.getServerGBId(), streamPushItem, CatalogEvent.ADD); - } - } - } - } - } @Override diff --git a/web_src/src/components/PushVideoList.vue b/web_src/src/components/PushVideoList.vue index d8d3aca7..58ce8a21 100644 --- a/web_src/src/components/PushVideoList.vue +++ b/web_src/src/components/PushVideoList.vue @@ -62,7 +62,12 @@ + + + diff --git a/web_src/src/components/dialog/platformEdit.vue b/web_src/src/components/dialog/platformEdit.vue index 512f00ad..819c002e 100644 --- a/web_src/src/components/dialog/platformEdit.vue +++ b/web_src/src/components/dialog/platformEdit.vue @@ -97,7 +97,6 @@ - @@ -159,7 +158,6 @@ export default { keepTimeout: 60, transport: "UDP", characterSet: "GB2312", - shareAllLiveStream: false, startOfflinePush: false, catalogGroup: 1, administrativeDivision: null, @@ -225,7 +223,6 @@ export default { this.platform.keepTimeout = platform.keepTimeout; this.platform.transport = platform.transport; this.platform.characterSet = platform.characterSet; - this.platform.shareAllLiveStream = platform.shareAllLiveStream; this.platform.catalogId = platform.catalogId; this.platform.startOfflinePush = platform.startOfflinePush; this.platform.catalogGroup = platform.catalogGroup; @@ -320,7 +317,6 @@ export default { transport: "UDP", characterSet: "GB2312", treeType: "BusinessGroup", - shareAllLiveStream: false, startOfflinePush: false, catalogGroup: 1, } From 716f0b95ccbf2b5067a60edeabbe53b12145ebf9 Mon Sep 17 00:00:00 2001 From: jiang <893224616@qq.com> Date: Tue, 19 Jul 2022 18:13:19 +0800 Subject: [PATCH 20/20] =?UTF-8?q?1.=E4=BF=AE=E5=A4=8D=E6=96=B0=E5=A2=9E?= =?UTF-8?q?=E7=94=A8=E6=88=B7=E6=B2=A1=E6=9C=89pushkey=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98=202.=E5=B0=86=E9=87=8D=E7=BD=AEpushkey=E6=94=B9?= =?UTF-8?q?=E4=B8=BA=E4=BF=AE=E6=94=B9pushkey?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../iot/vmp/service/IUserService.java | 2 +- .../iot/vmp/service/impl/UserServiceImpl.java | 4 +- .../iot/vmp/storager/dao/UserMapper.java | 4 +- .../iot/vmp/vmanager/user/UserController.java | 15 +-- web_src/src/components/UserManager.vue | 52 ++++----- .../src/components/dialog/changePushKey.vue | 102 ++++++++++++++++++ 6 files changed, 142 insertions(+), 37 deletions(-) create mode 100644 web_src/src/components/dialog/changePushKey.vue diff --git a/src/main/java/com/genersoft/iot/vmp/service/IUserService.java b/src/main/java/com/genersoft/iot/vmp/service/IUserService.java index 616fd1a3..7e2a8395 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/IUserService.java +++ b/src/main/java/com/genersoft/iot/vmp/service/IUserService.java @@ -25,5 +25,5 @@ public interface IUserService { PageInfo getUsers(int page, int count); - int resetPushKey(int id); + int changePushKey(int id, String pushKey); } diff --git a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java index 46d9ad5d..f5dc7b0f 100644 --- a/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java +++ b/src/main/java/com/genersoft/iot/vmp/service/impl/UserServiceImpl.java @@ -75,7 +75,7 @@ public class UserServiceImpl implements IUserService { } @Override - public int resetPushKey(int id) { - return userMapper.resetPushKey(id); + public int changePushKey(int id, String pushKey) { + return userMapper.changePushKey(id,pushKey); } } diff --git a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java index 57d2fdc3..c7a44fd2 100644 --- a/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java +++ b/src/main/java/com/genersoft/iot/vmp/storager/dao/UserMapper.java @@ -60,6 +60,6 @@ public interface UserMapper { @ResultMap(value="roleMap") List getUsers(); - @Delete("update user set pushKey=MD5(NOW()+#{id}) where id=#{id}") - int resetPushKey(int id); + @Update("update user set pushKey=#{pushKey} where id=#{id}") + int changePushKey(int id, String pushKey); } diff --git a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java index ca6fc84e..442832bf 100644 --- a/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java +++ b/src/main/java/com/genersoft/iot/vmp/vmanager/user/UserController.java @@ -124,7 +124,8 @@ public class UserController { User user = new User(); user.setUsername(username); user.setPassword(DigestUtils.md5DigestAsHex(password.getBytes())); - + //新增用户的pushKey的生成规则为md5(时间戳+用户名) + user.setPushKey(DigestUtils.md5DigestAsHex((System.currentTimeMillis()+password).getBytes())); Role role = roleService.getRoleById(roleId); if (role == null) { @@ -138,6 +139,7 @@ public class UserController { user.setUpdateTime(DateUtil.getNow()); int addResult = userService.addUser(user); + result.setCode(addResult > 0 ? 0 : -1); result.setMsg(addResult > 0 ? "success" : "fail"); result.setData(addResult); @@ -196,12 +198,13 @@ public class UserController { return userService.getUsers(page, count); } - @ApiOperation("重置pushkey") + @ApiOperation("修改pushkey") @ApiImplicitParams({ - @ApiImplicitParam(name = "id", required = true, value = "用户Id", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "userId", required = true, value = "用户Id", dataTypeClass = Integer.class), + @ApiImplicitParam(name = "pushKey", required = true, value = "新的pushKey", dataTypeClass = String.class), }) - @RequestMapping("/resetPushKey") - public ResponseEntity> resetPushKey(@RequestParam Integer id) { + @RequestMapping("/changePushKey") + public ResponseEntity> changePushKey(@RequestParam Integer userId,@RequestParam String pushKey) { // 获取当前登录用户id int currenRoleId = SecurityUtils.getUserInfo().getRole().getId(); WVPResult result = new WVPResult<>(); @@ -211,7 +214,7 @@ public class UserController { result.setMsg("用户无权限"); return new ResponseEntity<>(result, HttpStatus.FORBIDDEN); } - int resetPushKeyResult = userService.resetPushKey(id); + int resetPushKeyResult = userService.changePushKey(userId,pushKey); result.setCode(resetPushKeyResult > 0 ? 0 : -1); result.setMsg(resetPushKeyResult > 0 ? "success" : "fail"); diff --git a/web_src/src/components/UserManager.vue b/web_src/src/components/UserManager.vue index 10faf6d3..1048f539 100644 --- a/web_src/src/components/UserManager.vue +++ b/web_src/src/components/UserManager.vue @@ -21,7 +21,7 @@