Commit 44519949599bc020aa918a6140db3448a7f29577

Authored by 648540858
1 parent be5dbc9a

优化国标级联目录订阅通知以及目录查询回复

Showing 50 changed files with 1159 additions and 819 deletions
sql/mysql.sql
... ... @@ -50,7 +50,7 @@ CREATE TABLE `device` (
50 50 `treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
51 51 PRIMARY KEY (`id`) USING BTREE,
52 52 UNIQUE KEY `device_deviceId_uindex` (`deviceId`) USING BTREE
53   -) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  53 +) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
54 54 /*!40101 SET character_set_client = @saved_cs_client */;
55 55  
56 56 --
... ... @@ -142,7 +142,7 @@ CREATE TABLE `device_channel` (
142 142 PRIMARY KEY (`id`) USING BTREE,
143 143 UNIQUE KEY `device_channel_id_uindex` (`id`) USING BTREE,
144 144 UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) USING BTREE
145   -) ENGINE=InnoDB AUTO_INCREMENT=19331 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  145 +) ENGINE=InnoDB AUTO_INCREMENT=19336 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
146 146 /*!40101 SET character_set_client = @saved_cs_client */;
147 147  
148 148 --
... ... @@ -213,7 +213,7 @@ CREATE TABLE `gb_stream` (
213 213 PRIMARY KEY (`gbStreamId`) USING BTREE,
214 214 UNIQUE KEY `app` (`app`,`stream`) USING BTREE,
215 215 UNIQUE KEY `gbId` (`gbId`) USING BTREE
216   -) ENGINE=InnoDB AUTO_INCREMENT=301681 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  216 +) ENGINE=InnoDB AUTO_INCREMENT=301740 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
217 217 /*!40101 SET character_set_client = @saved_cs_client */;
218 218  
219 219 --
... ... @@ -243,7 +243,7 @@ CREATE TABLE `log` (
243 243 `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
244 244 `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
245 245 PRIMARY KEY (`id`) USING BTREE
246   -) ENGINE=InnoDB AUTO_INCREMENT=34997 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  246 +) ENGINE=InnoDB AUTO_INCREMENT=37760 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
247 247 /*!40101 SET character_set_client = @saved_cs_client */;
248 248  
249 249 --
... ... @@ -334,10 +334,11 @@ CREATE TABLE `parent_platform` (
334 334 `catalogGroup` int DEFAULT '1',
335 335 `createTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
336 336 `updateTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  337 + `treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
337 338 PRIMARY KEY (`id`) USING BTREE,
338 339 UNIQUE KEY `parent_platform_id_uindex` (`id`) USING BTREE,
339 340 UNIQUE KEY `parent_platform_pk` (`serverGBId`) USING BTREE
340   -) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  341 +) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
341 342 /*!40101 SET character_set_client = @saved_cs_client */;
342 343  
343 344 --
... ... @@ -361,6 +362,8 @@ CREATE TABLE `platform_catalog` (
361 362 `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
362 363 `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
363 364 `parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
  365 + `civilCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
  366 + `businessGroupId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
364 367 PRIMARY KEY (`id`) USING BTREE
365 368 ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
366 369 /*!40101 SET character_set_client = @saved_cs_client */;
... ... @@ -387,7 +390,7 @@ CREATE TABLE `platform_gb_channel` (
387 390 `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
388 391 `deviceChannelId` int NOT NULL,
389 392 PRIMARY KEY (`id`) USING BTREE
390   -) ENGINE=InnoDB AUTO_INCREMENT=4889 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  393 +) ENGINE=InnoDB AUTO_INCREMENT=4912 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
391 394 /*!40101 SET character_set_client = @saved_cs_client */;
392 395  
393 396 --
... ... @@ -413,7 +416,7 @@ CREATE TABLE `platform_gb_stream` (
413 416 `id` int NOT NULL AUTO_INCREMENT,
414 417 PRIMARY KEY (`id`) USING BTREE,
415 418 UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) USING BTREE
416   -) ENGINE=InnoDB AUTO_INCREMENT=302077 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  419 +) ENGINE=InnoDB AUTO_INCREMENT=302134 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
417 420 /*!40101 SET character_set_client = @saved_cs_client */;
418 421  
419 422 --
... ... @@ -489,7 +492,7 @@ CREATE TABLE `stream_push` (
489 492 `status` int DEFAULT NULL,
490 493 PRIMARY KEY (`id`) USING BTREE,
491 494 UNIQUE KEY `stream_push_pk` (`app`,`stream`) USING BTREE
492   -) ENGINE=InnoDB AUTO_INCREMENT=305315 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
  495 +) ENGINE=InnoDB AUTO_INCREMENT=305390 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
493 496 /*!40101 SET character_set_client = @saved_cs_client */;
494 497  
495 498 --
... ... @@ -567,4 +570,4 @@ UNLOCK TABLES;
567 570 /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
568 571 /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
569 572  
570   --- Dump completed on 2022-07-11 17:32:51
  573 +-- Dump completed on 2022-07-17 23:15:09
... ...
sql/update.sql
... ... @@ -65,4 +65,14 @@ alter table user
65 65 add pushKey varchar(50) default null;
66 66  
67 67  
  68 +alter table parent_platform
  69 + add treeType varchar(50) not null;
  70 +update parent_platform set parent_platform.treeType='BusinessGroup';
  71 +
  72 +alter table platform_catalog
  73 + add civilCode varchar(50) default null;
  74 +alter table platform_catalog
  75 + add businessGroupId varchar(50) default null;
  76 +
  77 +
68 78  
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
... ... @@ -154,6 +154,11 @@ public class ParentPlatform {
154 154 */
155 155 private String createTime;
156 156  
  157 + /**
  158 + * 树类型 国标规定了两种树的展现方式 行政区划 CivilCode 和业务分组:BusinessGroup
  159 + */
  160 + private String treeType;
  161 +
157 162 public Integer getId() {
158 163 return id;
159 164 }
... ... @@ -394,4 +399,12 @@ public class ParentPlatform {
394 399 public void setCreateTime(String createTime) {
395 400 this.createTime = createTime;
396 401 }
  402 +
  403 + public String getTreeType() {
  404 + return treeType;
  405 + }
  406 +
  407 + public void setTreeType(String treeType) {
  408 + this.treeType = treeType;
  409 + }
397 410 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/PlatformCatalog.java
1 1 package com.genersoft.iot.vmp.gb28181.bean;
2 2  
  3 +/**
  4 + * 国标级联-目录
  5 + * @author lin
  6 + */
3 7 public class PlatformCatalog {
4 8 private String id;
5 9 private String name;
6 10 private String platformId;
7 11 private String parentId;
8   - private int childrenCount; // 子节点数
9   - private int type; // 0 目录, 1 国标通道, 2 直播流
  12 +
  13 + private String civilCode;
  14 +
  15 + private String businessGroupId;
  16 +
  17 + /**
  18 + * 子节点数
  19 + */
  20 + private int childrenCount;
  21 +
  22 + /**
  23 + * 0 目录, 1 国标通道, 2 直播流
  24 + */
  25 + private int type;
10 26  
11 27 public String getId() {
12 28 return id;
... ... @@ -68,4 +84,19 @@ public class PlatformCatalog {
68 84 this.type = 2;
69 85 }
70 86  
  87 + public String getCivilCode() {
  88 + return civilCode;
  89 + }
  90 +
  91 + public void setCivilCode(String civilCode) {
  92 + this.civilCode = civilCode;
  93 + }
  94 +
  95 + public String getBusinessGroupId() {
  96 + return businessGroupId;
  97 + }
  98 +
  99 + public void setBusinessGroupId(String businessGroupId) {
  100 + this.businessGroupId = businessGroupId;
  101 + }
71 102 }
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/bean/TreeType.java 0 → 100644
  1 +package com.genersoft.iot.vmp.gb28181.bean;
  2 +
  3 +/**
  4 + * 目录结构类型
  5 + * @author lin
  6 + */
  7 +public class TreeType {
  8 + public static final String BUSINESS_GROUP = "BusinessGroup";
  9 + public static final String CIVIL_CODE = "CivilCode";
  10 +}
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEvent.java
... ... @@ -11,13 +11,40 @@ public class CatalogEvent extends ApplicationEvent {
11 11 super(source);
12 12 }
13 13  
14   - public static final String ON = "ON"; // 上线
15   - public static final String OFF = "OFF"; // 离线
16   - public static final String VLOST = "VLOST"; // 视频丢失
17   - public static final String DEFECT = "DEFECT"; // 故障
18   - public static final String ADD = "ADD"; // 增加
19   - public static final String DEL = "DEL"; // 删除
20   - public static final String UPDATE = "UPDATE"; // 更新
  14 + /**
  15 + * 上线
  16 + */
  17 + public static final String ON = "ON";
  18 +
  19 + /**
  20 + * 离线
  21 + */
  22 + public static final String OFF = "OFF";
  23 +
  24 + /**
  25 + * 视频丢失
  26 + */
  27 + public static final String VLOST = "VLOST";
  28 +
  29 + /**
  30 + * 故障
  31 + */
  32 + public static final String DEFECT = "DEFECT";
  33 +
  34 + /**
  35 + * 增加
  36 + */
  37 + public static final String ADD = "ADD";
  38 +
  39 + /**
  40 + * 删除
  41 + */
  42 + public static final String DEL = "DEL";
  43 +
  44 + /**
  45 + * 更新
  46 + */
  47 + public static final String UPDATE = "UPDATE";
21 48  
22 49 private List<DeviceChannel> deviceChannels;
23 50 private List<GbStream> gbStreams;
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/event/subscribe/catalog/CatalogEventLister.java
... ... @@ -59,16 +59,15 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
59 59  
60 60 Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
61 61 if (!StringUtils.isEmpty(event.getPlatformId())) {
  62 + subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
  63 + if (subscribe == null) {
  64 + return;
  65 + }
62 66 parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
63 67 if (parentPlatform != null && !parentPlatform.isStatus()) {
64 68 return;
65 69 }
66   - subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
67 70  
68   - if (subscribe == null) {
69   - logger.info("发送订阅消息时发现订阅信息已经不存在: {}", event.getPlatformId());
70   - return;
71   - }
72 71 }else {
73 72 // 获取所用订阅
74 73 List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform();
... ... @@ -144,11 +143,8 @@ public class CatalogEventLister implements ApplicationListener&lt;CatalogEvent&gt; {
144 143 }
145 144 if (event.getGbStreams() != null && event.getGbStreams().size() > 0){
146 145 for (GbStream gbStream : event.getGbStreams()) {
147   - DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform);
148   - if (deviceChannelByStream.getParentId().length() <= 10) { // 父节点是行政区划,则设置CivilCode使用此行政区划
149   - deviceChannelByStream.setCivilCode(deviceChannelByStream.getParentId());
150   - }
151   - deviceChannelList.add(deviceChannelByStream);
  146 + deviceChannelList.add(
  147 + gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform));
152 148 }
153 149 }
154 150 if (deviceChannelList.size() > 0) {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/MobilePositionSubscribeHandlerTask.java
... ... @@ -57,18 +57,14 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
57 57 SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
58 58 if (subscribe != null) {
59 59  
60   -// if (!parentPlatform.isStatus()) {
61   -// logger.info("发送订阅时发现平台已经离线:{}", platformId);
62   -// return;
63   -// }
64 60 // TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
65   - List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
  61 + List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
66 62 if (gbStreams.size() == 0) {
67 63 logger.info("发送订阅时发现平台已经没有关联的直播流:{}", platform.getServerGBId());
68 64 return;
69 65 }
70   - for (GbStream gbStream : gbStreams) {
71   - String gbId = gbStream.getGbId();
  66 + for (DeviceChannel deviceChannel : gbStreams) {
  67 + String gbId = deviceChannel.getChannelId();
72 68 GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
73 69 if (gpsMsgInfo != null) { // 无最新位置不发送
74 70 if (logger.isDebugEnabled()) {
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
... ... @@ -257,37 +257,37 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
257 257 catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
258 258 if (channels.size() > 0) {
259 259 for (DeviceChannel channel : channels) {
  260 + if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
  261 + channel.setParentId(parentPlatform.getDeviceGBId());
  262 + }
260 263 catalogXml.append("<Item>\r\n");
  264 + // 行政区划分组只需要这两项就可以
261 265 catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
262 266 catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
263   - catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
264 267 if (channel.getParentId() != null) {
  268 + // 业务分组加上这一项即可,提高兼容性,
265 269 catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
266 270 }
267   - if (channel.getChannelId().length() == 20) {
268   - if (Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段
269   - catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
270   - }
  271 + if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
  272 + // 虚拟组织增加BusinessGroupID字段
  273 + catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
  274 + }
  275 + catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
  276 + if (channel.getParental() == 0) {
  277 + // 通道项
271 278 catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
  279 + catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
272 280 catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
273   - catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n");
274   - if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下字段
275   - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
  281 + catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
  282 +
  283 + if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
276 284 catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
277   - catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n");
  285 + catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
278 286 catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
279 287 catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
280   - catalogXml.append("<Longitude>" + channel.getLongitudeWgs84() + "</Longitude>\r\n");
281   - catalogXml.append("<Latitude>" + channel.getLatitudeWgs84() + "</Latitude>\r\n");
282   - catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
283   - catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
284   - catalogXml.append("<Info>\r\n");
285   - catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
286   - catalogXml.append("</Info>\r\n");
287 288 }
288   - }
289   -
290 289  
  290 + }
291 291 catalogXml.append("</Item>\r\n");
292 292 }
293 293 }
... ... @@ -592,27 +592,35 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
592 592 channel.setParentId(parentPlatform.getDeviceGBId());
593 593 }
594 594 catalogXml.append("<Item>\r\n");
  595 + // 行政区划分组只需要这两项就可以
595 596 catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
596 597 catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
597   - catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
598   - catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
599 598 if (channel.getParentId() != null) {
  599 + // 业务分组加上这一项即可,提高兼容性,
600 600 catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
601 601 }
602   - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
603   - catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
604   - catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
605   - if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段
  602 + if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
  603 + // 虚拟组织增加BusinessGroupID字段
606 604 catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
607 605 }
608   - if (channel.getChannelType() == 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
609   - catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
610   - catalogXml.append("<Owner>0</Owner>\r\n");
611   - catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n");
612   - catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
613   - }
614   - if (!"presence".equals(subscribeInfo.getEventType())) {
615   - catalogXml.append("<Event>" + type + "</Event>\r\n");
  606 + catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
  607 + if (channel.getParental() == 0) {
  608 + // 通道项
  609 + catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
  610 + catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
  611 + catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
  612 + catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
  613 +
  614 + if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
  615 + catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
  616 + catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
  617 + catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
  618 + catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
  619 + }
  620 + if (!"presence".equals(subscribeInfo.getEventType())) {
  621 + catalogXml.append("<Event>" + type + "</Event>\r\n");
  622 + }
  623 +
616 624 }
617 625 catalogXml.append("</Item>\r\n");
618 626 }
... ...
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;
15 15 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
16 16 import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
17 17 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
  18 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
18 19 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
19 20 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
20 21 import com.genersoft.iot.vmp.utils.DateUtil;
... ... @@ -71,6 +72,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
71 72 @Autowired
72 73 private SIPProcessorObserver sipProcessorObserver;
73 74  
  75 + @Autowired
  76 + private IDeviceChannelService deviceChannelService;
  77 +
74 78 private boolean taskQueueHandlerRun = false;
75 79  
76 80 private final ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>();
... ... @@ -173,28 +177,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
173 177 logger.info("[收到 移动位置订阅]:{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
174 178 mobilePosition.getLongitude(), mobilePosition.getLatitude());
175 179 mobilePosition.setReportSource("Mobile Position");
176   - // 默认来源坐标系为WGS-84处理
177   - if ("WGS84".equals(device.getGeoCoordSys())) {
178   - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
179   - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
180   - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
181   - mobilePosition.setLongitudeGcj02(position[0]);
182   - mobilePosition.setLatitudeGcj02(position[1]);
183   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
184   - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
185   - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
186   - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
187   - mobilePosition.setLongitudeWgs84(position[0]);
188   - mobilePosition.setLatitudeWgs84(position[1]);
189   - }else {
190   - mobilePosition.setLongitudeGcj02(0.00);
191   - mobilePosition.setLatitudeGcj02(0.00);
192   - mobilePosition.setLongitudeWgs84(0.00);
193   - mobilePosition.setLatitudeWgs84(0.00);
194   - }
195   - if (userSetting.getSavePositionHistory()) {
196   - storager.insertMobilePosition(mobilePosition);
197   - }
  180 +
198 181  
199 182 // 更新device channel 的经纬度
200 183 DeviceChannel deviceChannel = new DeviceChannel();
... ... @@ -202,11 +185,18 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
202 185 deviceChannel.setChannelId(channelId);
203 186 deviceChannel.setLongitude(mobilePosition.getLongitude());
204 187 deviceChannel.setLatitude(mobilePosition.getLatitude());
205   - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
206   - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
207   - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
208   - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
209 188 deviceChannel.setGpsTime(mobilePosition.getTime());
  189 + deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
  190 +
  191 + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
  192 + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
  193 + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
  194 + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
  195 +
  196 + if (userSetting.getSavePositionHistory()) {
  197 + storager.insertMobilePosition(mobilePosition);
  198 + }
  199 +
210 200 storager.updateChannelPosition(deviceChannel);
211 201 // 发送redis消息。 通知位置信息的变化
212 202 JSONObject jsonObject = new JSONObject();
... ... @@ -281,38 +271,28 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
281 271 mobilePosition.setLongitude(deviceAlarm.getLongitude());
282 272 mobilePosition.setLatitude(deviceAlarm.getLatitude());
283 273 mobilePosition.setReportSource("GPS Alarm");
284   - if ("WGS84".equals(device.getGeoCoordSys())) {
285   - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
286   - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
287   - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
288   - mobilePosition.setLongitudeGcj02(position[0]);
289   - mobilePosition.setLatitudeGcj02(position[1]);
290   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
291   - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
292   - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
293   - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
294   - mobilePosition.setLongitudeWgs84(position[0]);
295   - mobilePosition.setLatitudeWgs84(position[1]);
296   - }else {
297   - mobilePosition.setLongitudeGcj02(0.00);
298   - mobilePosition.setLatitudeGcj02(0.00);
299   - mobilePosition.setLongitudeWgs84(0.00);
300   - mobilePosition.setLatitudeWgs84(0.00);
301   - }
302   - if (userSetting.getSavePositionHistory()) {
303   - storager.insertMobilePosition(mobilePosition);
304   - }
  274 +
  275 +
  276 +
305 277 // 更新device channel 的经纬度
306 278 DeviceChannel deviceChannel = new DeviceChannel();
307 279 deviceChannel.setDeviceId(device.getDeviceId());
308 280 deviceChannel.setChannelId(channelId);
309 281 deviceChannel.setLongitude(mobilePosition.getLongitude());
310 282 deviceChannel.setLatitude(mobilePosition.getLatitude());
311   - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
312   - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
313   - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
314   - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
315 283 deviceChannel.setGpsTime(mobilePosition.getTime());
  284 +
  285 + deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
  286 +
  287 + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
  288 + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
  289 + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
  290 + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
  291 +
  292 + if (userSetting.getSavePositionHistory()) {
  293 + storager.insertMobilePosition(mobilePosition);
  294 + }
  295 +
316 296 storager.updateChannelPosition(deviceChannel);
317 297 }
318 298 // TODO: 需要实现存储报警信息、报警分类
... ... @@ -364,7 +344,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
364 344 }else {
365 345 event = eventElement.getText().toUpperCase();
366 346 }
367   - DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device);
  347 + DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event);
