临时提交

pull/1642/head
648540858 2024-08-16 17:59:53 +08:00
parent 326025ee85
commit aeb3cd6a22
5 changed files with 202 additions and 75 deletions

View File

@ -218,13 +218,16 @@ public class CommonGBChannel {
private String updateTime;
public String encode(){
return encode(null);
public String encode(String serverDeviceId) {
return encode(null, serverDeviceId);
}
public String encode(String event){
public String encode(String event,String serverDeviceId) {
String content;
if (event == null) {
return getFullContent(null);
return getFullContent(null, serverDeviceId);
}
switch (event) {
case CatalogEvent.DEL:
@ -244,7 +247,7 @@ public class CommonGBChannel {
break;
case CatalogEvent.ADD:
case CatalogEvent.UPDATE:
content = getFullContent(event);
content = getFullContent(event, serverDeviceId);
break;
default:
content = null;
@ -253,69 +256,156 @@ public class CommonGBChannel {
return content;
}
private String getFullContent(String event) {
private String getFullContent(String event, String serverDeviceId) {
StringBuilder content = new StringBuilder();
// 行政区划目录项
content.append("<Item>\n")
.append("<DeviceID>" + this.getGbDeviceId() + "</DeviceID>\n")
.append("<Name>" + this.getGbName() + "</Name>\n");
if (this.getGbDeviceId().length() > 8) {
String type = this.getGbDeviceId().substring(10, 13);
if (type.equals("200")) {
// 业务分组目录项
content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n")
.append("<Model>" + this.getGbModel() + "</Model>\n")
.append("<Owner>" + this.getGbOwner() + "</Owner>\n")
.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n")
.append("<Address>" + this.getGbAddress() + "</Address>\n")
.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n")
.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
if (this.getGbManufacturer() != null) {
content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n");
}
if (this.getGbModel() != null) {
content.append("<Model>" + this.getGbModel() + "</Model>\n");
}
if (this.getGbOwner() != null) {
content.append("<Owner>" + this.getGbOwner() + "</Owner>\n");
}
if (this.getGbCivilCode() != null) {
content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
}
if (this.getGbAddress() != null) {
content.append("<Address>" + this.getGbAddress() + "</Address>\n");
}
if (this.getGbRegisterWay() != null) {
content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
}
if (this.getGbSecrecy() != null) {
content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
}
} else if (type.equals("215")) {
// 业务分组
content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n");
if (this.getGbCivilCode() != null) {
content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
}
content.append("<ParentID>" + serverDeviceId + "</ParentID>\n");
} else if (type.equals("216")) {
// 虚拟组织目录项
if (this.getGbCivilCode() != null) {
content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
}
content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n")
.append("<BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n");
} else {
// 设备目录项
content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n")
.append("<Model>" + this.getGbModel() + "</Model>\n")
.append("<Owner>" + this.getGbOwner() + "</Owner>\n")
.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n")
.append("<Block>" + this.getGbBlock() + "</Block>\n")
.append("<Address>" + this.getGbAddress() + "</Address>\n")
.append("<Parental>" + this.getGbParental() + "</Parental>\n")
.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n")
.append("<SafetyWay>" + this.getGbSafetyWay() + "</SafetyWay>\n")
.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n")
.append("<CertNum>" + this.getGbCertNum() + "</CertNum>\n")
.append("<Certifiable>" + this.getGbCertifiable() + "</Certifiable>\n")
.append("<ErrCode>" + this.getGbErrCode() + "</ErrCode>\n")
.append("<EndTime>" + this.getGbEndTime() + "</EndTime>\n")
.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n")
.append("<IPAddress>" + this.getGbIpAddress() + "</IPAddress>\n")
.append("<Port>" + this.getGbPort() + "</Port>\n")
.append("<Password>" + this.getGbPassword() + "</Password>\n")
.append("<Status>" + this.getGbStatus() + "</Status>\n")
.append("<Longitude>" + this.getGbLongitude() + "</Longitude>\n")
.append("<Latitude>" + this.getGbLatitude() + "</Latitude>\n")
.append("<Info>\n")
.append(" <PTZType>" + this.getGbPtzType() + "</PTZType>\n")
.append(" <PositionType>" + this.getGbPositionType() + "</PositionType>\n")
.append(" <RoomType>" + this.getGbRoomType() + "</RoomType>\n")
.append(" <UseType>" + this.getGbUseType() + "</UseType>\n")
.append(" <SupplyLightType>" + this.getGbSupplyLightType() + "</SupplyLightType>\n")
.append(" <DirectionType>" + this.getGbDirectionType() + "</DirectionType>\n")
.append(" <Resolution>" + this.getGbResolution() + "</Resolution>\n")
.append(" <BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n")
.append(" <DownloadSpeed>" + this.getGbDownloadSpeed() + "</DownloadSpeed>\n")
.append(" <SVCSpaceSupportMode>" + this.getGbSvcSpaceSupportMod() + "</SVCSpaceSupportMode>\n")
.append(" <SVCTimeSupportMode>" + this.getGbSvcTimeSupportMode() + "</SVCTimeSupportMode>\n")
.append("</Info>")
;
if (this.getGbManufacturer() != null) {
content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n");
}
if (this.getGbModel() != null) {
content.append("<Model>" + this.getGbModel() + "</Model>\n");
}
if (this.getGbOwner() != null) {
content.append("<Owner>" + this.getGbOwner() + "</Owner>\n");
}
if (this.getGbCivilCode() != null) {
content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
}
if (this.getGbAddress() != null) {
content.append("<Address>" + this.getGbAddress() + "</Address>\n");
}
if (this.getGbRegisterWay() != null) {
content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
}
if (this.getGbSecrecy() != null) {
content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
}
if (this.getGbParentId() != null) {
content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n");
}
if (this.getGbParental() != null) {
content.append("<Parental>" + this.getGbParental() + "</Parental>\n");
}
if (this.getGbSafetyWay() != null) {
content.append("<SafetyWay>" + this.getGbSafetyWay() + "</SafetyWay>\n");
}
if (this.getGbRegisterWay() != null) {
content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
}
if (this.getGbCertNum() != null) {
content.append("<CertNum>" + this.getGbCertNum() + "</CertNum>\n");
}
if (this.getGbCertifiable() != null) {
content.append("<Certifiable>" + this.getGbCertifiable() + "</Certifiable>\n");
}
if (this.getGbErrCode() != null) {
content.append("<ErrCode>" + this.getGbErrCode() + "</ErrCode>\n");
}
if (this.getGbEndTime() != null) {
content.append("<EndTime>" + this.getGbEndTime() + "</EndTime>\n");
}
if (this.getGbSecrecy() != null) {
content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
}
if (this.getGbIpAddress() != null) {
content.append("<IPAddress>" + this.getGbIpAddress() + "</IPAddress>\n");
}
if (this.getGbPort() != null) {
content.append("<Port>" + this.getGbPort() + "</Port>\n");
}
if (this.getGbPassword() != null) {
content.append("<Password>" + this.getGbPassword() + "</Password>\n");
}
if (this.getGbStatus() != null) {
content.append("<Status>" + this.getGbStatus() + "</Status>\n");
}
if (this.getGbLongitude() != null) {
content.append("<Longitude>" + this.getGbLongitude() + "</Longitude>\n");
}
if (this.getGbLatitude() != null) {
content.append("<Latitude>" + this.getGbLatitude() + "</Latitude>\n");
}
content.append("<Info>\n");
if (this.getGbPtzType() != null) {
content.append(" <PTZType>" + this.getGbPtzType() + "</PTZType>\n");
}
if (this.getGbPositionType() != null) {
content.append(" <PositionType>" + this.getGbPositionType() + "</PositionType>\n");
}
if (this.getGbRoomType() != null) {
content.append(" <RoomType>" + this.getGbRoomType() + "</RoomType>\n");
}
if (this.getGbUseType() != null) {
content.append(" <UseType>" + this.getGbUseType() + "</UseType>\n");
}
if (this.getGbSupplyLightType() != null) {
content.append(" <SupplyLightType>" + this.getGbSupplyLightType() + "</SupplyLightType>\n");
}
if (this.getGbDirectionType() != null) {
content.append(" <DirectionType>" + this.getGbDirectionType() + "</DirectionType>\n");
}
if (this.getGbResolution() != null) {
content.append(" <Resolution>" + this.getGbResolution() + "</Resolution>\n");
}
if (this.getGbBusinessGroupId() != null) {
content.append(" <BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n");
}
if (this.getGbDownloadSpeed() != null) {
content.append(" <DownloadSpeed>" + this.getGbDownloadSpeed() + "</DownloadSpeed>\n");
}
if (this.getGbSvcSpaceSupportMod() != null) {
content.append(" <SVCSpaceSupportMode>" + this.getGbSvcSpaceSupportMod() + "</SVCSpaceSupportMode>\n");
}
if (this.getGbSvcTimeSupportMode() != null) {
content.append(" <SVCTimeSupportMode>" + this.getGbSvcTimeSupportMode() + "</SVCTimeSupportMode>\n");
}
content.append("</Info>\n");
}
}
if (event != null) {
@ -356,4 +446,11 @@ public class CommonGBChannel {
return commonGBChannel;
}
public static CommonGBChannel build(Region region) {
CommonGBChannel commonGBChannel = new CommonGBChannel();
commonGBChannel.setGbDeviceId(region.getDeviceId());
commonGBChannel.setGbName(region.getName());
return null;
}
}

View File

@ -164,8 +164,11 @@ public interface GroupMapper {
@Select(" <script>" +
" SELECT " +
" device_id as gb_device_id" +
" name as gb_name" +
" device_id as gb_device_id," +
" name as gb_name," +
" business_group as gb_business_group," +
" 1 as gb_parental," +
" parent_device_id as gb_parent_id" +
" from wvp_common_group " +
" where (device_id, business_group) in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > (#{item.gbParentId}, #{item.gbBusinessGroupId})</foreach>" +

View File

@ -100,11 +100,20 @@ public interface RegionMapper {
@Select(" <script>" +
" SELECT " +
" device_id as gb_device_id" +
" name as gb_name" +
" * " +
" from wvp_common_region " +
" where device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" +
" </script>")
List<CommonGBChannel> queryInChannelList(List<CommonGBChannel> channelList);
List<Region> queryInChannelList(List<CommonGBChannel> channelList);
@Select(" <script>" +
" SELECT " +
" * " +
" from wvp_common_region " +
" where device_id in " +
" <foreach collection='regionChannelList' item='item' open='(' separator=',' close=')' > #{item.parentDeviceId}</foreach>" +
" </script>")
List<Region> queryParentInChannelList(List<Region> regionChannelList);
}

View File

@ -328,15 +328,20 @@ public class GbChannelServiceImpl implements IGbChannelService {
// 是否包含行政区划信息
if (platform.getCatalogWithRegion()) {
List<CommonGBChannel> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
List<Region> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
if (!regionChannelList.isEmpty()) {
channelList.addAll(regionChannelList);
// 获取这些节点的所有父节点
List<Region> allRegion = getAllRegion(regionChannelList);
for (Region region : allRegion) {
channelList.add(CommonGBChannel.build(region));
}
}
}
// 是否包含分组信息
if (platform.getCatalogWithGroup()) {
List<CommonGBChannel> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList);
if (!groupChannelList.isEmpty()) {
// 获取这些节点的所有父节点
channelList.addAll(groupChannelList);
}
}
@ -344,6 +349,19 @@ public class GbChannelServiceImpl implements IGbChannelService {
return channelList;
}
private List<Region> getAllRegion(List<Region> regionChannelList ) {
if (regionChannelList.isEmpty()) {
return new ArrayList<>();
}
List<Region> channelList = regionMapper.queryParentInChannelList(regionChannelList);
if (channelList.isEmpty()) {
return channelList;
}
List<Region> allParentRegion = getAllRegion(channelList);
channelList.addAll(allParentRegion);
return channelList;
}
@Override
public CommonGBChannel getOne(int id) {

View File

@ -204,19 +204,19 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
}
sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0, true);
}
private String getCatalogXml(List<CommonGBChannel> channels, String sn, Platform parentPlatform, int size) {
String characterSet = parentPlatform.getCharacterSet();
private String getCatalogXml(List<CommonGBChannel> channels, String sn, Platform platform, int size) {
String characterSet = platform.getCharacterSet();
StringBuffer catalogXml = new StringBuffer(600);
catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet +"\"?>\r\n")
.append("<Response>\r\n")
.append("<CmdType>Catalog</CmdType>\r\n")
.append("<SN>" +sn + "</SN>\r\n")
.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<DeviceID>" + platform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<SumNum>" + size + "</SumNum>\r\n")
.append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
if (!channels.isEmpty()) {
for (CommonGBChannel channel : channels) {
catalogXml.append(channel.encode());
catalogXml.append(channel.encode(platform.getDeviceGBId()));
}
}
@ -464,19 +464,19 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
sipSender.transmitRequest(parentPlatform.getDeviceIp(), notifyRequest, errorEvent, okEvent);
}
private String getCatalogXmlContentForCatalogAddOrUpdate(Platform parentPlatform, List<CommonGBChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) {
private String getCatalogXmlContentForCatalogAddOrUpdate(Platform platform, List<CommonGBChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) {
StringBuffer catalogXml = new StringBuffer(600);
String characterSet = parentPlatform.getCharacterSet();
String characterSet = platform.getCharacterSet();
catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
.append("<Notify>\r\n")
.append("<CmdType>Catalog</CmdType>\r\n")
.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n")
.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<DeviceID>" + platform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<SumNum>"+ sumNum +"</SumNum>\r\n")
.append("<DeviceList Num=\"" + channels.size() + "\">\r\n");
if (!channels.isEmpty()) {
for (CommonGBChannel channel : channels) {
catalogXml.append(channel.encode(type));
catalogXml.append(channel.encode(type, platform.getDeviceGBId()));
}
}
catalogXml.append("</DeviceList>\r\n")
@ -523,20 +523,20 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
});
}
private String getCatalogXmlContentForCatalogOther(Platform parentPlatform, List<CommonGBChannel> channels, String type) {
private String getCatalogXmlContentForCatalogOther(Platform platform, List<CommonGBChannel> channels, String type) {
String characterSet = parentPlatform.getCharacterSet();
String characterSet = platform.getCharacterSet();
StringBuffer catalogXml = new StringBuffer(600);
catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
.append("<Notify>\r\n")
.append("<CmdType>Catalog</CmdType>\r\n")
.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n")
.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<DeviceID>" + platform.getDeviceGBId() + "</DeviceID>\r\n")
.append("<SumNum>1</SumNum>\r\n")
.append("<DeviceList Num=\" " + channels.size() + " \">\r\n");
if (!channels.isEmpty()) {
for (CommonGBChannel channel : channels) {
catalogXml.append(channel.encode(type));
catalogXml.append(channel.encode(type, platform.getDeviceGBId()));
}
}
catalogXml.append("</DeviceList>\r\n")