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

This commit is contained in:
648540858 2022-07-17 23:17:36 +08:00
parent be5dbc9a21
commit 4451994959
50 changed files with 1159 additions and 819 deletions

View File

@ -50,7 +50,7 @@ CREATE TABLE `device` (
`treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL, `treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `device_deviceId_uindex` (`deviceId`) USING BTREE UNIQUE KEY `device_deviceId_uindex` (`deviceId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=42 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=45 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -142,7 +142,7 @@ CREATE TABLE `device_channel` (
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `device_channel_id_uindex` (`id`) USING BTREE, UNIQUE KEY `device_channel_id_uindex` (`id`) USING BTREE,
UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) USING BTREE UNIQUE KEY `device_channel_pk` (`channelId`,`deviceId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=19331 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=19336 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -213,7 +213,7 @@ CREATE TABLE `gb_stream` (
PRIMARY KEY (`gbStreamId`) USING BTREE, PRIMARY KEY (`gbStreamId`) USING BTREE,
UNIQUE KEY `app` (`app`,`stream`) USING BTREE, UNIQUE KEY `app` (`app`,`stream`) USING BTREE,
UNIQUE KEY `gbId` (`gbId`) USING BTREE UNIQUE KEY `gbId` (`gbId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=301681 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=301740 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -243,7 +243,7 @@ CREATE TABLE `log` (
`username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `username` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `createTime` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=34997 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=37760 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -334,10 +334,11 @@ CREATE TABLE `parent_platform` (
`catalogGroup` int DEFAULT '1', `catalogGroup` int DEFAULT '1',
`createTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, `createTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`updateTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL, `updateTime` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`treeType` varchar(50) COLLATE utf8mb4_general_ci NOT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `parent_platform_id_uindex` (`id`) USING BTREE, UNIQUE KEY `parent_platform_id_uindex` (`id`) USING BTREE,
UNIQUE KEY `parent_platform_pk` (`serverGBId`) USING BTREE UNIQUE KEY `parent_platform_pk` (`serverGBId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=33 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=35 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -361,6 +362,8 @@ CREATE TABLE `platform_catalog` (
`platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `platformId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `name` varchar(255) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL, `parentId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci DEFAULT NULL,
`civilCode` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
`businessGroupId` varchar(50) COLLATE utf8mb4_general_ci DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
@ -387,7 +390,7 @@ CREATE TABLE `platform_gb_channel` (
`catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL, `catalogId` varchar(50) CHARACTER SET utf8mb4 COLLATE utf8mb4_general_ci NOT NULL,
`deviceChannelId` int NOT NULL, `deviceChannelId` int NOT NULL,
PRIMARY KEY (`id`) USING BTREE PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=4889 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=4912 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -413,7 +416,7 @@ CREATE TABLE `platform_gb_stream` (
`id` int NOT NULL AUTO_INCREMENT, `id` int NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) USING BTREE UNIQUE KEY `platform_gb_stream_pk` (`platformId`,`catalogId`,`gbStreamId`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=302077 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=302134 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -489,7 +492,7 @@ CREATE TABLE `stream_push` (
`status` int DEFAULT NULL, `status` int DEFAULT NULL,
PRIMARY KEY (`id`) USING BTREE, PRIMARY KEY (`id`) USING BTREE,
UNIQUE KEY `stream_push_pk` (`app`,`stream`) USING BTREE UNIQUE KEY `stream_push_pk` (`app`,`stream`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=305315 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC; ) ENGINE=InnoDB AUTO_INCREMENT=305390 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_general_ci ROW_FORMAT=DYNAMIC;
/*!40101 SET character_set_client = @saved_cs_client */; /*!40101 SET character_set_client = @saved_cs_client */;
-- --
@ -567,4 +570,4 @@ UNLOCK TABLES;
/*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */; /*!40101 SET COLLATION_CONNECTION=@OLD_COLLATION_CONNECTION */;
/*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */; /*!40111 SET SQL_NOTES=@OLD_SQL_NOTES */;
-- Dump completed on 2022-07-11 17:32:51 -- Dump completed on 2022-07-17 23:15:09

View File

@ -65,4 +65,14 @@ alter table user
add pushKey varchar(50) default null; add pushKey varchar(50) default null;
alter table parent_platform
add treeType varchar(50) not null;
update parent_platform set parent_platform.treeType='BusinessGroup';
alter table platform_catalog
add civilCode varchar(50) default null;
alter table platform_catalog
add businessGroupId varchar(50) default null;

View File

@ -154,6 +154,11 @@ public class ParentPlatform {
*/ */
private String createTime; private String createTime;
/**
* 树类型 国标规定了两种树的展现方式 行政区划 CivilCode 和业务分组:BusinessGroup
*/
private String treeType;
public Integer getId() { public Integer getId() {
return id; return id;
} }
@ -394,4 +399,12 @@ public class ParentPlatform {
public void setCreateTime(String createTime) { public void setCreateTime(String createTime) {
this.createTime = createTime; this.createTime = createTime;
} }
public String getTreeType() {
return treeType;
}
public void setTreeType(String treeType) {
this.treeType = treeType;
}
} }

View File

@ -1,12 +1,28 @@
package com.genersoft.iot.vmp.gb28181.bean; package com.genersoft.iot.vmp.gb28181.bean;
/**
* 国标级联-目录
* @author lin
*/
public class PlatformCatalog { public class PlatformCatalog {
private String id; private String id;
private String name; private String name;
private String platformId; private String platformId;
private String parentId; private String parentId;
private int childrenCount; // 子节点数
private int type; // 0 目录, 1 国标通道, 2 直播流 private String civilCode;
private String businessGroupId;
/**
* 子节点数
*/
private int childrenCount;
/**
* 0 目录, 1 国标通道, 2 直播流
*/
private int type;
public String getId() { public String getId() {
return id; return id;
@ -68,4 +84,19 @@ public class PlatformCatalog {
this.type = 2; this.type = 2;
} }
public String getCivilCode() {
return civilCode;
}
public void setCivilCode(String civilCode) {
this.civilCode = civilCode;
}
public String getBusinessGroupId() {
return businessGroupId;
}
public void setBusinessGroupId(String businessGroupId) {
this.businessGroupId = businessGroupId;
}
} }

View File

@ -0,0 +1,10 @@
package com.genersoft.iot.vmp.gb28181.bean;
/**
* 目录结构类型
* @author lin
*/
public class TreeType {
public static final String BUSINESS_GROUP = "BusinessGroup";
public static final String CIVIL_CODE = "CivilCode";
}

View File

@ -11,13 +11,40 @@ public class CatalogEvent extends ApplicationEvent {
super(source); super(source);
} }
public static final String ON = "ON"; // 上线 /**
public static final String OFF = "OFF"; // 离线 * 上线
public static final String VLOST = "VLOST"; // 视频丢失 */
public static final String DEFECT = "DEFECT"; // 故障 public static final String ON = "ON";
public static final String ADD = "ADD"; // 增加
public static final String DEL = "DEL"; // 删除 /**
public static final String UPDATE = "UPDATE"; // 更新 * 离线
*/
public static final String OFF = "OFF";
/**
* 视频丢失
*/
public static final String VLOST = "VLOST";
/**
* 故障
*/
public static final String DEFECT = "DEFECT";
/**
* 增加
*/
public static final String ADD = "ADD";
/**
* 删除
*/
public static final String DEL = "DEL";
/**
* 更新
*/
public static final String UPDATE = "UPDATE";
private List<DeviceChannel> deviceChannels; private List<DeviceChannel> deviceChannels;
private List<GbStream> gbStreams; private List<GbStream> gbStreams;

View File

@ -59,16 +59,15 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>(); Map<String, List<ParentPlatform>> parentPlatformMap = new HashMap<>();
if (!StringUtils.isEmpty(event.getPlatformId())) { if (!StringUtils.isEmpty(event.getPlatformId())) {
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
if (subscribe == null) {
return;
}
parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId()); parentPlatform = storager.queryParentPlatByServerGBId(event.getPlatformId());
if (parentPlatform != null && !parentPlatform.isStatus()) { if (parentPlatform != null && !parentPlatform.isStatus()) {
return; return;
} }
subscribe = subscribeHolder.getCatalogSubscribe(event.getPlatformId());
if (subscribe == null) {
logger.info("发送订阅消息时发现订阅信息已经不存在: {}", event.getPlatformId());
return;
}
}else { }else {
// 获取所用订阅 // 获取所用订阅
List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform(); List<String> platforms = subscribeHolder.getAllCatalogSubscribePlatform();
@ -144,11 +143,8 @@ public class CatalogEventLister implements ApplicationListener<CatalogEvent> {
} }
if (event.getGbStreams() != null && event.getGbStreams().size() > 0){ if (event.getGbStreams() != null && event.getGbStreams().size() > 0){
for (GbStream gbStream : event.getGbStreams()) { for (GbStream gbStream : event.getGbStreams()) {
DeviceChannel deviceChannelByStream = gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform); deviceChannelList.add(
if (deviceChannelByStream.getParentId().length() <= 10) { // 父节点是行政区划,则设置CivilCode使用此行政区划 gbStreamService.getDeviceChannelListByStream(gbStream, gbStream.getCatalogId(), parentPlatform));
deviceChannelByStream.setCivilCode(deviceChannelByStream.getParentId());
}
deviceChannelList.add(deviceChannelByStream);
} }
} }
if (deviceChannelList.size() > 0) { if (deviceChannelList.size() > 0) {

View File

@ -57,18 +57,14 @@ public class MobilePositionSubscribeHandlerTask implements ISubscribeTask {
SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId()); SubscribeInfo subscribe = subscribeHolder.getMobilePositionSubscribe(platform.getServerGBId());
if (subscribe != null) { if (subscribe != null) {
// if (!parentPlatform.isStatus()) {
// logger.info("发送订阅时发现平台已经离线:{}", platformId);
// return;
// }
// TODO 暂时只处理视频流的回复,后续增加对国标设备的支持 // TODO 暂时只处理视频流的回复,后续增加对国标设备的支持
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId()); List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(platform.getServerGBId());
if (gbStreams.size() == 0) { if (gbStreams.size() == 0) {
logger.info("发送订阅时发现平台已经没有关联的直播流:{}", platform.getServerGBId()); logger.info("发送订阅时发现平台已经没有关联的直播流:{}", platform.getServerGBId());
return; return;
} }
for (GbStream gbStream : gbStreams) { for (DeviceChannel deviceChannel : gbStreams) {
String gbId = gbStream.getGbId(); String gbId = deviceChannel.getChannelId();
GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId); GPSMsgInfo gpsMsgInfo = redisCatchStorage.getGpsMsgInfo(gbId);
if (gpsMsgInfo != null) { // 无最新位置不发送 if (gpsMsgInfo != null) { // 无最新位置不发送
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {

View File

@ -257,37 +257,37 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n"); catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
if (channels.size() > 0) { if (channels.size() > 0) {
for (DeviceChannel channel : channels) { for (DeviceChannel channel : channels) {
if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
channel.setParentId(parentPlatform.getDeviceGBId());
}
catalogXml.append("<Item>\r\n"); catalogXml.append("<Item>\r\n");
// 行政区划分组只需要这两项就可以
catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParentId() != null) { if (channel.getParentId() != null) {
// 业务分组加上这一项即可提高兼容性
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
} }
if (channel.getChannelId().length() == 20) { if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
if (Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段 // 虚拟组织增加BusinessGroupID字段
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n"); catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
} }
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParental() == 0) {
// 通道项
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n"); catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下字段
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n"); catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n"); catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n"); catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
catalogXml.append("<Longitude>" + channel.getLongitudeWgs84() + "</Longitude>\r\n");
catalogXml.append("<Latitude>" + channel.getLatitudeWgs84() + "</Latitude>\r\n");
catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
catalogXml.append("<Info>\r\n");
catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
catalogXml.append("</Info>\r\n");
}
} }
}
catalogXml.append("</Item>\r\n"); catalogXml.append("</Item>\r\n");
} }
} }
@ -592,28 +592,36 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
channel.setParentId(parentPlatform.getDeviceGBId()); channel.setParentId(parentPlatform.getDeviceGBId());
} }
catalogXml.append("<Item>\r\n"); catalogXml.append("<Item>\r\n");
// 行政区划分组只需要这两项就可以
catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n"); catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n"); catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParentId() != null) { if (channel.getParentId() != null) {
// 业务分组加上这一项即可提高兼容性
catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
} }
if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) {
// 虚拟组织增加BusinessGroupID字段
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n");
}
catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
if (channel.getParental() == 0) {
// 通道项
catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n"); catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n"); catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n"); catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
if (channel.getChannelId().length() == 20 && Integer.parseInt(channel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织增加BusinessGroupID字段
catalogXml.append("<BusinessGroupID>" + channel.getParentId() + "</BusinessGroupID>\r\n"); if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
}
if (channel.getChannelType() == 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n"); catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
catalogXml.append("<Owner>0</Owner>\r\n"); catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n"); catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n"); catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
} }
if (!"presence".equals(subscribeInfo.getEventType())) { if (!"presence".equals(subscribeInfo.getEventType())) {
catalogXml.append("<Event>" + type + "</Event>\r\n"); catalogXml.append("<Event>" + type + "</Event>\r\n");
} }
}
catalogXml.append("</Item>\r\n"); catalogXml.append("</Item>\r\n");
} }
} }

View File

@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.gb28181.utils.SipUtils; import com.genersoft.iot.vmp.gb28181.utils.SipUtils;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
@ -71,6 +72,9 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
@Autowired @Autowired
private SIPProcessorObserver sipProcessorObserver; private SIPProcessorObserver sipProcessorObserver;
@Autowired
private IDeviceChannelService deviceChannelService;
private boolean taskQueueHandlerRun = false; private boolean taskQueueHandlerRun = false;
private final ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>(); private final ConcurrentLinkedQueue<HandlerCatchData> taskQueue = new ConcurrentLinkedQueue<>();
@ -173,28 +177,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
logger.info("[收到 移动位置订阅]{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(), logger.info("[收到 移动位置订阅]{}/{}->{}.{}", mobilePosition.getDeviceId(), mobilePosition.getChannelId(),
mobilePosition.getLongitude(), mobilePosition.getLatitude()); mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setReportSource("Mobile Position"); mobilePosition.setReportSource("Mobile Position");
// 默认来源坐标系为WGS-84处理
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度 // 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
@ -202,11 +185,18 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
deviceChannel.setChannelId(channelId); deviceChannel.setChannelId(channelId);
deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
storager.updateChannelPosition(deviceChannel); storager.updateChannelPosition(deviceChannel);
// 发送redis消息 通知位置信息的变化 // 发送redis消息 通知位置信息的变化
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
@ -281,38 +271,28 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
mobilePosition.setLongitude(deviceAlarm.getLongitude()); mobilePosition.setLongitude(deviceAlarm.getLongitude());
mobilePosition.setLatitude(deviceAlarm.getLatitude()); mobilePosition.setLatitude(deviceAlarm.getLatitude());
mobilePosition.setReportSource("GPS Alarm"); mobilePosition.setReportSource("GPS Alarm");
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度 // 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(channelId); deviceChannel.setChannelId(channelId);
deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
storager.updateChannelPosition(deviceChannel); storager.updateChannelPosition(deviceChannel);
} }
// TODO: 需要实现存储报警信息报警分类 // TODO: 需要实现存储报警信息报警分类
@ -364,7 +344,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
}else { }else {
event = eventElement.getText().toUpperCase(); event = eventElement.getText().toUpperCase();
} }
DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device); DeviceChannel channel = XmlUtil.channelContentHander(itemDevice, device, event);
channel.setDeviceId(device.getDeviceId()); channel.setDeviceId(device.getDeviceId());
logger.info("[收到 目录订阅]{}/{}", device.getDeviceId(), channel.getChannelId()); logger.info("[收到 目录订阅]{}/{}", device.getDeviceId(), channel.getChannelId());
switch (event) { switch (event) {
@ -389,7 +369,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
case CatalogEvent.ADD: case CatalogEvent.ADD:
// 增加 // 增加
logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channel.getChannelId()); logger.info("收到来自设备【{}】的增加通道【{}】通知", device.getDeviceId(), channel.getChannelId());
storager.updateChannel(deviceId, channel); deviceChannelService.updateChannel(deviceId, channel);
break; break;
case CatalogEvent.DEL: case CatalogEvent.DEL:
// 删除 // 删除
@ -399,7 +379,7 @@ public class NotifyRequestProcessor extends SIPRequestProcessorParent implements
case CatalogEvent.UPDATE: case CatalogEvent.UPDATE:
// 更新 // 更新
logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channel.getChannelId()); logger.info("收到来自设备【{}】的更新通道【{}】通知", device.getDeviceId(), channel.getChannelId());
storager.updateChannel(deviceId, channel); deviceChannelService.updateChannel(deviceId, channel);
break; break;
default: default:
logger.warn("[ NotifyCatalog ] event not found {}", event ); logger.warn("[ NotifyCatalog ] event not found {}", event );