368 348 channel.setDeviceId(device.getDeviceId());
369 349 logger.info("[收到 目录订阅]:{}/{}", device.getDeviceId(), channel.getChannelId());
370 350 switch (event) {
... ... @@ -389,7 +369,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
389 369 case CatalogEvent.ADD:
390 370 // 增加
391 371 logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channel.getChannelId());
392   - storager.updateChannel(deviceId, channel);
  372 + deviceChannelService.updateChannel(deviceId, channel);
393 373 break;
394 374 case CatalogEvent.DEL:
395 375 // 删除
... ... @@ -399,7 +379,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
399 379 case CatalogEvent.UPDATE:
400 380 // 更新
401 381 logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channel.getChannelId());
402   - storager.updateChannel(deviceId, channel);
  382 + deviceChannelService.updateChannel(deviceId, channel);
403 383 break;
404 384 default:
405 385 logger.warn("[ NotifyCatalog ] event not found : {}", event );
... ...
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;
11 11 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
12 12 import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
13 13 import com.genersoft.iot.vmp.service.IDeviceAlarmService;
  14 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
14 15 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
15 16 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
16 17 import com.genersoft.iot.vmp.utils.DateUtil;
... ... @@ -58,6 +59,9 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
58 59 @Autowired
59 60 private IDeviceAlarmService deviceAlarmService;
60 61  
  62 + @Autowired
  63 + private IDeviceChannelService deviceChannelService;
  64 +
61 65 @Override
62 66 public void afterPropertiesSet() throws Exception {
63 67 notifyMessageHandler.addHandler(cmdType, this);
... ... @@ -119,38 +123,26 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
119 123 mobilePosition.setLongitude(deviceAlarm.getLongitude());
120 124 mobilePosition.setLatitude(deviceAlarm.getLatitude());
121 125 mobilePosition.setReportSource("GPS Alarm");
122   - if ("WGS84".equals(device.getGeoCoordSys())) {
123   - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
124   - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
125   - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
126   - mobilePosition.setLongitudeGcj02(position[0]);
127   - mobilePosition.setLatitudeGcj02(position[1]);
128   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
129   - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
130   - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
131   - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
132   - mobilePosition.setLongitudeWgs84(position[0]);
133   - mobilePosition.setLatitudeWgs84(position[1]);
134   - }else {
135   - mobilePosition.setLongitudeGcj02(0.00);
136   - mobilePosition.setLatitudeGcj02(0.00);
137   - mobilePosition.setLongitudeWgs84(0.00);
138   - mobilePosition.setLatitudeWgs84(0.00);
139   - }
140   - if (userSetting.getSavePositionHistory()) {
141   - storager.insertMobilePosition(mobilePosition);
142   - }
  126 +
  127 +
143 128 // 更新device channel 的经纬度
144 129 DeviceChannel deviceChannel = new DeviceChannel();
145 130 deviceChannel.setDeviceId(device.getDeviceId());
146 131 deviceChannel.setChannelId(channelId);
147 132 deviceChannel.setLongitude(mobilePosition.getLongitude());
148 133 deviceChannel.setLatitude(mobilePosition.getLatitude());
149   - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
150   - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
151   - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
152   - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
153 134 deviceChannel.setGpsTime(mobilePosition.getTime());
  135 +
  136 + deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
  137 +
  138 + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
  139 + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
  140 + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
  141 + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
  142 +
  143 + if (userSetting.getSavePositionHistory()) {
  144 + storager.insertMobilePosition(mobilePosition);
  145 + }
154 146 storager.updateChannelPosition(deviceChannel);
155 147 }
156 148 }
... ...
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
58 58 // 准备回复通道信息
59 59 List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
60 60 // 查询关联的直播通道
61   - List<GbStream> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
  61 + List<DeviceChannel> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
  62 + // 回复目录信息
  63 + List<DeviceChannel> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
62 64  
63 65 List<DeviceChannel> allChannels = new ArrayList<>();
64   - // 回复目录信息
65   - List<PlatformCatalog> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
66 66 if (catalogs.size() > 0) {
67   - for (PlatformCatalog catalog : catalogs) {
68   - if (catalog.getParentId().equals(catalog.getPlatformId())) {
69   - catalog.setParentId(parentPlatform.getDeviceGBId());
70   - }
71   - DeviceChannel deviceChannel = new DeviceChannel();
72   - deviceChannel.setChannelId(catalog.getId());
73   - deviceChannel.setName(catalog.getName());
74   - deviceChannel.setLongitude(0.0);
75   - deviceChannel.setLatitude(0.0);
76   - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
77   - deviceChannel.setManufacture("wvp-pro");
78   - deviceChannel.setStatus(1);
79   - deviceChannel.setParental(1);
80   - deviceChannel.setParentId(catalog.getParentId());
81   - deviceChannel.setRegisterWay(1);
82   - if (catalog.getParentId() != null && catalog.getParentId().length() <= 10) {
83   - deviceChannel.setCivilCode(catalog.getParentId());
84   - }else {
85   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
86   - }
87   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
88   - deviceChannel.setModel("live");
89   - deviceChannel.setOwner("wvp-pro");
90   - deviceChannel.setSecrecy("0");
91   - allChannels.add(deviceChannel);
92   - }
  67 + allChannels.addAll(catalogs);
93 68 }
94 69 // 回复级联的通道
95 70 if (deviceChannels.size() > 0) {
96   - for (DeviceChannelInPlatform channel : deviceChannels) {
97   - if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
98   - channel.setCatalogId(parentPlatform.getDeviceGBId());
99   - }
100   - DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
101   - deviceChannel.setParental(0);
102   - deviceChannel.setParentId(channel.getCatalogId());
103   - if (channel.getCatalogId() != null && channel.getCatalogId().length() <= 10) {
104   - channel.setCivilCode(channel.getCatalogId());
105   - }else {
106   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
107   - }
108   -
109   - allChannels.add(deviceChannel);
110   - }
  71 + allChannels.addAll(deviceChannels);
111 72 }
112 73 // 回复直播的通道
113 74 if (gbStreams.size() > 0) {
114   - for (GbStream gbStream : gbStreams) {
115   - if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) {
116   - gbStream.setCatalogId(null);
117   - }
118   - DeviceChannel deviceChannel = new DeviceChannel();
119   - deviceChannel.setChannelId(gbStream.getGbId());
120   - deviceChannel.setName(gbStream.getName());
121   - deviceChannel.setLongitude(gbStream.getLongitude());
122   - deviceChannel.setLatitude(gbStream.getLatitude());
123   - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
124   - deviceChannel.setManufacture("wvp-pro");
125   -// deviceChannel.setStatus(gbStream.isStatus()?1:0);
126   - deviceChannel.setStatus(1);
127   - deviceChannel.setParentId(gbStream.getCatalogId());
128   - deviceChannel.setRegisterWay(1);
129   - if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() <= 10) {
130   - deviceChannel.setCivilCode(gbStream.getCatalogId());
131   - }else {
132   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
133   - }
134   - deviceChannel.setModel("live");
135   - deviceChannel.setOwner("wvp-pro");
136   - deviceChannel.setParental(0);
137   - deviceChannel.setSecrecy("0");
138   - allChannels.add(deviceChannel);
139   - }
  75 + allChannels.addAll(gbStreams);
140 76 }
141 77 if (allChannels.size() > 0) {
142 78 cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag());
... ...
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
7 7 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
8 8 import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
9 9 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
  10 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
10 11 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
11 12 import com.genersoft.iot.vmp.utils.DateUtil;
12 13 import com.genersoft.iot.vmp.utils.GpsUtil;
... ... @@ -42,6 +43,9 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
42 43 @Autowired
43 44 private IVideoManagerStorage storager;
44 45  
  46 + @Autowired
  47 + private IDeviceChannelService deviceChannelService;
  48 +
45 49 @Override
46 50 public void afterPropertiesSet() throws Exception {
47 51 notifyMessageHandler.addHandler(cmdType, this);
... ... @@ -79,38 +83,26 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
79 83 mobilePosition.setAltitude(0.0);
80 84 }
81 85 mobilePosition.setReportSource("Mobile Position");
82   - if ("WGS84".equals(device.getGeoCoordSys())) {
83   - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
84   - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
85   - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
86   - mobilePosition.setLongitudeGcj02(position[0]);
87   - mobilePosition.setLatitudeGcj02(position[1]);
88   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
89   - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
90   - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
91   - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
92   - mobilePosition.setLongitudeWgs84(position[0]);
93   - mobilePosition.setLatitudeWgs84(position[1]);
94   - }else {
95   - mobilePosition.setLongitudeGcj02(0.00);
96   - mobilePosition.setLatitudeGcj02(0.00);
97   - mobilePosition.setLongitudeWgs84(0.00);
98   - mobilePosition.setLatitudeWgs84(0.00);
99   - }
100   - if (userSetting.getSavePositionHistory()) {
101   - storager.insertMobilePosition(mobilePosition);
102   - }
  86 +
  87 +
103 88 // 更新device channel 的经纬度
104 89 DeviceChannel deviceChannel = new DeviceChannel();
105 90 deviceChannel.setDeviceId(device.getDeviceId());
106 91 deviceChannel.setChannelId(mobilePosition.getChannelId());
107 92 deviceChannel.setLongitude(mobilePosition.getLongitude());
108 93 deviceChannel.setLatitude(mobilePosition.getLatitude());
109   - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
110   - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
111   - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
112   - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
113 94 deviceChannel.setGpsTime(mobilePosition.getTime());
  95 +
  96 + deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
  97 +
  98 + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
  99 + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
  100 + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
  101 + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
  102 +
  103 + if (userSetting.getSavePositionHistory()) {
  104 + storager.insertMobilePosition(mobilePosition);
  105 + }
114 106 storager.updateChannelPosition(deviceChannel);
115 107 //回复 200 OK
116 108 responseAck(evt, Response.OK);
... ...
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
70 70 Element snElement = rootElement.element("SN");
71 71 String sn = snElement.getText();
72 72 // 准备回复通道信息
73   - List<DeviceChannelInPlatform> deviceChannelInPlatforms = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
  73 + List<DeviceChannel> deviceChannelInPlatforms = storager.queryChannelWithCatalog(parentPlatform.getServerGBId());
74 74 // 查询关联的直播通道
75   - List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
  75 + List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
76 76 // 回复目录信息
77   - List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
  77 + List<DeviceChannel> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
78 78  
79 79 List<DeviceChannel> allChannels = new ArrayList<>();
  80 +
80 81 if (catalogs.size() > 0) {
81   - for (PlatformCatalog catalog : catalogs) {
82   - if (catalog.getParentId().equals(catalog.getPlatformId())) {
83   - catalog.setParentId(parentPlatform.getDeviceGBId());
84   - }
85   - DeviceChannel deviceChannel = new DeviceChannel();
86   - // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
87   - deviceChannel.setChannelType(2);
88   - deviceChannel.setChannelId(catalog.getId());
89   - deviceChannel.setName(catalog.getName());
90   - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
91   - deviceChannel.setManufacture("wvp-pro");
92   - deviceChannel.setStatus(1);
93   - deviceChannel.setParental(1);
94   - deviceChannel.setParentId(catalog.getParentId());
95   - deviceChannel.setRegisterWay(1);
96   - if (catalog.getParentId() != null && catalog.getParentId().length() < 10) {
97   - deviceChannel.setCivilCode(catalog.getParentId());
98   - }else {
99   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
100   - }
101   - allChannels.add(deviceChannel);
102   - }
  82 + allChannels.addAll(catalogs);
103 83 }
104 84 // 回复级联的通道
105 85 if (deviceChannelInPlatforms.size() > 0) {
106   - for (DeviceChannelInPlatform channel : deviceChannelInPlatforms) {
107   - if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
108   - channel.setCatalogId(parentPlatform.getDeviceGBId());
109   - }
110   - DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
111   - // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
112   - deviceChannel.setChannelType(0);
113   - deviceChannel.setParental(0);
114   - deviceChannel.setParentId(channel.getCatalogId());
115   - if (channel.getCatalogId() != null && channel.getCatalogId().length() < 10) {
116   - deviceChannel.setCivilCode(channel.getCatalogId());
117   - }else {
118   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
119   - }
120   - allChannels.add(deviceChannel);
121   - }
  86 + allChannels.addAll(deviceChannelInPlatforms);
