Commit 6374a8f2e5829c1fc8d6f1bce49e5f824c69391c

Authored by 648540858
1 parent c19ad94c

优化目录推送

src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl;
2 2  
3 3 import com.alibaba.fastjson2.JSON;
  4 +import com.genersoft.iot.vmp.conf.DynamicTask;
4 5 import com.genersoft.iot.vmp.gb28181.SipLayer;
5 6 import com.genersoft.iot.vmp.gb28181.bean.*;
6 7 import com.genersoft.iot.vmp.gb28181.event.SipSubscribe;
... ... @@ -61,6 +62,9 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
61 62 @Autowired
62 63 private SIPSender sipSender;
63 64  
  65 + @Autowired
  66 + private DynamicTask dynamicTask;
  67 +
64 68 @Override
65 69 public void register(ParentPlatform parentPlatform, SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws InvalidArgumentException, ParseException, SipException {
66 70 register(parentPlatform, null, null, errorEvent, okEvent, false, true);
... ... @@ -109,13 +113,14 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
109 113 public String keepalive(ParentPlatform parentPlatform,SipSubscribe.Event errorEvent , SipSubscribe.Event okEvent) throws SipException, InvalidArgumentException, ParseException {
110 114 String characterSet = parentPlatform.getCharacterSet();
111 115 StringBuffer keepaliveXml = new StringBuffer(200);
112   - keepaliveXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
113   - keepaliveXml.append("<Notify>\r\n");
114   - keepaliveXml.append("<CmdType>Keepalive</CmdType>\r\n");
115   - keepaliveXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
116   - keepaliveXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
117   - keepaliveXml.append("<Status>OK</Status>\r\n");
118   - keepaliveXml.append("</Notify>\r\n");
  116 + keepaliveXml.append("<?xml version=\"1.0\" encoding=\"")
  117 + .append(characterSet).append("\"?>\r\n")
  118 + .append("<Notify>\r\n")
  119 + .append("<CmdType>Keepalive</CmdType>\r\n")
  120 + .append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n")
  121 + .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
  122 + .append("<Status>OK</Status>\r\n")
  123 + .append("</Notify>\r\n");
119 124  
120 125 CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
121 126  
... ... @@ -133,7 +138,6 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
133 138 * 向上级回复通道信息
134 139 * @param channel 通道信息
135 140 * @param parentPlatform 平台信息
136   - * @return
137 141 */
138 142 @Override
139 143 public void catalogQuery(DeviceChannel channel, ParentPlatform parentPlatform, String sn, String fromTag, int size) throws SipException, InvalidArgumentException, ParseException {
... ... @@ -160,18 +164,18 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
160 164 if ( parentPlatform ==null) {
161 165 return ;
162 166 }
163   - sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0);
  167 + sendCatalogResponse(channels, parentPlatform, sn, fromTag, 0, true);
164 168 }
165 169 private String getCatalogXml(List<DeviceChannel> channels, String sn, ParentPlatform parentPlatform, int size) {
166 170 String characterSet = parentPlatform.getCharacterSet();
167 171 StringBuffer catalogXml = new StringBuffer(600);
168   - catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet +"\"?>\r\n");
169   - catalogXml.append("<Response>\r\n");
170   - catalogXml.append("<CmdType>Catalog</CmdType>\r\n");
171   - catalogXml.append("<SN>" +sn + "</SN>\r\n");
172   - catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
173   - catalogXml.append("<SumNum>" + size + "</SumNum>\r\n");
174   - catalogXml.append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
  172 + catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet +"\"?>\r\n")
  173 + .append("<Response>\r\n")
  174 + .append("<CmdType>Catalog</CmdType>\r\n")
  175 + .append("<SN>" +sn + "</SN>\r\n")
  176 + .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
  177 + .append("<SumNum>" + size + "</SumNum>\r\n")
  178 + .append("<DeviceList Num=\"" + channels.size() +"\">\r\n");
175 179 if (channels.size() > 0) {
176 180 for (DeviceChannel channel : channels) {
177 181 if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
... ... @@ -222,7 +226,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
222 226 return catalogXml.toString();
223 227 }
224 228  
225   - private void sendCatalogResponse(List<DeviceChannel> channels, ParentPlatform parentPlatform, String sn, String fromTag, int index) throws SipException, InvalidArgumentException, ParseException {
  229 + private void sendCatalogResponse(List<DeviceChannel> channels, ParentPlatform parentPlatform, String sn, String fromTag, int index, boolean sendAfterResponse) throws SipException, InvalidArgumentException, ParseException {
226 230 if (index >= channels.size()) {
227 231 return;
228 232 }
... ... @@ -236,15 +240,49 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
236 240 // callid
237 241 CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
238 242  
239   - Request request = headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader);
240   - sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, null, eventResult -> {
241   - int indexNext = index + parentPlatform.getCatalogGroup();
242   - try {
243   - sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext);
244   - } catch (SipException | InvalidArgumentException | ParseException e) {
245   - logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage());
246   - }
247   - });
  243 + SIPRequest request = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, catalogXml, fromTag, SipUtils.getNewViaTag(), callIdHeader);
  244 +
  245 + String timeoutTaskKey = "catalog_task_" + parentPlatform.getServerGBId() + sn;
  246 +
  247 + String callId = request.getCallIdHeader().getCallId();
  248 +
  249 + if (sendAfterResponse) {
  250 + // 默认按照收到200回复后发送下一条, 如果超时收不到回复,就以30毫秒的间隔直接发送。
  251 + dynamicTask.startDelay(timeoutTaskKey, ()->{
  252 + sipSubscribe.removeOkSubscribe(callId);
  253 + int indexNext = index + parentPlatform.getCatalogGroup();
  254 + try {
  255 + sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext, false);
  256 + } catch (SipException | InvalidArgumentException | ParseException e) {
  257 + logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage());
  258 + }
  259 + }, 3000);
  260 + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, eventResult -> {
  261 + logger.error("[目录推送失败] 国标级联 platform : {}, code: {}, msg: {}, 停止发送", parentPlatform.getServerGBId(), eventResult.statusCode, eventResult.msg);
  262 + dynamicTask.stop(timeoutTaskKey);
  263 + }, eventResult -> {
  264 + dynamicTask.stop(timeoutTaskKey);
  265 + int indexNext = index + parentPlatform.getCatalogGroup();
  266 + try {
  267 + sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext, true);
  268 + } catch (SipException | InvalidArgumentException | ParseException e) {
  269 + logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage());
  270 + }
  271 + });
  272 + }else {
  273 + sipSender.transmitRequest(parentPlatform.getDeviceIp(), request, eventResult -> {
  274 + logger.error("[目录推送失败] 国标级联 platform : {}, code: {}, msg: {}, 停止发送", parentPlatform.getServerGBId(), eventResult.statusCode, eventResult.msg);
  275 + dynamicTask.stop(timeoutTaskKey);
  276 + }, null);
  277 + dynamicTask.startDelay(timeoutTaskKey, ()->{
  278 + int indexNext = index + parentPlatform.getCatalogGroup();
  279 + try {
  280 + sendCatalogResponse(channels, parentPlatform, sn, fromTag, indexNext, false);
  281 + } catch (SipException | InvalidArgumentException | ParseException e) {
  282 + logger.error("[命令发送失败] 国标级联 目录查询回复: {}", e.getMessage());
  283 + }
  284 + }, 30);
  285 + }
