Commit 93d69d54768a5536635a9228bcd437b01d86babf

Authored by 648540858
1 parent 20622d20

添加国标级联目录分组分组加快通道传输速度

src/main/java/com/genersoft/iot/vmp/gb28181/bean/ParentPlatform.java
@@ -134,6 +134,16 @@ public class ParentPlatform { @@ -134,6 +134,16 @@ public class ParentPlatform {
134 */ 134 */
135 private boolean startOfflinePush; 135 private boolean startOfflinePush;
136 136
  137 + /**
  138 + * 目录分组-每次向上级发送通道信息时单个包携带的通道数量,取值1,2,4,8
  139 + */
  140 + private int catalogGroup;
  141 +
  142 + /**
  143 + * 行政区划
  144 + */
  145 + private String administrativeDivision;
  146 +
137 public Integer getId() { 147 public Integer getId() {
138 return id; 148 return id;
139 } 149 }
@@ -342,4 +352,20 @@ public class ParentPlatform { @@ -342,4 +352,20 @@ public class ParentPlatform {
342 public void setStartOfflinePush(boolean startOfflinePush) { 352 public void setStartOfflinePush(boolean startOfflinePush) {
343 this.startOfflinePush = startOfflinePush; 353 this.startOfflinePush = startOfflinePush;
344 } 354 }
  355 +
  356 + public int getCatalogGroup() {
  357 + return catalogGroup;
  358 + }
  359 +
  360 + public void setCatalogGroup(int catalogGroup) {
  361 + this.catalogGroup = catalogGroup;
  362 + }
  363 +
  364 + public String getAdministrativeDivision() {
  365 + return administrativeDivision;
  366 + }
  367 +
  368 + public void setAdministrativeDivision(String administrativeDivision) {
  369 + this.administrativeDivision = administrativeDivision;
  370 + }
345 } 371 }
src/main/java/com/genersoft/iot/vmp/gb28181/task/impl/CatalogSubscribeTask.java
@@ -10,6 +10,8 @@ import org.springframework.scheduling.annotation.Async; @@ -10,6 +10,8 @@ import org.springframework.scheduling.annotation.Async;
10 import javax.sip.Dialog; 10 import javax.sip.Dialog;
11 import javax.sip.DialogState; 11 import javax.sip.DialogState;
12 import javax.sip.ResponseEvent; 12 import javax.sip.ResponseEvent;
  13 +import java.util.Timer;
  14 +import java.util.TimerTask;
13 15
14 /** 16 /**
15 * 目录订阅任务 17 * 目录订阅任务
@@ -20,6 +22,8 @@ public class CatalogSubscribeTask implements ISubscribeTask { @@ -20,6 +22,8 @@ public class CatalogSubscribeTask implements ISubscribeTask {
20 private final ISIPCommander sipCommander; 22 private final ISIPCommander sipCommander;
21 private Dialog dialog; 23 private Dialog dialog;
22 24
  25 + private Timer timer ;
  26 +
23 public CatalogSubscribeTask(Device device, ISIPCommander sipCommander) { 27 public CatalogSubscribeTask(Device device, ISIPCommander sipCommander) {
24 this.device = device; 28 this.device = device;
25 this.sipCommander = sipCommander; 29 this.sipCommander = sipCommander;
@@ -27,6 +31,10 @@ public class CatalogSubscribeTask implements ISubscribeTask { @@ -27,6 +31,10 @@ public class CatalogSubscribeTask implements ISubscribeTask {
27 31
28 @Override 32 @Override
29 public void run() { 33 public void run() {
  34 + if (timer != null ) {
  35 + timer.cancel();
  36 + timer = null;
  37 + }
30 sipCommander.catalogSubscribe(device, dialog, eventResult -> { 38 sipCommander.catalogSubscribe(device, dialog, eventResult -> {
31 if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) { 39 if (eventResult.dialog != null || eventResult.dialog.getState().equals(DialogState.CONFIRMED)) {
32 dialog = eventResult.dialog; 40 dialog = eventResult.dialog;
@@ -43,6 +51,13 @@ public class CatalogSubscribeTask implements ISubscribeTask { @@ -43,6 +51,13 @@ public class CatalogSubscribeTask implements ISubscribeTask {
43 dialog = null; 51 dialog = null;
44 // 失败 52 // 失败
45 logger.warn("[目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg); 53 logger.warn("[目录订阅]失败,信令发送失败: {}-{} ", device.getDeviceId(), eventResult.msg);
  54 + timer = new Timer();
  55 + timer.schedule(new TimerTask() {
  56 + @Override
  57 + public void run() {
  58 + CatalogSubscribeTask.this.run();
  59 + }
  60 + }, 2000);
46 }); 61 });
47 } 62 }
48 63
@@ -56,9 +71,13 @@ public class CatalogSubscribeTask implements ISubscribeTask { @@ -56,9 +71,13 @@ public class CatalogSubscribeTask implements ISubscribeTask {
56 * TERMINATED-> Terminated Dialog状态-终止 71 * TERMINATED-> Terminated Dialog状态-终止
57 */ 72 */
58 logger.info("取消目录订阅时dialog状态为{}", DialogState.CONFIRMED); 73 logger.info("取消目录订阅时dialog状态为{}", DialogState.CONFIRMED);
  74 + if (timer != null ) {
  75 + timer.cancel();
  76 + timer = null;
  77 + }
59 if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) { 78 if (dialog != null && dialog.getState().equals(DialogState.CONFIRMED)) {
60 device.setSubscribeCycleForCatalog(0); 79 device.setSubscribeCycleForCatalog(0);
61 - sipCommander.mobilePositionSubscribe(device, dialog, eventResult -> { 80 + sipCommander.catalogSubscribe(device, dialog, eventResult -> {
62 ResponseEvent event = (ResponseEvent) eventResult.event; 81 ResponseEvent event = (ResponseEvent) eventResult.event;
63 if (event.getResponse().getRawContent() != null) { 82 if (event.getResponse().getRawContent() != null) {
64 // 成功 83 // 成功
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
@@ -32,6 +32,7 @@ import javax.sip.header.*; @@ -32,6 +32,7 @@ import javax.sip.header.*;
32 import javax.sip.message.Request; 32 import javax.sip.message.Request;
33 import java.lang.reflect.Field; 33 import java.lang.reflect.Field;
34 import java.text.ParseException; 34 import java.text.ParseException;
  35 +import java.util.ArrayList;
35 import java.util.HashSet; 36 import java.util.HashSet;
36 import java.util.List; 37 import java.util.List;
37 import java.util.UUID; 38 import java.util.UUID;
@@ -215,7 +216,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -215,7 +216,11 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
215 return false; 216 return false;
216 } 217 }
217 try { 218 try {
218 - String catalogXml = getCatalogXml(channel, sn, parentPlatform, size); 219 + List<DeviceChannel> channels = new ArrayList<>();
  220 + if (channel != null) {
  221 + channels.add(channel);
  222 + }
  223 + String catalogXml = getCatalogXml(channels, sn, parentPlatform, size);
219 224
220 // callid 225 // callid
221 CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() 226 CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
@@ -239,7 +244,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -239,7 +244,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
239 sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0); 244 sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0);
240 return true; 245 return true;
241 } 246 }
242 - private String getCatalogXml(DeviceChannel channel, String sn, ParentPlatform parentPlatform, int size) { 247 + private String getCatalogXml(List<DeviceChannel> channels, String sn, ParentPlatform parentPlatform, int size) {
243 String characterSet = parentPlatform.getCharacterSet(); 248 String characterSet = parentPlatform.getCharacterSet();
244 StringBuffer catalogXml = new StringBuffer(600); 249 StringBuffer catalogXml = new StringBuffer(600);
245 catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet +"\"?>\r\n"); 250 catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet +"\"?>\r\n");
@@ -248,34 +253,35 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -248,34 +253,35 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
248 catalogXml.append("<SN>" +sn + "</SN>\r\n"); 253 catalogXml.append("<SN>" +sn + "</SN>\r\n");
249 catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); 254 catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
250 catalogXml.append("<SumNum>" + size + "</SumNum>\r\n"); 255 catalogXml.append("<SumNum>" + size + "</SumNum>\r\n");
251 - catalogXml.append("<DeviceList Num=\"1\">\r\n");  
252 - catalogXml.append("<Item>\r\n");  
253 - if (channel != null) {  
254 - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");  
255 - catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");  
256 - catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");  
257 - catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");  
258 - catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n");  
259 - catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");  
260 - catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");  
261 - catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");  
262 - if (channel.getParentId() != null) {  
263 - catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n"); 256 + catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
  257 + if (channels.size() > 0) {
  258 + for (DeviceChannel channel : channels) {
  259 + catalogXml.append("<Item>\r\n");
  260 + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
  261 + catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
  262 + catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
  263 + catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
  264 + catalogXml.append("<Owner>" + channel.getOwner() + "</Owner>\r\n");
  265 + catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
  266 + catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
  267 + catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
  268 + if (channel.getParentId() != null) {
  269 + catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
  270 + }
  271 + catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
  272 + catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
  273 + catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n");
  274 + catalogXml.append("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n");
  275 + catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n");
  276 + catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");
  277 + catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");
  278 + catalogXml.append("<Info>\r\n");
  279 + catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");
  280 + catalogXml.append("</Info>\r\n");
  281 + catalogXml.append("</Item>\r\n");
264 } 282 }
265 - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");  
266 - catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");  
267 - catalogXml.append("<Status>" + (channel.getStatus() == 0?"OFF":"ON") + "</Status>\r\n");  
268 - catalogXml.append("<Longitude>" + channel.getLongitude() + "</Longitude>\r\n");  
269 - catalogXml.append("<Latitude>" + channel.getLatitude() + "</Latitude>\r\n");  
270 - catalogXml.append("<IPAddress>" + channel.getIpAddress() + "</IPAddress>\r\n");  
271 - catalogXml.append("<Port>" + channel.getPort() + "</Port>\r\n");  
272 - catalogXml.append("<Info>\r\n");  
273 - catalogXml.append("<PTZType>" + channel.getPTZType() + "</PTZType>\r\n");  
274 - catalogXml.append("</Info>\r\n");  
275 } 283 }
276 284
277 -  
278 - catalogXml.append("</Item>\r\n");  
279 catalogXml.append("</DeviceList>\r\n"); 285 catalogXml.append("</DeviceList>\r\n");
280 catalogXml.append("</Response>\r\n"); 286 catalogXml.append("</Response>\r\n");
281 return catalogXml.toString(); 287 return catalogXml.toString();
@@ -286,15 +292,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -286,15 +292,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
286 return; 292 return;
287 } 293 }
288 try { 294 try {
289 - DeviceChannel deviceChannel = channels.get(index);  
290 - String catalogXml = getCatalogXml(deviceChannel, sn, parentPlatform, channels.size()); 295 + List<DeviceChannel> deviceChannels;
  296 + if (index + parentPlatform.getCatalogGroup() < channels.size() - 1) {
  297 + deviceChannels = channels.subList(index, index + parentPlatform.getCatalogGroup());
  298 + }else {
  299 + deviceChannels = channels.subList(index, channels.size());
  300 + }
  301 +
  302 + String catalogXml = getCatalogXml(deviceChannels, sn, parentPlatform, channels.size());
291 // callid 303 // callid
292 CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() 304 CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId()
293 : udpSipProvider.getNewCallId(); 305 : udpSipProvider.getNewCallId();
294 306
295 Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, callIdHeader); 307 Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, callIdHeader);
296 transmitRequest(parentPlatform, request, null, eventResult -> { 308 transmitRequest(parentPlatform, request, null, eventResult -> {
297 - int indexNext = index + 1; 309 + int indexNext = index + parentPlatform.getCatalogGroup();
298 sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext); 310 sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext);
299 }); 311 });
300 } catch (SipException | ParseException | InvalidArgumentException e) { 312 } catch (SipException | ParseException | InvalidArgumentException e) {
@@ -432,13 +444,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -432,13 +444,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
432 if (index >= deviceChannels.size()) { 444 if (index >= deviceChannels.size()) {
433 return true; 445 return true;
434 } 446 }
  447 + List<DeviceChannel> channels;
  448 + if (index + parentPlatform.getCatalogGroup() < deviceChannels.size() - 1) {
  449 + channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup());
  450 + }else {
  451 + channels = deviceChannels.subList(index, deviceChannels.size());
  452 + }