122 87 }
123 88 // 回复直播的通道
124 89 if (gbStreams.size() > 0) {
125   - for (GbStream gbStream : gbStreams) {
126   - if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) {
127   - gbStream.setCatalogId(null);
128   - }
129   - DeviceChannel deviceChannel = new DeviceChannel();
130   - // 通道的类型,0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
131   - deviceChannel.setChannelType(1);
132   - deviceChannel.setChannelId(gbStream.getGbId());
133   - deviceChannel.setName(gbStream.getName());
134   - deviceChannel.setLongitude(gbStream.getLongitude());
135   - deviceChannel.setLatitude(gbStream.getLatitude());
136   - deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
137   - deviceChannel.setManufacture("wvp-pro");
138   -// deviceChannel.setStatus(gbStream.isStatus()?1:0);
139   - deviceChannel.setStatus(1);
140   - deviceChannel.setParentId(gbStream.getCatalogId());
141   - deviceChannel.setRegisterWay(1);
142   - if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() < 10) {
143   - deviceChannel.setCivilCode(gbStream.getCatalogId());
144   - }else {
145   - deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
146   - }
147   - deviceChannel.setModel("live");
148   - deviceChannel.setOwner("wvp-pro");
149   - deviceChannel.setParental(0);
150   - deviceChannel.setSecrecy("0");
151   - allChannels.add(deviceChannel);
152   - }
  90 + allChannels.addAll(gbStreams);
153 91 }
154 92 if (allChannels.size() > 0) {
155 93 cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag());
... ...
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
125 125 if (channelDeviceElement == null) {
126 126 continue;
127 127 }
128   - //by brewswang
129   - // if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息,就更新一下位置
130   - // processNotifyMobilePosition(evt, itemDevice);
131   - // }
132   - DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device);
  128 + DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device, null);
133 129 deviceChannel.setDeviceId(take.getDevice().getDeviceId());
134 130  
135 131 channelList.add(deviceChannel);
... ...
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
87 87 device.setStreamMode("UDP");
88 88 }
89 89 deviceService.updateDevice(device);
90   -// storager.updateDevice(device);
91 90  
92 91 RequestMessage msg = new RequestMessage();
93 92 msg.setKey(key);
... ...
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
7 7 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
8 8 import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
9 9 import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
  10 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
10 11 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
11 12 import com.genersoft.iot.vmp.utils.DateUtil;
12 13 import com.genersoft.iot.vmp.utils.GpsUtil;
... ... @@ -42,6 +43,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
42 43 @Autowired
43 44 private IVideoManagerStorage storager;
44 45  
  46 + @Autowired
  47 + private IDeviceChannelService deviceChannelService;
  48 +
45 49 @Override
46 50 public void afterPropertiesSet() throws Exception {
47 51 responseMessageHandler.addHandler(cmdType, this);
... ... @@ -79,38 +83,25 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
79 83 mobilePosition.setAltitude(0.0);
80 84 }
81 85 mobilePosition.setReportSource("Mobile Position");
82   - if ("WGS84".equals(device.getGeoCoordSys())) {
83   - mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
84   - mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
85   - Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
86   - mobilePosition.setLongitudeGcj02(position[0]);
87   - mobilePosition.setLatitudeGcj02(position[1]);
88   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
89   - mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
90   - mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
91   - Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
92   - mobilePosition.setLongitudeWgs84(position[0]);
93   - mobilePosition.setLatitudeWgs84(position[1]);
94   - }else {
95   - mobilePosition.setLongitudeGcj02(0.00);
96   - mobilePosition.setLatitudeGcj02(0.00);
97   - mobilePosition.setLongitudeWgs84(0.00);
98   - mobilePosition.setLatitudeWgs84(0.00);
99   - }
100   - if (userSetting.getSavePositionHistory()) {
101   - storager.insertMobilePosition(mobilePosition);
102   - }
  86 +
103 87 // 更新device channel 的经纬度
104 88 DeviceChannel deviceChannel = new DeviceChannel();
105 89 deviceChannel.setDeviceId(device.getDeviceId());
106 90 deviceChannel.setChannelId(mobilePosition.getChannelId());
107 91 deviceChannel.setLongitude(mobilePosition.getLongitude());
108 92 deviceChannel.setLatitude(mobilePosition.getLatitude());
109   - deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
110   - deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
111   - deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
112   - deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
113 93 deviceChannel.setGpsTime(mobilePosition.getTime());
  94 +
  95 + deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
  96 +
  97 + mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
  98 + mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
  99 + mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
  100 + mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
  101 +
  102 + if (userSetting.getSavePositionHistory()) {
  103 + storager.insertMobilePosition(mobilePosition);
  104 + }
114 105 storager.updateChannelPosition(deviceChannel);
115 106 //回复 200 OK
116 107 responseAck(evt, Response.OK);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/utils/XmlUtil.java
... ... @@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONArray;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import com.genersoft.iot.vmp.gb28181.bean.Device;
6 6 import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  7 +import com.genersoft.iot.vmp.gb28181.bean.TreeType;
  8 +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
7 9 import com.genersoft.iot.vmp.utils.DateUtil;
8 10 import org.dom4j.Attribute;
9 11 import org.dom4j.Document;
... ... @@ -29,7 +31,7 @@ public class XmlUtil {
29 31 /**
30 32 * 日志服务
31 33 */
32   - private static Logger LOG = LoggerFactory.getLogger(XmlUtil.class);
  34 + private static Logger logger = LoggerFactory.getLogger(XmlUtil.class);
33 35  
34 36 /**
35 37 * 解析XML为Document对象
... ... @@ -46,7 +48,7 @@ public class XmlUtil {
46 48 try {
47 49 document = saxReader.read(sr);
48 50 } catch (DocumentException e) {
49   - LOG.error("解析失败", e);
  51 + logger.error("解析失败", e);
50 52 }
51 53 return null == document ? null : document.getRootElement();
52 54 }
... ... @@ -182,47 +184,69 @@ public class XmlUtil {
182 184 return xml.getRootElement();
183 185 }
184 186  
185   - public static DeviceChannel channelContentHander(Element itemDevice, Device device){
186   - Element channdelNameElement = itemDevice.element("Name");
187   - String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";
188   - Element statusElement = itemDevice.element("Status");
189   - String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON";
  187 + private enum ChannelType{
  188 + CivilCode, BusinessGroup,VirtualOrganization,Other
  189 + }
  190 +
  191 + public static DeviceChannel channelContentHander(Element itemDevice, Device device, String event){
190 192 DeviceChannel deviceChannel = new DeviceChannel();
191   - deviceChannel.setName(channelName);
  193 + deviceChannel.setDeviceId(device.getDeviceId());
192 194 Element channdelIdElement = itemDevice.element("DeviceID");
193   - String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : "";
  195 + if (channdelIdElement == null) {
  196 + logger.warn("解析Catalog消息时发现缺少 DeviceID");
  197 + return null;
  198 + }
  199 + String channelId = channdelIdElement.getTextTrim();
  200 + if (StringUtils.isEmpty(channelId)) {
  201 + logger.warn("解析Catalog消息时发现缺少 DeviceID");
  202 + return null;
  203 + }
194 204 deviceChannel.setChannelId(channelId);
195   - // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
196   - if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) {
197   - deviceChannel.setStatus(1);
  205 + if (event != null && !event.equals(CatalogEvent.ADD) && !event.equals(CatalogEvent.UPDATE)) {
  206 + // 除了ADD和update情况下需要识别全部内容,
  207 + return deviceChannel;
198 208 }
199   - if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
200   - deviceChannel.setStatus(0);
  209 +
  210 + ChannelType channelType = ChannelType.Other;
  211 + if (channelId.length() <= 8) {
  212 + channelType = ChannelType.CivilCode;
  213 + }else {
  214 + if (channelId.length() == 20) {
  215 + int code = Integer.parseInt(channelId.substring(10, 13));
  216 + switch (code){
  217 + case 215:
  218 + channelType = ChannelType.BusinessGroup;
  219 + break;
  220 + case 216:
  221 + channelType = ChannelType.VirtualOrganization;
  222 + break;
  223 + default:
  224 + break;
  225 +
  226 + }
  227 + }
201 228 }
202 229  
203   - deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));
204   - deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));
205   - deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));
206   - deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode"));
207   - deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
208   - deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
209   - String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
210   - if (XmlUtil.getText(itemDevice, "Parental") == null
211   - || XmlUtil.getText(itemDevice, "Parental").equals("")) {
212   - if (deviceChannel.getChannelId().length() <= 10
213   - || (deviceChannel.getChannelId().length() == 20 && (
214   - Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 215
215   - || Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216
216   - )
217   - )
218   - ) {
219   - deviceChannel.setParental(1);
220   - }else {
221   - deviceChannel.setParental(0);
  230 + Element channdelNameElement = itemDevice.element("Name");
  231 + String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim() : "";
  232 + deviceChannel.setName(channelName);
  233 +
  234 + String civilCode = XmlUtil.getText(itemDevice, "CivilCode");
  235 + deviceChannel.setCivilCode(civilCode);
  236 + if (channelType == ChannelType.CivilCode && civilCode == null) {
  237 + deviceChannel.setParental(1);
  238 + // 行政区划如果没有传递具体值,则推测一个
  239 + if (channelId.length() > 2) {
  240 + deviceChannel.setCivilCode(channelId.substring(0, channelId.length() - 2));
222 241 }
223   - } else {
224   - // 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
225   - deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")) == 1?1:0);
  242 + }
  243 + if (channelType.equals(ChannelType.CivilCode)) {
  244 + // 行政区划其他字段没必要识别了,默认在线即可
  245 + deviceChannel.setStatus(1);
  246 + deviceChannel.setParental(1);
  247 + deviceChannel.setCreateTime(DateUtil.getNow());
  248 + deviceChannel.setUpdateTime(DateUtil.getNow());
  249 + return deviceChannel;
226 250 }
227 251 /**
228 252 * 行政区划展示设备树与业务分组展示设备树是两种不同的模式
... ... @@ -230,7 +254,17 @@ public class XmlUtil {
230 254 * 河北省
231 255 * --> 石家庄市
232 256 * --> 摄像头
233   - * --> 正定县
  257 + *String parentId = XmlUtil.getText(itemDevice, "ParentID");
  258 + if (parentId != null) {
  259 + if (parentId.contains("/")) {
  260 + String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
  261 + String businessGroup = parentId.substring(0, parentId.indexOf("/"));
  262 + deviceChannel.setParentId(lastParentId);
  263 + }else {
  264 + deviceChannel.setParentId(parentId);
  265 + }
  266 + }
  267 + deviceCh --> 正定县
234 268 * --> 摄像头
235 269 * --> 摄像头
236 270 *
... ... @@ -243,59 +277,88 @@ public class XmlUtil {
243 277 * --> 摄像头
244 278 */
245 279 String parentId = XmlUtil.getText(itemDevice, "ParentID");
  280 + String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
246 281 if (parentId != null) {
247 282 if (parentId.contains("/")) {
248 283 String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
  284 + if (businessGroupID == null) {
  285 + businessGroupID = parentId.substring(0, parentId.indexOf("/"));
  286 + }
249 287 deviceChannel.setParentId(lastParentId);
250 288 }else {
251 289 deviceChannel.setParentId(parentId);
252 290 }
253 291 }
254 292 deviceChannel.setBusinessGroupId(businessGroupID);
  293 + if (channelType.equals(ChannelType.BusinessGroup) || channelType.equals(ChannelType.VirtualOrganization)) {
  294 + // 业务分组和虚拟组织 其他字段没必要识别了,默认在线即可
  295 + deviceChannel.setStatus(1);
  296 + deviceChannel.setParental(1);
  297 + deviceChannel.setCreateTime(DateUtil.getNow());
  298 + deviceChannel.setUpdateTime(DateUtil.getNow());
  299 + return deviceChannel;
  300 + }
255 301  
256   -// else {
257   -// if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联
258   -// deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2));
259   -// }else if (deviceChannel.getChannelId().length() == 20) {
260   -// if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织
261   -// deviceChannel.setBusinessGroupId(businessGroupID);
262   -// }else if (Integer.parseInt(device.getDeviceId().substring(10, 13) )== 118) {//NVR 如果上级设备编号是NVR则直接将NVR的编号设置给通道的上级编号
263   -// deviceChannel.setParentId(device.getDeviceId());
264   -// }else if (deviceChannel.getCivilCode() != null) {
265   -// // 设备, 无parentId的20位是使用CivilCode表示上级的设备,
266   -// // 注:215 业务分组是需要有parentId的
267   -// deviceChannel.setParentId(deviceChannel.getCivilCode());
268   -// }
269   -// }else {
270   -// deviceChannel.setParentId(deviceChannel.getDeviceId());
271   -// }
272   -// }
273   -
274   - if (XmlUtil.getText(itemDevice, "SafetyWay") == null
275   - || XmlUtil.getText(itemDevice, "SafetyWay") == "") {
  302 + Element statusElement = itemDevice.element("Status");
  303 +
  304 + if (statusElement != null) {
  305 + String status = statusElement.getTextTrim().trim();
  306 + // ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
  307 + if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) {
  308 + deviceChannel.setStatus(1);
  309 + }
  310 + if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
  311 + deviceChannel.setStatus(0);
  312 + }
  313 + }else {
  314 + deviceChannel.setStatus(1);
  315 + }
  316 + // 识别自带的目录标识
  317 + String parental = XmlUtil.getText(itemDevice, "Parental");
  318 + // 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
  319 + if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
  320 + deviceChannel.setParental(0);
  321 + }else {
  322 + deviceChannel.setParental(1);
  323 + }
  324 +
  325 +
  326 + deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));
  327 + deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));
  328 + deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));
  329 + deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
  330 + deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
  331 + deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
  332 + deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
  333 +
  334 + String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay");
  335 + if (StringUtils.isEmpty(safetyWay)) {
276 336 deviceChannel.setSafetyWay(0);
277 337 } else {
278   - deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay")));
  338 + deviceChannel.setSafetyWay(Integer.parseInt(safetyWay));
279 339 }
280   - if (XmlUtil.getText(itemDevice, "RegisterWay") == null
281   - || XmlUtil.getText(itemDevice, "RegisterWay") == "") {
  340 +
  341 + String registerWay = XmlUtil.getText(itemDevice, "RegisterWay");
  342 + if (StringUtils.isEmpty(registerWay)) {
282 343 deviceChannel.setRegisterWay(1);
283 344 } else {
284   - deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay")));
  345 + deviceChannel.setRegisterWay(Integer.parseInt(registerWay));
285 346 }
286   - deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
  347 +
287 348 if (XmlUtil.getText(itemDevice, "Certifiable") == null
288 349 || XmlUtil.getText(itemDevice, "Certifiable") == "") {
289 350 deviceChannel.setCertifiable(0);
290 351 } else {
291 352 deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable")));
292 353 }
  354 +
293 355 if (XmlUtil.getText(itemDevice, "ErrCode") == null
294 356 || XmlUtil.getText(itemDevice, "ErrCode") == "") {
295 357 deviceChannel.setErrCode(0);
296 358 } else {
297 359 deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode")));
298 360 }
  361 +
299 362 deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime"));
300 363 deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy"));
301 364 deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress"));
... ... @@ -304,43 +367,23 @@ public class XmlUtil {
304 367 } else {
305 368 deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port")));
306 369 }
307   - deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
308   - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {
309   - deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude")));
  370 +
  371 +
  372 + String longitude = XmlUtil.getText(itemDevice, "Longitude");
  373 + if (NumericUtil.isDouble(longitude)) {
  374 + deviceChannel.setLongitude(Double.parseDouble(longitude));
310 375 } else {
311 376 deviceChannel.setLongitude(0.00);
312 377 }
313   - if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) {
314   - deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude")));
  378 + String latitude = XmlUtil.getText(itemDevice, "Latitude");
  379 + if (NumericUtil.isDouble(latitude)) {
  380 + deviceChannel.setLatitude(Double.parseDouble(latitude));
315 381 } else {
316 382 deviceChannel.setLatitude(0.00);
317 383 }
318 384 deviceChannel.setGpsTime(DateUtil.getNow());
319   - if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
320   - if ("WGS84".equals(device.getGeoCoordSys())) {
321   - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
322   - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
323   - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
324   - deviceChannel.setLongitudeGcj02(position[0]);
325   - deviceChannel.setLatitudeGcj02(position[1]);
326   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
327   - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
328   - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
329   - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
330   - deviceChannel.setLongitudeWgs84(position[0]);
331   - deviceChannel.setLatitudeWgs84(position[1]);
332   - }else {
333   - deviceChannel.setLongitudeGcj02(0.00);
334   - deviceChannel.setLatitudeGcj02(0.00);
335   - deviceChannel.setLongitudeWgs84(0.00);
336   - deviceChannel.setLatitudeWgs84(0.00);
337   - }
338   - }else {
339   - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
340   - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
341   - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
342   - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
343   - }
  385 +
  386 +
344 387 if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) {
345 388 //兼容INFO中的信息
346 389 Element info = itemDevice.element("Info");
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/AssistRESTfulUtils.java
... ... @@ -136,4 +136,12 @@ public class AssistRESTfulUtils {
136 136 return sendGet(mediaServerItem, "api/record/file/duration",param, callback);
137 137 }
138 138  
  139 + public JSONObject addStreamCallInfo(MediaServerItem mediaServerItem, String app, String stream, String callId, RequestCallback callback){
  140 + Map<String, Object> param = new HashMap<>();
  141 + param.put("app",app);
  142 + param.put("stream",stream);
  143 + param.put("callId",callId);
  144 + return sendGet(mediaServerItem, "api/record/addStreamCallInfo",param, callback);
  145 + }
  146 +
139 147 }
... ...
src/main/java/com/genersoft/iot/vmp/media/zlm/ZLMHttpHookListener.java
... ... @@ -87,6 +87,9 @@ public class ZLMHttpHookListener {
87 87 @Autowired
88 88 private VideoStreamSessionManager sessionManager;
89 89  
  90 + @Autowired
  91 + private AssistRESTfulUtils assistRESTfulUtils;
  92 +
90 93 /**
91 94 * 服务器定时上报时间,上报间隔可配置,默认10s上报一次
92 95 *
... ... @@ -200,6 +203,8 @@ public class ZLMHttpHookListener {
200 203  
201 204 logger.info("[ ZLM HOOK ]on_publish API调用,参数:" + json.toString());
202 205 JSONObject ret = new JSONObject();
  206 + String mediaServerId = json.getString("mediaServerId");
  207 + MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
203 208 if (!"rtp".equals(param.getApp())) {
204 209 // 推流鉴权
205 210 if (param.getParams() == null) {
... ... @@ -231,6 +236,10 @@ public class ZLMHttpHookListener {
231 236 streamAuthorityInfo.setSign(sign);
232 237 // 鉴权通过
233 238 redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
  239 + // 通知assist新的callId
  240 + if (mediaInfo != null) {
  241 + assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
  242 + }
234 243 }
235 244  
236 245 ret.put("code", 0);
... ... @@ -240,10 +249,9 @@ public class ZLMHttpHookListener {
240 249 ret.put("enable_audio", true);
241 250 }
242 251  
243   - String mediaServerId = json.getString("mediaServerId");
  252 +
244 253 ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
245 254 if (subscribe != null) {
246   - MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
247 255 if (mediaInfo != null) {
248 256 subscribe.response(mediaInfo, json);
249 257 }else {
... ... @@ -270,10 +278,12 @@ public class ZLMHttpHookListener {
270 278 ret.put("mp4_max_second", 10);
271 279 ret.put("enable_mp4", true);
272 280 ret.put("enable_audio", true);
  281 +
273 282 }
274 283 }
275 284  
276 285  
  286 +
277 287 return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
278 288 }
279 289  
... ...
src/main/java/com/genersoft/iot/vmp/service/IDeviceChannelService.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service;
  2 +
  3 +import com.genersoft.iot.vmp.gb28181.bean.Device;
  4 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  5 +
  6 +import java.util.List;
  7 +
  8 +/**
  9 + * 国标通道业务类
  10 + * @author lin
  11 + */
  12 +public interface IDeviceChannelService {
  13 +
  14 + /**
  15 + * 更新gps信息
  16 + */
  17 + DeviceChannel updateGps(DeviceChannel deviceChannel, Device device);
  18 +
  19 + /**
  20 + * 添加设备通道
  21 + *
  22 + * @param deviceId 设备id
  23 + * @param channel 通道
  24 + */
  25 + void updateChannel(String deviceId, DeviceChannel channel);
  26 +
  27 + /**
  28 + * 批量添加设备通道
  29 + *
  30 + * @param deviceId 设备id
  31 + * @param channels 多个通道
  32 + */
  33 + int updateChannels(String deviceId, List<DeviceChannel> channels);
  34 +
  35 +}
... ...
src/main/java/com/genersoft/iot/vmp/service/IGbStreamService.java
... ... @@ -18,7 +18,7 @@ public interface IGbStreamService {
18 18 * @param count
19 19 * @return
20 20 */
21   - PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId,String query,Boolean pushing,String mediaServerId);
  21 + PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId,String query,String mediaServerId);
