Commit c9bfdf2525c5e000d1f02e0e15183ca1b4fee9f3
1 parent
00afecac
实现国标的级联录像查询
Showing
13 changed files
with
203 additions
and
89 deletions
src/main/java/com/genersoft/iot/vmp/gb28181/bean/Device.java
| @@ -4,11 +4,6 @@ package com.genersoft.iot.vmp.gb28181.bean; | @@ -4,11 +4,6 @@ package com.genersoft.iot.vmp.gb28181.bean; | ||
| 4 | public class Device { | 4 | public class Device { |
| 5 | 5 | ||
| 6 | /** | 6 | /** |
| 7 | - * Id | ||
| 8 | - */ | ||
| 9 | - private int id; | ||
| 10 | - | ||
| 11 | - /** | ||
| 12 | * 设备Id | 7 | * 设备Id |
| 13 | */ | 8 | */ |
| 14 | private String deviceId; | 9 | private String deviceId; |
| @@ -119,13 +114,7 @@ public class Device { | @@ -119,13 +114,7 @@ public class Device { | ||
| 119 | */ | 114 | */ |
| 120 | private int subscribeCycleForCatalog ; | 115 | private int subscribeCycleForCatalog ; |
| 121 | 116 | ||
| 122 | - public int getId() { | ||
| 123 | - return id; | ||
| 124 | - } | ||
| 125 | 117 | ||
| 126 | - public void setId(int id) { | ||
| 127 | - this.id = id; | ||
| 128 | - } | ||
| 129 | 118 | ||
| 130 | public String getDeviceId() { | 119 | public String getDeviceId() { |
| 131 | return deviceId; | 120 | return deviceId; |
| @@ -294,6 +283,4 @@ public class Device { | @@ -294,6 +283,4 @@ public class Device { | ||
| 294 | public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) { | 283 | public void setSubscribeCycleForCatalog(int subscribeCycleForCatalog) { |
| 295 | this.subscribeCycleForCatalog = subscribeCycleForCatalog; | 284 | this.subscribeCycleForCatalog = subscribeCycleForCatalog; |
| 296 | } | 285 | } |
| 297 | - | ||
| 298 | - | ||
| 299 | } | 286 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/MobilePosition.java
| @@ -8,10 +8,6 @@ package com.genersoft.iot.vmp.gb28181.bean; | @@ -8,10 +8,6 @@ package com.genersoft.iot.vmp.gb28181.bean; | ||
| 8 | 8 | ||
| 9 | public class MobilePosition { | 9 | public class MobilePosition { |
| 10 | /** | 10 | /** |
| 11 | - * Id | ||
| 12 | - */ | ||
| 13 | - private int id; | ||
| 14 | - /** | ||
| 15 | * 设备Id | 11 | * 设备Id |
| 16 | */ | 12 | */ |
| 17 | private String deviceId; | 13 | private String deviceId; |
| @@ -76,13 +72,6 @@ public class MobilePosition { | @@ -76,13 +72,6 @@ public class MobilePosition { | ||
| 76 | */ | 72 | */ |
| 77 | private String cnLat; | 73 | private String cnLat; |
| 78 | 74 | ||
| 79 | - public int getId() { | ||
| 80 | - return id; | ||
| 81 | - } | ||
| 82 | - | ||
| 83 | - public void setId(int id) { | ||
| 84 | - this.id = id; | ||
| 85 | - } | ||
| 86 | 75 | ||
| 87 | public String getDeviceId() { | 76 | public String getDeviceId() { |
| 88 | return deviceId; | 77 | return deviceId; |
src/main/java/com/genersoft/iot/vmp/gb28181/bean/RecordItem.java
| @@ -19,7 +19,9 @@ public class RecordItem implements Comparable<RecordItem>{ | @@ -19,7 +19,9 @@ public class RecordItem implements Comparable<RecordItem>{ | ||
| 19 | private String name; | 19 | private String name; |
| 20 | 20 | ||
| 21 | private String filePath; | 21 | private String filePath; |
| 22 | - | 22 | + |
| 23 | + private String fileSize; | ||
| 24 | + | ||
| 23 | private String address; | 25 | private String address; |
| 24 | 26 | ||
| 25 | private String startTime; | 27 | private String startTime; |
| @@ -104,6 +106,14 @@ public class RecordItem implements Comparable<RecordItem>{ | @@ -104,6 +106,14 @@ public class RecordItem implements Comparable<RecordItem>{ | ||
| 104 | this.recorderId = recorderId; | 106 | this.recorderId = recorderId; |
| 105 | } | 107 | } |
| 106 | 108 | ||
| 109 | + public String getFileSize() { | ||
| 110 | + return fileSize; | ||
| 111 | + } | ||
| 112 | + | ||
| 113 | + public void setFileSize(String fileSize) { | ||
| 114 | + this.fileSize = fileSize; | ||
| 115 | + } | ||
| 116 | + | ||
| 107 | @Override | 117 | @Override |
| 108 | public int compareTo(@NotNull RecordItem recordItem) { | 118 | public int compareTo(@NotNull RecordItem recordItem) { |
| 109 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); | 119 | SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss"); |
src/main/java/com/genersoft/iot/vmp/gb28181/event/EventPublisher.java
| 1 | package com.genersoft.iot.vmp.gb28181.event; | 1 | package com.genersoft.iot.vmp.gb28181.event; |
| 2 | 2 | ||
| 3 | -import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 5 | -import com.genersoft.iot.vmp.gb28181.bean.GbStream; | 3 | +import com.genersoft.iot.vmp.gb28181.bean.*; |
| 6 | import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent; | 4 | import com.genersoft.iot.vmp.gb28181.event.offline.OfflineEvent; |
| 7 | import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent; | 5 | import com.genersoft.iot.vmp.gb28181.event.platformKeepaliveExpire.PlatformKeepaliveExpireEvent; |
| 8 | import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformCycleRegisterEvent; | 6 | import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformCycleRegisterEvent; |
| 9 | import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent; | 7 | import com.genersoft.iot.vmp.gb28181.event.platformNotRegister.PlatformNotRegisterEvent; |
| 8 | +import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEvent; | ||
| 10 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; | 9 | import com.genersoft.iot.vmp.gb28181.event.subscribe.catalog.CatalogEvent; |
| 11 | import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent; | 10 | import com.genersoft.iot.vmp.media.zlm.event.ZLMOfflineEvent; |
| 12 | import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent; | 11 | import com.genersoft.iot.vmp.media.zlm.event.ZLMOnlineEvent; |
| @@ -15,7 +14,6 @@ import org.springframework.context.ApplicationEventPublisher; | @@ -15,7 +14,6 @@ import org.springframework.context.ApplicationEventPublisher; | ||
| 15 | import org.springframework.scheduling.annotation.Async; | 14 | import org.springframework.scheduling.annotation.Async; |
| 16 | import org.springframework.stereotype.Component; | 15 | import org.springframework.stereotype.Component; |
| 17 | 16 | ||
| 18 | -import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm; | ||
| 19 | import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; | 17 | import com.genersoft.iot.vmp.gb28181.event.alarm.AlarmEvent; |
| 20 | import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent; | 18 | import com.genersoft.iot.vmp.gb28181.event.online.OnlineEvent; |
| 21 | 19 | ||
| @@ -144,4 +142,11 @@ public class EventPublisher { | @@ -144,4 +142,11 @@ public class EventPublisher { | ||
| 144 | GbStream[] gbStreams = {gbStream}; | 142 | GbStream[] gbStreams = {gbStream}; |
| 145 | catalogEventPublishForStream(platformId, gbStreams, type); | 143 | catalogEventPublishForStream(platformId, gbStreams, type); |
| 146 | } | 144 | } |
| 145 | + | ||
| 146 | + public void recordEndEventPush(RecordInfo recordInfo) { | ||
| 147 | + RecordEndEvent outEvent = new RecordEndEvent(this); | ||
| 148 | + outEvent.setRecordInfo(recordInfo); | ||
| 149 | + applicationEventPublisher.publishEvent(outEvent); | ||
| 150 | + } | ||
| 151 | + | ||
| 147 | } | 152 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/event/offline/KeepaliveTimeoutListenerForPlatform.java
| @@ -76,10 +76,7 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent | @@ -76,10 +76,7 @@ public class KeepaliveTimeoutListenerForPlatform extends RedisKeyExpirationEvent | ||
| 76 | eventResult.callId = callid; | 76 | eventResult.callId = callid; |
| 77 | eventResult.msg = "注册超时"; | 77 | eventResult.msg = "注册超时"; |
| 78 | eventResult.type = "register timeout"; | 78 | eventResult.type = "register timeout"; |
| 79 | - if (sipSubscribe.getErrorSubscribe(callid) != null) { | ||
| 80 | - sipSubscribe.getErrorSubscribe(callid).response(eventResult); | ||
| 81 | - } | ||
| 82 | - | 79 | + sipSubscribe.getErrorSubscribe(callid).response(eventResult); |
| 83 | } | 80 | } |
| 84 | 81 | ||
| 85 | } | 82 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/event/record/RecordEndEventListener.java
| 1 | package com.genersoft.iot.vmp.gb28181.event.record; | 1 | package com.genersoft.iot.vmp.gb28181.event.record; |
| 2 | 2 | ||
| 3 | +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.RecordItem; | 4 | import com.genersoft.iot.vmp.gb28181.bean.RecordItem; |
| 4 | import org.slf4j.Logger; | 5 | import org.slf4j.Logger; |
| 5 | import org.slf4j.LoggerFactory; | 6 | import org.slf4j.LoggerFactory; |
| @@ -23,12 +24,8 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven | @@ -23,12 +24,8 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven | ||
| 23 | 24 | ||
| 24 | private static Map<String, SseEmitter> sseEmitters = new Hashtable<>(); | 25 | private static Map<String, SseEmitter> sseEmitters = new Hashtable<>(); |
| 25 | 26 | ||
| 26 | - public void addSseEmitters(String browserId, SseEmitter sseEmitter) { | ||
| 27 | - sseEmitters.put(browserId, sseEmitter); | ||
| 28 | - } | ||
| 29 | - | ||
| 30 | public interface RecordEndEventHandler{ | 27 | public interface RecordEndEventHandler{ |
| 31 | - void handler(List<RecordItem> recordItems); | 28 | + void handler(RecordInfo recordInfo); |
| 32 | } | 29 | } |
| 33 | 30 | ||
| 34 | private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>(); | 31 | private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>(); |
| @@ -38,6 +35,15 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven | @@ -38,6 +35,15 @@ public class RecordEndEventListener implements ApplicationListener<RecordEndEven | ||
| 38 | logger.debug("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(), | 35 | logger.debug("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(), |
| 39 | event.getRecordInfo().getChannelId(), event.getRecordInfo().getRecordList().size() ); | 36 | event.getRecordInfo().getChannelId(), event.getRecordInfo().getRecordList().size() ); |
| 40 | } | 37 | } |
| 38 | + if (handlerMap.size() > 0) { | ||
| 39 | + for (RecordEndEventHandler recordEndEventHandler : handlerMap.values()) { | ||
| 40 | + recordEndEventHandler.handler(event.getRecordInfo()); | ||
| 41 | + } | ||
| 42 | + } | ||
| 43 | + | ||
| 44 | + } | ||
| 41 | 45 | ||
| 46 | + public void addEndEventHandler(String device, String channelId, RecordEndEventHandler recordEndEventHandler) { | ||
| 47 | + handlerMap.put(device + channelId, recordEndEventHandler); | ||
| 42 | } | 48 | } |
| 43 | } | 49 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/ISIPCommanderForPlatform.java
| @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; | @@ -2,6 +2,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.cmd; | ||
| 2 | 2 | ||
| 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | 3 | import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | +import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; | ||
| 5 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; | 6 | import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; |
| 6 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 7 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 7 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | 8 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| @@ -87,4 +88,12 @@ public interface ISIPCommanderForPlatform { | @@ -87,4 +88,12 @@ public interface ISIPCommanderForPlatform { | ||
| 87 | */ | 88 | */ |
| 88 | boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo); | 89 | boolean sendNotifyForCatalogOther(String type, ParentPlatform parentPlatform, List<DeviceChannel> deviceChannels, SubscribeInfo subscribeInfo); |
| 89 | 90 | ||
| 91 | + /** | ||
| 92 | + * 回复recordInfo | ||
| 93 | + * @param deviceChannel 通道信息 | ||
| 94 | + * @param parentPlatform 平台信息 | ||
| 95 | + * @param fromTag fromTag | ||
| 96 | + * @param recordInfo 录像信息 | ||
| 97 | + */ | ||
| 98 | + boolean recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo); | ||
| 90 | } | 99 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommander.java
| @@ -1210,11 +1210,19 @@ public class SIPCommander implements ISIPCommander { | @@ -1210,11 +1210,19 @@ public class SIPCommander implements ISIPCommander { | ||
| 1210 | recordInfoXml.append("<CmdType>RecordInfo</CmdType>\r\n"); | 1210 | recordInfoXml.append("<CmdType>RecordInfo</CmdType>\r\n"); |
| 1211 | recordInfoXml.append("<SN>" + sn + "</SN>\r\n"); | 1211 | recordInfoXml.append("<SN>" + sn + "</SN>\r\n"); |
| 1212 | recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); | 1212 | recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n"); |
| 1213 | - recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n"); | ||
| 1214 | - recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n"); | ||
| 1215 | - recordInfoXml.append("<Secrecy> "+ secrecy + " </Secrecy>\r\n"); | ||
| 1216 | - // 大华NVR要求必须增加一个值为all的文本元素节点Type | ||
| 1217 | - recordInfoXml.append("<Type>" + type+"</Type>\r\n"); | 1213 | + if (startTime != null) { |
| 1214 | + recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n"); | ||
| 1215 | + } | ||
| 1216 | + if (endTime != null) { | ||
| 1217 | + recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n"); | ||
| 1218 | + } | ||
| 1219 | + if (secrecy != null) { | ||
| 1220 | + recordInfoXml.append("<Secrecy> "+ secrecy + " </Secrecy>\r\n"); | ||
| 1221 | + } | ||
| 1222 | + if (type != null) { | ||
| 1223 | + // 大华NVR要求必须增加一个值为all的文本元素节点Type | ||
| 1224 | + recordInfoXml.append("<Type>" + type+"</Type>\r\n"); | ||
| 1225 | + } | ||
| 1218 | recordInfoXml.append("</Query>\r\n"); | 1226 | recordInfoXml.append("</Query>\r\n"); |
| 1219 | 1227 | ||
| 1220 | String tm = Long.toString(System.currentTimeMillis()); | 1228 | String tm = Long.toString(System.currentTimeMillis()); |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/cmd/impl/SIPCommanderFroPlatform.java
| 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; | 1 | package com.genersoft.iot.vmp.gb28181.transmit.cmd.impl; |
| 2 | 2 | ||
| 3 | -import com.genersoft.iot.vmp.gb28181.bean.DeviceChannel; | ||
| 4 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | ||
| 5 | -import com.genersoft.iot.vmp.gb28181.bean.ParentPlatformCatch; | ||
| 6 | -import com.genersoft.iot.vmp.gb28181.bean.SubscribeInfo; | 3 | +import com.genersoft.iot.vmp.gb28181.bean.*; |
| 7 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; | 4 | import com.genersoft.iot.vmp.gb28181.event.SipSubscribe; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; | 5 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.ISIPCommanderForPlatform; |
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; | 6 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.SIPRequestHeaderPlarformProvider; |
| 7 | +import com.genersoft.iot.vmp.gb28181.utils.DateUtil; | ||
| 10 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; | 8 | import com.genersoft.iot.vmp.service.bean.GPSMsgInfo; |
| 11 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; | 9 | import com.genersoft.iot.vmp.storager.IRedisCatchStorage; |
| 12 | import org.slf4j.Logger; | 10 | import org.slf4j.Logger; |
| @@ -17,6 +15,7 @@ import org.springframework.context.annotation.DependsOn; | @@ -17,6 +15,7 @@ import org.springframework.context.annotation.DependsOn; | ||
| 17 | import org.springframework.context.annotation.Lazy; | 15 | import org.springframework.context.annotation.Lazy; |
| 18 | import org.springframework.lang.Nullable; | 16 | import org.springframework.lang.Nullable; |
| 19 | import org.springframework.stereotype.Component; | 17 | import org.springframework.stereotype.Component; |
| 18 | +import org.springframework.util.StringUtils; | ||
| 20 | 19 | ||
| 21 | import javax.sip.*; | 20 | import javax.sip.*; |
| 22 | import javax.sip.header.CallIdHeader; | 21 | import javax.sip.header.CallIdHeader; |
| @@ -470,4 +469,55 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | @@ -470,4 +469,55 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform { | ||
| 470 | return true; | 469 | return true; |
| 471 | } | 470 | } |
| 472 | 471 | ||
| 472 | + @Override | ||
| 473 | + public boolean recordInfo(DeviceChannel deviceChannel, ParentPlatform parentPlatform, String fromTag, RecordInfo recordInfo) { | ||
| 474 | + if ( parentPlatform ==null) { | ||
| 475 | + return false; | ||
| 476 | + } | ||
| 477 | + try { | ||
| 478 | + StringBuffer recordXml = new StringBuffer(600); | ||
| 479 | + recordXml.append("<?xml version=\"1.0\" encoding=\"GB2312\"?>\r\n"); | ||
| 480 | + recordXml.append("<Response>\r\n"); | ||
| 481 | + recordXml.append("<CmdType>RecordInfo</CmdType>\r\n"); | ||
| 482 | + recordXml.append("<SN>" +recordInfo.getSn() + "</SN>\r\n"); | ||
| 483 | + recordXml.append("<DeviceID>" + recordInfo.getDeviceId() + "</DeviceID>\r\n"); | ||
| 484 | + recordXml.append("<SumNum>" + recordInfo.getSumNum() + "</SumNum>\r\n"); | ||
| 485 | + recordXml.append("<RecordList Num=\"" + recordInfo.getRecordList().size()+"\">\r\n"); | ||
| 486 | + for (RecordItem recordItem : recordInfo.getRecordList()) { | ||
| 487 | + recordXml.append("<Item>\r\n"); | ||
| 488 | + if (deviceChannel != null) { | ||
| 489 | + recordXml.append("<DeviceID>" + recordItem.getDeviceId() + "</DeviceID>\r\n"); | ||
| 490 | + recordXml.append("<Name>" + recordItem.getName() + "</Name>\r\n"); | ||
| 491 | + recordXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getStartTime()) + "</StartTime>\r\n"); | ||
| 492 | + recordXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(recordItem.getEndTime()) + "</EndTime>\r\n"); | ||
| 493 | + recordXml.append("<Secrecy>" + recordItem.getSecrecy() + "</Secrecy>\r\n"); | ||
| 494 | + recordXml.append("<Type>" + recordItem.getType() + "</Type>\r\n"); | ||
| 495 | + if (!StringUtils.isEmpty(recordItem.getFileSize())) { | ||
| 496 | + recordXml.append("<FileSize>" + recordItem.getFileSize() + "</FileSize>\r\n"); | ||
| 497 | + } | ||
| 498 | + if (!StringUtils.isEmpty(recordItem.getFilePath())) { | ||
| 499 | + recordXml.append("<FilePath>" + recordItem.getFilePath() + "</FilePath>\r\n"); | ||
| 500 | + } | ||
| 501 | + } | ||
| 502 | + recordXml.append("</Item>\r\n"); | ||
| 503 | + } | ||
| 504 | + | ||
| 505 | + recordXml.append("</RecordList>\r\n"); | ||
| 506 | + recordXml.append("</Response>\r\n"); | ||
| 507 | + | ||
| 508 | + // callid | ||
| 509 | + CallIdHeader callIdHeader = parentPlatform.getTransport().equals("TCP") ? tcpSipProvider.getNewCallId() | ||
| 510 | + : udpSipProvider.getNewCallId(); | ||
| 511 | + System.out.println( | ||
| 512 | + recordXml.toString() | ||
| 513 | + ); | ||
| 514 | + Request request = headerProviderPlarformProvider.createMessageRequest(parentPlatform, recordXml.toString(), fromTag, callIdHeader); | ||
| 515 | + transmitRequest(parentPlatform, request); | ||
| 516 | + | ||
| 517 | + } catch (SipException | ParseException | InvalidArgumentException e) { | ||
| 518 | + e.printStackTrace(); | ||
| 519 | + return false; | ||
| 520 | + } | ||
| 521 | + return true; | ||
| 522 | + } | ||
| 473 | } | 523 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/query/cmd/RecordInfoQueryMessageHandler.java
| @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query. | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query. | ||
| 3 | import com.genersoft.iot.vmp.conf.SipConfig; | 3 | import com.genersoft.iot.vmp.conf.SipConfig; |
| 4 | import com.genersoft.iot.vmp.gb28181.bean.*; | 4 | import com.genersoft.iot.vmp.gb28181.bean.*; |
| 5 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | 5 | import com.genersoft.iot.vmp.gb28181.event.EventPublisher; |
| 6 | +import com.genersoft.iot.vmp.gb28181.event.record.RecordEndEventListener; | ||
| 6 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 7 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 7 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform; |
| @@ -47,6 +48,9 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp | @@ -47,6 +48,9 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp | ||
| 47 | private SIPCommander commander; | 48 | private SIPCommander commander; |
| 48 | 49 | ||
| 49 | @Autowired | 50 | @Autowired |
| 51 | + private RecordEndEventListener recordEndEventListener; | ||
| 52 | + | ||
| 53 | + @Autowired | ||
| 50 | private SipConfig config; | 54 | private SipConfig config; |
| 51 | 55 | ||
| 52 | @Autowired | 56 | @Autowired |
| @@ -65,49 +69,89 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp | @@ -65,49 +69,89 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp | ||
| 65 | @Override | 69 | @Override |
| 66 | public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { | 70 | public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) { |
| 67 | 71 | ||
| 68 | - String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + parentPlatform.getServerGBId(); | ||
| 69 | FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); | 72 | FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME); |
| 70 | - try { | ||
| 71 | - // 回复200 OK | ||
| 72 | - responseAck(evt, Response.OK); | ||
| 73 | - Element snElement = rootElement.element("SN"); | ||
| 74 | - int sn = Integer.parseInt(snElement.getText()); | ||
| 75 | - Element deviceIDElement = rootElement.element("DeviceID"); | ||
| 76 | - String channelId = deviceIDElement.getText(); | ||
| 77 | - Element startTimeElement = rootElement.element("StartTime"); | ||
| 78 | - String startTime = startTimeElement.getText(); | ||
| 79 | - Element endTimeElement = rootElement.element("EndTime"); | ||
| 80 | - String endTime = endTimeElement.getText(); | ||
| 81 | - Element secrecyElement = rootElement.element("Secrecy"); | ||
| 82 | - int secrecy = Integer.parseInt(secrecyElement.getText()); | ||
| 83 | - Element typeElement = rootElement.element("Type"); | ||
| 84 | - String type = typeElement.getText(); | ||
| 85 | - // 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务 | ||
| 86 | - List<ChannelSourceInfo> channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId); | ||
| 87 | - if (channelSources.get(0).getCount() > 0) { // 国标 | ||
| 88 | - // 向国标设备请求录像数据 | ||
| 89 | - Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); | ||
| 90 | - commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime), | ||
| 91 | - DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> { | ||
| 92 | - // 查询成功 | ||
| 93 | - | ||
| 94 | - }),(eventResult -> { | ||
| 95 | - // 查询失败 | ||
| 96 | - | ||
| 97 | - })); | ||
| 98 | - | ||
| 99 | - }else if (channelSources.get(0).getCount() > 0) { // 直播流 | ||
| 100 | - // TODO | ||
| 101 | - }else { // 错误的请求 | ||
| 102 | 73 | ||
| 74 | + Element snElement = rootElement.element("SN"); | ||
| 75 | + int sn = Integer.parseInt(snElement.getText()); | ||
| 76 | + Element deviceIDElement = rootElement.element("DeviceID"); | ||
| 77 | + String channelId = deviceIDElement.getText(); | ||
| 78 | + Element startTimeElement = rootElement.element("StartTime"); | ||
| 79 | + String startTime = null; | ||
| 80 | + if (startTimeElement != null) { | ||
| 81 | + startTime = startTimeElement.getText(); | ||
| 82 | + } | ||
| 83 | + Element endTimeElement = rootElement.element("EndTime"); | ||
| 84 | + String endTime = null; | ||
| 85 | + if (endTimeElement != null) { | ||
| 86 | + endTime = endTimeElement.getText(); | ||
| 87 | + } | ||
| 88 | + Element secrecyElement = rootElement.element("Secrecy"); | ||
| 89 | + int secrecy = 0; | ||
| 90 | + if (secrecyElement != null) { | ||
| 91 | + secrecy = Integer.parseInt(secrecyElement.getText()); | ||
| 92 | + } | ||
| 93 | + String type = "all"; | ||
| 94 | + Element typeElement = rootElement.element("Type"); | ||
| 95 | + if (typeElement != null) { | ||
| 96 | + type = typeElement.getText(); | ||
| 97 | + } | ||
| 98 | + // 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务 | ||
| 99 | + List<ChannelSourceInfo> channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId); | ||
| 100 | + | ||
| 101 | + if (channelSources.get(0).getCount() > 0) { // 国标 | ||
| 102 | + // 向国标设备请求录像数据 | ||
| 103 | + Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId); | ||
| 104 | + DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId); | ||
| 105 | + // 接收录像数据 | ||
| 106 | + recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{ | ||
| 107 | + cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, fromHeader.getTag(), recordInfo); | ||
| 108 | + }); | ||
| 109 | + commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime), | ||
| 110 | + DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> { | ||
| 111 | + // 回复200 OK | ||
| 112 | + try { | ||
| 113 | + responseAck(evt, Response.OK); | ||
| 114 | + } catch (SipException e) { | ||
| 115 | + e.printStackTrace(); | ||
| 116 | + } catch (InvalidArgumentException e) { | ||
| 117 | + e.printStackTrace(); | ||
| 118 | + } catch (ParseException e) { | ||
| 119 | + e.printStackTrace(); | ||
| 120 | + } | ||
| 121 | + }),(eventResult -> { | ||
| 122 | + // 查询失败 | ||
| 123 | + try { | ||
| 124 | + responseAck(evt, eventResult.statusCode, eventResult.msg); | ||
| 125 | + } catch (SipException e) { | ||
| 126 | + e.printStackTrace(); | ||
| 127 | + } catch (InvalidArgumentException e) { | ||
| 128 | + e.printStackTrace(); | ||
| 129 | + } catch (ParseException e) { | ||
| 130 | + e.printStackTrace(); | ||
| 131 | + } | ||
| 132 | + })); | ||
| 133 | + | ||
| 134 | + }else if (channelSources.get(1).getCount() > 0) { // 直播流 | ||
| 135 | + // TODO | ||
| 136 | + try { | ||
| 137 | + responseAck(evt, Response.NOT_IMPLEMENTED); // 回复未实现 | ||
| 138 | + } catch (SipException e) { | ||
| 139 | + e.printStackTrace(); | ||
| 140 | + } catch (InvalidArgumentException e) { | ||
| 141 | + e.printStackTrace(); | ||
| 142 | + } catch (ParseException e) { | ||
| 143 | + e.printStackTrace(); | ||
| 144 | + } | ||
| 145 | + }else { // 错误的请求 | ||
| 146 | + try { | ||
| 147 | + responseAck(evt, Response.BAD_REQUEST); | ||
| 148 | + } catch (SipException e) { | ||
| 149 | + e.printStackTrace(); | ||
| 150 | + } catch (InvalidArgumentException e) { | ||
| 151 | + e.printStackTrace(); | ||
| 152 | + } catch (ParseException e) { | ||
| 153 | + e.printStackTrace(); | ||
| 103 | } | 154 | } |
| 104 | - } catch (SipException e) { | ||
| 105 | - e.printStackTrace(); | ||
| 106 | - } catch (InvalidArgumentException e) { | ||
| 107 | - e.printStackTrace(); | ||
| 108 | - } catch (ParseException e) { | ||
| 109 | - e.printStackTrace(); | ||
| 110 | } | 155 | } |
| 111 | - | ||
| 112 | } | 156 | } |
| 113 | } | 157 | } |
src/main/java/com/genersoft/iot/vmp/gb28181/transmit/event/request/impl/message/response/cmd/RecordInfoResponseMessageHandler.java
| @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | @@ -4,6 +4,7 @@ import com.genersoft.iot.vmp.gb28181.bean.Device; | ||
| 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; | 4 | import com.genersoft.iot.vmp.gb28181.bean.ParentPlatform; |
| 5 | import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; | 5 | import com.genersoft.iot.vmp.gb28181.bean.RecordInfo; |
| 6 | import com.genersoft.iot.vmp.gb28181.bean.RecordItem; | 6 | import com.genersoft.iot.vmp.gb28181.bean.RecordItem; |
| 7 | +import com.genersoft.iot.vmp.gb28181.event.EventPublisher; | ||
| 7 | import com.genersoft.iot.vmp.gb28181.transmit.callback.CheckForAllRecordsThread; | 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.CheckForAllRecordsThread; |
| 8 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; | 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder; |
| 9 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; | 10 | import com.genersoft.iot.vmp.gb28181.transmit.callback.RequestMessage; |
| @@ -49,6 +50,9 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | @@ -49,6 +50,9 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | ||
| 49 | @Autowired | 50 | @Autowired |
| 50 | private DeferredResultHolder deferredResultHolder; | 51 | private DeferredResultHolder deferredResultHolder; |
| 51 | 52 | ||
| 53 | + @Autowired | ||
| 54 | + private EventPublisher eventPublisher; | ||
| 55 | + | ||
| 52 | @Override | 56 | @Override |
| 53 | public void afterPropertiesSet() throws Exception { | 57 | public void afterPropertiesSet() throws Exception { |
| 54 | responseMessageHandler.addHandler(cmdType, this); | 58 | responseMessageHandler.addHandler(cmdType, this); |
| @@ -77,6 +81,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | @@ -77,6 +81,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | ||
| 77 | Element recordListElement = rootElement.element("RecordList"); | 81 | Element recordListElement = rootElement.element("RecordList"); |
| 78 | if (recordListElement == null || recordInfo.getSumNum() == 0) { | 82 | if (recordListElement == null || recordInfo.getSumNum() == 0) { |
| 79 | logger.info("无录像数据"); | 83 | logger.info("无录像数据"); |
| 84 | + eventPublisher.recordEndEventPush(recordInfo); | ||
| 80 | RequestMessage msg = new RequestMessage(); | 85 | RequestMessage msg = new RequestMessage(); |
| 81 | msg.setKey(key); | 86 | msg.setKey(key); |
| 82 | msg.setData(recordInfo); | 87 | msg.setData(recordInfo); |
| @@ -99,6 +104,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | @@ -99,6 +104,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | ||
| 99 | record.setDeviceId(getText(itemRecord, "DeviceID")); | 104 | record.setDeviceId(getText(itemRecord, "DeviceID")); |
| 100 | record.setName(getText(itemRecord, "Name")); | 105 | record.setName(getText(itemRecord, "Name")); |
| 101 | record.setFilePath(getText(itemRecord, "FilePath")); | 106 | record.setFilePath(getText(itemRecord, "FilePath")); |
| 107 | + record.setFileSize(getText(itemRecord, "FileSize")); | ||
| 102 | record.setAddress(getText(itemRecord, "Address")); | 108 | record.setAddress(getText(itemRecord, "Address")); |
| 103 | record.setStartTime( | 109 | record.setStartTime( |
| 104 | DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(getText(itemRecord, "StartTime"))); | 110 | DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(getText(itemRecord, "StartTime"))); |
| @@ -112,7 +118,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | @@ -112,7 +118,7 @@ public class RecordInfoResponseMessageHandler extends SIPRequestProcessorParent | ||
| 112 | } | 118 | } |
| 113 | recordInfo.setRecordList(recordList); | 119 | recordInfo.setRecordList(recordList); |
| 114 | } | 120 | } |
| 115 | - | 121 | + eventPublisher.recordEndEventPush(recordInfo); |
| 116 | // 改用单独线程统计已获取录像文件数量,避免多包并行分别统计不完整的问题 | 122 | // 改用单独线程统计已获取录像文件数量,避免多包并行分别统计不完整的问题 |
| 117 | String cacheKey = CACHE_RECORDINFO_KEY + device.getDeviceId() + sn; | 123 | String cacheKey = CACHE_RECORDINFO_KEY + device.getDeviceId() + sn; |
| 118 | redis.set(cacheKey + "_" + uuid, recordList, 90); | 124 | redis.set(cacheKey + "_" + uuid, recordList, 90); |
src/main/java/com/genersoft/iot/vmp/storager/dao/ParentPlatformMapper.java
| @@ -90,6 +90,6 @@ public interface ParentPlatformMapper { | @@ -90,6 +90,6 @@ public interface ParentPlatformMapper { | ||
| 90 | 90 | ||
| 91 | @Select("select 'channel' as name, count(pgc.platformId) count from platform_gb_channel pgc where pgc.platformId=#{platformId} and pgc.channelId =#{gbId} " + | 91 | @Select("select 'channel' as name, count(pgc.platformId) count from platform_gb_channel pgc where pgc.platformId=#{platformId} and pgc.channelId =#{gbId} " + |
| 92 | "union " + | 92 | "union " + |
| 93 | - "select 'stream' as name, count(pgs.platformId) count from platform_gb_stream pgs left join gb_stream gs on pgs.gbStreamId = gs.id where pgs.platformId=#{platformId} and gs.gbId = #{gbId}") | 93 | + "select 'stream' as name, count(pgs.platformId) count from platform_gb_stream pgs left join gb_stream gs on pgs.gbStreamId = gs.gbStreamId where pgs.platformId=#{platformId} and gs.gbId = #{gbId}") |
| 94 | List<ChannelSourceInfo> getChannelSource(String platformId, String gbId); | 94 | List<ChannelSourceInfo> getChannelSource(String platformId, String gbId); |
| 95 | } | 95 | } |
src/main/java/com/genersoft/iot/vmp/storager/dao/PlatformChannelMapper.java
| @@ -34,6 +34,7 @@ public interface PlatformChannelMapper { | @@ -34,6 +34,7 @@ public interface PlatformChannelMapper { | ||
| 34 | "</script>") | 34 | "</script>") |
| 35 | int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); | 35 | int addChannels(String platformId, List<ChannelReduce> channelReducesToAdd); |
| 36 | 36 | ||
| 37 | + | ||
| 37 | @Delete("<script> "+ | 38 | @Delete("<script> "+ |
| 38 | "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + | 39 | "DELETE FROM platform_gb_channel WHERE platformId='${platformId}' AND deviceAndChannelId in" + |
| 39 | "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" + | 40 | "<foreach collection='channelReducesToDel' item='item' open='(' separator=',' close=')' > '${item.deviceId}_${item.channelId}'</foreach>" + |
| @@ -50,10 +51,12 @@ public interface PlatformChannelMapper { | @@ -50,10 +51,12 @@ public interface PlatformChannelMapper { | ||
| 50 | "</script>") | 51 | "</script>") |
| 51 | int cleanChannelForGB(String platformId); | 52 | int cleanChannelForGB(String platformId); |
| 52 | 53 | ||
| 54 | + | ||
| 53 | @Select("SELECT * FROM device_channel WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE " + | 55 | @Select("SELECT * FROM device_channel WHERE deviceId = (SELECT deviceId FROM platform_gb_channel WHERE " + |
| 54 | "platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'") | 56 | "platformId='${platformId}' AND channelId='${channelId}' ) AND channelId='${channelId}'") |
| 55 | DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); | 57 | DeviceChannel queryChannelInParentPlatform(String platformId, String channelId); |
| 56 | 58 | ||
| 59 | + | ||
| 57 | @Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " + | 60 | @Select("select dc.channelId as id, dc.name as name, pgc.platformId as platformId, pgc.catalogId as parentId, 0 as childrenCount, 1 as type " + |
| 58 | "from device_channel dc left join platform_gb_channel pgc on dc.deviceId = pgc.deviceId and dc.channelId = pgc.channelId " + | 61 | "from device_channel dc left join platform_gb_channel pgc on dc.deviceId = pgc.deviceId and dc.channelId = pgc.channelId " + |
| 59 | "where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}") | 62 | "where pgc.platformId=#{platformId} and pgc.catalogId=#{catalogId}") |