435 try { 453 try {
436 Integer finalIndex = index; 454 Integer finalIndex = index;
437 - String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, deviceChannels.get(index ), deviceChannels.size(), type, subscribeInfo); 455 + String catalogXmlContent = getCatalogXmlContentForCatalogAddOrUpdate(parentPlatform, channels,
  456 + deviceChannels.size(), type, subscribeInfo);
438 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { 457 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {
439 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); 458 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
440 }, (eventResult -> { 459 }, (eventResult -> {
441 - sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex + 1); 460 + sendNotifyForCatalogAddOrUpdate(type, parentPlatform, deviceChannels, subscribeInfo,
  461 + finalIndex + parentPlatform.getCatalogGroup());
442 })); 462 }));
443 } catch (SipException | ParseException e) { 463 } catch (SipException | ParseException e) {
444 e.printStackTrace(); 464 e.printStackTrace();
@@ -500,11 +520,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -500,11 +520,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
500 520
501 } 521 }
502 522
503 - private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, DeviceChannel channel, int sumNum, String type, SubscribeInfo subscribeInfo) { 523 + private String getCatalogXmlContentForCatalogAddOrUpdate(ParentPlatform parentPlatform, List<DeviceChannel> channels, int sumNum, String type, SubscribeInfo subscribeInfo) {
504 StringBuffer catalogXml = new StringBuffer(600); 524 StringBuffer catalogXml = new StringBuffer(600);
505 - if (parentPlatform.getServerGBId().equals(channel.getParentId())) {  
506 - channel.setParentId(parentPlatform.getDeviceGBId());  
507 - } 525 +
508 String characterSet = parentPlatform.getCharacterSet(); 526 String characterSet = parentPlatform.getCharacterSet();
509 catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); 527 catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
510 catalogXml.append("<Notify>\r\n"); 528 catalogXml.append("<Notify>\r\n");
@@ -512,26 +530,33 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -512,26 +530,33 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
512 catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); 530 catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
513 catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); 531 catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
514 catalogXml.append("<SumNum>1</SumNum>\r\n"); 532 catalogXml.append("<SumNum>1</SumNum>\r\n");
515 - catalogXml.append("<DeviceList Num=\"1\">\r\n");  
516 - catalogXml.append("<Item>\r\n");  
517 - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");  
518 - catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");  
519 - catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");  
520 - catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");  
521 - catalogXml.append("<Owner>0</Owner>\r\n");  
522 - catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n");  
523 - catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");  
524 - catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");  
525 - if (channel.getParentId() != null) {  
526 - catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");  
527 - }  
528 - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");  
529 - catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");  
530 - catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");  
531 - if (!"presence".equals(subscribeInfo.getEventType())) {  
532 - catalogXml.append("<Event>" + type + "</Event>\r\n");  
533 - }  
534 - catalogXml.append("</Item>\r\n"); 533 + catalogXml.append("<DeviceList Num=\"" + channels.size() + "\">\r\n");
  534 + if (channels.size() > 0) {
  535 + for (DeviceChannel channel : channels) {
  536 + if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
  537 + channel.setParentId(parentPlatform.getDeviceGBId());
  538 + }
  539 + catalogXml.append("<Item>\r\n");
  540 + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
  541 + catalogXml.append("<Name>" + channel.getName() + "</Name>\r\n");
  542 + catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
  543 + catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
  544 + catalogXml.append("<Owner>0</Owner>\r\n");
  545 + catalogXml.append("<CivilCode>CivilCode</CivilCode>\r\n");
  546 + catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
  547 + catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
  548 + if (channel.getParentId() != null) {
  549 + catalogXml.append("<ParentID>" + channel.getParentId() + "</ParentID>\r\n");
  550 + }
  551 + catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
  552 + catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
  553 + catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
  554 + if (!"presence".equals(subscribeInfo.getEventType())) {
  555 + catalogXml.append("<Event>" + type + "</Event>\r\n");
  556 + }
  557 + catalogXml.append("</Item>\r\n");
  558 + }
  559 + }