22 22  
23 23  
24 24 /**
... ...
src/main/java/com/genersoft/iot/vmp/service/IPlatformChannelService.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service;
  2 +
  3 +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
  4 +
  5 +import java.util.List;
  6 +
  7 +/**
  8 + * 平台关联通道管理
  9 + * @author lin
  10 + */
  11 +public interface IPlatformChannelService {
  12 +
  13 + /**
  14 + * 更新目录下的通道
  15 + * @param platformId 平台编号
  16 + * @param channelReduces 通道信息
  17 + * @param catalogId 目录编号
  18 + * @return
  19 + */
  20 + int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
  21 +
  22 +}
... ...
src/main/java/com/genersoft/iot/vmp/service/IStreamProxyService.java
... ... @@ -101,4 +101,9 @@ public interface IStreamProxyService {
101 101 void zlmServerOffline(String mediaServerId);
102 102  
103 103 void clean();
  104 +
  105 + /**
  106 + * 更新代理流
  107 + */
  108 + boolean updateStreamProxy(StreamProxyItem streamProxyItem);
104 109 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceAlarmServiceImpl.java
... ... @@ -17,7 +17,6 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
17 17 @Autowired
18 18 private DeviceAlarmMapper deviceAlarmMapper;
19 19  
20   -
21 20 @Override
22 21 public PageInfo<DeviceAlarm> getAllAlarm(int page, int count, String deviceId, String alarmPriority, String alarmMethod, String alarmType, String startTime, String endTime) {
23 22 PageHelper.startPage(page, count);
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceChannelServiceImpl.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service.impl;
  2 +
  3 +import com.genersoft.iot.vmp.common.StreamInfo;
  4 +import com.genersoft.iot.vmp.gb28181.bean.Device;
  5 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  6 +import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
  7 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
  8 +import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
  9 +import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
  10 +import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
  11 +import com.genersoft.iot.vmp.utils.DateUtil;
  12 +import org.slf4j.Logger;
  13 +import org.slf4j.LoggerFactory;
  14 +import org.springframework.beans.factory.annotation.Autowired;
  15 +import org.springframework.stereotype.Service;
  16 +
  17 +import java.util.ArrayList;
  18 +import java.util.HashMap;
  19 +import java.util.List;
  20 +
  21 +/**
  22 + * @author lin
  23 + */
  24 +@Service
  25 +public class DeviceChannelServiceImpl implements IDeviceChannelService {
  26 +
  27 + private final static Logger logger = LoggerFactory.getLogger(DeviceChannelServiceImpl.class);
  28 +
  29 + @Autowired
  30 + private IRedisCatchStorage redisCatchStorage;
  31 +
  32 + @Autowired
  33 + private DeviceChannelMapper channelMapper;
  34 +
  35 + @Autowired
  36 + private DeviceMapper deviceMapper;
  37 +
  38 + @Override
  39 + public DeviceChannel updateGps(DeviceChannel deviceChannel, Device device) {
  40 + if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
  41 + if (device == null) {
  42 + device = deviceMapper.getDeviceByDeviceId(deviceChannel.getDeviceId());
  43 + }
  44 +
  45 + if ("WGS84".equals(device.getGeoCoordSys())) {
  46 + deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
  47 + deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
  48 + Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
  49 + deviceChannel.setLongitudeGcj02(position[0]);
  50 + deviceChannel.setLatitudeGcj02(position[1]);
  51 + }else if ("GCJ02".equals(device.getGeoCoordSys())) {
  52 + deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
  53 + deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
  54 + Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
  55 + deviceChannel.setLongitudeWgs84(position[0]);
  56 + deviceChannel.setLatitudeWgs84(position[1]);
  57 + }else {
  58 + deviceChannel.setLongitudeGcj02(0.00);
  59 + deviceChannel.setLatitudeGcj02(0.00);
  60 + deviceChannel.setLongitudeWgs84(0.00);
  61 + deviceChannel.setLatitudeWgs84(0.00);
  62 + }
  63 + }else {
  64 + deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
  65 + deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
  66 + deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
  67 + deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
  68 + }
  69 + return deviceChannel;
  70 + }
  71 +
  72 + @Override
  73 + public void updateChannel(String deviceId, DeviceChannel channel) {
  74 + String channelId = channel.getChannelId();
  75 + channel.setDeviceId(deviceId);
  76 + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
  77 + if (streamInfo != null) {
  78 + channel.setStreamId(streamInfo.getStream());
  79 + }
  80 + String now = DateUtil.getNow();
  81 + channel.setUpdateTime(now);
  82 + DeviceChannel deviceChannel = channelMapper.queryChannel(deviceId, channelId);
  83 + channel = updateGps(channel, null);
  84 + if (deviceChannel == null) {
  85 + channel.setCreateTime(now);
  86 + channelMapper.add(channel);
  87 + }else {
  88 + channelMapper.update(channel);
  89 + }
  90 + channelMapper.updateChannelSubCount(deviceId,channel.getParentId());
  91 + }
  92 +
  93 + @Override
  94 + public int updateChannels(String deviceId, List<DeviceChannel> channels) {
  95 + List<DeviceChannel> addChannels = new ArrayList<>();
  96 + List<DeviceChannel> updateChannels = new ArrayList<>();
  97 + HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
  98 + Device device = deviceMapper.getDeviceByDeviceId(deviceId);
  99 + if (channels != null && channels.size() > 0) {
  100 + List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null);
  101 + if (channelList.size() == 0) {
  102 + for (DeviceChannel channel : channels) {
  103 + channel.setDeviceId(deviceId);
  104 + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
  105 + if (streamInfo != null) {
  106 + channel.setStreamId(streamInfo.getStream());
  107 + }
  108 + String now = DateUtil.getNow();
  109 + channel.setUpdateTime(now);
  110 + channel.setCreateTime(now);
  111 + channel = updateGps(channel, device);
  112 + addChannels.add(channel);
  113 + }
  114 + }else {
  115 + for (DeviceChannel deviceChannel : channelList) {
  116 + channelsInStore.put(deviceChannel.getChannelId(), deviceChannel);
  117 + }
  118 + for (DeviceChannel channel : channels) {
  119 + channel.setDeviceId(deviceId);
  120 + StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
  121 + if (streamInfo != null) {
  122 + channel.setStreamId(streamInfo.getStream());
  123 + }
  124 + String now = DateUtil.getNow();
  125 + channel.setUpdateTime(now);
  126 + channel = updateGps(channel, device);
  127 + if (channelsInStore.get(channel.getChannelId()) != null) {
  128 + updateChannels.add(channel);
  129 + }else {
  130 + addChannels.add(channel);
  131 + channel.setCreateTime(now);
  132 + }
  133 + }
  134 + }
  135 + int limitCount = 300;
  136 + if (addChannels.size() > 0) {
  137 + if (addChannels.size() > limitCount) {
  138 + for (int i = 0; i < addChannels.size(); i += limitCount) {
  139 + int toIndex = i + limitCount;
  140 + if (i + limitCount > addChannels.size()) {
  141 + toIndex = addChannels.size();
  142 + }
  143 + channelMapper.batchAdd(addChannels.subList(i, toIndex));
  144 + }
  145 + }else {
  146 + channelMapper.batchAdd(addChannels);
  147 + }
  148 + }
  149 + if (updateChannels.size() > 0) {
  150 + if (updateChannels.size() > limitCount) {
  151 + for (int i = 0; i < updateChannels.size(); i += limitCount) {
  152 + int toIndex = i + limitCount;
  153 + if (i + limitCount > updateChannels.size()) {
  154 + toIndex = updateChannels.size();
  155 + }
  156 + channelMapper.batchUpdate(updateChannels.subList(i, toIndex));
  157 + }
  158 + }else {
  159 + channelMapper.batchUpdate(updateChannels);
  160 + }
  161 + }
  162 + }
  163 + return addChannels.size() + updateChannels.size();
  164 + }
  165 +}
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
... ... @@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
7 7 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
8 8 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
9 9 import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
  10 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
10 11 import com.genersoft.iot.vmp.service.IDeviceService;
11 12 import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
12 13 import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
... ... @@ -56,6 +57,9 @@ public class DeviceServiceImpl implements IDeviceService {
56 57 private DeviceMapper deviceMapper;
57 58  
58 59 @Autowired
  60 + private IDeviceChannelService deviceChannelService;
  61 +
  62 + @Autowired
59 63 private DeviceChannelMapper deviceChannelMapper;
60 64  
61 65 @Autowired
... ... @@ -324,23 +328,12 @@ public class DeviceServiceImpl implements IDeviceService {
324 328 private void updateDeviceChannelGeoCoordSys(Device device) {
325 329 List<DeviceChannel> deviceChannels = deviceChannelMapper.getAllChannelWithCoordinate(device.getDeviceId());
326 330 if (deviceChannels.size() > 0) {
  331 + List<DeviceChannel> deviceChannelsForStore = new ArrayList<>();
327 332 for (DeviceChannel deviceChannel : deviceChannels) {
328   - if ("WGS84".equals(device.getGeoCoordSys())) {
329   - deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
330   - deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
331   - Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
332   - deviceChannel.setLongitudeGcj02(position[0]);
333   - deviceChannel.setLatitudeGcj02(position[1]);
334   - }else if ("GCJ02".equals(device.getGeoCoordSys())) {
335   - deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
336   - deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
337   - Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
338   - deviceChannel.setLongitudeWgs84(position[0]);
339   - deviceChannel.setLatitudeWgs84(position[1]);
340   - }
  333 + deviceChannelsForStore.add(deviceChannelService.updateGps(deviceChannel, device));
341 334 }
  335 + deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore);
342 336 }
343   - storage.updateChannels(device.getDeviceId(), deviceChannels);
344 337 }
345 338  
346 339  
... ... @@ -352,11 +345,11 @@ public class DeviceServiceImpl implements IDeviceService {
352 345 }
353 346 if (parentId == null || parentId.equals(deviceId)) {
354 347 // 字根节点开始查询
355   - List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), true, !onlyCatalog);
  348 + List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), true, !onlyCatalog);