248 286 }
249 287  
250 288 /**
... ... @@ -261,17 +299,17 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
261 299 }
262 300 String characterSet = parentPlatform.getCharacterSet();
263 301 StringBuffer deviceInfoXml = new StringBuffer(600);
264   - deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
265   - deviceInfoXml.append("<Response>\r\n");
266   - deviceInfoXml.append("<CmdType>DeviceInfo</CmdType>\r\n");
267   - deviceInfoXml.append("<SN>" +sn + "</SN>\r\n");
268   - deviceInfoXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
269   - deviceInfoXml.append("<DeviceName>" + parentPlatform.getName() + "</DeviceName>\r\n");
270   - deviceInfoXml.append("<Manufacturer>wvp</Manufacturer>\r\n");
271   - deviceInfoXml.append("<Model>wvp-28181-2.0</Model>\r\n");
272   - deviceInfoXml.append("<Firmware>2.0.202107</Firmware>\r\n");
273   - deviceInfoXml.append("<Result>OK</Result>\r\n");
274   - deviceInfoXml.append("</Response>\r\n");
  302 + deviceInfoXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  303 + .append("<Response>\r\n")
  304 + .append("<CmdType>DeviceInfo</CmdType>\r\n")
  305 + .append("<SN>" +sn + "</SN>\r\n")
  306 + .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
  307 + .append("<DeviceName>" + parentPlatform.getName() + "</DeviceName>\r\n")
  308 + .append("<Manufacturer>wvp</Manufacturer>\r\n")
  309 + .append("<Model>wvp-28181-2.0</Model>\r\n")
  310 + .append("<Firmware>2.0.202107</Firmware>\r\n")
  311 + .append("<Result>OK</Result>\r\n")
  312 + .append("</Response>\r\n");
275 313  
276 314 CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
277 315  
... ... @@ -294,15 +332,15 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
294 332 String statusStr = (status==1)?"ONLINE":"OFFLINE";
295 333 String characterSet = parentPlatform.getCharacterSet();
296 334 StringBuffer deviceStatusXml = new StringBuffer(600);
297   - deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
298   - deviceStatusXml.append("<Response>\r\n");
299   - deviceStatusXml.append("<CmdType>DeviceStatus</CmdType>\r\n");
300   - deviceStatusXml.append("<SN>" +sn + "</SN>\r\n");
301   - deviceStatusXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
302   - deviceStatusXml.append("<Result>OK</Result>\r\n");
303   - deviceStatusXml.append("<Online>"+statusStr+"</Online>\r\n");
304   - deviceStatusXml.append("<Status>OK</Status>\r\n");
305   - deviceStatusXml.append("</Response>\r\n");
  335 + deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  336 + .append("<Response>\r\n")
  337 + .append("<CmdType>DeviceStatus</CmdType>\r\n")
  338 + .append("<SN>" +sn + "</SN>\r\n")
  339 + .append("<DeviceID>" + channelId + "</DeviceID>\r\n")
  340 + .append("<Result>OK</Result>\r\n")
  341 + .append("<Online>"+statusStr+"</Online>\r\n")
  342 + .append("<Status>OK</Status>\r\n")
  343 + .append("</Response>\r\n");
306 344  
307 345 CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
308 346  
... ... @@ -321,18 +359,18 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
321 359  
322 360 String characterSet = parentPlatform.getCharacterSet();
323 361 StringBuffer deviceStatusXml = new StringBuffer(600);
324   - deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
325   - deviceStatusXml.append("<Notify>\r\n");
326   - deviceStatusXml.append("<CmdType>MobilePosition</CmdType>\r\n");
327   - deviceStatusXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
328   - deviceStatusXml.append("<DeviceID>" + gpsMsgInfo.getId() + "</DeviceID>\r\n");
329   - deviceStatusXml.append("<Time>" + gpsMsgInfo.getTime() + "</Time>\r\n");
330   - deviceStatusXml.append("<Longitude>" + gpsMsgInfo.getLng() + "</Longitude>\r\n");
331   - deviceStatusXml.append("<Latitude>" + gpsMsgInfo.getLat() + "</Latitude>\r\n");
332   - deviceStatusXml.append("<Speed>" + gpsMsgInfo.getSpeed() + "</Speed>\r\n");
333   - deviceStatusXml.append("<Direction>" + gpsMsgInfo.getDirection() + "</Direction>\r\n");
334   - deviceStatusXml.append("<Altitude>" + gpsMsgInfo.getAltitude() + "</Altitude>\r\n");
335   - deviceStatusXml.append("</Notify>\r\n");
  362 + deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  363 + .append("<Notify>\r\n")
  364 + .append("<CmdType>MobilePosition</CmdType>\r\n")
  365 + .append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n")
  366 + .append("<DeviceID>" + gpsMsgInfo.getId() + "</DeviceID>\r\n")
  367 + .append("<Time>" + gpsMsgInfo.getTime() + "</Time>\r\n")
  368 + .append("<Longitude>" + gpsMsgInfo.getLng() + "</Longitude>\r\n")
  369 + .append("<Latitude>" + gpsMsgInfo.getLat() + "</Latitude>\r\n")
  370 + .append("<Speed>" + gpsMsgInfo.getSpeed() + "</Speed>\r\n")
  371 + .append("<Direction>" + gpsMsgInfo.getDirection() + "</Direction>\r\n")
  372 + .append("<Altitude>" + gpsMsgInfo.getAltitude() + "</Altitude>\r\n")
  373 + .append("</Notify>\r\n");
336 374  
337 375 sendNotify(parentPlatform, deviceStatusXml.toString(), subscribeInfo, eventResult -> {
338 376 logger.error("发送NOTIFY通知消息失败。错误:{} {}", eventResult.statusCode, eventResult.msg);
... ... @@ -349,21 +387,21 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
349 387 deviceAlarm.getLongitude(), deviceAlarm.getLatitude(), JSON.toJSONString(deviceAlarm));
350 388 String characterSet = parentPlatform.getCharacterSet();
351 389 StringBuffer deviceStatusXml = new StringBuffer(600);
352   - deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
353   - deviceStatusXml.append("<Notify>\r\n");
354   - deviceStatusXml.append("<CmdType>Alarm</CmdType>\r\n");
355   - deviceStatusXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
356   - deviceStatusXml.append("<DeviceID>" + deviceAlarm.getChannelId() + "</DeviceID>\r\n");
357   - deviceStatusXml.append("<AlarmPriority>" + deviceAlarm.getAlarmPriority() + "</AlarmPriority>\r\n");
358   - deviceStatusXml.append("<AlarmMethod>" + deviceAlarm.getAlarmMethod() + "</AlarmMethod>\r\n");
359   - deviceStatusXml.append("<AlarmTime>" + deviceAlarm.getAlarmTime() + "</AlarmTime>\r\n");
360   - deviceStatusXml.append("<AlarmDescription>" + deviceAlarm.getAlarmDescription() + "</AlarmDescription>\r\n");
361   - deviceStatusXml.append("<Longitude>" + deviceAlarm.getLongitude() + "</Longitude>\r\n");
362   - deviceStatusXml.append("<Latitude>" + deviceAlarm.getLatitude() + "</Latitude>\r\n");
363   - deviceStatusXml.append("<info>\r\n");
364   - deviceStatusXml.append("<AlarmType>" + deviceAlarm.getAlarmType() + "</AlarmType>\r\n");
365   - deviceStatusXml.append("</info>\r\n");
366   - deviceStatusXml.append("</Notify>\r\n");
  390 + deviceStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  391 + .append("<Notify>\r\n")
  392 + .append("<CmdType>Alarm</CmdType>\r\n")
  393 + .append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n")
  394 + .append("<DeviceID>" + deviceAlarm.getChannelId() + "</DeviceID>\r\n")
  395 + .append("<AlarmPriority>" + deviceAlarm.getAlarmPriority() + "</AlarmPriority>\r\n")
  396 + .append("<AlarmMethod>" + deviceAlarm.getAlarmMethod() + "</AlarmMethod>\r\n")
  397 + .append("<AlarmTime>" + deviceAlarm.getAlarmTime() + "</AlarmTime>\r\n")
  398 + .append("<AlarmDescription>" + deviceAlarm.getAlarmDescription() + "</AlarmDescription>\r\n")
  399 + .append("<Longitude>" + deviceAlarm.getLongitude() + "</Longitude>\r\n")
  400 + .append("<Latitude>" + deviceAlarm.getLatitude() + "</Latitude>\r\n")
  401 + .append("<info>\r\n")
  402 + .append("<AlarmType>" + deviceAlarm.getAlarmType() + "</AlarmType>\r\n")
  403 + .append("</info>\r\n")
  404 + .append("</Notify>\r\n");
367 405  
368 406 CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
369 407  
... ... @@ -422,13 +460,13 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
422 460 StringBuffer catalogXml = new StringBuffer(600);
423 461  
424 462 String characterSet = parentPlatform.getCharacterSet();
425   - catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
426   - catalogXml.append("<Notify>\r\n");
427   - catalogXml.append("<CmdType>Catalog</CmdType>\r\n");
428   - catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
429   - catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
430   - catalogXml.append("<SumNum>1</SumNum>\r\n");
431   - catalogXml.append("<DeviceList Num=\"" + channels.size() + "\">\r\n");
  463 + catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  464 + .append("<Notify>\r\n")
  465 + .append("<CmdType>Catalog</CmdType>\r\n")
  466 + .append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n")
  467 + .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
  468 + .append("<SumNum>1</SumNum>\r\n")
  469 + .append("<DeviceList Num=\"" + channels.size() + "\">\r\n");
432 470 if (channels.size() > 0) {
433 471 for (DeviceChannel channel : channels) {
434 472 if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
... ... @@ -449,16 +487,16 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
449 487 catalogXml.append("<Parental>" + channel.getParental() + "</Parental>\r\n");
450 488 if (channel.getParental() == 0) {
451 489 // 通道项
452   - catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n");
453   - catalogXml.append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n");
454   - catalogXml.append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n");
455   - catalogXml.append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
  490 + catalogXml.append("<Manufacturer>" + channel.getManufacture() + "</Manufacturer>\r\n")
  491 + .append("<Secrecy>" + channel.getSecrecy() + "</Secrecy>\r\n")
  492 + .append("<RegisterWay>" + channel.getRegisterWay() + "</RegisterWay>\r\n")
  493 + .append("<Status>" + (channel.getStatus() == 0 ? "OFF" : "ON") + "</Status>\r\n");
456 494  
457 495 if (channel.getChannelType() != 2) { // 业务分组/虚拟组织/行政区划 不设置以下属性
458   - catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n");
459   - catalogXml.append("<Owner> " + channel.getOwner()+ "</Owner>\r\n");
460   - catalogXml.append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n");
461   - catalogXml.append("<Address>" + channel.getAddress() + "</Address>\r\n");
  496 + catalogXml.append("<Model>" + channel.getModel() + "</Model>\r\n")
  497 + .append("<Owner> " + channel.getOwner()+ "</Owner>\r\n")
  498 + .append("<CivilCode>" + channel.getCivilCode() + "</CivilCode>\r\n")
  499 + .append("<Address>" + channel.getAddress() + "</Address>\r\n");
462 500 }
463 501 if (!"presence".equals(subscribeInfo.getEventType())) {
464 502 catalogXml.append("<Event>" + type + "</Event>\r\n");
... ... @@ -468,8 +506,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
468 506 catalogXml.append("</Item>\r\n");
469 507 }
470 508 }
471   - catalogXml.append("</DeviceList>\r\n");
472   - catalogXml.append("</Notify>\r\n");
  509 + catalogXml.append("</DeviceList>\r\n")
  510 + .append("</Notify>\r\n");
473 511 return catalogXml.toString();
474 512 }
475 513  
... ... @@ -515,26 +553,26 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
515 553  
516 554 String characterSet = parentPlatform.getCharacterSet();
517 555 StringBuffer catalogXml = new StringBuffer(600);
518   - catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
519   - catalogXml.append("<Notify>\r\n");
520   - catalogXml.append("<CmdType>Catalog</CmdType>\r\n");
521   - catalogXml.append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n");
522   - catalogXml.append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n");
523   - catalogXml.append("<SumNum>1</SumNum>\r\n");
524   - catalogXml.append("<DeviceList Num=\" " + channels.size() + " \">\r\n");
  556 + catalogXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  557 + .append("<Notify>\r\n")
  558 + .append("<CmdType>Catalog</CmdType>\r\n")
  559 + .append("<SN>" + (int) ((Math.random() * 9 + 1) * 100000) + "</SN>\r\n")
  560 + .append("<DeviceID>" + parentPlatform.getDeviceGBId() + "</DeviceID>\r\n")
  561 + .append("<SumNum>1</SumNum>\r\n")
  562 + .append("<DeviceList Num=\" " + channels.size() + " \">\r\n");
525 563 if (channels.size() > 0) {
526 564 for (DeviceChannel channel : channels) {
527 565 if (parentPlatform.getServerGBId().equals(channel.getParentId())) {
528 566 channel.setParentId(parentPlatform.getDeviceGBId());
529 567 }
530   - catalogXml.append("<Item>\r\n");
531   - catalogXml.append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n");
532   - catalogXml.append("<Event>" + type + "</Event>\r\n");
533   - catalogXml.append("</Item>\r\n");
  568 + catalogXml.append("<Item>\r\n")
  569 + .append("<DeviceID>" + channel.getChannelId() + "</DeviceID>\r\n")
  570 + .append("<Event>" + type + "</Event>\r\n")
  571 + .append("</Item>\r\n");
534 572 }
535 573 }
536   - catalogXml.append("</DeviceList>\r\n");
537   - catalogXml.append("</Notify>\r\n");
  574 + catalogXml.append("</DeviceList>\r\n")
  575 + .append("</Notify>\r\n");
538 576 return catalogXml.toString();
539 577 }
540 578 @Override
... ... @@ -544,12 +582,12 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
544 582 }
545 583 String characterSet = parentPlatform.getCharacterSet();
546 584 StringBuffer recordXml = new StringBuffer(600);
547   - recordXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
548   - recordXml.append("<Response>\r\n");
549   - recordXml.append("<CmdType>RecordInfo</CmdType>\r\n");
550   - recordXml.append("<SN>" +recordInfo.getSn() + "</SN>\r\n");
551   - recordXml.append("<DeviceID>" + recordInfo.getDeviceId() + "</DeviceID>\r\n");
552   - recordXml.append("<SumNum>" + recordInfo.getSumNum() + "</SumNum>\r\n");
  585 + recordXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  586 + .append("<Response>\r\n")
  587 + .append("<CmdType>RecordInfo</CmdType>\r\n")
  588 + .append("<SN>" +recordInfo.getSn() + "</SN>\r\n")
  589 + .append("<DeviceID>" + recordInfo.getDeviceId() + "</DeviceID>\r\n")
  590 + .append("<SumNum>" + recordInfo.getSumNum() + "</SumNum>\r\n");
553 591 if (recordInfo.getRecordList() == null ) {
554 592 recordXml.append("<RecordList Num=\"0\">\r\n");
555 593 }else {
... ... @@ -558,12 +596,12 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
558 596 for (RecordItem recordItem : recordInfo.getRecordList()) {
559 597 recordXml.append("<Item>\r\n");
560 598 if (deviceChannel != null) {
561   - recordXml.append("<DeviceID>" + recordItem.getDeviceId() + "</DeviceID>\r\n");
562   - recordXml.append("<Name>" + recordItem.getName() + "</Name>\r\n");
563   - recordXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getStartTime()) + "</StartTime>\r\n");
564   - recordXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n");
565   - recordXml.append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n");
566   - recordXml.append("<Type>" + recordItem.getType() + "</Type>\r\n");
  599 + recordXml.append("<DeviceID>" + recordItem.getDeviceId() + "</DeviceID>\r\n")
  600 + .append("<Name>" + recordItem.getName() + "</Name>\r\n")
  601 + .append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getStartTime()) + "</StartTime>\r\n")
  602 + .append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n")
  603 + .append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n")
  604 + .append("<Type>" + recordItem.getType() + "</Type>\r\n");
567 605 if (!ObjectUtils.isEmpty(recordItem.getFileSize())) {
568 606 recordXml.append("<FileSize>" + recordItem.getFileSize() + "</FileSize>\r\n");
569 607 }
... ... @@ -576,8 +614,8 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
576 614 }
577 615 }
578 616  
579   - recordXml.append("</RecordList>\r\n");
580   - recordXml.append("</Response>\r\n");
  617 + recordXml.append("</RecordList>\r\n")
  618 + .append("</Response>\r\n");
581 619  
582 620 // callid
583 621 CallIdHeader callIdHeader = sipSender.getNewCallIdHeader(parentPlatform.getDeviceIp(),parentPlatform.getTransport());
... ... @@ -596,13 +634,13 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
596 634  
597 635 String characterSet = parentPlatform.getCharacterSet();
598 636 StringBuffer mediaStatusXml = new StringBuffer(200);
599   - mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n");
600   - mediaStatusXml.append("<Notify>\r\n");
601   - mediaStatusXml.append("<CmdType>MediaStatus</CmdType>\r\n");
602   - mediaStatusXml.append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n");
603   - mediaStatusXml.append("<DeviceID>" + sendRtpItem.getChannelId() + "</DeviceID>\r\n");
604   - mediaStatusXml.append("<NotifyType>121</NotifyType>\r\n");
605   - mediaStatusXml.append("</Notify>\r\n");
  637 + mediaStatusXml.append("<?xml version=\"1.0\" encoding=\"" + characterSet + "\"?>\r\n")
  638 + .append("<Notify>\r\n")
  639 + .append("<CmdType>MediaStatus</CmdType>\r\n")
  640 + .append("<SN>" + (int)((Math.random()*9+1)*100000) + "</SN>\r\n")
  641 + .append("<DeviceID>" + sendRtpItem.getChannelId() + "</DeviceID>\r\n")
  642 + .append("<NotifyType>121</NotifyType>\r\n")
  643 + .append("</Notify>\r\n");
606 644  
607 645 SIPRequest messageRequest = (SIPRequest)headerProviderPlatformProvider.createMessageRequest(parentPlatform, mediaStatusXml.toString(),
608 646 sendRtpItem);
... ...
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/CatalogQueryMessageHandler.java
1 1 package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.cmd;
2 2  
3 3 import com.genersoft.iot.vmp.conf.SipConfig;
4   -import com.genersoft.iot.vmp.gb28181.bean.*;
  4 +import com.genersoft.iot.vmp.gb28181.bean.Device;
  5 +import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel;
  6 +import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform;
5 7 import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
6   -import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
7 8 import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
8 9 import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
9 10 import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
... ... @@ -63,7 +64,6 @@ public class CatalogQueryMessageHandler extends SIPRequestProcessorParent implem
63 64 @Override
64 65 public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) {
65 66  
66   - String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + parentPlatform.getServerGBId();
67 67 FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
68 68 try {
69 69 // 回复200 OK
... ...