View File

@ -11,6 +11,7 @@ import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.gb28181.utils.XmlUtil; import com.genersoft.iot.vmp.gb28181.utils.XmlUtil;
import com.genersoft.iot.vmp.service.IDeviceAlarmService; import com.genersoft.iot.vmp.service.IDeviceAlarmService;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
@ -58,6 +59,9 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
@Autowired @Autowired
private IDeviceAlarmService deviceAlarmService; private IDeviceAlarmService deviceAlarmService;
@Autowired
private IDeviceChannelService deviceChannelService;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
notifyMessageHandler.addHandler(cmdType, this); notifyMessageHandler.addHandler(cmdType, this);
@ -119,38 +123,26 @@ public class AlarmNotifyMessageHandler extends SIPRequestProcessorParent impleme
mobilePosition.setLongitude(deviceAlarm.getLongitude()); mobilePosition.setLongitude(deviceAlarm.getLongitude());
mobilePosition.setLatitude(deviceAlarm.getLatitude()); mobilePosition.setLatitude(deviceAlarm.getLatitude());
mobilePosition.setReportSource("GPS Alarm"); mobilePosition.setReportSource("GPS Alarm");
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度 // 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(channelId); deviceChannel.setChannelId(channelId);
deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
storager.updateChannelPosition(deviceChannel); storager.updateChannelPosition(deviceChannel);
} }
} }

View File

@ -58,85 +58,21 @@ public class CatalogNotifyMessageHandler extends SIPRequestProcessorParent imple
// 准备回复通道信息 // 准备回复通道信息
List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); List<DeviceChannelInPlatform> deviceChannels = storage.queryChannelListInParentPlatform(parentPlatform.getServerGBId());
// 查询关联的直播通道 // 查询关联的直播通道
List<GbStream> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); List<DeviceChannel> gbStreams = storage.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
// 回复目录信息
List<DeviceChannel> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
List<DeviceChannel> allChannels = new ArrayList<>(); List<DeviceChannel> allChannels = new ArrayList<>();
// 回复目录信息
List<PlatformCatalog> catalogs = storage.queryCatalogInPlatform(parentPlatform.getServerGBId());
if (catalogs.size() > 0) { if (catalogs.size() > 0) {
for (PlatformCatalog catalog : catalogs) { allChannels.addAll(catalogs);
if (catalog.getParentId().equals(catalog.getPlatformId())) {
catalog.setParentId(parentPlatform.getDeviceGBId());
}
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(catalog.getId());
deviceChannel.setName(catalog.getName());
deviceChannel.setLongitude(0.0);
deviceChannel.setLatitude(0.0);
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro");
deviceChannel.setStatus(1);
deviceChannel.setParental(1);
deviceChannel.setParentId(catalog.getParentId());
deviceChannel.setRegisterWay(1);
if (catalog.getParentId() != null && catalog.getParentId().length() <= 10) {
deviceChannel.setCivilCode(catalog.getParentId());
}else {
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
}
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
deviceChannel.setModel("live");
deviceChannel.setOwner("wvp-pro");
deviceChannel.setSecrecy("0");
allChannels.add(deviceChannel);
}
} }
// 回复级联的通道 // 回复级联的通道
if (deviceChannels.size() > 0) { if (deviceChannels.size() > 0) {
for (DeviceChannelInPlatform channel : deviceChannels) { allChannels.addAll(deviceChannels);
if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
channel.setCatalogId(parentPlatform.getDeviceGBId());
}
DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
deviceChannel.setParental(0);
deviceChannel.setParentId(channel.getCatalogId());
if (channel.getCatalogId() != null && channel.getCatalogId().length() <= 10) {
channel.setCivilCode(channel.getCatalogId());
}else {
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
}
allChannels.add(deviceChannel);
}
} }
// 回复直播的通道 // 回复直播的通道
if (gbStreams.size() > 0) { if (gbStreams.size() > 0) {
for (GbStream gbStream : gbStreams) { allChannels.addAll(gbStreams);
if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) {
gbStream.setCatalogId(null);
}
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(gbStream.getGbId());
deviceChannel.setName(gbStream.getName());
deviceChannel.setLongitude(gbStream.getLongitude());
deviceChannel.setLatitude(gbStream.getLatitude());
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro");
// deviceChannel.setStatus(gbStream.isStatus()?1:0);
deviceChannel.setStatus(1);
deviceChannel.setParentId(gbStream.getCatalogId());
deviceChannel.setRegisterWay(1);
if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() <= 10) {
deviceChannel.setCivilCode(gbStream.getCatalogId());
}else {
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
}
deviceChannel.setModel("live");
deviceChannel.setOwner("wvp-pro");
deviceChannel.setParental(0);
deviceChannel.setSecrecy("0");
allChannels.add(deviceChannel);
}
} }
if (allChannels.size() > 0) { if (allChannels.size() > 0) {
cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag()); cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag());

View File

@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.notify.NotifyMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.GpsUtil; import com.genersoft.iot.vmp.utils.GpsUtil;
@ -42,6 +43,9 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
@Autowired @Autowired
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired
private IDeviceChannelService deviceChannelService;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
notifyMessageHandler.addHandler(cmdType, this); notifyMessageHandler.addHandler(cmdType, this);
@ -79,38 +83,26 @@ public class MobilePositionNotifyMessageHandler extends SIPRequestProcessorParen
mobilePosition.setAltitude(0.0); mobilePosition.setAltitude(0.0);
} }
mobilePosition.setReportSource("Mobile Position"); mobilePosition.setReportSource("Mobile Position");
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度 // 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(mobilePosition.getChannelId()); deviceChannel.setChannelId(mobilePosition.getChannelId());
deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
storager.updateChannelPosition(deviceChannel); storager.updateChannelPosition(deviceChannel);
//回复 200 OK //回复 200 OK
responseAck(evt, Response.OK); responseAck(evt, Response.OK);

View File

@ -70,86 +70,24 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
Element snElement = rootElement.element("SN"); Element snElement = rootElement.element("SN");
String sn = snElement.getText(); String sn = snElement.getText();
// 准备回复通道信息 // 准备回复通道信息
List<DeviceChannelInPlatform> deviceChannelInPlatforms = storager.queryChannelListInParentPlatform(parentPlatform.getServerGBId()); List<DeviceChannel> deviceChannelInPlatforms = storager.queryChannelWithCatalog(parentPlatform.getServerGBId());
// 查询关联的直播通道 // 查询关联的直播通道
List<GbStream> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId()); List<DeviceChannel> gbStreams = storager.queryGbStreamListInPlatform(parentPlatform.getServerGBId());
// 回复目录信息 // 回复目录信息
List<PlatformCatalog> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId()); List<DeviceChannel> catalogs = storager.queryCatalogInPlatform(parentPlatform.getServerGBId());
List<DeviceChannel> allChannels = new ArrayList<>(); List<DeviceChannel> allChannels = new ArrayList<>();
if (catalogs.size() > 0) { if (catalogs.size() > 0) {
for (PlatformCatalog catalog : catalogs) { allChannels.addAll(catalogs);
if (catalog.getParentId().equals(catalog.getPlatformId())) {
catalog.setParentId(parentPlatform.getDeviceGBId());
}
DeviceChannel deviceChannel = new DeviceChannel();
// 通道的类型0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
deviceChannel.setChannelType(2);
deviceChannel.setChannelId(catalog.getId());
deviceChannel.setName(catalog.getName());
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro");
deviceChannel.setStatus(1);
deviceChannel.setParental(1);
deviceChannel.setParentId(catalog.getParentId());
deviceChannel.setRegisterWay(1);
if (catalog.getParentId() != null && catalog.getParentId().length() < 10) {
deviceChannel.setCivilCode(catalog.getParentId());
}else {
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
}
allChannels.add(deviceChannel);
}
} }
// 回复级联的通道 // 回复级联的通道
if (deviceChannelInPlatforms.size() > 0) { if (deviceChannelInPlatforms.size() > 0) {
for (DeviceChannelInPlatform channel : deviceChannelInPlatforms) { allChannels.addAll(deviceChannelInPlatforms);
if (channel.getCatalogId().equals(parentPlatform.getServerGBId())) {
channel.setCatalogId(parentPlatform.getDeviceGBId());
}
DeviceChannel deviceChannel = storage.queryChannel(channel.getDeviceId(), channel.getChannelId());
// 通道的类型0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
deviceChannel.setChannelType(0);
deviceChannel.setParental(0);
deviceChannel.setParentId(channel.getCatalogId());
if (channel.getCatalogId() != null && channel.getCatalogId().length() < 10) {
deviceChannel.setCivilCode(channel.getCatalogId());
}else {
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
}
allChannels.add(deviceChannel);
}
} }
// 回复直播的通道 // 回复直播的通道
if (gbStreams.size() > 0) { if (gbStreams.size() > 0) {
for (GbStream gbStream : gbStreams) { allChannels.addAll(gbStreams);
if (gbStream.getCatalogId().equals(parentPlatform.getServerGBId())) {
gbStream.setCatalogId(null);
}
DeviceChannel deviceChannel = new DeviceChannel();
// 通道的类型0->国标通道 1->直播流通道 2->业务分组/虚拟组织/行政区划
deviceChannel.setChannelType(1);
deviceChannel.setChannelId(gbStream.getGbId());
deviceChannel.setName(gbStream.getName());
deviceChannel.setLongitude(gbStream.getLongitude());
deviceChannel.setLatitude(gbStream.getLatitude());
deviceChannel.setDeviceId(parentPlatform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro");
// deviceChannel.setStatus(gbStream.isStatus()?1:0);
deviceChannel.setStatus(1);
deviceChannel.setParentId(gbStream.getCatalogId());
deviceChannel.setRegisterWay(1);
if (gbStream.getCatalogId() != null && gbStream.getCatalogId().length() < 10) {
deviceChannel.setCivilCode(gbStream.getCatalogId());
}else {
deviceChannel.setCivilCode(parentPlatform.getAdministrativeDivision());
}
deviceChannel.setModel("live");
deviceChannel.setOwner("wvp-pro");
deviceChannel.setParental(0);
deviceChannel.setSecrecy("0");
allChannels.add(deviceChannel);
}
} }
if (allChannels.size() > 0) { if (allChannels.size() > 0) {
cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag()); cmderFroPlatform.catalogQuery(allChannels, parentPlatform, sn, fromHeader.getTag());

View File

@ -125,11 +125,7 @@ public class CatalogResponseMessageHandler extends SIPRequestProcessorParent imp
if (channelDeviceElement == null) { if (channelDeviceElement == null) {
continue; continue;
} }
//by brewswang DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device, null);
// if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {//如果包含位置信息就更新一下位置
// processNotifyMobilePosition(evt, itemDevice);
// }
DeviceChannel deviceChannel = XmlUtil.channelContentHander(itemDevice, device);
deviceChannel.setDeviceId(take.getDevice().getDeviceId()); deviceChannel.setDeviceId(take.getDevice().getDeviceId());
channelList.add(deviceChannel); channelList.add(deviceChannel);

View File

@ -87,7 +87,6 @@ public class DeviceInfoResponseMessageHandler extends SIPRequestProcessorParent
device.setStreamMode("UDP"); device.setStreamMode("UDP");
} }
deviceService.updateDevice(device); deviceService.updateDevice(device);
// storager.updateDevice(device);
RequestMessage msg = new RequestMessage(); RequestMessage msg = new RequestMessage();
msg.setKey(key); msg.setKey(key);

View File