356 349 return transportChannelsToTree(rootNodes, "");
357 350 }
358 351  
359   - if ("CivilCode".equals(device.getTreeType())) {
  352 + if (TreeType.CIVIL_CODE.equals(device.getTreeType())) {
360 353 if (parentId.length()%2 != 0) {
361 354 return null;
362 355 }
... ... @@ -386,7 +379,7 @@ public class DeviceServiceImpl implements IDeviceService {
386 379  
387 380 }
388 381 // 使用业务分组展示树
389   - if ("BusinessGroup".equals(device.getTreeType())) {
  382 + if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) {
390 383 if (parentId.length() < 14 ) {
391 384 return null;
392 385 }
... ... @@ -406,11 +399,11 @@ public class DeviceServiceImpl implements IDeviceService {
406 399 }
407 400 if (parentId == null || parentId.equals(deviceId)) {
408 401 // 字根节点开始查询
409   - List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), false, true);
  402 + List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), false, true);
410 403 return rootNodes;
411 404 }
412 405  
413   - if ("CivilCode".equals(device.getTreeType())) {
  406 + if (TreeType.CIVIL_CODE.equals(device.getTreeType())) {
414 407 if (parentId.length()%2 != 0) {
415 408 return null;
416 409 }
... ... @@ -431,7 +424,7 @@ public class DeviceServiceImpl implements IDeviceService {
431 424  
432 425 }
433 426 // 使用业务分组展示树
434   - if ("BusinessGroup".equals(device.getTreeType())) {
  427 + if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) {
435 428 if (parentId.length() < 14 ) {
436 429 return null;
437 430 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/GbStreamServiceImpl.java
1 1 package com.genersoft.iot.vmp.service.impl;
2 2  
3 3 import com.genersoft.iot.vmp.conf.SipConfig;
4   -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
5   -import com.genersoft.iot.vmp.gb28181.bean.GbStream;
6   -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
  4 +import com.genersoft.iot.vmp.gb28181.bean.*;
7 5 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
8 6 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
9 7 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
10 8 import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
11 9 import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
  10 +import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper;
12 11 import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
13 12 import com.genersoft.iot.vmp.service.IGbStreamService;
14 13 import com.github.pagehelper.PageHelper;
... ... @@ -46,15 +45,15 @@ public class GbStreamServiceImpl implements IGbStreamService {
46 45 private ParentPlatformMapper platformMapper;
47 46  
48 47 @Autowired
49   - private SipConfig sipConfig;
  48 + private PlatformCatalogMapper catalogMapper;
50 49  
51 50 @Autowired
52 51 private EventPublisher eventPublisher;
53 52  
54 53 @Override
55   - public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId, String query, Boolean pushing, String mediaServerId) {
  54 + public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId, String query, String mediaServerId) {
56 55 PageHelper.startPage(page, count);
57   - List<GbStream> all = gbStreamMapper.selectAll(platFormId, catalogId, query, pushing, mediaServerId);
  56 + List<GbStream> all = gbStreamMapper.selectAll(platFormId, catalogId, query, mediaServerId);
58 57 return new PageInfo<>(all);
59 58 }
60 59  
... ... @@ -102,16 +101,25 @@ public class GbStreamServiceImpl implements IGbStreamService {
102 101 deviceChannel.setLatitude(gbStream.getLatitude());
103 102 deviceChannel.setDeviceId(platform.getDeviceGBId());
104 103 deviceChannel.setManufacture("wvp-pro");
105   -// deviceChannel.setStatus(gbStream.isStatus()?1:0);
106   - deviceChannel.setStatus(1);
107   - deviceChannel.setParentId(catalogId ==null?gbStream.getCatalogId():catalogId);
  104 + deviceChannel.setStatus(gbStream.isStatus()?1:0);
  105 +
108 106 deviceChannel.setRegisterWay(1);
109   - if (catalogId.length() > 0 && catalogId.length() <= 10) {
110   - // 父节点是行政区划,则设置CivilCode使用此行政区划
  107 + deviceChannel.setCivilCode(platform.getAdministrativeDivision());
  108 +
  109 + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
111 110 deviceChannel.setCivilCode(catalogId);
112   - }else {
113   - deviceChannel.setCivilCode(platform.getAdministrativeDivision());
  111 + }else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
  112 + PlatformCatalog catalog = catalogMapper.select(catalogId);
  113 + if (catalog == null) {
  114 + deviceChannel.setParentId(platform.getDeviceGBId());
  115 + deviceChannel.setBusinessGroupId(null);
  116 + }else {
  117 + deviceChannel.setParentId(catalog.getId());
  118 + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
  119 + }
  120 +
114 121 }
  122 +
115 123 deviceChannel.setModel("live");
116 124 deviceChannel.setOwner("wvp-pro");
117 125 deviceChannel.setParental(0);
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/PlatformChannelServiceImpl.java 0 → 100644
  1 +package com.genersoft.iot.vmp.service.impl;
  2 +
  3 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  4 +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
  5 +import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
  6 +import com.genersoft.iot.vmp.gb28181.bean.TreeType;
  7 +import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
  8 +import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
  9 +import com.genersoft.iot.vmp.service.IPlatformChannelService;
  10 +import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
  11 +import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
  12 +import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper;
  13 +import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper;
  14 +import com.genersoft.iot.vmp.vmanager.gb28181.platform.PlatformController;
  15 +import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
  16 +import com.sun.org.apache.xml.internal.resolver.CatalogManager;
  17 +import javafx.application.Platform;
  18 +import org.apache.ibatis.annotations.Mapper;
  19 +import org.slf4j.Logger;
  20 +import org.slf4j.LoggerFactory;
  21 +import org.springframework.beans.factory.annotation.Autowired;
  22 +import org.springframework.stereotype.Service;
  23 +
  24 +import java.util.ArrayList;
  25 +import java.util.HashMap;
  26 +import java.util.List;
  27 +import java.util.Map;
  28 +
  29 +/**
  30 + * @author lin
  31 + */
  32 +@Service
  33 +public class PlatformChannelServiceImpl implements IPlatformChannelService {
  34 +
  35 + private final static Logger logger = LoggerFactory.getLogger(PlatformChannelServiceImpl.class);
  36 +
  37 + @Autowired
  38 + private PlatformChannelMapper platformChannelMapper;
  39 +
  40 + @Autowired
  41 + private DeviceChannelMapper deviceChannelMapper;
  42 +
  43 + @Autowired
  44 + private PlatformCatalogMapper catalogManager;
  45 +
  46 + @Autowired
  47 + private ParentPlatformMapper platformMapper;
  48 +
  49 + @Autowired
  50 + EventPublisher eventPublisher;
  51 +
  52 + @Override
  53 + public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
  54 + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId);
  55 + if (platform == null) {
  56 + logger.warn("更新级联通道信息时未找到平台{}的信息", platformId);
  57 + return 0;
  58 + }
  59 + Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
  60 + for (ChannelReduce channelReduce : channelReduces) {
  61 + channelReduce.setCatalogId(catalogId);
  62 + deviceAndChannels.put(channelReduce.getId(), channelReduce);
  63 + }
  64 + List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
  65 + // 查询当前已经存在的
  66 + List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
  67 + if (deviceAndChannelList != null) {
  68 + deviceAndChannelList.removeAll(channelIds);
  69 + }
  70 + for (Integer channelId : channelIds) {
  71 + deviceAndChannels.remove(channelId);
  72 + }
  73 + List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
  74 + // 对剩下的数据进行存储
  75 + int result = 0;
  76 + if (channelReducesToAdd.size() > 0) {
  77 + result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
  78 + // TODO 后续给平台增加控制开关以控制是否响应目录订阅
  79 + List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform);
  80 + eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
  81 + }
  82 +
  83 + return result;
  84 + }
  85 +
  86 + private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) {
  87 + List<DeviceChannel> deviceChannelList = new ArrayList<>();
  88 + if (channelReduces.size() > 0){
  89 + PlatformCatalog catalog = catalogManager.select(catalogId);
  90 + if (catalog == null && !catalogId.equals(platform.getServerGBId())) {
  91 + logger.warn("未查询到目录{}的信息", catalogId);
  92 + return null;
  93 + }
  94 + for (ChannelReduce channelReduce : channelReduces) {
  95 + DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
  96 + deviceChannel.setParental(0);
  97 + deviceChannelList.add(deviceChannel);
  98 + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
  99 + deviceChannel.setCivilCode(catalogId);
  100 + }else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
  101 + deviceChannel.setParentId(catalogId);
  102 + if (catalog != null) {
  103 + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
  104 + }
  105 + }
  106 + }
  107 + }
  108 + return deviceChannelList;
  109 + }
  110 +}
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/RedisPushStreamStatusMsgListener.java
... ... @@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
15 15 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
16 16 import com.genersoft.iot.vmp.service.IStreamPushService;
17 17 import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto;
  18 +import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis;
18 19 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
19 20 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
20 21 import org.slf4j.Logger;
... ... @@ -26,6 +27,7 @@ import org.springframework.data.redis.connection.Message;
26 27 import org.springframework.data.redis.connection.MessageListener;
27 28 import org.springframework.stereotype.Component;
28 29  
  30 +import java.util.ArrayList;
29 31 import java.util.List;
30 32  
31 33  
... ... @@ -55,7 +57,6 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
55 57  
56 58 @Override
57 59 public void onMessage(Message message, byte[] bytes) {
58   -
59 60 PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(message.getBody(), PushStreamStatusChangeFromRedisDto.class);
60 61 if (statusChangeFromPushStream == null) {
61 62 logger.warn("[REDIS 消息]推流设备状态变化消息解析失败");
... ... @@ -65,11 +66,13 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
65 66 // 所有设备离线
66 67 streamPushService.allStreamOffline();
67 68 }
68   - if (statusChangeFromPushStream.getOfflineStreams().size() > 0) {
  69 + if (statusChangeFromPushStream.getOfflineStreams() != null
  70 + && statusChangeFromPushStream.getOfflineStreams().size() > 0) {
69 71 // 更新部分设备离线
70 72 streamPushService.offline(statusChangeFromPushStream.getOfflineStreams());
71 73 }
72   - if (statusChangeFromPushStream.getOnlineStreams().size() > 0) {
  74 + if (statusChangeFromPushStream.getOnlineStreams() != null &&
  75 + statusChangeFromPushStream.getOnlineStreams().size() > 0) {
73 76 // 更新部分设备上线
74 77 streamPushService.online(statusChangeFromPushStream.getOnlineStreams());
75 78 }
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamProxyServiceImpl.java
... ... @@ -3,10 +3,10 @@ package com.genersoft.iot.vmp.service.impl;
3 3 import com.alibaba.fastjson.JSONArray;
4 4 import com.alibaba.fastjson.JSONObject;
5 5 import com.genersoft.iot.vmp.common.StreamInfo;
6   -import com.genersoft.iot.vmp.conf.SipConfig;
7 6 import com.genersoft.iot.vmp.conf.UserSetting;
8 7 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
9 8 import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
  9 +import com.genersoft.iot.vmp.gb28181.bean.TreeType;
10 10 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
11 11 import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
12 12 import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
... ... @@ -23,14 +23,19 @@ import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
23 23 import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
24 24 import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
25 25 import com.genersoft.iot.vmp.service.IStreamProxyService;
  26 +import com.genersoft.iot.vmp.utils.DateUtil;
26 27 import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
27 28 import com.github.pagehelper.PageInfo;
28 29 import org.slf4j.Logger;
29 30 import org.slf4j.LoggerFactory;
30 31 import org.springframework.beans.factory.annotation.Autowired;
  32 +import org.springframework.jdbc.datasource.DataSourceTransactionManager;
31 33 import org.springframework.stereotype.Service;
  34 +import org.springframework.transaction.TransactionDefinition;
  35 +import org.springframework.transaction.TransactionStatus;
32 36 import org.springframework.util.StringUtils;
33 37  
  38 +import java.net.InetAddress;
34 39 import java.util.*;
35 40  
36 41 /**
... ... @@ -48,7 +53,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
48 53 private IMediaService mediaService;
49 54  
50 55 @Autowired
51   - private ZLMRESTfulUtils zlmresTfulUtils;;
  56 + private ZLMRESTfulUtils zlmresTfulUtils;
52 57  
53 58 @Autowired
54 59 private StreamProxyMapper streamProxyMapper;
... ... @@ -63,9 +68,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
63 68 private UserSetting userSetting;
64 69  
65 70 @Autowired
66   - private SipConfig sipConfig;
67   -
68   - @Autowired
69 71 private GbStreamMapper gbStreamMapper;
70 72  
71 73 @Autowired
... ... @@ -83,6 +85,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
83 85 @Autowired
84 86 private IMediaServerService mediaServerService;
85 87  
  88 + @Autowired
  89 + DataSourceTransactionManager dataSourceTransactionManager;
  90 +
  91 + @Autowired
  92 + TransactionDefinition transactionDefinition;
  93 +
86 94  
87 95 @Override
88 96 public WVPResult<StreamInfo> save(StreamProxyItem param) {
... ... @@ -99,6 +107,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
99 107 wvpResult.setMsg("保存失败");
100 108 return wvpResult;
101 109 }
  110 +
102 111 String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
103 112 param.getStream() );
104 113 param.setDst_url(dstUrl);
... ... @@ -108,9 +117,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
108 117 boolean saveResult;
109 118 // 更新
110 119 if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) {
111   - saveResult = videoManagerStorager.updateStreamProxy(param);
  120 + saveResult = updateStreamProxy(param);
112 121 }else { // 新增
113   - saveResult = videoManagerStorager.addStreamProxy(param);
  122 + saveResult = addStreamProxy(param);
114 123 }
115 124 if (saveResult) {
116 125 result.append("保存成功");
... ... @@ -124,7 +133,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
124 133 if (param.isEnable_remove_none_reader()) {
125 134 del(param.getApp(), param.getStream());
126 135 }else {
127   - videoManagerStorager.updateStreamProxy(param);
  136 + updateStreamProxy(param);
128 137 }
129 138  
130 139 }else {
... ... @@ -154,6 +163,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
154 163 for (ParentPlatform parentPlatform : parentPlatforms) {
155 164 param.setPlatformId(parentPlatform.getServerGBId());
156 165 param.setCatalogId(parentPlatform.getCatalogId());
  166 +
157 167 String stream = param.getStream();
158 168 StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId());
159 169 if (streamProxyItems == null) {
... ... @@ -168,6 +178,77 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
168 178 return wvpResult;
169 179 }
170 180  
  181 + /**
  182 + * 新增代理流
  183 + * @param streamProxyItem
  184 + * @return
  185 + */
  186 + private boolean addStreamProxy(StreamProxyItem streamProxyItem) {
  187 + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
  188 + boolean result = false;
  189 + streamProxyItem.setStreamType("proxy");
  190 + streamProxyItem.setStatus(true);
  191 + String now = DateUtil.getNow();
  192 + streamProxyItem.setCreateTime(now);
  193 + try {
  194 + if (streamProxyMapper.add(streamProxyItem) > 0) {
  195 + if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
  196 + if (gbStreamMapper.add(streamProxyItem) < 0) {
  197 + //事务回滚
  198 + dataSourceTransactionManager.rollback(transactionStatus);
  199 + return false;
  200 + }
  201 + }
  202 + }else {
  203 + //事务回滚
  204 + dataSourceTransactionManager.rollback(transactionStatus);
  205 + return false;
  206 + }
  207 + result = true;
  208 + dataSourceTransactionManager.commit(transactionStatus); //手动提交
  209 + }catch (Exception e) {
  210 + logger.error("向数据库添加流代理失败:", e);
  211 + dataSourceTransactionManager.rollback(transactionStatus);
  212 + }
  213 +
  214 +
  215 + return result;
  216 + }
  217 +
  218 + /**
  219 + * 更新代理流
  220 + * @param streamProxyItem
  221 + * @return
  222 + */
  223 + @Override
  224 + public boolean updateStreamProxy(StreamProxyItem streamProxyItem) {
  225 + TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
  226 + boolean result = false;
  227 + streamProxyItem.setStreamType("proxy");
  228 + try {
  229 + if (streamProxyMapper.update(streamProxyItem) > 0) {
  230 + if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
  231 + if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) {
  232 + //事务回滚
  233 + dataSourceTransactionManager.rollback(transactionStatus);
  234 + return false;
  235 + }
  236 + }
  237 + } else {
  238 + //事务回滚
  239 + dataSourceTransactionManager.rollback(transactionStatus);
  240 + return false;
  241 + }
  242 +
  243 + dataSourceTransactionManager.commit(transactionStatus); //手动提交
  244 + result = true;
  245 + }catch (Exception e) {
  246 + e.printStackTrace();
  247 + dataSourceTransactionManager.rollback(transactionStatus);
  248 + }
  249 + return result;
  250 + }
  251 +
