临时提交

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; 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; String content;
if (event == null) { if (event == null) {
return getFullContent(null); return getFullContent(null, serverDeviceId);
} }
switch (event) { switch (event) {
case CatalogEvent.DEL: case CatalogEvent.DEL:
@ -244,7 +247,7 @@ public class CommonGBChannel {
break; break;
case CatalogEvent.ADD: case CatalogEvent.ADD:
case CatalogEvent.UPDATE: case CatalogEvent.UPDATE:
content = getFullContent(event); content = getFullContent(event, serverDeviceId);
break; break;
default: default:
content = null; content = null;
@ -253,69 +256,156 @@ public class CommonGBChannel {
return content; return content;
} }
private String getFullContent(String event) { private String getFullContent(String event, String serverDeviceId) {
StringBuilder content = new StringBuilder(); StringBuilder content = new StringBuilder();
// 行政区划目录项 // 行政区划目录项
content.append("<Item>\n") content.append("<Item>\n")
.append("<DeviceID>" + this.getGbDeviceId() + "</DeviceID>\n") .append("<DeviceID>" + this.getGbDeviceId() + "</DeviceID>\n")
.append("<Name>" + this.getGbName() + "</Name>\n"); .append("<Name>" + this.getGbName() + "</Name>\n");
if (this.getGbDeviceId().length() > 8) { if (this.getGbDeviceId().length() > 8) {
String type = this.getGbDeviceId().substring(10,13); String type = this.getGbDeviceId().substring(10, 13);
if (type.equals("200")) { if (type.equals("200")) {
// 业务分组目录项 // 业务分组目录项
content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n") if (this.getGbManufacturer() != null) {
.append("<Model>" + this.getGbModel() + "</Model>\n") content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n");
.append("<Owner>" + this.getGbOwner() + "</Owner>\n") }
.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n") if (this.getGbModel() != null) {
.append("<Address>" + this.getGbAddress() + "</Address>\n") content.append("<Model>" + this.getGbModel() + "</Model>\n");
.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n") }
.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n"); if (this.getGbOwner() != null) {
}else if (type.equals("215")) { 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) {
}else if (type.equals("216")) { 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") content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n")
.append("<BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n"); .append("<BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n");
}else { } else {
// 设备目录项 if (this.getGbManufacturer() != null) {
content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n") content.append("<Manufacturer>" + this.getGbManufacturer() + "</Manufacturer>\n");
.append("<Model>" + this.getGbModel() + "</Model>\n") }
.append("<Owner>" + this.getGbOwner() + "</Owner>\n") if (this.getGbModel() != null) {
.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n") content.append("<Model>" + this.getGbModel() + "</Model>\n");
.append("<Block>" + this.getGbBlock() + "</Block>\n") }
.append("<Address>" + this.getGbAddress() + "</Address>\n") if (this.getGbOwner() != null) {
.append("<Parental>" + this.getGbParental() + "</Parental>\n") content.append("<Owner>" + this.getGbOwner() + "</Owner>\n");
.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n") }
.append("<SafetyWay>" + this.getGbSafetyWay() + "</SafetyWay>\n") if (this.getGbCivilCode() != null) {
.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n") content.append("<CivilCode>" + this.getGbCivilCode() + "</CivilCode>\n");
.append("<CertNum>" + this.getGbCertNum() + "</CertNum>\n") }
.append("<Certifiable>" + this.getGbCertifiable() + "</Certifiable>\n") if (this.getGbAddress() != null) {
.append("<ErrCode>" + this.getGbErrCode() + "</ErrCode>\n") content.append("<Address>" + this.getGbAddress() + "</Address>\n");
.append("<EndTime>" + this.getGbEndTime() + "</EndTime>\n") }
.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n") if (this.getGbRegisterWay() != null) {
.append("<IPAddress>" + this.getGbIpAddress() + "</IPAddress>\n") content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
.append("<Port>" + this.getGbPort() + "</Port>\n") }
.append("<Password>" + this.getGbPassword() + "</Password>\n") if (this.getGbSecrecy() != null) {
.append("<Status>" + this.getGbStatus() + "</Status>\n") content.append("<Secrecy>" + this.getGbSecrecy() + "</Secrecy>\n");
.append("<Longitude>" + this.getGbLongitude() + "</Longitude>\n") }
.append("<Latitude>" + this.getGbLatitude() + "</Latitude>\n") if (this.getGbParentId() != null) {
.append("<Info>\n") content.append("<ParentID>" + this.getGbParentId() + "</ParentID>\n");
.append(" <PTZType>" + this.getGbPtzType() + "</PTZType>\n") }
.append(" <PositionType>" + this.getGbPositionType() + "</PositionType>\n") if (this.getGbParental() != null) {
.append(" <RoomType>" + this.getGbRoomType() + "</RoomType>\n") content.append("<Parental>" + this.getGbParental() + "</Parental>\n");
.append(" <UseType>" + this.getGbUseType() + "</UseType>\n") }
.append(" <SupplyLightType>" + this.getGbSupplyLightType() + "</SupplyLightType>\n") if (this.getGbSafetyWay() != null) {
.append(" <DirectionType>" + this.getGbDirectionType() + "</DirectionType>\n") content.append("<SafetyWay>" + this.getGbSafetyWay() + "</SafetyWay>\n");
.append(" <Resolution>" + this.getGbResolution() + "</Resolution>\n") }
.append(" <BusinessGroupID>" + this.getGbBusinessGroupId() + "</BusinessGroupID>\n") if (this.getGbRegisterWay() != null) {
.append(" <DownloadSpeed>" + this.getGbDownloadSpeed() + "</DownloadSpeed>\n") content.append("<RegisterWay>" + this.getGbRegisterWay() + "</RegisterWay>\n");
.append(" <SVCSpaceSupportMode>" + this.getGbSvcSpaceSupportMod() + "</SVCSpaceSupportMode>\n") }
.append(" <SVCTimeSupportMode>" + this.getGbSvcTimeSupportMode() + "</SVCTimeSupportMode>\n") if (this.getGbCertNum() != null) {
.append("</Info>") 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) { if (event != null) {
@ -332,7 +422,7 @@ public class CommonGBChannel {
// 业务分组 // 业务分组
channel.setGbName(group.getName()); channel.setGbName(group.getName());
channel.setGbDeviceId(group.getDeviceId()); channel.setGbDeviceId(group.getDeviceId());
}else { } else {
// 虚拟组织 // 虚拟组织
channel.setGbName(group.getName()); channel.setGbName(group.getName());
channel.setGbDeviceId(group.getDeviceId()); channel.setGbDeviceId(group.getDeviceId());
@ -352,8 +442,15 @@ public class CommonGBChannel {
commonGBChannel.setGbAddress(platform.getAddress()); commonGBChannel.setGbAddress(platform.getAddress());
commonGBChannel.setGbRegisterWay(platform.getRegisterWay()); commonGBChannel.setGbRegisterWay(platform.getRegisterWay());
commonGBChannel.setGbSecrecy(platform.getSecrecy()); commonGBChannel.setGbSecrecy(platform.getSecrecy());
commonGBChannel.setGbStatus(platform.isStatus()?"ON":"OFF"); commonGBChannel.setGbStatus(platform.isStatus() ? "ON" : "OFF");
return 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(" <script>" +
" SELECT " + " SELECT " +
" device_id as gb_device_id" + " device_id as gb_device_id," +
" name as gb_name" + " 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 " + " from wvp_common_group " +
" where (device_id, business_group) in " + " where (device_id, business_group) in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > (#{item.gbParentId}, #{item.gbBusinessGroupId})</foreach>" + " <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(" <script>" +
" SELECT " + " SELECT " +
" device_id as gb_device_id" + " * " +
" name as gb_name" +
" from wvp_common_region " + " from wvp_common_region " +
" where device_id in " + " where device_id in " +
" <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" + " <foreach collection='channelList' item='item' open='(' separator=',' close=')' > #{item.gbCivilCode}</foreach>" +
" </script>") " </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()) { if (platform.getCatalogWithRegion()) {
List<CommonGBChannel> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList); List<Region> regionChannelList = regionMapper.queryInChannelList(commonGBChannelList);
if (!regionChannelList.isEmpty()) { if (!regionChannelList.isEmpty()) {
channelList.addAll(regionChannelList); // 获取这些节点的所有父节点
List<Region> allRegion = getAllRegion(regionChannelList);
for (Region region : allRegion) {
channelList.add(CommonGBChannel.build(region));
}
} }
} }
// 是否包含分组信息 // 是否包含分组信息
if (platform.getCatalogWithGroup()) { if (platform.getCatalogWithGroup()) {
List<CommonGBChannel> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList); List<CommonGBChannel> groupChannelList = groupMapper.queryInChannelList(commonGBChannelList);
if (!groupChannelList.isEmpty()) { if (!groupChannelList.isEmpty()) {
// 获取这些节点的所有父节点
channelList.addAll(groupChannelList); channelList.addAll(groupChannelList);
} }
} }
@ -344,6 +349,19 @@ public class GbChannelServiceImpl implements IGbChannelService {
return channelList; 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 @Override
public CommonGBChannel getOne(int id) { public CommonGBChannel getOne(int id) {

View File

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