@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessag
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.ResponseMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.gb28181.utils.NumericUtil; import com.genersoft.iot.vmp.gb28181.utils.NumericUtil;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.utils.GpsUtil; import com.genersoft.iot.vmp.utils.GpsUtil;
@ -42,6 +43,9 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
@Autowired @Autowired
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired
private IDeviceChannelService deviceChannelService;
@Override @Override
public void afterPropertiesSet() throws Exception { public void afterPropertiesSet() throws Exception {
responseMessageHandler.addHandler(cmdType, this); responseMessageHandler.addHandler(cmdType, this);
@ -79,38 +83,25 @@ public class MobilePositionResponseMessageHandler extends SIPRequestProcessorPar
mobilePosition.setAltitude(0.0); mobilePosition.setAltitude(0.0);
} }
mobilePosition.setReportSource("Mobile Position"); mobilePosition.setReportSource("Mobile Position");
if ("WGS84".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeWgs84(mobilePosition.getLongitude());
mobilePosition.setLatitudeWgs84(mobilePosition.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeGcj02(position[0]);
mobilePosition.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
mobilePosition.setLongitudeGcj02(mobilePosition.getLongitude());
mobilePosition.setLatitudeGcj02(mobilePosition.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(mobilePosition.getLongitude(), mobilePosition.getLatitude());
mobilePosition.setLongitudeWgs84(position[0]);
mobilePosition.setLatitudeWgs84(position[1]);
}else {
mobilePosition.setLongitudeGcj02(0.00);
mobilePosition.setLatitudeGcj02(0.00);
mobilePosition.setLongitudeWgs84(0.00);
mobilePosition.setLatitudeWgs84(0.00);
}
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
// 更新device channel 的经纬度 // 更新device channel 的经纬度
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setDeviceId(device.getDeviceId()); deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setChannelId(mobilePosition.getChannelId()); deviceChannel.setChannelId(mobilePosition.getChannelId());
deviceChannel.setLongitude(mobilePosition.getLongitude()); deviceChannel.setLongitude(mobilePosition.getLongitude());
deviceChannel.setLatitude(mobilePosition.getLatitude()); deviceChannel.setLatitude(mobilePosition.getLatitude());
deviceChannel.setLongitudeWgs84(mobilePosition.getLongitudeWgs84());
deviceChannel.setLatitudeWgs84(mobilePosition.getLatitudeWgs84());
deviceChannel.setLongitudeGcj02(mobilePosition.getLongitudeGcj02());
deviceChannel.setLatitudeGcj02(mobilePosition.getLatitudeGcj02());
deviceChannel.setGpsTime(mobilePosition.getTime()); deviceChannel.setGpsTime(mobilePosition.getTime());
deviceChannel = deviceChannelService.updateGps(deviceChannel, device);
mobilePosition.setLongitudeWgs84(deviceChannel.getLongitudeWgs84());
mobilePosition.setLatitudeWgs84(deviceChannel.getLatitudeWgs84());
mobilePosition.setLongitudeGcj02(deviceChannel.getLongitudeGcj02());
mobilePosition.setLatitudeGcj02(deviceChannel.getLatitudeGcj02());
if (userSetting.getSavePositionHistory()) {
storager.insertMobilePosition(mobilePosition);
}
storager.updateChannelPosition(deviceChannel); storager.updateChannelPosition(deviceChannel);
//回复 200 OK //回复 200 OK
responseAck(evt, Response.OK); responseAck(evt, Response.OK);

View File

@ -4,6 +4,8 @@ import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.gb28181.bean.Device; import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
import org.dom4j.Attribute; import org.dom4j.Attribute;
import org.dom4j.Document; import org.dom4j.Document;
@ -29,7 +31,7 @@ public class XmlUtil {
/** /**
* 日志服务 * 日志服务
*/ */
private static Logger LOG = LoggerFactory.getLogger(XmlUtil.class); private static Logger logger = LoggerFactory.getLogger(XmlUtil.class);
/** /**
* 解析XML为Document对象 * 解析XML为Document对象
@ -46,7 +48,7 @@ public class XmlUtil {
try { try {
document = saxReader.read(sr); document = saxReader.read(sr);
} catch (DocumentException e) { } catch (DocumentException e) {
LOG.error("解析失败", e); logger.error("解析失败", e);
} }
return null == document ? null : document.getRootElement(); return null == document ? null : document.getRootElement();
} }
@ -182,47 +184,69 @@ public class XmlUtil {
return xml.getRootElement(); return xml.getRootElement();
} }
public static DeviceChannel channelContentHander(Element itemDevice, Device device){ private enum ChannelType{
Element channdelNameElement = itemDevice.element("Name"); CivilCode, BusinessGroup,VirtualOrganization,Other
String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim().toString() : "";
Element statusElement = itemDevice.element("Status");
String status = statusElement != null ? statusElement.getTextTrim().toString() : "ON";
DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setName(channelName);
Element channdelIdElement = itemDevice.element("DeviceID");
String channelId = channdelIdElement != null ? channdelIdElement.getTextTrim().toString() : "";
deviceChannel.setChannelId(channelId);
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) {
deviceChannel.setStatus(1);
}
if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
deviceChannel.setStatus(0);
} }
deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer")); public static DeviceChannel channelContentHander(Element itemDevice, Device device, String event){
deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model")); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner")); deviceChannel.setDeviceId(device.getDeviceId());
deviceChannel.setCivilCode(XmlUtil.getText(itemDevice, "CivilCode")); Element channdelIdElement = itemDevice.element("DeviceID");
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block")); if (channdelIdElement == null) {
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address")); logger.warn("解析Catalog消息时发现缺少 DeviceID");
String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID"); return null;
if (XmlUtil.getText(itemDevice, "Parental") == null
|| XmlUtil.getText(itemDevice, "Parental").equals("")) {
if (deviceChannel.getChannelId().length() <= 10
|| (deviceChannel.getChannelId().length() == 20 && (
Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 215
|| Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216
)
)
) {
deviceChannel.setParental(1);
}else {
deviceChannel.setParental(0);
} }
String channelId = channdelIdElement.getTextTrim();
if (StringUtils.isEmpty(channelId)) {
logger.warn("解析Catalog消息时发现缺少 DeviceID");
return null;
}
deviceChannel.setChannelId(channelId);
if (event != null && !event.equals(CatalogEvent.ADD) && !event.equals(CatalogEvent.UPDATE)) {
// 除了ADD和update情况下需要识别全部内容
return deviceChannel;
}
ChannelType channelType = ChannelType.Other;
if (channelId.length() <= 8) {
channelType = ChannelType.CivilCode;
}else { }else {
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1 if (channelId.length() == 20) {
deviceChannel.setParental(Integer.parseInt(XmlUtil.getText(itemDevice, "Parental")) == 1?1:0); int code = Integer.parseInt(channelId.substring(10, 13));
switch (code){
case 215:
channelType = ChannelType.BusinessGroup;
break;
case 216:
channelType = ChannelType.VirtualOrganization;
break;
default:
break;
}
}
}
Element channdelNameElement = itemDevice.element("Name");
String channelName = channdelNameElement != null ? channdelNameElement.getTextTrim() : "";
deviceChannel.setName(channelName);
String civilCode = XmlUtil.getText(itemDevice, "CivilCode");
deviceChannel.setCivilCode(civilCode);
if (channelType == ChannelType.CivilCode && civilCode == null) {
deviceChannel.setParental(1);
// 行政区划如果没有传递具体值则推测一个
if (channelId.length() > 2) {
deviceChannel.setCivilCode(channelId.substring(0, channelId.length() - 2));
}
}
if (channelType.equals(ChannelType.CivilCode)) {
// 行政区划其他字段没必要识别了默认在线即可
deviceChannel.setStatus(1);
deviceChannel.setParental(1);
deviceChannel.setCreateTime(DateUtil.getNow());
deviceChannel.setUpdateTime(DateUtil.getNow());
return deviceChannel;
} }
/** /**
* 行政区划展示设备树与业务分组展示设备树是两种不同的模式 * 行政区划展示设备树与业务分组展示设备树是两种不同的模式
@ -230,7 +254,17 @@ public class XmlUtil {
* 河北省 * 河北省
* --> 石家庄市 * --> 石家庄市
* --> 摄像头 * --> 摄像头
* --> 正定县 *String parentId = XmlUtil.getText(itemDevice, "ParentID");
if (parentId != null) {
if (parentId.contains("/")) {
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
String businessGroup = parentId.substring(0, parentId.indexOf("/"));
deviceChannel.setParentId(lastParentId);
}else {
deviceChannel.setParentId(parentId);
}
}
deviceCh --> 正定县
* --> 摄像头 * --> 摄像头
* --> 摄像头 * --> 摄像头
* *
@ -243,59 +277,88 @@ public class XmlUtil {
* --> 摄像头 * --> 摄像头
*/ */
String parentId = XmlUtil.getText(itemDevice, "ParentID"); String parentId = XmlUtil.getText(itemDevice, "ParentID");
String businessGroupID = XmlUtil.getText(itemDevice, "BusinessGroupID");
if (parentId != null) { if (parentId != null) {
if (parentId.contains("/")) { if (parentId.contains("/")) {
String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1); String lastParentId = parentId.substring(parentId.lastIndexOf("/") + 1);
if (businessGroupID == null) {
businessGroupID = parentId.substring(0, parentId.indexOf("/"));
}
deviceChannel.setParentId(lastParentId); deviceChannel.setParentId(lastParentId);
}else { }else {
deviceChannel.setParentId(parentId); deviceChannel.setParentId(parentId);
} }
} }
deviceChannel.setBusinessGroupId(businessGroupID); deviceChannel.setBusinessGroupId(businessGroupID);
if (channelType.equals(ChannelType.BusinessGroup) || channelType.equals(ChannelType.VirtualOrganization)) {
// 业务分组和虚拟组织 其他字段没必要识别了默认在线即可
deviceChannel.setStatus(1);
deviceChannel.setParental(1);
deviceChannel.setCreateTime(DateUtil.getNow());
deviceChannel.setUpdateTime(DateUtil.getNow());
return deviceChannel;
}
// else { Element statusElement = itemDevice.element("Status");
// if (deviceChannel.getChannelId().length() <= 10) { // 此时为行政区划, 上下级行政区划使用DeviceId关联
// deviceChannel.setParentId(deviceChannel.getChannelId().substring(0, deviceChannel.getChannelId().length() - 2));
// }else if (deviceChannel.getChannelId().length() == 20) {
// if (Integer.parseInt(deviceChannel.getChannelId().substring(10, 13)) == 216) { // 虚拟组织
// deviceChannel.setBusinessGroupId(businessGroupID);
// }else if (Integer.parseInt(device.getDeviceId().substring(10, 13) )== 118) {//NVR 如果上级设备编号是NVR则直接将NVR的编号设置给通道的上级编号
// deviceChannel.setParentId(device.getDeviceId());
// }else if (deviceChannel.getCivilCode() != null) {
// // 设备 无parentId的20位是使用CivilCode表示上级的设备
// // 215 业务分组是需要有parentId的
// deviceChannel.setParentId(deviceChannel.getCivilCode());
// }
// }else {
// deviceChannel.setParentId(deviceChannel.getDeviceId());
// }
// }
if (XmlUtil.getText(itemDevice, "SafetyWay") == null if (statusElement != null) {
|| XmlUtil.getText(itemDevice, "SafetyWay") == "") { String status = statusElement.getTextTrim().trim();
// ONLINE OFFLINE HIKVISION DS-7716N-E4 NVR的兼容性处理
if (status.equals("ON") || status.equals("On") || status.equals("ONLINE") || status.equals("OK")) {
deviceChannel.setStatus(1);
}
if (status.equals("OFF") || status.equals("Off") || status.equals("OFFLINE")) {
deviceChannel.setStatus(0);
}
}else {
deviceChannel.setStatus(1);
}
// 识别自带的目录标识
String parental = XmlUtil.getText(itemDevice, "Parental");
// 由于海康会错误的发送65535作为这里的取值,所以这里除非是0否则认为是1
if (!StringUtils.isEmpty(parental) && parental.length() == 1 && Integer.parseInt(parental) == 0) {
deviceChannel.setParental(0);
}else {
deviceChannel.setParental(1);
}
deviceChannel.setManufacture(XmlUtil.getText(itemDevice, "Manufacturer"));
deviceChannel.setModel(XmlUtil.getText(itemDevice, "Model"));
deviceChannel.setOwner(XmlUtil.getText(itemDevice, "Owner"));
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
deviceChannel.setBlock(XmlUtil.getText(itemDevice, "Block"));
deviceChannel.setAddress(XmlUtil.getText(itemDevice, "Address"));
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
String safetyWay = XmlUtil.getText(itemDevice, "SafetyWay");
if (StringUtils.isEmpty(safetyWay)) {
deviceChannel.setSafetyWay(0); deviceChannel.setSafetyWay(0);
} else { } else {
deviceChannel.setSafetyWay(Integer.parseInt(XmlUtil.getText(itemDevice, "SafetyWay"))); deviceChannel.setSafetyWay(Integer.parseInt(safetyWay));
} }
if (XmlUtil.getText(itemDevice, "RegisterWay") == null
|| XmlUtil.getText(itemDevice, "RegisterWay") == "") { String registerWay = XmlUtil.getText(itemDevice, "RegisterWay");
if (StringUtils.isEmpty(registerWay)) {
deviceChannel.setRegisterWay(1); deviceChannel.setRegisterWay(1);
} else { } else {
deviceChannel.setRegisterWay(Integer.parseInt(XmlUtil.getText(itemDevice, "RegisterWay"))); deviceChannel.setRegisterWay(Integer.parseInt(registerWay));
} }
deviceChannel.setCertNum(XmlUtil.getText(itemDevice, "CertNum"));
if (XmlUtil.getText(itemDevice, "Certifiable") == null if (XmlUtil.getText(itemDevice, "Certifiable") == null
|| XmlUtil.getText(itemDevice, "Certifiable") == "") { || XmlUtil.getText(itemDevice, "Certifiable") == "") {
deviceChannel.setCertifiable(0); deviceChannel.setCertifiable(0);
} else { } else {
deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable"))); deviceChannel.setCertifiable(Integer.parseInt(XmlUtil.getText(itemDevice, "Certifiable")));
} }
if (XmlUtil.getText(itemDevice, "ErrCode") == null if (XmlUtil.getText(itemDevice, "ErrCode") == null
|| XmlUtil.getText(itemDevice, "ErrCode") == "") { || XmlUtil.getText(itemDevice, "ErrCode") == "") {
deviceChannel.setErrCode(0); deviceChannel.setErrCode(0);
} else { } else {
deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode"))); deviceChannel.setErrCode(Integer.parseInt(XmlUtil.getText(itemDevice, "ErrCode")));
} }
deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime")); deviceChannel.setEndTime(XmlUtil.getText(itemDevice, "EndTime"));
deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy")); deviceChannel.setSecrecy(XmlUtil.getText(itemDevice, "Secrecy"));
deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress")); deviceChannel.setIpAddress(XmlUtil.getText(itemDevice, "IPAddress"));
@ -304,43 +367,23 @@ public class XmlUtil {
} else { } else {
deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port"))); deviceChannel.setPort(Integer.parseInt(XmlUtil.getText(itemDevice, "Port")));
} }
deviceChannel.setPassword(XmlUtil.getText(itemDevice, "Password"));
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Longitude"))) {
deviceChannel.setLongitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Longitude"))); String longitude = XmlUtil.getText(itemDevice, "Longitude");
if (NumericUtil.isDouble(longitude)) {
deviceChannel.setLongitude(Double.parseDouble(longitude));
} else { } else {
deviceChannel.setLongitude(0.00); deviceChannel.setLongitude(0.00);
} }
if (NumericUtil.isDouble(XmlUtil.getText(itemDevice, "Latitude"))) { String latitude = XmlUtil.getText(itemDevice, "Latitude");
deviceChannel.setLatitude(Double.parseDouble(XmlUtil.getText(itemDevice, "Latitude"))); if (NumericUtil.isDouble(latitude)) {
deviceChannel.setLatitude(Double.parseDouble(latitude));
} else { } else {
deviceChannel.setLatitude(0.00); deviceChannel.setLatitude(0.00);
} }
deviceChannel.setGpsTime(DateUtil.getNow()); deviceChannel.setGpsTime(DateUtil.getNow());
if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
if ("WGS84".equals(device.getGeoCoordSys())) {
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeGcj02(position[0]);
deviceChannel.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(position[0]);
deviceChannel.setLatitudeWgs84(position[1]);
}else {
deviceChannel.setLongitudeGcj02(0.00);
deviceChannel.setLatitudeGcj02(0.00);
deviceChannel.setLongitudeWgs84(0.00);
deviceChannel.setLatitudeWgs84(0.00);
}
}else {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
}
if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) { if (XmlUtil.getText(itemDevice, "PTZType") == null || "".equals(XmlUtil.getText(itemDevice, "PTZType"))) {
//兼容INFO中的信息 //兼容INFO中的信息
Element info = itemDevice.element("Info"); Element info = itemDevice.element("Info");

View File

@ -136,4 +136,12 @@ public class AssistRESTfulUtils {
return sendGet(mediaServerItem, "api/record/file/duration",param, callback); return sendGet(mediaServerItem, "api/record/file/duration",param, callback);
} }
public JSONObject addStreamCallInfo(MediaServerItem mediaServerItem, String app, String stream, String callId, RequestCallback callback){
Map<String, Object> param = new HashMap<>();
param.put("app",app);
param.put("stream",stream);
param.put("callId",callId);
return sendGet(mediaServerItem, "api/record/addStreamCallInfo",param, callback);
}
} }

View File