171 252 @Override
172 253 public JSONObject addStreamProxyToZlm(StreamProxyItem param) {
173 254 JSONObject result = null;
... ... @@ -239,7 +320,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
239 320 if (jsonObject.getInteger("code") == 0) {
240 321 result = true;
241 322 streamProxy.setEnable(true);
242   - videoManagerStorager.updateStreamProxy(streamProxy);
  323 + updateStreamProxy(streamProxy);
243 324 }
244 325 }
245 326 return result;
... ... @@ -253,7 +334,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
253 334 JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto);
254 335 if (jsonObject != null && jsonObject.getInteger("code") == 0) {
255 336 streamProxyDto.setEnable(false);
256   - result = videoManagerStorager.updateStreamProxy(streamProxyDto);
  337 + result = updateStreamProxy(streamProxyDto);
257 338 }
258 339 }
259 340 return result;
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushServiceImpl.java
... ... @@ -488,7 +488,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
488 488 if (onlinePushers.size() == 0) {
489 489 return;
490 490 }
491   - streamPushMapper.allStreamOffline();
  491 + streamPushMapper.setAllStreamOffline();
492 492  
493 493 // 发送通知
494 494 eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF);
... ...
src/main/java/com/genersoft/iot/vmp/service/impl/StreamPushUploadFileHandler.java
... ... @@ -14,38 +14,60 @@ import java.util.*;
14 14  
15 15 public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> {
16 16  
17   - // 错误数据的回调,用于将错误数据发送给页面
  17 + /**
  18 + * 错误数据的回调,用于将错误数据发送给页面
  19 + */
18 20 private ErrorDataHandler errorDataHandler;
19 21  
20   - // 推流的业务类用于存储数据
  22 + /**
  23 + * 推流的业务类用于存储数据
  24 + */
21 25 private IStreamPushService pushService;
22 26  
23   - // 默认流媒体节点ID
  27 + /**
  28 + * 默认流媒体节点ID
  29 + */
24 30 private String defaultMediaServerId;
25 31  
26   - // 用于存储不加过滤的所有数据
  32 + /**
  33 + * 用于存储不加过滤的所有数据
  34 + */
27 35 private List<StreamPushItem> streamPushItems = new ArrayList<>();
28 36  
29   - // 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表
  37 + /**
  38 + * 用于存储更具APP+Stream过滤后的数据,可以直接存入stream_push表与gb_stream表
  39 + */
30 40 private Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>();
31 41  
32   - // 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表
  42 + /**
  43 + * 用于存储按照APP+Stream为KEY, 平台ID+目录Id 为value的数据,用于存储到gb_stream表后获取app+Stream对应的平台与目录信息,然后存入关联表
  44 + */
33 45 private Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>();
34 46  
35   - // 用于判断文件是否存在重复的app+Stream+平台ID
  47 + /**
  48 + * 用于判断文件是否存在重复的app+Stream+平台ID
  49 + */
36 50 private Set<String> streamPushStreamSet = new HashSet<>();
37 51  
38   - // 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应,全局判断APP+Stream->国标ID是否存在不对应
  52 + /**
  53 + * 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应,全局判断APP+Stream->国标ID是否存在不对应
  54 + */
39 55 private BiMap<String,String> gBMap = HashBiMap.create();
40 56  
41   - // 记录错误的APP+Stream
  57 + /**
  58 + * 记录错误的APP+Stream
  59 + */
42 60 private List<String> errorStreamList = new ArrayList<>();
43 61  
44 62  
45   - // 记录错误的国标ID
  63 + /**
  64 + * 记录错误的国标ID
  65 + */
46 66 private List<String> errorGBList = new ArrayList<>();
47 67  
48   - // 读取数量计数器
  68 + /**
  69 + * 读取数量计数器
  70 + */
49 71 private int loadedSize = 0;
50 72  
51 73 public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId, ErrorDataHandler errorDataHandler) {
... ...
src/main/java/com/genersoft/iot/vmp/storager/IVideoManagerStorage.java
... ... @@ -27,22 +27,6 @@ public interface IVideoManagerStorage {
27 27 public boolean exists(String deviceId);
28 28  
29 29 /**
30   - * 添加设备通道
31   - *
32   - * @param deviceId 设备id
33   - * @param channel 通道
34   - */
35   - public void updateChannel(String deviceId, DeviceChannel channel);
36   -
37   - /**
38   - * 批量添加设备通道
39   - *
40   - * @param deviceId 设备id
41   - * @param channels 多个通道
42   - */
43   - public int updateChannels(String deviceId, List<DeviceChannel> channels);
44   -
45   - /**
46 30 * 开始播放
47 31 * @param deviceId 设备id
48 32 * @param channelId 通道ID
... ... @@ -224,13 +208,6 @@ public interface IVideoManagerStorage {
224 208 List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId);
225 209  
226 210  
227   - /**
228   - * 更新上级平台的通道信息
229   - * @param platformId
230   - * @param channelReduces
231   - * @return
232   - */
233   - int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
234 211  
235 212 /**
236 213 * 移除上级平台的通道信息
... ... @@ -277,20 +254,6 @@ public interface IVideoManagerStorage {
277 254 public int clearMobilePositionsByDeviceId(String deviceId);
278 255  
279 256 /**
280   - * 新增代理流
281   - * @param streamProxyDto
282   - * @return
283   - */
284   - public boolean addStreamProxy(StreamProxyItem streamProxyDto);
285   -
286   - /**
287   - * 更新代理流
288   - * @param streamProxyDto
289   - * @return
290   - */
291   - public boolean updateStreamProxy(StreamProxyItem streamProxyDto);
292   -
293   - /**
294 257 * 移除代理流
295 258 * @param app
296 259 * @param stream
... ... @@ -334,7 +297,7 @@ public interface IVideoManagerStorage {
334 297 * @param platformId
335 298 * @return
336 299 */
337   - List<GbStream> queryGbStreamListInPlatform(String platformId);
  300 + List<DeviceChannel> queryGbStreamListInPlatform(String platformId);
338 301  
339 302 /**
340 303 * 批量更新推流列表
... ... @@ -445,7 +408,7 @@ public interface IVideoManagerStorage {
445 408  
446 409 int setDefaultCatalog(String platformId, String catalogId);
447 410  
448   - List<PlatformCatalog> queryCatalogInPlatform(String serverGBId);
  411 + List<DeviceChannel> queryCatalogInPlatform(String serverGBId);
449 412  
450 413 int delRelation(PlatformCatalog platformCatalog);
451 414  
... ... @@ -466,4 +429,8 @@ public interface IVideoManagerStorage {
466 429 List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
467 430  
468 431 void updateChannelPosition(DeviceChannel deviceChannel);
  432 +
  433 + void cleanContentForPlatform(String serverGBId);
  434 +
  435 + List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
469 436 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/DeviceChannelMapper.java
... ... @@ -329,5 +329,13 @@ public interface DeviceChannelMapper {
329 329 @Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}")
330 330 List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode);
331 331  
332   -
  332 + @Select("select dc.id, dc.channelId, dc.deviceId, dc.name, dc.manufacture,dc.model,dc.owner, pc.civilCode,dc.block, " +
  333 + " dc.address, '0' as parental,'0' as channelType, pc.id as parentId, dc.safetyWay, dc.registerWay,dc.certNum, dc.certifiable, " +
  334 + " dc.errCode,dc.endTime, dc.secrecy, dc.ipAddress, dc.port, dc.PTZType, dc.password, dc.status, " +
  335 + " dc.longitudeWgs84 as longitude, dc.latitudeWgs84 as latitude, pc.businessGroupId " +
  336 + " from device_channel dc" +
  337 + " left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId" +
  338 + " left join platform_catalog pc on pgc.catalogId = pc.id and pgc.platformId = pc.platformId" +
  339 + " where pgc.platformId=#{serverGBId}")
  340 + List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
333 341 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/GbStreamMapper.java
1 1 package com.genersoft.iot.vmp.storager.dao;
2 2  
  3 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
3 4 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
4 5 import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
5 6 import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
... ... @@ -15,10 +16,10 @@ import java.util.List;
15 16 public interface GbStreamMapper {
16 17  
17 18 @Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
18   - "longitude, latitude, streamType, mediaServerId, status, createTime) VALUES" +
  19 + "longitude, latitude, streamType, mediaServerId, createTime) VALUES" +
19 20 "('${app}', '${stream}', '${gbId}', '${name}', " +
20 21 "'${longitude}', '${latitude}', '${streamType}', " +
21   - "'${mediaServerId}', ${status}, '${createTime}')")
  22 + "'${mediaServerId}', '${createTime}')")
22 23 @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
23 24 int add(GbStream gbStream);
24 25  
... ... @@ -30,8 +31,7 @@ public interface GbStreamMapper {
30 31 "streamType=#{streamType}," +
31 32 "longitude=#{longitude}, " +
32 33 "latitude=#{latitude}," +
33   - "mediaServerId=#{mediaServerId}," +
34   - "status=${status} " +
  34 + "mediaServerId=#{mediaServerId}" +
35 35 "WHERE app=#{app} AND stream=#{stream}")
36 36 int updateByAppAndStream(GbStream gbStream);
37 37  
... ... @@ -43,8 +43,7 @@ public interface GbStreamMapper {
43 43 "streamType=#{streamType}," +
44 44 "longitude=#{longitude}, " +
45 45 "latitude=#{latitude}," +
46   - "mediaServerId=#{mediaServerId}," +
47   - "status=${status} " +
  46 + "mediaServerId=#{mediaServerId}" +
48 47 "WHERE gbStreamId=#{gbStreamId}")
49 48 int update(GbStream gbStream);
50 49  
... ... @@ -60,12 +59,10 @@ public interface GbStreamMapper {
60 59 " <if test='catalogId == null'> AND gs.gbStreamId not in" +
61 60 "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " +
62 61 " <if test='query != null'> AND (gs.app LIKE '%${query}%' OR gs.stream LIKE '%${query}%' OR gs.gbId LIKE '%${query}%' OR gs.name LIKE '%${query}%')</if> " +
63   - " <if test='pushing == true' > AND gs.status=1</if>" +
64   - " <if test='pushing == false' > AND gs.status=0</if>" +
65 62 " <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" +
66 63 " order by gs.gbStreamId asc " +
67 64 "</script>")
68   - List<GbStream> selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId);
  65 + List<GbStream> selectAll(String platformId, String catalogId, String query, String mediaServerId);
69 66  
70 67 @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
71 68 GbStream selectOne(String app, String stream);
... ... @@ -78,10 +75,18 @@ public interface GbStreamMapper {
78 75 "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
79 76 GbStream queryStreamInPlatform(String platformId, String gbId);
80 77  
81   - @Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " +
82   - "LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " +
83   - "WHERE pgs.platformId = #{platformId}")
84   - List<GbStream> queryGbStreamListInPlatform(String platformId);
  78 + @Select("select gt.gbId as channelId, gt.name, 'wvp-pro' as manufacture, st.status, gt.longitude, gt.latitude, pc.id as parentId," +
  79 + " '1' as registerWay, pc.civilCode, 'live' as model, 'wvp-pro' as owner, '0' as parental,'0' as secrecy" +
  80 + " from gb_stream gt " +
  81 + " left join (" +
  82 + " select sp.status, sp.app, sp.stream from stream_push sp" +
  83 + " union all" +
  84 + " select spxy.status, spxy.app, spxy.stream from stream_proxy spxy" +
  85 + " ) st on st.app = gt.app and st.stream = gt.stream" +
  86 + " left join platform_gb_stream pgs on gt.gbStreamId = pgs.gbStreamId" +
  87 + " left join platform_catalog pc on pgs.catalogId = pc.id and pgs.platformId = pc.platformId" +
  88 + " where pgs.platformId=#{platformId}")
  89 + List<DeviceChannel> queryGbStreamListInPlatform(String platformId);
85 90  
86 91  
87 92 @Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " +
... ... @@ -110,12 +115,12 @@ public interface GbStreamMapper {
110 115 @Insert("<script> " +
111 116 "INSERT IGNORE into gb_stream " +
112 117 "(app, stream, gbId, name, " +
113   - "longitude, latitude, streamType, mediaServerId, status, createTime)" +
  118 + "longitude, latitude, streamType, mediaServerId, createTime)" +
114 119 "values " +
115 120 "<foreach collection='subList' index='index' item='item' separator=','> " +
116 121 "('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " +
117 122 "'${item.longitude}', '${item.latitude}', '${item.streamType}', " +
118   - "'${item.mediaServerId}', ${item.status}, '${item.createTime}') "+
  123 + "'${item.mediaServerId}', '${item.createTime}') "+
119 124 "</foreach> " +
120 125 "</script>")
121 126 @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java
... ... @@ -16,10 +16,10 @@ public interface ParentPlatformMapper {
16 16  
17 17 @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
18 18 " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
19   - " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime) " +
  19 + " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " +
20 20 " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
21 21 " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
22   - " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})")
  22 + " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
23 23 int addParentPlatform(ParentPlatform parentPlatform);
24 24  
25 25 @Update("UPDATE parent_platform " +
... ... @@ -47,6 +47,7 @@ public interface ParentPlatformMapper {
47 47 "administrativeDivision=#{administrativeDivision}, " +
48 48 "createTime=#{createTime}, " +
49 49 "updateTime=#{updateTime}, " +
  50 + "treeType=#{treeType}, " +
50 51 "catalogId=#{catalogId} " +
51 52 "WHERE id=#{id}")
52 53 int updateParentPlatform(ParentPlatform parentPlatform);
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformCatalogMapper.java
1 1 package com.genersoft.iot.vmp.storager.dao;
2 2  
  3 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
3 4 import com.genersoft.iot.vmp.gb28181.bean.GbStream;
4 5 import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
5 6 import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
... ... @@ -14,8 +15,8 @@ import java.util.List;
14 15 @Repository
15 16 public interface PlatformCatalogMapper {
16 17  
17   - @Insert("INSERT INTO platform_catalog (id, name, platformId, parentId) VALUES" +
18   - "(#{id}, #{name}, #{platformId}, #{parentId})")
  18 + @Insert("INSERT INTO platform_catalog (id, name, platformId, parentId, civilCode, businessGroupId) VALUES" +
  19 + "(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})")
19 20 int add(PlatformCatalog platformCatalog);
20 21  
21 22 @Delete("DELETE FROM platform_catalog WHERE id=#{id}")
... ... @@ -44,4 +45,12 @@ public interface PlatformCatalogMapper {
44 45  
45 46 @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})")
46 47 PlatformCatalog selectDefaultByPlatFormId(String platformId);
  48 +
  49 +
  50 + @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = #{id}")
  51 + PlatformCatalog selectParentCatalog(String id);
  52 +
  53 + @Select("SELECT pc.id as channelId, pc.name, pc.civilCode, pc.businessGroupId,'0' as parental, pc.parentId " +
  54 + " FROM platform_catalog pc WHERE pc.platformId=#{platformId}")
  55 + List<DeviceChannel> queryCatalogInPlatform(String platformId);
47 56 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/dao/StreamPushMapper.java
... ... @@ -88,10 +88,10 @@ public interface StreamPushMapper {
88 88  
89 89 @Insert("<script>" +
90 90 "Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
91   - "createTime, aliveSecond, mediaServerId) " +
  91 + "createTime, aliveSecond, mediaServerId, status) " +
92 92 "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
93 93 "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
94   - "'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}' )" +
  94 + "'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}', ${item.status} )" +
95 95 " </foreach>" +
96 96 "</script>")
97 97 @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
... ... @@ -122,41 +122,41 @@ public interface StreamPushMapper {
122 122  
123 123 @Select("<script> "+
124 124 "SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " +
125   - "where sp.status = 1 and (gs.app, gs.stream) in" +
  125 + "where sp.status = 1 and (gs.app, gs.stream) in (" +
126 126 "<foreach collection='offlineStreams' item='item' separator=','>" +
127   - "(#{item.app}, {item.stream}) " +
128   - "</foreach>" +
  127 + "(#{item.app}, #{item.stream}) " +
  128 + ")</foreach>" +
129 129 "</script>")
130 130 List<GbStream> getOnlinePusherForGbInList(List<StreamPushItemFromRedis> offlineStreams);
131 131  
132 132 @Update("<script> "+
133   - "UPDATE stream_push SET status=0 where (app, stream) in" +
  133 + "UPDATE stream_push SET status=0 where (app, stream) in (" +
134 134 "<foreach collection='offlineStreams' item='item' separator=','>" +
135   - "(#{item.app}, {item.stream}) " +
136   - "</foreach>" +
  135 + "(#{item.app}, #{item.stream}) " +
  136 + ")</foreach>" +
137 137 "</script>")
138 138 void offline(List<StreamPushItemFromRedis> offlineStreams);
139 139  
140 140 @Select("<script> "+
141 141 "SELECT * FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " +
142   - "where sp.status = 0 and (gs.app, gs.stream) in" +
143   - "<foreach collection='offlineStreams' item='item' separator=','>" +
144   - "(#{item.app}, {item.stream}) " +
  142 + "where sp.status = 0 and (gs.app, gs.stream) in (" +
  143 + "<foreach collection='onlineStreams' item='item' separator=','>" +
  144 + "(#{item.app}, #{item.stream}) " +
145 145 "</foreach>" +
146   - "</script>")
  146 + ") </script>")
147 147 List<GbStream> getOfflinePusherForGbInList(List<StreamPushItemFromRedis> onlineStreams);
148 148  
149 149 @Update("<script> "+
150   - "UPDATE stream_push SET status=1 where (app, stream) in" +
151   - "<foreach collection='offlineStreams' item='item' separator=','>" +
152   - "(#{item.app}, {item.stream}) " +
153   - "</foreach>" +
  150 + "UPDATE stream_push SET status=1 where (app, stream) in (" +
  151 + "<foreach collection='onlineStreams' item='item' separator=','>" +
  152 + "(#{item.app}, #{item.stream}) " +
  153 + ")</foreach>" +
154 154 "</script>")
155 155 void online(List<StreamPushItemFromRedis> onlineStreams);
156 156  
157   - @Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream")
  157 + @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")
158 158 List<GbStream> getOnlinePusherForGb();
159 159  
160 160 @Update("UPDATE stream_push SET status=0")
161   - void allStreamOffline();
  161 + void setAllStreamOffline();
162 162 }
... ...
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
... ... @@ -48,13 +48,14 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
48 48 @Autowired
49 49 SipConfig sipConfig;
50 50  
51   - @Autowired
52   - DataSourceTransactionManager dataSourceTransactionManager;
53 51  
54 52 @Autowired
55 53 TransactionDefinition transactionDefinition;
56 54  
57 55 @Autowired
  56 + DataSourceTransactionManager dataSourceTransactionManager;
  57 +
  58 + @Autowired
58 59 private DeviceMapper deviceMapper;
59 60  
60 61 @Autowired
... ... @@ -105,96 +106,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
105 106 }
106 107  
107 108 @Override
108   - public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
109   - String channelId = channel.getChannelId();
110   - channel.setDeviceId(deviceId);
111   - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
112   - if (streamInfo != null) {
113   - channel.setStreamId(streamInfo.getStream());
114   - }
115   - String now = DateUtil.getNow();
116   - channel.setUpdateTime(now);
117   - DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
118   - if (deviceChannel == null) {
119   - channel.setCreateTime(now);
120   - deviceChannelMapper.add(channel);
121   - }else {
122   - deviceChannelMapper.update(channel);
123   - }
124   - deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId());
125   - }
126   -
127   - @Override
128   - public int updateChannels(String deviceId, List<DeviceChannel> channels) {
129   - List<DeviceChannel> addChannels = new ArrayList<>();
130   - List<DeviceChannel> updateChannels = new ArrayList<>();
131   - HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
132   - if (channels != null && channels.size() > 0) {
133   - List<DeviceChannel> channelList = deviceChannelMapper.queryChannels(deviceId, null, null, null, null);
134   - if (channelList.size() == 0) {
135   - for (DeviceChannel channel : channels) {
136   - channel.setDeviceId(deviceId);
137   - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
138   - if (streamInfo != null) {
139   - channel.setStreamId(streamInfo.getStream());
140   - }
141   - String now = DateUtil.getNow();
142   - channel.setUpdateTime(now);
143   - channel.setCreateTime(now);
144   - addChannels.add(channel);
145   - }
146   - }else {
147   - for (DeviceChannel deviceChannel : channelList) {
148   - channelsInStore.put(deviceChannel.getChannelId(), deviceChannel);
149   - }
150   - for (DeviceChannel channel : channels) {
151   - channel.setDeviceId(deviceId);
152   - StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
153   - if (streamInfo != null) {
154   - channel.setStreamId(streamInfo.getStream());
155   - }
156   - String now = DateUtil.getNow();
157   - channel.setUpdateTime(now);
158   - if (channelsInStore.get(channel.getChannelId()) != null) {
159   - updateChannels.add(channel);
160   - }else {
161   - addChannels.add(channel);
162   - channel.setCreateTime(now);
163   - }
164   - }
165   - }
166   - int limitCount = 300;
167   - if (addChannels.size() > 0) {
168   - if (addChannels.size() > limitCount) {
169   - for (int i = 0; i < addChannels.size(); i += limitCount) {
170   - int toIndex = i + limitCount;
171   - if (i + limitCount > addChannels.size()) {
172   - toIndex = addChannels.size();
173   - }
174   - deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex));
175   - }
176   - }else {
177   - deviceChannelMapper.batchAdd(addChannels);
178   - }
179   - }
180   - if (updateChannels.size() > 0) {
181   - if (updateChannels.size() > limitCount) {
182   - for (int i = 0; i < updateChannels.size(); i += limitCount) {
183   - int toIndex = i + limitCount;
184   - if (i + limitCount > updateChannels.size()) {
185   - toIndex = updateChannels.size();
186   - }
187   - deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex));
188   - }
189   - }else {
190   - deviceChannelMapper.batchUpdate(updateChannels);
191   - }
192   - }
193   - }
194   - return addChannels.size() + updateChannels.size();
195   - }
196   -
197   - @Override
198 109 public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
199 110 if (CollectionUtils.isEmpty(deviceChannelList)) {
200 111 return false;
... ... @@ -596,36 +507,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
596 507 return deviceChannelMapper.queryChannelByPlatformId(platformId);
597 508 }
598 509  
599   - @Override
600   - public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
601   -
602   - Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
603   - for (ChannelReduce channelReduce : channelReduces) {
604   - channelReduce.setCatalogId(catalogId);
605   - deviceAndChannels.put(channelReduce.getId(), channelReduce);
606   - }
607   - List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
608   - // 查询当前已经存在的
609   - List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
610   - if (deviceAndChannelList != null) {
611   - deviceAndChannelList.removeAll(channelIds);
612   - }
613   - for (Integer channelId : channelIds) {
614   - deviceAndChannels.remove(channelId);
615   - }
616   - List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
617   - // 对剩下的数据进行存储
618   - int result = 0;
619   - if (channelReducesToAdd.size() > 0) {
620   - result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
621   - // TODO 后续给平台增加控制开关以控制是否响应目录订阅
622   - List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId);
623   - eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
624   - }
625   -
626   - return result;
627   - }
628   -
629 510  
630 511 @Override
631 512 public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
... ... @@ -701,77 +582,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
701 582 return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId);
702 583 }
703 584  
704   - /**
705   - * 新增代理流
706   - * @param streamProxyItem
707   - * @return
708   - */
709   - @Override
710   - public boolean addStreamProxy(StreamProxyItem streamProxyItem) {
711   - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
712   - boolean result = false;
713   - streamProxyItem.setStreamType("proxy");
714   - streamProxyItem.setStatus(true);
715   - String now = DateUtil.getNow();
716   - streamProxyItem.setCreateTime(now);
717   - try {
718   - if (streamProxyMapper.add(streamProxyItem) > 0) {
719   - if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
720   - if (gbStreamMapper.add(streamProxyItem) < 0) {
721   - //事务回滚
722   - dataSourceTransactionManager.rollback(transactionStatus);
723   - return false;
724   - }
725   - }
726   - }else {
727   - //事务回滚
728   - dataSourceTransactionManager.rollback(transactionStatus);
729   - return false;
730   - }
731   - result = true;
732   - dataSourceTransactionManager.commit(transactionStatus); //手动提交
733   - }catch (Exception e) {
734   - logger.error("向数据库添加流代理失败:", e);
735   - dataSourceTransactionManager.rollback(transactionStatus);
736   - }
737   -
738   -
739   - return result;
740   - }
741   -
742   - /**
743   - * 更新代理流
744   - * @param streamProxyItem
745   - * @return
746   - */
747   - @Override
748   - public boolean updateStreamProxy(StreamProxyItem streamProxyItem) {
749   - TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
750   - boolean result = false;
751   - streamProxyItem.setStreamType("proxy");
752   - try {
753   - if (streamProxyMapper.update(streamProxyItem) > 0) {
754   - if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
755   - if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) {
756   - //事务回滚
757   - dataSourceTransactionManager.rollback(transactionStatus);
758   - return false;
759   - }
760   - }
761   - } else {
762   - //事务回滚
763   - dataSourceTransactionManager.rollback(transactionStatus);
764   - return false;
765   - }
766   -
767   - dataSourceTransactionManager.commit(transactionStatus); //手动提交
768   - result = true;
769   - }catch (Exception e) {
770   - e.printStackTrace();
771   - dataSourceTransactionManager.rollback(transactionStatus);
772   - }
773   - return result;
774   - }
775 585  
776 586 /**
777 587 * 移除代理流
... ... @@ -824,7 +634,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
824 634 * @return
825 635 */
826 636 @Override
827   - public List<GbStream> queryGbStreamListInPlatform(String platformId) {
  637 + public List<DeviceChannel> queryGbStreamListInPlatform(String platformId) {
828 638 return gbStreamMapper.queryGbStreamListInPlatform(platformId);
829 639 }
830 640  
... ... @@ -910,6 +720,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
910 720 return result;
911 721 }
912 722  
  723 + @Override