535 catalogXml.append("</DeviceList>\r\n"); 560 catalogXml.append("</DeviceList>\r\n");
536 catalogXml.append("</Notify>\r\n"); 561 catalogXml.append("</Notify>\r\n");
537 return catalogXml.toString(); 562 return catalogXml.toString();
@@ -553,13 +578,20 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -553,13 +578,20 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
553 if (index >= deviceChannels.size()) { 578 if (index >= deviceChannels.size()) {
554 return true; 579 return true;
555 } 580 }
  581 + List<DeviceChannel> channels;
  582 + if (index + parentPlatform.getCatalogGroup() < deviceChannels.size() - 1) {
  583 + channels = deviceChannels.subList(index, index + parentPlatform.getCatalogGroup());
  584 + }else {
  585 + channels = deviceChannels.subList(index, deviceChannels.size());
  586 + }
556 try { 587 try {
557 Integer finalIndex = index; 588 Integer finalIndex = index;
558 - String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, deviceChannels.get(index), type); 589 + String catalogXmlContent = getCatalogXmlContentForCatalogOther(parentPlatform, channels, type);
559 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> { 590 sendNotify(parentPlatform, catalogXmlContent, subscribeInfo, eventResult -> {
560 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg); 591 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
561 }, (eventResult -> { 592 }, (eventResult -> {
562 - sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo, finalIndex + 1); 593 + sendNotifyForCatalogOther(type, parentPlatform, deviceChannels, subscribeInfo,
  594 + finalIndex + parentPlatform.getCatalogGroup());
563 })); 595 }));
564 } catch (SipException e) { 596 } catch (SipException e) {
565 e.printStackTrace(); 597 e.printStackTrace();
@@ -574,10 +606,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -574,10 +606,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
574 return true; 606 return true;
575 } 607 }
576 608
577 - private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, DeviceChannel channel, String type) {  
578 - if (parentPlatform.getServerGBId().equals(channel.getParentId())) {  
579 - channel.setParentId(parentPlatform.getDeviceGBId());  
580 - } 609 + private String getCatalogXmlContentForCatalogOther(ParentPlatform parentPlatform, List<DeviceChannel> channels, String type) {
  610 +
581 String characterSet = parentPlatform.getCharacterSet(); 611 String characterSet = parentPlatform.getCharacterSet();
582 StringBuffer catalogXml = new StringBuffer(600); 612 StringBuffer catalogXml = new StringBuffer(600);
583 catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n"); 613 catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
@@ -586,11 +616,18 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { @@ -586,11 +616,18 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
586 catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n"); 616 catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
587 catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n"); 617 catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
588 catalogXml.append("<SumNum>1</SumNum>\r\n"); 618 catalogXml.append("<SumNum>1</SumNum>\r\n");
589 - catalogXml.append("<DeviceList Num=\"1\">\r\n");  
590 - catalogXml.append("<Item>\r\n");  
591 - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");  
592 - catalogXml.append("<Event>" + type + "</Event>\r\n");  
593 - catalogXml.append("</Item>\r\n"); 619 + catalogXml.append("<DeviceList Num=\" " + channels.size() + " \">\r\n");
  620 + if (channels.size() > 0) {
  621 + for (DeviceChannel channel : channels) {
  622 + if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
  623 + channel.setParentId(parentPlatform.getDeviceGBId());
  624 + }
  625 + catalogXml.append("<Item>\r\n");
  626 + catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
  627 + catalogXml.append("<Event>" + type + "</Event>\r\n");
  628 + catalogXml.append("</Item>\r\n");
  629 + }
  630 + }
594 catalogXml.append("</DeviceList>\r\n"); 631 catalogXml.append("</DeviceList>\r\n");
595 catalogXml.append("</Notify>\r\n"); 632 catalogXml.append("</Notify>\r\n");
596 return catalogXml.toString(); 633 return catalogXml.toString();
src/main/java/com/genersoft/iot/vmp/service/impl/DeviceServiceImpl.java
@@ -41,10 +41,6 @@ public class DeviceServiceImpl implements IDeviceService { @@ -41,10 +41,6 @@ public class DeviceServiceImpl implements IDeviceService {
41 if (device == null || device.getSubscribeCycleForCatalog() < 0) { 41 if (device == null || device.getSubscribeCycleForCatalog() < 0) {
42 return false; 42 return false;
43 } 43 }
44 - CatalogSubscribeTask task = (CatalogSubscribeTask)dynamicTask.get(device.getDeviceId() + "catalog");  
45 - if (task != null && task.getDialogState() != null && task.getDialogState().equals(DialogState.CONFIRMED)) { // 已存在不需要再次添加  
46 - return true;  
47 - }  
48 logger.info("[添加目录订阅] 设备{}", device.getDeviceId()); 44 logger.info("[添加目录订阅] 设备{}", device.getDeviceId());
49 // 添加目录订阅 45 // 添加目录订阅
50 CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander); 46 CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander);
@@ -71,10 +67,6 @@ public class DeviceServiceImpl implements IDeviceService { @@ -71,10 +67,6 @@ public class DeviceServiceImpl implements IDeviceService {
71 return false; 67 return false;
72 } 68 }
73 logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId()); 69 logger.info("[添加移动位置订阅] 设备{}", device.getDeviceId());
74 - MobilePositionSubscribeTask task = (MobilePositionSubscribeTask)dynamicTask.get(device.getDeviceId() + "mobile_position");  
75 - if (task != null && task.getDialogState() != null && task.getDialogState().equals(DialogState.CONFIRMED)) { // 已存在不需要再次添加  
76 - return true;  
77 - }  
78 // 添加目录订阅 70 // 添加目录订阅
79 MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander); 71 MobilePositionSubscribeTask mobilePositionSubscribeTask = new MobilePositionSubscribeTask(device, sipCommander);
80 // 提前开始刷新订阅 72 // 提前开始刷新订阅
@@ -106,7 +98,7 @@ public class DeviceServiceImpl implements IDeviceService { @@ -106,7 +98,7 @@ public class DeviceServiceImpl implements IDeviceService {
106 98
107 @Override 99 @Override
108 public void sync(Device device) { 100 public void sync(Device device) {
109 - if (catalogResponseMessageHandler.getChannelSyncProgress(device.getDeviceId()) != null) { 101 + if (catalogResponseMessageHandler.isSyncRunning(device.getDeviceId())) {
110 logger.info("开启同步时发现同步已经存在"); 102 logger.info("开启同步时发现同步已经存在");
111 return; 103 return;
112 } 104 }
src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java
@@ -16,10 +16,10 @@ public interface ParentPlatformMapper { @@ -16,10 +16,10 @@ public interface ParentPlatformMapper {
16 16
17 @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " + 17 @Insert("INSERT INTO parent_platform (enable, name, serverGBId, serverGBDomain, serverIP, serverPort, deviceGBId, deviceIp, " +
18 " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " + 18 " devicePort, username, password, expires, keepTimeout, transport, characterSet, ptz, rtcp, " +
19 - " status, shareAllLiveStream, startOfflinePush, catalogId) " + 19 + " status, shareAllLiveStream, startOfflinePush, catalogId, administrativeDivision, catalogGroup) " +
20 " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " + 20 " VALUES (${enable}, '${name}', '${serverGBId}', '${serverGBDomain}', '${serverIP}', ${serverPort}, '${deviceGBId}', '${deviceIp}', " +
21 " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " + 21 " '${devicePort}', '${username}', '${password}', '${expires}', '${keepTimeout}', '${transport}', '${characterSet}', ${ptz}, ${rtcp}, " +
22 - " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId})") 22 + " ${status}, ${shareAllLiveStream}, ${startOfflinePush}, #{catalogId}, #{administrativeDivision}, #{catalogGroup})")
23 int addParentPlatform(ParentPlatform parentPlatform); 23 int addParentPlatform(ParentPlatform parentPlatform);
24 24
25 @Update("UPDATE parent_platform " + 25 @Update("UPDATE parent_platform " +
@@ -43,6 +43,8 @@ public interface ParentPlatformMapper { @@ -43,6 +43,8 @@ public interface ParentPlatformMapper {
43 "status=#{status}, " + 43 "status=#{status}, " +
44 "shareAllLiveStream=#{shareAllLiveStream}, " + 44 "shareAllLiveStream=#{shareAllLiveStream}, " +
45 "startOfflinePush=${startOfflinePush}, " + 45 "startOfflinePush=${startOfflinePush}, " +
  46 + "catalogGroup=#{catalogGroup}, " +
  47 + "administrativeDivision=#{administrativeDivision}, " +
46 "catalogId=#{catalogId} " + 48 "catalogId=#{catalogId} " +
47 "WHERE id=#{id}") 49 "WHERE id=#{id}")
48 int updateParentPlatform(ParentPlatform parentPlatform); 50 int updateParentPlatform(ParentPlatform parentPlatform);
src/main/java/com/genersoft/iot/vmp/storager/impl/VideoManagerStorageImpl.java
@@ -520,6 +520,12 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -520,6 +520,12 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
520 @Override 520 @Override
521 public boolean updateParentPlatform(ParentPlatform parentPlatform) { 521 public boolean updateParentPlatform(ParentPlatform parentPlatform) {
522 int result = 0; 522 int result = 0;
  523 + if (parentPlatform.getCatalogGroup() == 0) {
  524 + parentPlatform.setCatalogGroup(1);
  525 + }
  526 + if (parentPlatform.getAdministrativeDivision() == null) {
  527 + parentPlatform.setAdministrativeDivision(parentPlatform.getDeviceGBId().substring(0,6));
  528 + }
523 ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId()); 529 ParentPlatformCatch parentPlatformCatch = redisCatchStorage.queryPlatformCatchInfo(parentPlatform.getServerGBId()); // .getDeviceGBId());
524 if (parentPlatform.getId() == null ) { 530 if (parentPlatform.getId() == null ) {
525 if (parentPlatform.getCatalogId() == null) { 531 if (parentPlatform.getCatalogId() == null) {
@@ -539,6 +545,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage { @@ -539,6 +545,7 @@ public class VideoManagerStorageImpl implements IVideoManagerStorage {
539 parentPlatformCatch.setId(parentPlatform.getServerGBId()); 545 parentPlatformCatch.setId(parentPlatform.getServerGBId());
540 redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId()); 546 redisCatchStorage.delPlatformCatchInfo(parentPlatById.getServerGBId());
541 } 547 }
  548 +
542 result = platformMapper.updateParentPlatform(parentPlatform); 549 result = platformMapper.updateParentPlatform(parentPlatform);
543 } 550 }
544 // 更新缓存 551 // 更新缓存
web_src/src/components/dialog/platformEdit.vue
@@ -63,6 +63,18 @@ @@ -63,6 +63,18 @@
63 <el-option label="TCP" value="TCP"></el-option> 63 <el-option label="TCP" value="TCP"></el-option>
64 </el-select> 64 </el-select>
65 </el-form-item> 65 </el-form-item>
  66 + <el-form-item label="目录分组" prop="catalogGroup">
  67 + <el-select
  68 + v-model="platform.catalogGroup"
  69 + style="width: 100%"
  70 + placeholder="请选择目录分组"
  71 + >
  72 + <el-option label="1" value="1"></el-option>
  73 + <el-option label="2" value="2"></el-option>
  74 + <el-option label="4" value="4"></el-option>
  75 + <el-option label="8" value="8"></el-option>
  76 + </el-select>
  77 + </el-form-item>
66 <el-form-item label="字符集" prop="characterSet"> 78 <el-form-item label="字符集" prop="characterSet">
67 <el-select 79 <el-select
68 v-model="platform.characterSet" 80 v-model="platform.characterSet"
@@ -140,6 +152,7 @@ export default { @@ -140,6 +152,7 @@ export default {
140 characterSet: "GB2312", 152 characterSet: "GB2312",
141 shareAllLiveStream: false, 153 shareAllLiveStream: false,
142 startOfflinePush: false, 154 startOfflinePush: false,
  155 + catalogGroup: 1,
143 }, 156 },
144 rules: { 157 rules: {
145 name: [{ required: true, message: "请输入平台名称", trigger: "blur" }], 158 name: [{ required: true, message: "请输入平台名称", trigger: "blur" }],
@@ -202,6 +215,7 @@ export default { @@ -202,6 +215,7 @@ export default {
202 this.platform.shareAllLiveStream = platform.shareAllLiveStream; 215 this.platform.shareAllLiveStream = platform.shareAllLiveStream;
203 this.platform.catalogId = platform.catalogId; 216 this.platform.catalogId = platform.catalogId;
204 this.platform.startOfflinePush = platform.startOfflinePush; 217 this.platform.startOfflinePush = platform.startOfflinePush;
  218 + this.platform.catalogGroup = platform.catalogGroup;
205 this.onSubmit_text = "保存"; 219 this.onSubmit_text = "保存";
206 this.saveUrl = "/api/platform/save"; 220 this.saveUrl = "/api/platform/save";
207 } 221 }
@@ -270,6 +284,7 @@ export default { @@ -270,6 +284,7 @@ export default {
270 characterSet: "GB2312", 284 characterSet: "GB2312",
271 shareAllLiveStream: false, 285 shareAllLiveStream: false,
272 startOfflinePush: false, 286 startOfflinePush: false,
  287 + catalogGroup: 1,
273 } 288 }
274 }, 289 },
275 deviceGBIdExit: async function (deviceGbId) { 290 deviceGBIdExit: async function (deviceGbId) {