@ -87,6 +87,9 @@ public class ZLMHttpHookListener {
@Autowired @Autowired
private VideoStreamSessionManager sessionManager; private VideoStreamSessionManager sessionManager;
@Autowired
private AssistRESTfulUtils assistRESTfulUtils;
/** /**
* 服务器定时上报时间上报间隔可配置默认10s上报一次 * 服务器定时上报时间上报间隔可配置默认10s上报一次
* *
@ -200,6 +203,8 @@ public class ZLMHttpHookListener {
logger.info("[ ZLM HOOK ]on_publish API调用参数" + json.toString()); logger.info("[ ZLM HOOK ]on_publish API调用参数" + json.toString());
JSONObject ret = new JSONObject(); JSONObject ret = new JSONObject();
String mediaServerId = json.getString("mediaServerId");
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (!"rtp".equals(param.getApp())) { if (!"rtp".equals(param.getApp())) {
// 推流鉴权 // 推流鉴权
if (param.getParams() == null) { if (param.getParams() == null) {
@ -231,6 +236,10 @@ public class ZLMHttpHookListener {
streamAuthorityInfo.setSign(sign); streamAuthorityInfo.setSign(sign);
// 鉴权通过 // 鉴权通过
redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo); redisCatchStorage.updateStreamAuthorityInfo(param.getApp(), param.getStream(), streamAuthorityInfo);
// 通知assist新的callId
if (mediaInfo != null) {
assistRESTfulUtils.addStreamCallInfo(mediaInfo, param.getApp(), param.getStream(), callId, null);
}
} }
ret.put("code", 0); ret.put("code", 0);
@ -240,10 +249,9 @@ public class ZLMHttpHookListener {
ret.put("enable_audio", true); ret.put("enable_audio", true);
} }
String mediaServerId = json.getString("mediaServerId");
ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json); ZLMHttpHookSubscribe.Event subscribe = this.subscribe.getSubscribe(ZLMHttpHookSubscribe.HookType.on_publish, json);
if (subscribe != null) { if (subscribe != null) {
MediaServerItem mediaInfo = mediaServerService.getOne(mediaServerId);
if (mediaInfo != null) { if (mediaInfo != null) {
subscribe.response(mediaInfo, json); subscribe.response(mediaInfo, json);
}else { }else {
@ -270,10 +278,12 @@ public class ZLMHttpHookListener {
ret.put("mp4_max_second", 10); ret.put("mp4_max_second", 10);
ret.put("enable_mp4", true); ret.put("enable_mp4", true);
ret.put("enable_audio", true); ret.put("enable_audio", true);
} }
} }
return new ResponseEntity<String>(ret.toString(), HttpStatus.OK); return new ResponseEntity<String>(ret.toString(), HttpStatus.OK);
} }

View File

@ -0,0 +1,35 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import java.util.List;
/**
* 国标通道业务类
* @author lin
*/
public interface IDeviceChannelService {
/**
* 更新gps信息
*/
DeviceChannel updateGps(DeviceChannel deviceChannel, Device device);
/**
* 添加设备通道
*
* @param deviceId 设备id
* @param channel 通道
*/
void updateChannel(String deviceId, DeviceChannel channel);
/**
* 批量添加设备通道
*
* @param deviceId 设备id
* @param channels 多个通道
*/
int updateChannels(String deviceId, List<DeviceChannel> channels);
}

View File

@ -18,7 +18,7 @@ public interface IGbStreamService {
* @param count * @param count
* @return * @return
*/ */
PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId,String query,Boolean pushing,String mediaServerId); PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId,String query,String mediaServerId);
/** /**

View File

@ -0,0 +1,22 @@
package com.genersoft.iot.vmp.service;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import java.util.List;
/**
* 平台关联通道管理
* @author lin
*/
public interface IPlatformChannelService {
/**
* 更新目录下的通道
* @param platformId 平台编号
* @param channelReduces 通道信息
* @param catalogId 目录编号
* @return
*/
int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
}

View File

@ -101,4 +101,9 @@ public interface IStreamProxyService {
void zlmServerOffline(String mediaServerId); void zlmServerOffline(String mediaServerId);
void clean(); void clean();
/**
* 更新代理流
*/
boolean updateStreamProxy(StreamProxyItem streamProxyItem);
} }

View File

@ -17,7 +17,6 @@ public class DeviceAlarmServiceImpl implements IDeviceAlarmService {
@Autowired @Autowired
private DeviceAlarmMapper deviceAlarmMapper; private DeviceAlarmMapper deviceAlarmMapper;
@Override @Override
public PageInfo<DeviceAlarm> getAllAlarm(int page, int count, String deviceId, String alarmPriority, String alarmMethod, String alarmType, String startTime, String endTime) { public PageInfo<DeviceAlarm> getAllAlarm(int page, int count, String deviceId, String alarmPriority, String alarmMethod, String alarmType, String startTime, String endTime) {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);

View File

@ -0,0 +1,165 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.gb28181.bean.Device;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.DeviceMapper;
import com.genersoft.iot.vmp.utils.DateUtil;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/**
* @author lin
*/
@Service
public class DeviceChannelServiceImpl implements IDeviceChannelService {
private final static Logger logger = LoggerFactory.getLogger(DeviceChannelServiceImpl.class);
@Autowired
private IRedisCatchStorage redisCatchStorage;
@Autowired
private DeviceChannelMapper channelMapper;
@Autowired
private DeviceMapper deviceMapper;
@Override
public DeviceChannel updateGps(DeviceChannel deviceChannel, Device device) {
if (deviceChannel.getLongitude()*deviceChannel.getLatitude() > 0) {
if (device == null) {
device = deviceMapper.getDeviceByDeviceId(deviceChannel.getDeviceId());
}
if ("WGS84".equals(device.getGeoCoordSys())) {
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeGcj02(position[0]);
deviceChannel.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(position[0]);
deviceChannel.setLatitudeWgs84(position[1]);
}else {
deviceChannel.setLongitudeGcj02(0.00);
deviceChannel.setLatitudeGcj02(0.00);
deviceChannel.setLongitudeWgs84(0.00);
deviceChannel.setLatitudeWgs84(0.00);
}
}else {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
}
return deviceChannel;
}
@Override
public void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
DeviceChannel deviceChannel = channelMapper.queryChannel(deviceId, channelId);
channel = updateGps(channel, null);
if (deviceChannel == null) {
channel.setCreateTime(now);
channelMapper.add(channel);
}else {
channelMapper.update(channel);
}
channelMapper.updateChannelSubCount(deviceId,channel.getParentId());
}
@Override
public int updateChannels(String deviceId, List<DeviceChannel> channels) {
List<DeviceChannel> addChannels = new ArrayList<>();
List<DeviceChannel> updateChannels = new ArrayList<>();
HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
Device device = deviceMapper.getDeviceByDeviceId(deviceId);
if (channels != null && channels.size() > 0) {
List<DeviceChannel> channelList = channelMapper.queryChannels(deviceId, null, null, null, null);
if (channelList.size() == 0) {
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
channel.setCreateTime(now);
channel = updateGps(channel, device);
addChannels.add(channel);
}
}else {
for (DeviceChannel deviceChannel : channelList) {
channelsInStore.put(deviceChannel.getChannelId(), deviceChannel);
}
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
channel = updateGps(channel, device);
if (channelsInStore.get(channel.getChannelId()) != null) {
updateChannels.add(channel);
}else {
addChannels.add(channel);
channel.setCreateTime(now);
}
}
}
int limitCount = 300;
if (addChannels.size() > 0) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > addChannels.size()) {
toIndex = addChannels.size();
}
channelMapper.batchAdd(addChannels.subList(i, toIndex));
}
}else {
channelMapper.batchAdd(addChannels);
}
}
if (updateChannels.size() > 0) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > updateChannels.size()) {
toIndex = updateChannels.size();
}
channelMapper.batchUpdate(updateChannels.subList(i, toIndex));
}
}else {
channelMapper.batchUpdate(updateChannels);
}
}
}
return addChannels.size() + updateChannels.size();
}
}

View File

@ -7,6 +7,7 @@ import com.genersoft.iot.vmp.gb28181.task.ISubscribeTask;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommander;
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler; import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.response.cmd.CatalogResponseMessageHandler;
import com.genersoft.iot.vmp.gb28181.utils.Coordtransform; import com.genersoft.iot.vmp.gb28181.utils.Coordtransform;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.CatalogSubscribeTask;
import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask; import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
@ -55,6 +56,9 @@ public class DeviceServiceImpl implements IDeviceService {
@Autowired @Autowired
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired @Autowired
private DeviceChannelMapper deviceChannelMapper; private DeviceChannelMapper deviceChannelMapper;
@ -324,24 +328,13 @@ public class DeviceServiceImpl implements IDeviceService {
private void updateDeviceChannelGeoCoordSys(Device device) { private void updateDeviceChannelGeoCoordSys(Device device) {
List<DeviceChannel> deviceChannels = deviceChannelMapper.getAllChannelWithCoordinate(device.getDeviceId()); List<DeviceChannel> deviceChannels = deviceChannelMapper.getAllChannelWithCoordinate(device.getDeviceId());
if (deviceChannels.size() > 0) { if (deviceChannels.size() > 0) {
List<DeviceChannel> deviceChannelsForStore = new ArrayList<>();
for (DeviceChannel deviceChannel : deviceChannels) { for (DeviceChannel deviceChannel : deviceChannels) {
if ("WGS84".equals(device.getGeoCoordSys())) { deviceChannelsForStore.add(deviceChannelService.updateGps(deviceChannel, device));
deviceChannel.setLongitudeWgs84(deviceChannel.getLongitude());
deviceChannel.setLatitudeWgs84(deviceChannel.getLatitude());
Double[] position = Coordtransform.WGS84ToGCJ02(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeGcj02(position[0]);
deviceChannel.setLatitudeGcj02(position[1]);
}else if ("GCJ02".equals(device.getGeoCoordSys())) {
deviceChannel.setLongitudeGcj02(deviceChannel.getLongitude());
deviceChannel.setLatitudeGcj02(deviceChannel.getLatitude());
Double[] position = Coordtransform.GCJ02ToWGS84(deviceChannel.getLongitude(), deviceChannel.getLatitude());
deviceChannel.setLongitudeWgs84(position[0]);
deviceChannel.setLatitudeWgs84(position[1]);
} }
deviceChannelService.updateChannels(device.getDeviceId(), deviceChannelsForStore);
} }
} }
storage.updateChannels(device.getDeviceId(), deviceChannels);
}
@Override @Override
@ -352,11 +345,11 @@ public class DeviceServiceImpl implements IDeviceService {
} }
if (parentId == null || parentId.equals(deviceId)) { if (parentId == null || parentId.equals(deviceId)) {
// 字根节点开始查询 // 字根节点开始查询
List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), true, !onlyCatalog); List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), true, !onlyCatalog);
return transportChannelsToTree(rootNodes, ""); return transportChannelsToTree(rootNodes, "");
} }
if ("CivilCode".equals(device.getTreeType())) { if (TreeType.CIVIL_CODE.equals(device.getTreeType())) {
if (parentId.length()%2 != 0) { if (parentId.length()%2 != 0) {
return null; return null;
} }
@ -386,7 +379,7 @@ public class DeviceServiceImpl implements IDeviceService {
} }
// 使用业务分组展示树 // 使用业务分组展示树
if ("BusinessGroup".equals(device.getTreeType())) { if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) {
if (parentId.length() < 14 ) { if (parentId.length() < 14 ) {
return null; return null;
} }
@ -406,11 +399,11 @@ public class DeviceServiceImpl implements IDeviceService {
} }
if (parentId == null || parentId.equals(deviceId)) { if (parentId == null || parentId.equals(deviceId)) {
// 字根节点开始查询 // 字根节点开始查询
List<DeviceChannel> rootNodes = getRootNodes(deviceId, "CivilCode".equals(device.getTreeType()), false, true); List<DeviceChannel> rootNodes = getRootNodes(deviceId, TreeType.CIVIL_CODE.equals(device.getTreeType()), false, true);
return rootNodes; return rootNodes;
} }
if ("CivilCode".equals(device.getTreeType())) { if (TreeType.CIVIL_CODE.equals(device.getTreeType())) {
if (parentId.length()%2 != 0) { if (parentId.length()%2 != 0) {
return null; return null;
} }
@ -431,7 +424,7 @@ public class DeviceServiceImpl implements IDeviceService {
} }
// 使用业务分组展示树 // 使用业务分组展示树
if ("BusinessGroup".equals(device.getTreeType())) { if (TreeType.BUSINESS_GROUP.equals(device.getTreeType())) {
if (parentId.length() < 14 ) { if (parentId.length() < 14 ) {
return null; return null;
} }

View File

@ -1,14 +1,13 @@
package com.genersoft.iot.vmp.service.impl; package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.conf.SipConfig; import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; import com.genersoft.iot.vmp.gb28181.bean.*;
import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.storager.dao.GbStreamMapper; import com.genersoft.iot.vmp.storager.dao.GbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper; import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.service.IGbStreamService; import com.genersoft.iot.vmp.service.IGbStreamService;
import com.github.pagehelper.PageHelper; import com.github.pagehelper.PageHelper;
@ -46,15 +45,15 @@ public class GbStreamServiceImpl implements IGbStreamService {
private ParentPlatformMapper platformMapper; private ParentPlatformMapper platformMapper;
@Autowired @Autowired
private SipConfig sipConfig; private PlatformCatalogMapper catalogMapper;
@Autowired @Autowired
private EventPublisher eventPublisher; private EventPublisher eventPublisher;
@Override @Override
public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId, String query, Boolean pushing, String mediaServerId) { public PageInfo<GbStream> getAll(Integer page, Integer count, String platFormId, String catalogId, String query, String mediaServerId) {
PageHelper.startPage(page, count); PageHelper.startPage(page, count);
List<GbStream> all = gbStreamMapper.selectAll(platFormId, catalogId, query, pushing, mediaServerId); List<GbStream> all = gbStreamMapper.selectAll(platFormId, catalogId, query, mediaServerId);
return new PageInfo<>(all); return new PageInfo<>(all);
} }
@ -102,16 +101,25 @@ public class GbStreamServiceImpl implements IGbStreamService {
deviceChannel.setLatitude(gbStream.getLatitude()); deviceChannel.setLatitude(gbStream.getLatitude());
deviceChannel.setDeviceId(platform.getDeviceGBId()); deviceChannel.setDeviceId(platform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro"); deviceChannel.setManufacture("wvp-pro");
// deviceChannel.setStatus(gbStream.isStatus()?1:0); deviceChannel.setStatus(gbStream.isStatus()?1:0);
deviceChannel.setStatus(1);
deviceChannel.setParentId(catalogId ==null?gbStream.getCatalogId():catalogId);
deviceChannel.setRegisterWay(1); deviceChannel.setRegisterWay(1);
if (catalogId.length() > 0 && catalogId.length() <= 10) {
// 父节点是行政区划,则设置CivilCode使用此行政区划
deviceChannel.setCivilCode(catalogId);
}else {
deviceChannel.setCivilCode(platform.getAdministrativeDivision()); deviceChannel.setCivilCode(platform.getAdministrativeDivision());
if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
deviceChannel.setCivilCode(catalogId);
}else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
PlatformCatalog catalog = catalogMapper.select(catalogId);
if (catalog == null) {
deviceChannel.setParentId(platform.getDeviceGBId());
deviceChannel.setBusinessGroupId(null);
}else {
deviceChannel.setParentId(catalog.getId());
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
} }
}
deviceChannel.setModel("live"); deviceChannel.setModel("live");
deviceChannel.setOwner("wvp-pro"); deviceChannel.setOwner("wvp-pro");
deviceChannel.setParental(0); deviceChannel.setParental(0);

View File

@ -0,0 +1,110 @@
package com.genersoft.iot.vmp.service.impl;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.service.IPlatformChannelService;
import com.genersoft.iot.vmp.storager.dao.DeviceChannelMapper;
import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformCatalogMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformChannelMapper;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.PlatformController;
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
import com.sun.org.apache.xml.internal.resolver.CatalogManager;
import javafx.application.Platform;
import org.apache.ibatis.annotations.Mapper;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
/**
* @author lin
*/
@Service
public class PlatformChannelServiceImpl implements IPlatformChannelService {
private final static Logger logger = LoggerFactory.getLogger(PlatformChannelServiceImpl.class);
@Autowired
private PlatformChannelMapper platformChannelMapper;
@Autowired
private DeviceChannelMapper deviceChannelMapper;
@Autowired
private PlatformCatalogMapper catalogManager;
@Autowired
private ParentPlatformMapper platformMapper;
@Autowired
EventPublisher eventPublisher;
@Override
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformId);
if (platform == null) {
logger.warn("更新级联通道信息时未找到平台{}的信息", platformId);
return 0;
}
Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
for (ChannelReduce channelReduce : channelReduces) {
channelReduce.setCatalogId(catalogId);
deviceAndChannels.put(channelReduce.getId(), channelReduce);
}
List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
// 查询当前已经存在的
List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
if (deviceAndChannelList != null) {
deviceAndChannelList.removeAll(channelIds);
}
for (Integer channelId : channelIds) {
deviceAndChannels.remove(channelId);
}
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
// 对剩下的数据进行存储
int result = 0;
if (channelReducesToAdd.size() > 0) {
result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
// TODO 后续给平台增加控制开关以控制是否响应目录订阅
List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId, platform);
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
}
return result;
}
private List<DeviceChannel> getDeviceChannelListByChannelReduceList(List<ChannelReduce> channelReduces, String catalogId, ParentPlatform platform) {
List<DeviceChannel> deviceChannelList = new ArrayList<>();
if (channelReduces.size() > 0){
PlatformCatalog catalog = catalogManager.select(catalogId);
if (catalog == null && !catalogId.equals(platform.getServerGBId())) {
logger.warn("未查询到目录{}的信息", catalogId);
return null;
}
for (ChannelReduce channelReduce : channelReduces) {
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(channelReduce.getDeviceId(), channelReduce.getChannelId());
deviceChannel.setParental(0);
deviceChannelList.add(deviceChannel);
if (platform.getTreeType().equals(TreeType.CIVIL_CODE)){
deviceChannel.setCivilCode(catalogId);
}else if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)){
deviceChannel.setParentId(catalogId);
if (catalog != null) {
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
}
}
}
}
return deviceChannelList;
}
}