913 724 public int mediaOnline(String app, String stream) {
914 725 GbStream gbStream = gbStreamMapper.selectOne(app, stream);
915 726 int result;
... ... @@ -954,6 +765,24 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
954 765  
955 766 @Override
956 767 public int addCatalog(PlatformCatalog platformCatalog) {
  768 + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformCatalog.getPlatformId());
  769 + if (platform == null) {
  770 + return 0;
  771 + }
  772 + if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) {
  773 + if (platformCatalog.getPlatformId().equals(platformCatalog.getParentId())) {
  774 + // 第一层节点
  775 + platformCatalog.setBusinessGroupId(platformCatalog.getId());
  776 + }else {
  777 + // 获取顶层的
  778 + PlatformCatalog topCatalog = getTopCatalog(platformCatalog.getParentId(), platformCatalog.getPlatformId());
  779 + platformCatalog.setBusinessGroupId(topCatalog.getId());
  780 + }
  781 + }
  782 + if (platform.getTreeType().equals(TreeType.CIVIL_CODE)) {
  783 + platformCatalog.setCivilCode(platformCatalog.getId());
  784 + }
  785 +
957 786 int result = catalogMapper.add(platformCatalog);
958 787 if (result > 0) {
959 788 DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog);
... ... @@ -962,6 +791,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
962 791 return result;
963 792 }
964 793  
  794 + private PlatformCatalog getTopCatalog(String id, String platformId) {
  795 + PlatformCatalog catalog = catalogMapper.selectParentCatalog(id);
  796 + if (catalog.getParentId().equals(platformId)) {
  797 + return catalog;
  798 + }else {
  799 + return getTopCatalog(catalog.getParentId(), platformId);
  800 + }
  801 + }
  802 +
965 803 @Override
966 804 public PlatformCatalog getCatalog(String id) {
967 805 return catalogMapper.select(id);
... ... @@ -1032,8 +870,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
1032 870 }
1033 871  
1034 872 @Override
1035   - public List<PlatformCatalog> queryCatalogInPlatform(String platformId) {
1036   - return catalogMapper.selectByPlatForm(platformId);
  873 + public List<DeviceChannel> queryCatalogInPlatform(String platformId) {
  874 + return catalogMapper.queryCatalogInPlatform(platformId);
1037 875 }
1038 876  
1039 877 @Override
... ... @@ -1076,20 +914,24 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
1076 914 }
1077 915  
1078 916 private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) {
1079   - ParentPlatform parentPlatByServerGBId = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId());
  917 + ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId());
1080 918 DeviceChannel deviceChannel = new DeviceChannel();
1081 919 deviceChannel.setChannelId(catalog.getId());
1082 920 deviceChannel.setName(catalog.getName());
1083 921 deviceChannel.setLongitude(0.0);
1084 922 deviceChannel.setLatitude(0.0);
1085   - deviceChannel.setDeviceId(parentPlatByServerGBId.getDeviceGBId());
  923 + deviceChannel.setDeviceId(platform.getDeviceGBId());
1086 924 deviceChannel.setManufacture("wvp-pro");
1087 925 deviceChannel.setStatus(1);
1088 926 deviceChannel.setParental(1);
1089   - deviceChannel.setParentId(catalog.getParentId());
  927 +
1090 928 deviceChannel.setRegisterWay(1);
1091 929 // 行政区划应该是Domain的前八位
1092   - deviceChannel.setCivilCode(parentPlatByServerGBId.getAdministrativeDivision());
  930 + if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) {
  931 + deviceChannel.setParentId(catalog.getParentId());
  932 + deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
  933 + }
  934 +
1093 935 deviceChannel.setModel("live");
1094 936 deviceChannel.setOwner("wvp-pro");
1095 937 deviceChannel.setSecrecy("0");
... ... @@ -1151,4 +993,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
1151 993  
1152 994 deviceChannelMapper.updatePosition(deviceChannel);
1153 995 }
  996 +
  997 + @Override
  998 + public void cleanContentForPlatform(String serverGBId) {
  999 +// List<PlatformCatalog> catalogList = catalogMapper.selectByPlatForm(serverGBId);
  1000 +// if (catalogList.size() > 0) {
  1001 +// int result = catalogMapper.delByPlatformId(serverGBId);
  1002 +// if (result > 0) {
  1003 +// List<DeviceChannel> deviceChannels = new ArrayList<>();
  1004 +// for (PlatformCatalog catalog : catalogList) {
  1005 +// deviceChannels.add(getDeviceChannelByCatalog(catalog));
  1006 +// }
  1007 +// eventPublisher.catalogEventPublish(serverGBId, deviceChannels, CatalogEvent.DEL);
  1008 +// }
  1009 +// }
  1010 + catalogMapper.delByPlatformId(serverGBId);
  1011 + platformChannelMapper.delByPlatformId(serverGBId);
  1012 + platformGbStreamMapper.delByPlatformId(serverGBId);
  1013 + }
  1014 +
  1015 + @Override
  1016 + public List<DeviceChannel> queryChannelWithCatalog(String serverGBId) {
  1017 + return deviceChannelMapper.queryChannelWithCatalog(serverGBId);
  1018 + }
1154 1019 }
... ...
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;
12 12 import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
13 13 import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
14 14 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
  15 +import com.genersoft.iot.vmp.service.IDeviceChannelService;