View File

@ -15,6 +15,7 @@ import com.genersoft.iot.vmp.media.zlm.dto.MediaItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
import com.genersoft.iot.vmp.service.IStreamPushService; import com.genersoft.iot.vmp.service.IStreamPushService;
import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto; import com.genersoft.iot.vmp.service.bean.PushStreamStatusChangeFromRedisDto;
import com.genersoft.iot.vmp.service.bean.StreamPushItemFromRedis;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import org.slf4j.Logger; import org.slf4j.Logger;
@ -26,6 +27,7 @@ import org.springframework.data.redis.connection.Message;
import org.springframework.data.redis.connection.MessageListener; import org.springframework.data.redis.connection.MessageListener;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -55,7 +57,6 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
@Override @Override
public void onMessage(Message message, byte[] bytes) { public void onMessage(Message message, byte[] bytes) {
PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(message.getBody(), PushStreamStatusChangeFromRedisDto.class); PushStreamStatusChangeFromRedisDto statusChangeFromPushStream = JSON.parseObject(message.getBody(), PushStreamStatusChangeFromRedisDto.class);
if (statusChangeFromPushStream == null) { if (statusChangeFromPushStream == null) {
logger.warn("[REDIS 消息]推流设备状态变化消息解析失败"); logger.warn("[REDIS 消息]推流设备状态变化消息解析失败");
@ -65,11 +66,13 @@ public class RedisPushStreamStatusMsgListener implements MessageListener, Applic
// 所有设备离线 // 所有设备离线
streamPushService.allStreamOffline(); streamPushService.allStreamOffline();
} }
if (statusChangeFromPushStream.getOfflineStreams().size() > 0) { if (statusChangeFromPushStream.getOfflineStreams() != null
&& statusChangeFromPushStream.getOfflineStreams().size() > 0) {
// 更新部分设备离线 // 更新部分设备离线
streamPushService.offline(statusChangeFromPushStream.getOfflineStreams()); streamPushService.offline(statusChangeFromPushStream.getOfflineStreams());
} }
if (statusChangeFromPushStream.getOnlineStreams().size() > 0) { if (statusChangeFromPushStream.getOnlineStreams() != null &&
statusChangeFromPushStream.getOnlineStreams().size() > 0) {
// 更新部分设备上线 // 更新部分设备上线
streamPushService.online(statusChangeFromPushStream.getOnlineStreams()); streamPushService.online(statusChangeFromPushStream.getOnlineStreams());
} }

View File

@ -3,10 +3,10 @@ package com.genersoft.iot.vmp.service.impl;
import com.alibaba.fastjson.JSONArray; import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.genersoft.iot.vmp.common.StreamInfo; import com.genersoft.iot.vmp.common.StreamInfo;
import com.genersoft.iot.vmp.conf.SipConfig;
import com.genersoft.iot.vmp.conf.UserSetting; import com.genersoft.iot.vmp.conf.UserSetting;
import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.TreeType;
import com.genersoft.iot.vmp.gb28181.event.EventPublisher; import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent;
import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils; import com.genersoft.iot.vmp.media.zlm.ZLMRESTfulUtils;
@ -23,14 +23,19 @@ import com.genersoft.iot.vmp.storager.dao.ParentPlatformMapper;
import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper; import com.genersoft.iot.vmp.storager.dao.PlatformGbStreamMapper;
import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper; import com.genersoft.iot.vmp.storager.dao.StreamProxyMapper;
import com.genersoft.iot.vmp.service.IStreamProxyService; import com.genersoft.iot.vmp.service.IStreamProxyService;
import com.genersoft.iot.vmp.utils.DateUtil;
import com.genersoft.iot.vmp.vmanager.bean.WVPResult; import com.genersoft.iot.vmp.vmanager.bean.WVPResult;
import com.github.pagehelper.PageInfo; import com.github.pagehelper.PageInfo;
import org.slf4j.Logger; import org.slf4j.Logger;
import org.slf4j.LoggerFactory; import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.datasource.DataSourceTransactionManager;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.transaction.TransactionDefinition;
import org.springframework.transaction.TransactionStatus;
import org.springframework.util.StringUtils; import org.springframework.util.StringUtils;
import java.net.InetAddress;
import java.util.*; import java.util.*;
/** /**
@ -48,7 +53,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
private IMediaService mediaService; private IMediaService mediaService;
@Autowired @Autowired
private ZLMRESTfulUtils zlmresTfulUtils;; private ZLMRESTfulUtils zlmresTfulUtils;
@Autowired @Autowired
private StreamProxyMapper streamProxyMapper; private StreamProxyMapper streamProxyMapper;
@ -62,9 +67,6 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Autowired @Autowired
private UserSetting userSetting; private UserSetting userSetting;
@Autowired
private SipConfig sipConfig;
@Autowired @Autowired
private GbStreamMapper gbStreamMapper; private GbStreamMapper gbStreamMapper;
@ -83,6 +85,12 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
@Autowired @Autowired
private IMediaServerService mediaServerService; private IMediaServerService mediaServerService;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@Autowired
TransactionDefinition transactionDefinition;
@Override @Override
public WVPResult<StreamInfo> save(StreamProxyItem param) { public WVPResult<StreamInfo> save(StreamProxyItem param) {
@ -99,6 +107,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
wvpResult.setMsg("保存失败"); wvpResult.setMsg("保存失败");
return wvpResult; return wvpResult;
} }
String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(), String dstUrl = String.format("rtmp://%s:%s/%s/%s", "127.0.0.1", mediaInfo.getRtmpPort(), param.getApp(),
param.getStream() ); param.getStream() );
param.setDst_url(dstUrl); param.setDst_url(dstUrl);
@ -108,9 +117,9 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
boolean saveResult; boolean saveResult;
// 更新 // 更新
if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) { if (videoManagerStorager.queryStreamProxy(param.getApp(), param.getStream()) != null) {
saveResult = videoManagerStorager.updateStreamProxy(param); saveResult = updateStreamProxy(param);
}else { // 新增 }else { // 新增
saveResult = videoManagerStorager.addStreamProxy(param); saveResult = addStreamProxy(param);
} }
if (saveResult) { if (saveResult) {
result.append("保存成功"); result.append("保存成功");
@ -124,7 +133,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
if (param.isEnable_remove_none_reader()) { if (param.isEnable_remove_none_reader()) {
del(param.getApp(), param.getStream()); del(param.getApp(), param.getStream());
}else { }else {
videoManagerStorager.updateStreamProxy(param); updateStreamProxy(param);
} }
}else { }else {
@ -154,6 +163,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
for (ParentPlatform parentPlatform : parentPlatforms) { for (ParentPlatform parentPlatform : parentPlatforms) {
param.setPlatformId(parentPlatform.getServerGBId()); param.setPlatformId(parentPlatform.getServerGBId());
param.setCatalogId(parentPlatform.getCatalogId()); param.setCatalogId(parentPlatform.getCatalogId());
String stream = param.getStream(); String stream = param.getStream();
StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId()); StreamProxyItem streamProxyItems = platformGbStreamMapper.selectOne(param.getApp(), stream, parentPlatform.getServerGBId());
if (streamProxyItems == null) { if (streamProxyItems == null) {
@ -168,6 +178,77 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
return wvpResult; return wvpResult;
} }
/**
* 新增代理流
* @param streamProxyItem
* @return
*/
private boolean addStreamProxy(StreamProxyItem streamProxyItem) {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
streamProxyItem.setStreamType("proxy");
streamProxyItem.setStatus(true);
String now = DateUtil.getNow();
streamProxyItem.setCreateTime(now);
try {
if (streamProxyMapper.add(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.add(streamProxyItem) < 0) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
}else {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
result = true;
dataSourceTransactionManager.commit(transactionStatus); //手动提交
}catch (Exception e) {
logger.error("向数据库添加流代理失败:", e);
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
}
/**
* 更新代理流
* @param streamProxyItem
* @return
*/
@Override
public boolean updateStreamProxy(StreamProxyItem streamProxyItem) {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
streamProxyItem.setStreamType("proxy");
try {
if (streamProxyMapper.update(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
} else {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
dataSourceTransactionManager.commit(transactionStatus); //手动提交
result = true;
}catch (Exception e) {
e.printStackTrace();
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
}
@Override @Override
public JSONObject addStreamProxyToZlm(StreamProxyItem param) { public JSONObject addStreamProxyToZlm(StreamProxyItem param) {
JSONObject result = null; JSONObject result = null;
@ -239,7 +320,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
if (jsonObject.getInteger("code") == 0) { if (jsonObject.getInteger("code") == 0) {
result = true; result = true;
streamProxy.setEnable(true); streamProxy.setEnable(true);
videoManagerStorager.updateStreamProxy(streamProxy); updateStreamProxy(streamProxy);
} }
} }
return result; return result;
@ -253,7 +334,7 @@ public class StreamProxyServiceImpl implements IStreamProxyService {
JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto); JSONObject jsonObject = removeStreamProxyFromZlm(streamProxyDto);
if (jsonObject != null && jsonObject.getInteger("code") == 0) { if (jsonObject != null && jsonObject.getInteger("code") == 0) {
streamProxyDto.setEnable(false); streamProxyDto.setEnable(false);
result = videoManagerStorager.updateStreamProxy(streamProxyDto); result = updateStreamProxy(streamProxyDto);
} }
} }
return result; return result;

View File

@ -488,7 +488,7 @@ public class StreamPushServiceImpl implements IStreamPushService {
if (onlinePushers.size() == 0) { if (onlinePushers.size() == 0) {
return; return;
} }
streamPushMapper.allStreamOffline(); streamPushMapper.setAllStreamOffline();
// 发送通知 // 发送通知
eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF); eventPublisher.catalogEventPublishForStream(null, onlinePushers, CatalogEvent.OFF);

View File

@ -14,38 +14,60 @@ import java.util.*;
public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> { public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> {
// 错误数据的回调用于将错误数据发送给页面 /**
* 错误数据的回调用于将错误数据发送给页面
*/
private ErrorDataHandler errorDataHandler; private ErrorDataHandler errorDataHandler;
// 推流的业务类用于存储数据 /**
* 推流的业务类用于存储数据
*/
private IStreamPushService pushService; private IStreamPushService pushService;
// 默认流媒体节点ID /**
* 默认流媒体节点ID
*/
private String defaultMediaServerId; private String defaultMediaServerId;
// 用于存储不加过滤的所有数据 /**
* 用于存储不加过滤的所有数据
*/
private List<StreamPushItem> streamPushItems = new ArrayList<>(); private List<StreamPushItem> streamPushItems = new ArrayList<>();
// 用于存储更具APP+Stream过滤后的数据可以直接存入stream_push表与gb_stream表 /**
* 用于存储更具APP+Stream过滤后的数据可以直接存入stream_push表与gb_stream表
*/
private Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>(); private Map<String,StreamPushItem> streamPushItemForSave = new HashMap<>();
// 用于存储按照APP+Stream为KEY 平台ID+目录Id 为value的数据用于存储到gb_stream表后获取app+Stream对应的平台与目录信息然后存入关联表 /**
* 用于存储按照APP+Stream为KEY 平台ID+目录Id 为value的数据用于存储到gb_stream表后获取app+Stream对应的平台与目录信息然后存入关联表
*/
private Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>(); private Map<String, List<String[]>> streamPushItemsForPlatform = new HashMap<>();
// 用于判断文件是否存在重复的app+Stream+平台ID /**
* 用于判断文件是否存在重复的app+Stream+平台ID
*/
private Set<String> streamPushStreamSet = new HashSet<>(); private Set<String> streamPushStreamSet = new HashSet<>();
// 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应全局判断APP+Stream->国标ID是否存在不对应 /**
* 用于存储APP+Stream->国标ID 的数据结构, 数据一一对应全局判断APP+Stream->国标ID是否存在不对应
*/
private BiMap<String,String> gBMap = HashBiMap.create(); private BiMap<String,String> gBMap = HashBiMap.create();
// 记录错误的APP+Stream /**
* 记录错误的APP+Stream
*/
private List<String> errorStreamList = new ArrayList<>(); private List<String> errorStreamList = new ArrayList<>();
// 记录错误的国标ID /**
* 记录错误的国标ID
*/
private List<String> errorGBList = new ArrayList<>(); private List<String> errorGBList = new ArrayList<>();
// 读取数量计数器 /**
* 读取数量计数器
*/
private int loadedSize = 0; private int loadedSize = 0;
public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId, ErrorDataHandler errorDataHandler) { public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId, ErrorDataHandler errorDataHandler) {

View File

@ -26,22 +26,6 @@ public interface IVideoManagerStorage {
*/ */
public boolean exists(String deviceId); public boolean exists(String deviceId);
/**
* 添加设备通道
*
* @param deviceId 设备id
* @param channel 通道
*/
public void updateChannel(String deviceId, DeviceChannel channel);
/**
* 批量添加设备通道
*
* @param deviceId 设备id
* @param channels 多个通道
*/
public int updateChannels(String deviceId, List<DeviceChannel> channels);
/** /**
* 开始播放 * 开始播放
* @param deviceId 设备id * @param deviceId 设备id
@ -224,13 +208,6 @@ public interface IVideoManagerStorage {
List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId); List<DeviceChannelInPlatform> queryChannelListInParentPlatform(String platformId);
/**
* 更新上级平台的通道信息
* @param platformId
* @param channelReduces
* @return
*/
int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId);
/** /**
* 移除上级平台的通道信息 * 移除上级平台的通道信息
@ -276,20 +253,6 @@ public interface IVideoManagerStorage {
*/ */
public int clearMobilePositionsByDeviceId(String deviceId); public int clearMobilePositionsByDeviceId(String deviceId);
/**
* 新增代理流
* @param streamProxyDto
* @return
*/
public boolean addStreamProxy(StreamProxyItem streamProxyDto);
/**
* 更新代理流
* @param streamProxyDto
* @return
*/
public boolean updateStreamProxy(StreamProxyItem streamProxyDto);
/** /**
* 移除代理流 * 移除代理流
* @param app * @param app
@ -334,7 +297,7 @@ public interface IVideoManagerStorage {
* @param platformId * @param platformId
* @return * @return
*/ */
List<GbStream> queryGbStreamListInPlatform(String platformId); List<DeviceChannel> queryGbStreamListInPlatform(String platformId);
/** /**
* 批量更新推流列表 * 批量更新推流列表
@ -445,7 +408,7 @@ public interface IVideoManagerStorage {
int setDefaultCatalog(String platformId, String catalogId); int setDefaultCatalog(String platformId, String catalogId);
List<PlatformCatalog> queryCatalogInPlatform(String serverGBId); List<DeviceChannel> queryCatalogInPlatform(String serverGBId);
int delRelation(PlatformCatalog platformCatalog); int delRelation(PlatformCatalog platformCatalog);
@ -466,4 +429,8 @@ public interface IVideoManagerStorage {
List<ChannelSourceInfo> getChannelSource(String platformId, String gbId); List<ChannelSourceInfo> getChannelSource(String platformId, String gbId);
void updateChannelPosition(DeviceChannel deviceChannel); void updateChannelPosition(DeviceChannel deviceChannel);
void cleanContentForPlatform(String serverGBId);
List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
} }

View File

@ -329,5 +329,13 @@ public interface DeviceChannelMapper {
@Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}") @Select("select * from device_channel where deviceId=#{deviceId} and SUBSTRING(channelId, 11, 3)=#{typeCode}")
List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode); List<DeviceChannel> getBusinessGroups(String deviceId, String typeCode);
@Select("select dc.id, dc.channelId, dc.deviceId, dc.name, dc.manufacture,dc.model,dc.owner, pc.civilCode,dc.block, " +
" dc.address, '0' as parental,'0' as channelType, pc.id as parentId, dc.safetyWay, dc.registerWay,dc.certNum, dc.certifiable, " +
" dc.errCode,dc.endTime, dc.secrecy, dc.ipAddress, dc.port, dc.PTZType, dc.password, dc.status, " +
" dc.longitudeWgs84 as longitude, dc.latitudeWgs84 as latitude, pc.businessGroupId " +
" from device_channel dc" +
" left join platform_gb_channel pgc on dc.id = pgc.deviceChannelId" +
" left join platform_catalog pc on pgc.catalogId = pc.id and pgc.platformId = pc.platformId" +
" where pgc.platformId=#{serverGBId}")
List<DeviceChannel> queryChannelWithCatalog(String serverGBId);
} }

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.storager.dao; package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamProxyItem;
import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem; import com.genersoft.iot.vmp.media.zlm.dto.StreamPushItem;
@ -15,10 +16,10 @@ import java.util.List;
public interface GbStreamMapper { public interface GbStreamMapper {
@Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " + @Insert("REPLACE INTO gb_stream (app, stream, gbId, name, " +
"longitude, latitude, streamType, mediaServerId, status, createTime) VALUES" + "longitude, latitude, streamType, mediaServerId, createTime) VALUES" +
"('${app}', '${stream}', '${gbId}', '${name}', " + "('${app}', '${stream}', '${gbId}', '${name}', " +
"'${longitude}', '${latitude}', '${streamType}', " + "'${longitude}', '${latitude}', '${streamType}', " +
"'${mediaServerId}', ${status}, '${createTime}')") "'${mediaServerId}', '${createTime}')")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")
int add(GbStream gbStream); int add(GbStream gbStream);
@ -30,8 +31,7 @@ public interface GbStreamMapper {
"streamType=#{streamType}," + "streamType=#{streamType}," +
"longitude=#{longitude}, " + "longitude=#{longitude}, " +
"latitude=#{latitude}," + "latitude=#{latitude}," +
"mediaServerId=#{mediaServerId}," + "mediaServerId=#{mediaServerId}" +
"status=${status} " +
"WHERE app=#{app} AND stream=#{stream}") "WHERE app=#{app} AND stream=#{stream}")
int updateByAppAndStream(GbStream gbStream); int updateByAppAndStream(GbStream gbStream);
@ -43,8 +43,7 @@ public interface GbStreamMapper {
"streamType=#{streamType}," + "streamType=#{streamType}," +
"longitude=#{longitude}, " + "longitude=#{longitude}, " +
"latitude=#{latitude}," + "latitude=#{latitude}," +
"mediaServerId=#{mediaServerId}," + "mediaServerId=#{mediaServerId}" +
"status=${status} " +
"WHERE gbStreamId=#{gbStreamId}") "WHERE gbStreamId=#{gbStreamId}")
int update(GbStream gbStream); int update(GbStream gbStream);
@ -60,12 +59,10 @@ public interface GbStreamMapper {
" <if test='catalogId == null'> AND gs.gbStreamId not in" + " <if test='catalogId == null'> AND gs.gbStreamId not in" +
"(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " + "(select pgs.gbStreamId from platform_gb_stream pgs where pgs.platformId = #{platformId}) </if> " +
" <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> " + " <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> " +
" <if test='pushing == true' > AND gs.status=1</if>" +
" <if test='pushing == false' > AND gs.status=0</if>" +
" <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" + " <if test='mediaServerId != null' > AND gs.mediaServerId=#{mediaServerId} </if>" +
" order by gs.gbStreamId asc " + " order by gs.gbStreamId asc " +
"</script>") "</script>")
List<GbStream> selectAll(String platformId, String catalogId, String query, Boolean pushing, String mediaServerId); List<GbStream> selectAll(String platformId, String catalogId, String query, String mediaServerId);
@Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}") @Select("SELECT * FROM gb_stream WHERE app=#{app} AND stream=#{stream}")
GbStream selectOne(String app, String stream); GbStream selectOne(String app, String stream);
@ -78,10 +75,18 @@ public interface GbStreamMapper {
"WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'") "WHERE gs.gbId = '${gbId}' AND pgs.platformId = '${platformId}'")
GbStream queryStreamInPlatform(String platformId, String gbId); GbStream queryStreamInPlatform(String platformId, String gbId);
@Select("SELECT gs.*, pgs.platformId as platformId, pgs.catalogId as catalogId FROM gb_stream gs " + @Select("select gt.gbId as channelId, gt.name, 'wvp-pro' as manufacture, st.status, gt.longitude, gt.latitude, pc.id as parentId," +
"LEFT JOIN platform_gb_stream pgs ON gs.gbStreamId = pgs.gbStreamId " + " '1' as registerWay, pc.civilCode, 'live' as model, 'wvp-pro' as owner, '0' as parental,'0' as secrecy" +
"WHERE pgs.platformId = #{platformId}") " from gb_stream gt " +
List<GbStream> queryGbStreamListInPlatform(String platformId); " left join (" +
" select sp.status, sp.app, sp.stream from stream_push sp" +
" union all" +
" select spxy.status, spxy.app, spxy.stream from stream_proxy spxy" +
" ) st on st.app = gt.app and st.stream = gt.stream" +
" left join platform_gb_stream pgs on gt.gbStreamId = pgs.gbStreamId" +
" left join platform_catalog pc on pgs.catalogId = pc.id and pgs.platformId = pc.platformId" +
" where pgs.platformId=#{platformId}")
List<DeviceChannel> queryGbStreamListInPlatform(String platformId);
@Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " + @Select("SELECT gs.* FROM gb_stream gs LEFT JOIN platform_gb_stream pgs " +
@ -110,12 +115,12 @@ public interface GbStreamMapper {
@Insert("<script> " + @Insert("<script> " +
"INSERT IGNORE into gb_stream " + "INSERT IGNORE into gb_stream " +
"(app, stream, gbId, name, " + "(app, stream, gbId, name, " +
"longitude, latitude, streamType, mediaServerId, status, createTime)" + "longitude, latitude, streamType, mediaServerId, createTime)" +
"values " + "values " +
"<foreach collection='subList' index='index' item='item' separator=','> " + "<foreach collection='subList' index='index' item='item' separator=','> " +
"('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " + "('${item.app}', '${item.stream}', '${item.gbId}', '${item.name}', " +
"'${item.longitude}', '${item.latitude}', '${item.streamType}', " + "'${item.longitude}', '${item.latitude}', '${item.streamType}', " +
"'${item.mediaServerId}', ${item.status}, '${item.createTime}') "+ "'${item.mediaServerId}', '${item.createTime}') "+
"</foreach> " + "</foreach> " +
"</script>") "</script>")
@Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId") @Options(useGeneratedKeys = true, keyProperty = "gbStreamId", keyColumn = "gbStreamId")

View File

@ -16,10 +16,10 @@ public interface ParentPlatformMapper {
@Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
" devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
" status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime) " + " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup, createTime, updateTime, treeType) " +
" VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
" '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
" ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime})") " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup}, #{createTime}, #{updateTime}, #{treeType})")
int addParentPlatform(ParentPlatform parentPlatform); int addParentPlatform(ParentPlatform parentPlatform);
@Update("UPDATE parent_platform " + @Update("UPDATE parent_platform " +
@ -47,6 +47,7 @@ public interface ParentPlatformMapper {
"administrativeDivision=#{administrativeDivision}, " + "administrativeDivision=#{administrativeDivision}, " +
"createTime=#{createTime}, " + "createTime=#{createTime}, " +
"updateTime=#{updateTime}, " + "updateTime=#{updateTime}, " +
"treeType=#{treeType}, " +
"catalogId=#{catalogId} " + "catalogId=#{catalogId} " +
"WHERE id=#{id}") "WHERE id=#{id}")
int updateParentPlatform(ParentPlatform parentPlatform); int updateParentPlatform(ParentPlatform parentPlatform);

View File

@ -1,5 +1,6 @@
package com.genersoft.iot.vmp.storager.dao; package com.genersoft.iot.vmp.storager.dao;
import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
import com.genersoft.iot.vmp.gb28181.bean.GbStream; import com.genersoft.iot.vmp.gb28181.bean.GbStream;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream; import com.genersoft.iot.vmp.gb28181.bean.PlatformGbStream;
@ -14,8 +15,8 @@ import java.util.List;
@Repository @Repository
public interface PlatformCatalogMapper { public interface PlatformCatalogMapper {
@Insert("INSERT INTO platform_catalog (id, name, platformId, parentId) VALUES" + @Insert("INSERT INTO platform_catalog (id, name, platformId, parentId, civilCode, businessGroupId) VALUES" +
"(#{id}, #{name}, #{platformId}, #{parentId})") "(#{id}, #{name}, #{platformId}, #{parentId}, #{civilCode}, #{businessGroupId})")
int add(PlatformCatalog platformCatalog); int add(PlatformCatalog platformCatalog);
@Delete("DELETE FROM platform_catalog WHERE id=#{id}") @Delete("DELETE FROM platform_catalog WHERE id=#{id}")
@ -44,4 +45,12 @@ public interface PlatformCatalogMapper {
@Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})") @Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = (SELECT pp.catalogId from parent_platform pp WHERE pp.serverGBId=#{platformId})")
PlatformCatalog selectDefaultByPlatFormId(String platformId); PlatformCatalog selectDefaultByPlatFormId(String platformId);
@Select("SELECT pc.* FROM platform_catalog pc WHERE pc.id = #{id}")
PlatformCatalog selectParentCatalog(String id);
@Select("SELECT pc.id as channelId, pc.name, pc.civilCode, pc.businessGroupId,'0' as parental, pc.parentId " +
" FROM platform_catalog pc WHERE pc.platformId=#{platformId}")
List<DeviceChannel> queryCatalogInPlatform(String platformId);
} }

View File

@ -88,10 +88,10 @@ public interface StreamPushMapper {
@Insert("<script>" + @Insert("<script>" +
"Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " + "Insert IGNORE INTO stream_push (app, stream, totalReaderCount, originType, originTypeStr, " +
"createTime, aliveSecond, mediaServerId) " + "createTime, aliveSecond, mediaServerId, status) " +
"VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" + "VALUES <foreach collection='streamPushItems' item='item' index='index' separator=','>" +
"( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " + "( '${item.app}', '${item.stream}', '${item.totalReaderCount}', #{item.originType}, " +
"'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}' )" + "'${item.originTypeStr}',#{item.createTime}, #{item.aliveSecond}, '${item.mediaServerId}', ${item.status} )" +
" </foreach>" + " </foreach>" +
"</script>") "</script>")
@Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id") @Options(useGeneratedKeys = true, keyProperty = "id", keyColumn = "id")
@ -122,41 +122,41 @@ public interface StreamPushMapper {
@Select("<script> "+ @Select("<script> "+
"SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " + "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 and (gs.app, gs.stream) in" + "where sp.status = 1 and (gs.app, gs.stream) in (" +
"<foreach collection='offlineStreams' item='item' separator=','>" + "<foreach collection='offlineStreams' item='item' separator=','>" +
"(#{item.app}, {item.stream}) " + "(#{item.app}, #{item.stream}) " +
"</foreach>" + ")</foreach>" +
"</script>") "</script>")
List<GbStream> getOnlinePusherForGbInList(List<StreamPushItemFromRedis> offlineStreams); List<GbStream> getOnlinePusherForGbInList(List<StreamPushItemFromRedis> offlineStreams);
@Update("<script> "+ @Update("<script> "+
"UPDATE stream_push SET status=0 where (app, stream) in" + "UPDATE stream_push SET status=0 where (app, stream) in (" +
"<foreach collection='offlineStreams' item='item' separator=','>" + "<foreach collection='offlineStreams' item='item' separator=','>" +
"(#{item.app}, {item.stream}) " + "(#{item.app}, #{item.stream}) " +
"</foreach>" + ")</foreach>" +
"</script>") "</script>")
void offline(List<StreamPushItemFromRedis> offlineStreams); void offline(List<StreamPushItemFromRedis> offlineStreams);
@Select("<script> "+ @Select("<script> "+
"SELECT * FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " + "SELECT * FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream " +
"where sp.status = 0 and (gs.app, gs.stream) in" + "where sp.status = 0 and (gs.app, gs.stream) in (" +
"<foreach collection='offlineStreams' item='item' separator=','>" + "<foreach collection='onlineStreams' item='item' separator=','>" +
"(#{item.app}, {item.stream}) " + "(#{item.app}, #{item.stream}) " +
"</foreach>" + "</foreach>" +
"</script>") ") </script>")
List<GbStream> getOfflinePusherForGbInList(List<StreamPushItemFromRedis> onlineStreams); List<GbStream> getOfflinePusherForGbInList(List<StreamPushItemFromRedis> onlineStreams);
@Update("<script> "+ @Update("<script> "+
"UPDATE stream_push SET status=1 where (app, stream) in" + "UPDATE stream_push SET status=1 where (app, stream) in (" +
"<foreach collection='offlineStreams' item='item' separator=','>" + "<foreach collection='onlineStreams' item='item' separator=','>" +
"(#{item.app}, {item.stream}) " + "(#{item.app}, #{item.stream}) " +
"</foreach>" + ")</foreach>" +
"</script>") "</script>")
void online(List<StreamPushItemFromRedis> onlineStreams); void online(List<StreamPushItemFromRedis> onlineStreams);
@Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream") @Select("SELECT gs.* FROM stream_push sp left join gb_stream gs on sp.app = gs.app AND sp.stream = gs.stream where sp.status = 1")
List<GbStream> getOnlinePusherForGb(); List<GbStream> getOnlinePusherForGb();
@Update("UPDATE stream_push SET status=0") @Update("UPDATE stream_push SET status=0")
void allStreamOffline(); void setAllStreamOffline();
} }

View File

@ -48,12 +48,13 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
@Autowired @Autowired
SipConfig sipConfig; SipConfig sipConfig;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@Autowired @Autowired
TransactionDefinition transactionDefinition; TransactionDefinition transactionDefinition;
@Autowired
DataSourceTransactionManager dataSourceTransactionManager;
@Autowired @Autowired
private DeviceMapper deviceMapper; private DeviceMapper deviceMapper;
@ -104,96 +105,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMapper.getDeviceByDeviceId(deviceId) != null; return deviceMapper.getDeviceByDeviceId(deviceId) != null;
} }
@Override
public synchronized void updateChannel(String deviceId, DeviceChannel channel) {
String channelId = channel.getChannelId();
channel.setDeviceId(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channelId);
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
DeviceChannel deviceChannel = deviceChannelMapper.queryChannel(deviceId, channelId);
if (deviceChannel == null) {
channel.setCreateTime(now);
deviceChannelMapper.add(channel);
}else {
deviceChannelMapper.update(channel);
}
deviceChannelMapper.updateChannelSubCount(deviceId,channel.getParentId());
}
@Override
public int updateChannels(String deviceId, List<DeviceChannel> channels) {
List<DeviceChannel> addChannels = new ArrayList<>();
List<DeviceChannel> updateChannels = new ArrayList<>();
HashMap<String, DeviceChannel> channelsInStore = new HashMap<>();
if (channels != null && channels.size() > 0) {
List<DeviceChannel> channelList = deviceChannelMapper.queryChannels(deviceId, null, null, null, null);
if (channelList.size() == 0) {
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
channel.setCreateTime(now);
addChannels.add(channel);
}
}else {
for (DeviceChannel deviceChannel : channelList) {
channelsInStore.put(deviceChannel.getChannelId(), deviceChannel);
}
for (DeviceChannel channel : channels) {
channel.setDeviceId(deviceId);
StreamInfo streamInfo = redisCatchStorage.queryPlayByDevice(deviceId, channel.getChannelId());
if (streamInfo != null) {
channel.setStreamId(streamInfo.getStream());
}
String now = DateUtil.getNow();
channel.setUpdateTime(now);
if (channelsInStore.get(channel.getChannelId()) != null) {
updateChannels.add(channel);
}else {
addChannels.add(channel);
channel.setCreateTime(now);
}
}
}
int limitCount = 300;
if (addChannels.size() > 0) {
if (addChannels.size() > limitCount) {
for (int i = 0; i < addChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > addChannels.size()) {
toIndex = addChannels.size();
}
deviceChannelMapper.batchAdd(addChannels.subList(i, toIndex));
}
}else {
deviceChannelMapper.batchAdd(addChannels);
}
}
if (updateChannels.size() > 0) {
if (updateChannels.size() > limitCount) {
for (int i = 0; i < updateChannels.size(); i += limitCount) {
int toIndex = i + limitCount;
if (i + limitCount > updateChannels.size()) {
toIndex = updateChannels.size();
}
deviceChannelMapper.batchUpdate(updateChannels.subList(i, toIndex));
}
}else {
deviceChannelMapper.batchUpdate(updateChannels);
}
}
}
return addChannels.size() + updateChannels.size();
}
@Override @Override
public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) { public boolean resetChannels(String deviceId, List<DeviceChannel> deviceChannelList) {
if (CollectionUtils.isEmpty(deviceChannelList)) { if (CollectionUtils.isEmpty(deviceChannelList)) {
@ -596,36 +507,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceChannelMapper.queryChannelByPlatformId(platformId); return deviceChannelMapper.queryChannelByPlatformId(platformId);
} }
@Override
public int updateChannelForGB(String platformId, List<ChannelReduce> channelReduces, String catalogId) {
Map<Integer, ChannelReduce> deviceAndChannels = new HashMap<>();
for (ChannelReduce channelReduce : channelReduces) {
channelReduce.setCatalogId(catalogId);
deviceAndChannels.put(channelReduce.getId(), channelReduce);
}
List<Integer> deviceAndChannelList = new ArrayList<>(deviceAndChannels.keySet());
// 查询当前已经存在的
List<Integer> channelIds = platformChannelMapper.findChannelRelatedPlatform(platformId, channelReduces);
if (deviceAndChannelList != null) {
deviceAndChannelList.removeAll(channelIds);
}
for (Integer channelId : channelIds) {
deviceAndChannels.remove(channelId);
}
List<ChannelReduce> channelReducesToAdd = new ArrayList<>(deviceAndChannels.values());
// 对剩下的数据进行存储
int result = 0;
if (channelReducesToAdd.size() > 0) {
result = platformChannelMapper.addChannels(platformId, channelReducesToAdd);
// TODO 后续给平台增加控制开关以控制是否响应目录订阅
List<DeviceChannel> deviceChannelList = getDeviceChannelListByChannelReduceList(channelReducesToAdd, catalogId);
eventPublisher.catalogEventPublish(platformId, deviceChannelList, CatalogEvent.ADD);
}
return result;
}
@Override @Override
public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) { public int delChannelForGB(String platformId, List<ChannelReduce> channelReduces) {
@ -701,77 +582,6 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId); return deviceMobilePositionMapper.clearMobilePositionsByDeviceId(deviceId);
} }
/**
* 新增代理流
* @param streamProxyItem
* @return
*/
@Override
public boolean addStreamProxy(StreamProxyItem streamProxyItem) {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
streamProxyItem.setStreamType("proxy");
streamProxyItem.setStatus(true);
String now = DateUtil.getNow();
streamProxyItem.setCreateTime(now);
try {
if (streamProxyMapper.add(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.add(streamProxyItem) < 0) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
}else {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
result = true;
dataSourceTransactionManager.commit(transactionStatus); //手动提交
}catch (Exception e) {
logger.error("向数据库添加流代理失败:", e);
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
}
/**
* 更新代理流
* @param streamProxyItem
* @return
*/
@Override
public boolean updateStreamProxy(StreamProxyItem streamProxyItem) {
TransactionStatus transactionStatus = dataSourceTransactionManager.getTransaction(transactionDefinition);
boolean result = false;
streamProxyItem.setStreamType("proxy");
try {
if (streamProxyMapper.update(streamProxyItem) > 0) {
if (!StringUtils.isEmpty(streamProxyItem.getGbId())) {
if (gbStreamMapper.updateByAppAndStream(streamProxyItem) == 0) {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
}
} else {
//事务回滚
dataSourceTransactionManager.rollback(transactionStatus);
return false;
}
dataSourceTransactionManager.commit(transactionStatus); //手动提交
result = true;
}catch (Exception e) {
e.printStackTrace();
dataSourceTransactionManager.rollback(transactionStatus);
}
return result;
}
/** /**
* 移除代理流 * 移除代理流
@ -824,7 +634,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
* @return * @return
*/ */
@Override @Override
public List<GbStream> queryGbStreamListInPlatform(String platformId) { public List<DeviceChannel> queryGbStreamListInPlatform(String platformId) {
return gbStreamMapper.queryGbStreamListInPlatform(platformId); return gbStreamMapper.queryGbStreamListInPlatform(platformId);
} }
@ -910,6 +720,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return result; return result;
} }
@Override
public int mediaOnline(String app, String stream) { public int mediaOnline(String app, String stream) {
GbStream gbStream = gbStreamMapper.selectOne(app, stream); GbStream gbStream = gbStreamMapper.selectOne(app, stream);
int result; int result;
@ -954,6 +765,24 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
@Override @Override
public int addCatalog(PlatformCatalog platformCatalog) { public int addCatalog(PlatformCatalog platformCatalog) {
ParentPlatform platform = platformMapper.getParentPlatByServerGBId(platformCatalog.getPlatformId());
if (platform == null) {
return 0;
}
if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) {
if (platformCatalog.getPlatformId().equals(platformCatalog.getParentId())) {
// 第一层节点
platformCatalog.setBusinessGroupId(platformCatalog.getId());
}else {
// 获取顶层的
PlatformCatalog topCatalog = getTopCatalog(platformCatalog.getParentId(), platformCatalog.getPlatformId());
platformCatalog.setBusinessGroupId(topCatalog.getId());
}
}
if (platform.getTreeType().equals(TreeType.CIVIL_CODE)) {
platformCatalog.setCivilCode(platformCatalog.getId());
}
int result = catalogMapper.add(platformCatalog); int result = catalogMapper.add(platformCatalog);
if (result > 0) { if (result > 0) {
DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog); DeviceChannel deviceChannel = getDeviceChannelByCatalog(platformCatalog);
@ -962,6 +791,15 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
return result; return result;
} }
private PlatformCatalog getTopCatalog(String id, String platformId) {
PlatformCatalog catalog = catalogMapper.selectParentCatalog(id);
if (catalog.getParentId().equals(platformId)) {
return catalog;
}else {
return getTopCatalog(catalog.getParentId(), platformId);
}
}
@Override @Override
public PlatformCatalog getCatalog(String id) { public PlatformCatalog getCatalog(String id) {
return catalogMapper.select(id); return catalogMapper.select(id);
@ -1032,8 +870,8 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
} }
@Override @Override
public List<PlatformCatalog> queryCatalogInPlatform(String platformId) { public List<DeviceChannel> queryCatalogInPlatform(String platformId) {
return catalogMapper.selectByPlatForm(platformId); return catalogMapper.queryCatalogInPlatform(platformId);
} }
@Override @Override
@ -1076,20 +914,24 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
} }
private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) { private DeviceChannel getDeviceChannelByCatalog(PlatformCatalog catalog) {
ParentPlatform parentPlatByServerGBId = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId()); ParentPlatform platform = platformMapper.getParentPlatByServerGBId(catalog.getPlatformId());
DeviceChannel deviceChannel = new DeviceChannel(); DeviceChannel deviceChannel = new DeviceChannel();
deviceChannel.setChannelId(catalog.getId()); deviceChannel.setChannelId(catalog.getId());
deviceChannel.setName(catalog.getName()); deviceChannel.setName(catalog.getName());
deviceChannel.setLongitude(0.0); deviceChannel.setLongitude(0.0);
deviceChannel.setLatitude(0.0); deviceChannel.setLatitude(0.0);
deviceChannel.setDeviceId(parentPlatByServerGBId.getDeviceGBId()); deviceChannel.setDeviceId(platform.getDeviceGBId());
deviceChannel.setManufacture("wvp-pro"); deviceChannel.setManufacture("wvp-pro");
deviceChannel.setStatus(1); deviceChannel.setStatus(1);
deviceChannel.setParental(1); deviceChannel.setParental(1);
deviceChannel.setParentId(catalog.getParentId());
deviceChannel.setRegisterWay(1); deviceChannel.setRegisterWay(1);
// 行政区划应该是Domain的前八位 // 行政区划应该是Domain的前八位
deviceChannel.setCivilCode(parentPlatByServerGBId.getAdministrativeDivision()); if (platform.getTreeType().equals(TreeType.BUSINESS_GROUP)) {
deviceChannel.setParentId(catalog.getParentId());
deviceChannel.setBusinessGroupId(catalog.getBusinessGroupId());
}
deviceChannel.setModel("live"); deviceChannel.setModel("live");
deviceChannel.setOwner("wvp-pro"); deviceChannel.setOwner("wvp-pro");
deviceChannel.setSecrecy("0"); deviceChannel.setSecrecy("0");
@ -1151,4 +993,27 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
deviceChannelMapper.updatePosition(deviceChannel); deviceChannelMapper.updatePosition(deviceChannel);
} }
@Override
public void cleanContentForPlatform(String serverGBId) {
// List<PlatformCatalog> catalogList = catalogMapper.selectByPlatForm(serverGBId);
// if (catalogList.size() > 0) {
// int result = catalogMapper.delByPlatformId(serverGBId);
// if (result > 0) {
// List<DeviceChannel> deviceChannels = new ArrayList<>();
// for (PlatformCatalog catalog : catalogList) {
// deviceChannels.add(getDeviceChannelByCatalog(catalog));
// }
// eventPublisher.catalogEventPublish(serverGBId, deviceChannels, CatalogEvent.DEL);
// }
// }
catalogMapper.delByPlatformId(serverGBId);
platformChannelMapper.delByPlatformId(serverGBId);
platformGbStreamMapper.delByPlatformId(serverGBId);
}
@Override
public List<DeviceChannel> queryChannelWithCatalog(String serverGBId) {
return deviceChannelMapper.queryChannelWithCatalog(serverGBId);
}
} }

View File

@ -12,6 +12,7 @@ import com.genersoft.iot.vmp.gb28181.task.impl.MobilePositionSubscribeTask;
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
import com.genersoft.iot.vmp.service.IDeviceChannelService;
import com.genersoft.iot.vmp.service.IDeviceService; import com.genersoft.iot.vmp.service.IDeviceService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
@ -52,6 +53,9 @@ public class DeviceQuery {
@Autowired @Autowired
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired
private IDeviceChannelService deviceChannelService;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@ -280,7 +284,7 @@ public class DeviceQuery {
}) })
@PostMapping("/channel/update/{deviceId}") @PostMapping("/channel/update/{deviceId}")
public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){ public ResponseEntity<PageInfo> updateChannel(@PathVariable String deviceId,DeviceChannel channel){
storager.updateChannel(deviceId, channel); deviceChannelService.updateChannel(deviceId, channel);
return new ResponseEntity<>(null,HttpStatus.OK); return new ResponseEntity<>(null,HttpStatus.OK);
} }

View File

@ -44,7 +44,6 @@ public class GbStreamController {
@ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = String.class), @ApiImplicitParam(name = "platformId", value = "平台ID", required = true , dataTypeClass = String.class),
@ApiImplicitParam(name = "catalogId", value = "目录ID", required = false , dataTypeClass = String.class), @ApiImplicitParam(name = "catalogId", value = "目录ID", required = false , dataTypeClass = String.class),
@ApiImplicitParam(name="query", value = "查询内容", required = false , dataTypeClass = String.class), @ApiImplicitParam(name="query", value = "查询内容", required = false , dataTypeClass = String.class),
@ApiImplicitParam(name="pushing", value = "是否正在推流", required = false , dataTypeClass = Boolean.class),
@ApiImplicitParam(name="mediaServerId", value = "流媒体ID", required = false , dataTypeClass = String.class), @ApiImplicitParam(name="mediaServerId", value = "流媒体ID", required = false , dataTypeClass = String.class),
}) })
@ -55,7 +54,6 @@ public class GbStreamController {
@RequestParam(required = true)String platformId, @RequestParam(required = true)String platformId,
@RequestParam(required = false)String catalogId, @RequestParam(required = false)String catalogId,
@RequestParam(required = false)String query, @RequestParam(required = false)String query,
@RequestParam(required = false)Boolean pushing,
@RequestParam(required = false)String mediaServerId){ @RequestParam(required = false)String mediaServerId){
if (StringUtils.isEmpty(catalogId)) { if (StringUtils.isEmpty(catalogId)) {
catalogId = null; catalogId = null;
@ -69,7 +67,7 @@ public class GbStreamController {
// catalogId 为null 查询未在平台下分配的数据 // catalogId 为null 查询未在平台下分配的数据
// catalogId 不为null 查询平台下这个目录下的通道 // catalogId 不为null 查询平台下这个目录下的通道
return gbStreamService.getAll(page, count, platformId, catalogId, query, pushing, mediaServerId); return gbStreamService.getAll(page, count, platformId, catalogId, query, mediaServerId);
} }

View File

@ -9,6 +9,7 @@ import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog; import com.genersoft.iot.vmp.gb28181.bean.PlatformCatalog;
import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder; import com.genersoft.iot.vmp.gb28181.bean.SubscribeHolder;
import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform;
import com.genersoft.iot.vmp.service.IPlatformChannelService;
import com.genersoft.iot.vmp.storager.IRedisCatchStorage; import com.genersoft.iot.vmp.storager.IRedisCatchStorage;
import com.genersoft.iot.vmp.storager.IVideoManagerStorage; import com.genersoft.iot.vmp.storager.IVideoManagerStorage;
import com.genersoft.iot.vmp.utils.DateUtil; import com.genersoft.iot.vmp.utils.DateUtil;
@ -48,6 +49,9 @@ public class PlatformController {
@Autowired @Autowired
private IVideoManagerStorage storager; private IVideoManagerStorage storager;
@Autowired
private IPlatformChannelService platformChannelService;
@Autowired @Autowired
private IRedisCatchStorage redisCatchStorage; private IRedisCatchStorage redisCatchStorage;
@ -236,6 +240,12 @@ public class PlatformController {
parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase()); parentPlatform.setCharacterSet(parentPlatform.getCharacterSet().toUpperCase());
ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId()); ParentPlatform parentPlatformOld = storager.queryParentPlatByServerGBId(parentPlatform.getServerGBId());
parentPlatform.setUpdateTime(DateUtil.getNow()); parentPlatform.setUpdateTime(DateUtil.getNow());
if (!parentPlatformOld.getTreeType().equals(parentPlatform.getTreeType())) {
// 目录结构发生变化清空之前的关联关系
logger.info("保存平台{}时发现目录结构变化,清空关联关系", parentPlatform.getDeviceGBId());
storager.cleanContentForPlatform(parentPlatform.getServerGBId());
}
boolean updateResult = storager.updateParentPlatform(parentPlatform); boolean updateResult = storager.updateParentPlatform(parentPlatform);
if (updateResult) { if (updateResult) {
@ -256,6 +266,8 @@ public class PlatformController {
} }
} else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 关闭启用时注销 } else if (parentPlatformOld != null && parentPlatformOld.isEnable() && !parentPlatform.isEnable()) { // 关闭启用时注销
commanderForPlatform.unregister(parentPlatformOld, null, null); commanderForPlatform.unregister(parentPlatformOld, null, null);
// 停止订阅相关的定时任务
subscribeHolder.removeAllSubscribe(parentPlatform.getServerGBId());
} }
wvpResult.setCode(0); wvpResult.setCode(0);
wvpResult.setMsg("success"); wvpResult.setMsg("success");
@ -405,7 +417,7 @@ public class PlatformController {
if (logger.isDebugEnabled()) { if (logger.isDebugEnabled()) {
logger.debug("给上级平台添加国标通道API调用"); logger.debug("给上级平台添加国标通道API调用");
} }
int result = storager.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId()); int result = platformChannelService.updateChannelForGB(param.getPlatformId(), param.getChannelReduces(), param.getCatalogId());
return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK); return new ResponseEntity<>(String.valueOf(result > 0), HttpStatus.OK);
} }
@ -485,7 +497,6 @@ public class PlatformController {
PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId()); PlatformCatalog platformCatalogInStore = storager.getCatalog(platformCatalog.getId());
WVPResult<List<PlatformCatalog>> result = new WVPResult<>(); WVPResult<List<PlatformCatalog>> result = new WVPResult<>();
if (platformCatalogInStore != null) { if (platformCatalogInStore != null) {
result.setCode(-1); result.setCode(-1);
result.setMsg(platformCatalog.getId() + " already exists"); result.setMsg(platformCatalog.getId() + " already exists");

View File

@ -143,7 +143,7 @@ export default {
}); });
}, },
chooseChannel: function(platform) { chooseChannel: function(platform) {
this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, this.initData) this.$refs.chooseChannelDialog.openDialog(platform.serverGBId, platform.name, platform.catalogId, platform.treeType, this.initData)
}, },
initData: function() { initData: function() {
this.getPlatformList(); this.getPlatformList();

View File

@ -56,7 +56,7 @@
<el-table-column label="开始时间" min-width="200"> <el-table-column label="开始时间" min-width="200">
<template slot-scope="scope"> <template slot-scope="scope">
<el-button-group> <el-button-group>
{{ dateFormat(parseInt(scope.row.createStamp)) }} {{ scope.row.pushTime == null? "-":scope.row.pushTime }}
</el-button-group> </el-button-group>
</template> </template>
</el-table-column> </el-table-column>
@ -242,19 +242,6 @@ export default {
console.error(error); console.error(error);
}); });
}, },
dateFormat: function (/** timestamp=0 **/) {
let ts = arguments[0] || 0;
let t, y, m, d, h, i, s;
t = ts ? new Date(ts) : new Date();
y = t.getFullYear();
m = t.getMonth() + 1;
d = t.getDate();
h = t.getHours();
i = t.getMinutes();
s = t.getSeconds();
//
return y + '-' + (m < 10 ? '0' + m : m) + '-' + (d < 10 ? '0' + d : d) + ' ' + (h < 10 ? '0' + h : h) + ':' + (i < 10 ? '0' + i : i) + ':' + (s < 10 ? '0' + s : s);
},
importChannel: function () { importChannel: function () {
this.$refs.importChannel.openDialog(() => { this.$refs.importChannel.openDialog(() => {

View File

@ -49,11 +49,43 @@ export default {
props: ['platformId'], props: ['platformId'],
created() {}, created() {},
data() { data() {
let checkId = (rule, value, callback) => {
console.log("checkId")
console.log(this.treeType)
console.log(rule)
console.log(value)
console.log(value.length)
console.log(this.level)
if (!value) {
return callback(new Error('编号不能为空'));
}
if (this.treeType === "BusinessGroup" && value.length !== 20) {
return callback(new Error('编号必须由20位数字组成'));
}
if (this.treeType === "CivilCode" && value.length <= 8 && value.length%2 !== 0) {
return callback(new Error('行政区划必须是八位以下的偶数个数字组成'));
}
if (this.treeType === "BusinessGroup") {
let catalogType = value.substring(10, 13);
console.log(catalogType)
// 216 215
if (this.level === 1 && catalogType !== "215") {
return callback(new Error('业务分组模式下第一层目录的编号10到13位必须为215'));
}
if (this.level > 1 && catalogType !== "216") {
return callback(new Error('业务分组模式下第一层以下目录的编号10到13位必须为216'));
}
}
callback();
}
return { return {
submitCallback: null, submitCallback: null,
showDialog: false, showDialog: false,
isLoging: false, isLoging: false,
isEdit: false, isEdit: false,
treeType: null,
level: 0,
form: { form: {
id: null, id: null,
name: null, name: null,
@ -62,12 +94,12 @@ export default {
}, },
rules: { rules: {
name: [{ required: true, message: "请输入名称", trigger: "blur" }], name: [{ required: true, message: "请输入名称", trigger: "blur" }],
id: [{ required: true, message: "请输入ID", trigger: "blur" }] id: [{ trigger: "blur",validator: checkId }]
}, },
}; };
}, },
methods: { methods: {
openDialog: function (isEdit, id, name, parentId, callback) { openDialog: function (isEdit, id, name, parentId, treeType, level, callback) {
console.log("parentId: " + parentId) console.log("parentId: " + parentId)
console.log(this.form) console.log(this.form)
this.isEdit = isEdit; this.isEdit = isEdit;
@ -77,6 +109,8 @@ export default {
this.form.parentId = parentId; this.form.parentId = parentId;
this.showDialog = true; this.showDialog = true;
this.submitCallback = callback; this.submitCallback = callback;
this.treeType = treeType;
this.level = level;
}, },
onSubmit: function () { onSubmit: function () {
console.log("onSubmit"); console.log("onSubmit");

View File

@ -8,7 +8,7 @@
<el-tab-pane label="目录结构" name="catalog"> <el-tab-pane label="目录结构" name="catalog">
<el-container> <el-container>
<el-main v-bind:style="{backgroundColor: '#FFF', maxHeight: winHeight + 'px'}"> <el-main v-bind:style="{backgroundColor: '#FFF', maxHeight: winHeight + 'px'}">
<chooseChannelForCatalog ref="chooseChannelForCatalog" :platformId=platformId :platformName=platformName :defaultCatalogId=defaultCatalogId :catalogIdChange="catalogIdChange" ></chooseChannelForCatalog> <chooseChannelForCatalog ref="chooseChannelForCatalog" :platformId=platformId :platformName=platformName :defaultCatalogId=defaultCatalogId :catalogIdChange="catalogIdChange" :treeType=treeType ></chooseChannelForCatalog>
</el-main> </el-main>
</el-container> </el-container>
</el-tab-pane> </el-tab-pane>
@ -66,18 +66,20 @@ export default {
platformName: "", platformName: "",
defaultCatalogId: "", defaultCatalogId: "",
showDialog: false, showDialog: false,
treeType: null,
chooseData: {}, chooseData: {},
winHeight: window.innerHeight - 250, winHeight: window.innerHeight - 250,
}; };
}, },
methods: { methods: {
openDialog(platformId, platformName, defaultCatalogId, closeCallback) { openDialog(platformId, platformName, defaultCatalogId, treeType, closeCallback) {
this.platformId = platformId this.platformId = platformId
this.platformName = platformName this.platformName = platformName
this.defaultCatalogId = defaultCatalogId this.defaultCatalogId = defaultCatalogId
this.showDialog = true this.showDialog = true
this.closeCallback = closeCallback this.closeCallback = closeCallback
this.treeType = treeType
}, },
tabClick (tab, event){ tabClick (tab, event){

View File

@ -38,7 +38,7 @@
import catalogEdit from './catalogEdit.vue' import catalogEdit from './catalogEdit.vue'
export default { export default {
name: 'chooseChannelForCatalog', name: 'chooseChannelForCatalog',
props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange'], props: ['platformId', 'platformName', 'defaultCatalogId', 'catalogIdChange', 'treeType'],
created() { created() {
this.chooseId = this.defaultCatalogId; this.chooseId = this.defaultCatalogId;
this.defaultCatalogIdSign = this.defaultCatalogId; this.defaultCatalogIdSign = this.defaultCatalogId;
@ -102,8 +102,9 @@ export default {
}, },
addCatalog: function (parentId, node){ addCatalog: function (parentId, node){
let that = this; let that = this;
console.log(this.treeType)
// //
that.$refs.catalogEdit.openDialog(false, null, null, parentId, ()=>{ that.$refs.catalogEdit.openDialog(false, null, null, parentId, this.treeType, node.level, ()=>{
node.loaded = false node.loaded = false
node.expand(); node.expand();
}); });

View File

@ -174,7 +174,6 @@ export default {
page: that.currentPage, page: that.currentPage,
count: that.count, count: that.count,
query: that.searchSrt, query: that.searchSrt,
pushing: that.pushing,
platformId: that.platformId, platformId: that.platformId,
catalogId: that.catalogId, catalogId: that.catalogId,
mediaServerId: that.mediaServerId mediaServerId: that.mediaServerId

View File

@ -78,6 +78,12 @@
<el-option label="8" value="8"></el-option> <el-option label="8" value="8"></el-option>
</el-select> </el-select>
</el-form-item> </el-form-item>
<el-form-item label="目录结构" prop="treeType" >
<el-select v-model="platform.treeType" style="width: 100%" >
<el-option key="WGS84" label="行政区划" value="CivilCode"></el-option>
<el-option key="GCJ02" label="业务分组" value="BusinessGroup"></el-option>
</el-select>
</el-form-item>
<el-form-item label="字符集" prop="characterSet"> <el-form-item label="字符集" prop="characterSet">
<el-select <el-select
v-model="platform.characterSet" v-model="platform.characterSet"
@ -157,6 +163,7 @@ export default {
startOfflinePush: false, startOfflinePush: false,
catalogGroup: 1, catalogGroup: 1,
administrativeDivision: null, administrativeDivision: null,
treeType: "BusinessGroup",
}, },
rules: { rules: {
name: [{ required: true, message: "请输入平台名称", trigger: "blur" }], name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
@ -194,6 +201,7 @@ export default {
that.platform.devicePort = res.data.devicePort; that.platform.devicePort = res.data.devicePort;
that.platform.username = res.data.username; that.platform.username = res.data.username;
that.platform.password = res.data.password; that.platform.password = res.data.password;
that.platform.treeType = res.data.treeType;
that.platform.administrativeDivision = res.data.username.substr(0, 6); that.platform.administrativeDivision = res.data.username.substr(0, 6);
}).catch(function (error) { }).catch(function (error) {
console.log(error); console.log(error);
@ -222,6 +230,7 @@ export default {
this.platform.startOfflinePush = platform.startOfflinePush; this.platform.startOfflinePush = platform.startOfflinePush;
this.platform.catalogGroup = platform.catalogGroup; this.platform.catalogGroup = platform.catalogGroup;
this.platform.administrativeDivision = platform.administrativeDivision; this.platform.administrativeDivision = platform.administrativeDivision;
this.platform.treeType = platform.treeType;
this.onSubmit_text = "保存"; this.onSubmit_text = "保存";
this.saveUrl = "/api/platform/save"; this.saveUrl = "/api/platform/save";
} }
@ -242,6 +251,23 @@ export default {
}, },
onSubmit: function () { onSubmit: function () {
if (this.onSubmit_text === "保存") {
this.$confirm("修改目录结构会导致关联目录与通道数据被清空", '提示', {
dangerouslyUseHTMLString: true,
confirmButtonText: '确定',
cancelButtonText: '取消',
center: true,
type: 'warning'
}).then(() => {
this.saveForm()
}).catch(() => {
});
}else {
this.saveForm()
}
},
saveForm: function (){
var that = this; var that = this;
that.$axios({ that.$axios({
method: 'post', method: 'post',
@ -293,6 +319,7 @@ export default {
keepTimeout: 60, keepTimeout: 60,
transport: "UDP", transport: "UDP",
characterSet: "GB2312", characterSet: "GB2312",
treeType: "BusinessGroup",
shareAllLiveStream: false, shareAllLiveStream: false,
startOfflinePush: false, startOfflinePush: false,
catalogGroup: 1, catalogGroup: 1,