15 16 import com.genersoft.iot.vmp.service.IDeviceService;
16 17 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
17 18 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
... ... @@ -53,6 +54,9 @@ public class DeviceQuery {
53 54 private IVideoManagerStorage storager;
54 55  
55 56 @Autowired
  57 + private IDeviceChannelService deviceChannelService;
  58 +
  59 + @Autowired
56 60 private IRedisCatchStorage redisCatchStorage;
57 61  
58 62 @Autowired
... ... @@ -280,7 +284,7 @@ public class DeviceQuery {
280 284 })
281 285 @PostMapping("/channel/update/{deviceId}")
282 286 public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
283   - storager.updateChannel(deviceId, channel);
  287 + deviceChannelService.updateChannel(deviceId, channel);
284 288 return new ResponseEntity<>(null,HttpStatus.OK);
285 289 }
286 290  
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/gbStream/GbStreamController.java
... ... @@ -44,7 +44,6 @@ public class GbStreamController {
44 44 @ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = String.class),
45 45 @ApiImplicitParam(name = "catalogId", value = "目录ID", required = false , dataTypeClass = String.class),
46 46 @ApiImplicitParam(name="query", value = "查询内容", required = false , dataTypeClass = String.class),
47   - @ApiImplicitParam(name="pushing", value = "是否正在推流", required = false , dataTypeClass = Boolean.class),
48 47 @ApiImplicitParam(name="mediaServerId", value = "流媒体ID", required = false , dataTypeClass = String.class),
49 48  
50 49 })
... ... @@ -55,7 +54,6 @@ public class GbStreamController {
55 54 @RequestParam(required = true)String platformId,
56 55 @RequestParam(required = false)String catalogId,
57 56 @RequestParam(required = false)String query,
58   - @RequestParam(required = false)Boolean pushing,
59 57 @RequestParam(required = false)String mediaServerId){
60 58 if (StringUtils.isEmpty(catalogId)) {
61 59 catalogId = null;
... ... @@ -69,7 +67,7 @@ public class GbStreamController {
69 67  
70 68 // catalogId 为null 查询未在平台下分配的数据
71 69 // catalogId 不为null 查询平台下这个,目录下的通道
72   - return gbStreamService.getAll(page, count, platformId, catalogId, query, pushing, mediaServerId);
  70 + return gbStreamService.getAll(page, count, platformId, catalogId, query, mediaServerId);
73 71 }
74 72  
75 73  
... ...
src/main/java/com/genersoft/iot/vmp/vmanager/gb28181/platform/PlatformController.java
... ... @@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
9 9 import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
10 10 import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
11 11 import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
  12 +import com.genersoft.iot.vmp.service.IPlatformChannelService;
12 13 import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
13 14 import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
14 15 import com.genersoft.iot.vmp.utils.DateUtil;
... ... @@ -49,6 +50,9 @@ public class PlatformController {
49 50 private IVideoManagerStorage storager;
50 51  
51 52 @Autowired
  53 + private IPlatformChannelService platformChannelService;
  54 +
  55 + @Autowired
52 56 private IRedisCatchStorage redisCatchStorage;
53 57  
54 58 @Autowired
... ... @@ -236,6 +240,12 @@ public class PlatformController {
236 240 parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
237 241 ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
238 242 parentPlatform.setUpdateTime(DateUtil.getNow());
  243 + if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) {
  244 + // 目录结构发生变化,清空之前的关联关系
  245 + logger.info("保存平台{}时发现目录结构变化,清空关联关系", parentPlatform.getDeviceGBId());
  246 + storager.cleanContentForPlatform(parentPlatform.getServerGBId());
  247 +
  248 + }
239 249 boolean updateResult = storager.updateParentPlatform(parentPlatform);
240 250  
241 251 if (updateResult) {
... ... @@ -256,6 +266,8 @@ public class PlatformController {
256 266 }
257 267 } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 关闭启用时注销
258 268 commanderForPlatform.unregister(parentPlatformOld, null, null);
  269 + // 停止订阅相关的定时任务
  270 + subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
259 271 }
260 272 wvpResult.setCode(0);
261 273 wvpResult.setMsg("success");
... ... @@ -405,7 +417,7 @@ public class PlatformController {
405 417 if (logger.isDebugEnabled()) {
406 418 logger.debug("给上级平台添加国标通道API调用");
407 419 }
408   - int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
  420 + int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
409 421  
410 422 return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
411 423 }
... ... @@ -485,7 +497,6 @@ public class PlatformController {
485 497 PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
486 498 WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
487 499  
488   -
489 500 if (platformCatalogInStore != null) {
490 501 result.setCode(-1);
491 502 result.setMsg(platformCatalog.getId() + " already exists");
... ...
web_src/src/components/ParentPlatformList.vue
... ... @@ -143,7 +143,7 @@ export default {
143 143 });
144 144 },
145 145 chooseChannel: function(platform) {
146   - this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, this.initData)
  146 + this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, platform.treeType, this.initData)
147 147 },
148 148 initData: function() {
149 149 this.getPlatformList();
... ...
web_src/src/components/PushVideoList.vue
... ... @@ -56,7 +56,7 @@
56 56 <el-table-column label="开始时间" min-width="200">
57 57 <template slot-scope="scope">
58 58 <el-button-group>
59   - {{ dateFormat(parseInt(scope.row.createStamp)) }}
  59 + {{ scope.row.pushTime == null? "-":scope.row.pushTime }}
60 60 </el-button-group>
61 61 </template>
62 62 </el-table-column>
... ... @@ -242,19 +242,6 @@ export default {
242 242 console.error(error);
243 243 });
244 244 },
245   - dateFormat: function (/** timestamp=0 **/) {
246   - let ts = arguments[0] || 0;
247   - let t, y, m, d, h, i, s;
248   - t = ts ? new Date(ts) : new Date();
249   - y = t.getFullYear();
250   - m = t.getMonth() + 1;
251   - d = t.getDate();
252   - h = t.getHours();
253   - i = t.getMinutes();
254   - s = t.getSeconds();
255   - // 可根据需要在这里定义时间格式
256   - 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);
257   - },
258 245 importChannel: function () {
259 246 this.$refs.importChannel.openDialog(() => {
260 247  
... ...
web_src/src/components/dialog/catalogEdit.vue
... ... @@ -49,11 +49,43 @@ export default {
49 49 props: ['platformId'],
50 50 created() {},
51 51 data() {
  52 + let checkId = (rule, value, callback) => {
  53 + console.log("checkId")
  54 + console.log(this.treeType)
  55 + console.log(rule)
  56 + console.log(value)
  57 + console.log(value.length)
  58 + console.log(this.level)
  59 + if (!value) {
  60 + return callback(new Error('编号不能为空'));
  61 + }
  62 + if (this.treeType === "BusinessGroup" && value.length !== 20) {
  63 + return callback(new Error('编号必须由20位数字组成'));
  64 + }
  65 + if (this.treeType === "CivilCode" && value.length <= 8 && value.length%2 !== 0) {
  66 + return callback(new Error('行政区划必须是八位以下的偶数个数字组成'));
  67 + }
  68 + if (this.treeType === "BusinessGroup") {
  69 + let catalogType = value.substring(10, 13);
  70 + console.log(catalogType)
  71 + // 216 为虚拟组织 215 为业务分组;目录第一级必须为业务分组, 业务分组下为虚拟组织,虚拟组织下可以有其他虚拟组织
  72 + if (this.level === 1 && catalogType !== "215") {
  73 + return callback(new Error('业务分组模式下第一层目录的编号10到13位必须为215'));
  74 + }
  75 + if (this.level > 1 && catalogType !== "216") {
  76 + return callback(new Error('业务分组模式下第一层以下目录的编号10到13位必须为216'));
  77 + }
  78 +
  79 + }
  80 + callback();
  81 + }
52 82 return {
53 83 submitCallback: null,
54 84 showDialog: false,
55 85 isLoging: false,
56 86 isEdit: false,
  87 + treeType: null,
  88 + level: 0,
57 89 form: {
58 90 id: null,
59 91 name: null,
... ... @@ -62,12 +94,12 @@ export default {
62 94 },
63 95 rules: {
64 96 name: [{ required: true, message: "请输入名称", trigger: "blur" }],
65   - id: [{ required: true, message: "请输入ID", trigger: "blur" }]
  97 + id: [{ trigger: "blur",validator: checkId }]
66 98 },
67 99 };
68 100 },
69 101 methods: {
70   - openDialog: function (isEdit, id, name, parentId, callback) {
  102 + openDialog: function (isEdit, id, name, parentId, treeType, level, callback) {
71 103 console.log("parentId: " + parentId)
72 104 console.log(this.form)
73 105 this.isEdit = isEdit;
... ... @@ -77,6 +109,8 @@ export default {
77 109 this.form.parentId = parentId;
78 110 this.showDialog = true;
79 111 this.submitCallback = callback;
  112 + this.treeType = treeType;
  113 + this.level = level;
80 114 },
81 115 onSubmit: function () {
82 116 console.log("onSubmit");
... ...
web_src/src/components/dialog/chooseChannel.vue
... ... @@ -8,7 +8,7 @@
8 8 <el-tab-pane label="目录结构" name="catalog">
9 9 <el-container>
10 10 <el-main v-bind:style="{backgroundColor: '#FFF', maxHeight: winHeight + 'px'}">
11   - <chooseChannelForCatalog ref="chooseChannelForCatalog" :platformId=platformId :platformName=platformName :defaultCatalogId=defaultCatalogId :catalogIdChange="catalogIdChange" ></chooseChannelForCatalog>
  11 + <chooseChannelForCatalog ref="chooseChannelForCatalog" :platformId=platformId :platformName=platformName :defaultCatalogId=defaultCatalogId :catalogIdChange="catalogIdChange" :treeType=treeType ></chooseChannelForCatalog>
12 12 </el-main>
13 13 </el-container>
14 14 </el-tab-pane>
... ... @@ -66,18 +66,20 @@ export default {
66 66 platformName: "",
67 67 defaultCatalogId: "",
68 68 showDialog: false,
  69 + treeType: null,
69 70 chooseData: {},
70 71 winHeight: window.innerHeight - 250,
71 72  
72 73 };
73 74 },
74 75 methods: {
75   - openDialog(platformId, platformName, defaultCatalogId, closeCallback) {
  76 + openDialog(platformId, platformName, defaultCatalogId, treeType, closeCallback) {
76 77 this.platformId = platformId
77 78 this.platformName = platformName
78 79 this.defaultCatalogId = defaultCatalogId
79 80 this.showDialog = true
80 81 this.closeCallback = closeCallback
  82 + this.treeType = treeType
81 83 },
82 84 tabClick (tab, event){
83 85  
... ...
web_src/src/components/dialog/chooseChannelForCatalog.vue
... ... @@ -38,7 +38,7 @@
38 38 import catalogEdit from './catalogEdit.vue'
39 39 export default {
40 40 name: 'chooseChannelForCatalog',
41   - props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'],
  41 + props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange', 'treeType'],
42 42 created() {
43 43 this.chooseId = this.defaultCatalogId;
44 44 this.defaultCatalogIdSign = this.defaultCatalogId;
... ... @@ -102,8 +102,9 @@ export default {
102 102 },
103 103 addCatalog: function (parentId, node){
104 104 let that = this;
  105 + console.log(this.treeType)
105 106 // 打开添加弹窗
106   - that.$refs.catalogEdit.openDialog(false, null, null, parentId, ()=>{
  107 + that.$refs.catalogEdit.openDialog(false, null, null, parentId, this.treeType, node.level, ()=>{
107 108 node.loaded = false
108 109 node.expand();
109 110 });
... ...
web_src/src/components/dialog/chooseChannelForStream.vue
... ... @@ -174,7 +174,6 @@ export default {
174 174 page: that.currentPage,
175 175 count: that.count,
176 176 query: that.searchSrt,
177   - pushing: that.pushing,
178 177 platformId: that.platformId,
179 178 catalogId: that.catalogId,
180 179 mediaServerId: that.mediaServerId
... ...
web_src/src/components/dialog/platformEdit.vue
... ... @@ -78,6 +78,12 @@
78 78 <el-option label="8" value="8"></el-option>
79 79 </el-select>
80 80 </el-form-item>
  81 + <el-form-item label="目录结构" prop="treeType" >
  82 + <el-select v-model="platform.treeType" style="width: 100%" >
  83 + <el-option key="WGS84" label="行政区划" value="CivilCode"></el-option>
  84 + <el-option key="GCJ02" label="业务分组" value="BusinessGroup"></el-option>
  85 + </el-select>
  86 + </el-form-item>
81 87 <el-form-item label="字符集" prop="characterSet">
82 88 <el-select
83 89 v-model="platform.characterSet"
... ... @@ -157,6 +163,7 @@ export default {
157 163 startOfflinePush: false,
158 164 catalogGroup: 1,
159 165 administrativeDivision: null,
  166 + treeType: "BusinessGroup",
160 167 },
161 168 rules: {
162 169 name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
... ... @@ -194,6 +201,7 @@ export default {
194 201 that.platform.devicePort = res.data.devicePort;
195 202 that.platform.username = res.data.username;
196 203 that.platform.password = res.data.password;
  204 + that.platform.treeType = res.data.treeType;
197 205 that.platform.administrativeDivision = res.data.username.substr(0, 6);
198 206 }).catch(function (error) {
199 207 console.log(error);
... ... @@ -222,6 +230,7 @@ export default {
222 230 this.platform.startOfflinePush = platform.startOfflinePush;
223 231 this.platform.catalogGroup = platform.catalogGroup;
224 232 this.platform.administrativeDivision = platform.administrativeDivision;
  233 + this.platform.treeType = platform.treeType;
225 234 this.onSubmit_text = "保存";
226 235 this.saveUrl = "/api/platform/save";
227 236 }
... ... @@ -242,32 +251,49 @@ export default {
242 251  
243 252 },
244 253 onSubmit: function () {
  254 + if (this.onSubmit_text === "保存") {
  255 + this.$confirm("修改目录结构会导致关联目录与通道数据被清空", '提示', {
  256 + dangerouslyUseHTMLString: true,
  257 + confirmButtonText: '确定',
  258 + cancelButtonText: '取消',
  259 + center: true,
  260 + type: 'warning'
  261 + }).then(() => {
  262 + this.saveForm()
  263 + }).catch(() => {
  264 +
  265 + });
  266 + }else {
  267 + this.saveForm()
  268 + }
  269 + },
  270 + saveForm: function (){
245 271 var that = this;
246 272 that.$axios({
247 273 method: 'post',
248 274 url: this.saveUrl,
249 275 data: that.platform
250 276 }).then(function (res) {
251   - if (res.data.code === 0) {
252   - that.$message({
253   - showClose: true,
254   - message: "保存成功",
255   - type: "success",
256   - });
257   - that.showDialog = false;
258   - if (that.listChangeCallback != null) {
259   - that.listChangeCallback();
260   - }
261   - }else {
262   - that.$message({
263   - showClose: true,
264   - message: res.data.msg,
265   - type: "error",
266   - });
  277 + if (res.data.code === 0) {
  278 + that.$message({
  279 + showClose: true,
  280 + message: "保存成功",
  281 + type: "success",
  282 + });
  283 + that.showDialog = false;
  284 + if (that.listChangeCallback != null) {
  285 + that.listChangeCallback();
267 286 }
268   - }).catch(function (error) {
269   - console.log(error);
270   - });
  287 + }else {
  288 + that.$message({
  289 + showClose: true,
  290 + message: res.data.msg,
  291 + type: "error",
  292 + });
  293 + }
  294 + }).catch(function (error) {
  295 + console.log(error);
  296 + });
271 297 },
272 298 close: function () {
273 299 this.showDialog = false;
... ... @@ -293,6 +319,7 @@ export default {
293 319 keepTimeout: 60,
294 320 transport: "UDP",
295 321 characterSet: "GB2312",
  322 + treeType: "BusinessGroup",
296 323 shareAllLiveStream: false,
297 324 startOfflinePush: false,
298 325 catalogGroup: 1,
... ...