同步主线
This commit is contained in:
@@ -0,0 +1,32 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event.record;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.DeviceAlarm;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RecordInfo;
|
||||
import org.springframework.context.ApplicationEvent;
|
||||
|
||||
/**
|
||||
* @description: 录像查询结束时间
|
||||
* @author: pan
|
||||
* @data: 2022-02-23
|
||||
*/
|
||||
|
||||
public class RecordEndEvent extends ApplicationEvent {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = 1L;
|
||||
|
||||
public RecordEndEvent(Object source) {
|
||||
super(source);
|
||||
}
|
||||
|
||||
private RecordInfo recordInfo;
|
||||
|
||||
public RecordInfo getRecordInfo() {
|
||||
return recordInfo;
|
||||
}
|
||||
|
||||
public void setRecordInfo(RecordInfo recordInfo) {
|
||||
this.recordInfo = recordInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,43 @@
|
||||
package com.genersoft.iot.vmp.gb28181.event.record;
|
||||
|
||||
import com.genersoft.iot.vmp.gb28181.bean.RecordItem;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import org.springframework.context.ApplicationListener;
|
||||
import org.springframework.stereotype.Component;
|
||||
import org.springframework.web.servlet.mvc.method.annotation.SseEmitter;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* @description: 录像查询结束时间
|
||||
* @author: pan
|
||||
* @data: 2022-02-23
|
||||
*/
|
||||
|
||||
@Component
|
||||
public class RecordEndEventListener implements ApplicationListener<RecordEndEvent> {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(RecordEndEventListener.class);
|
||||
|
||||
private static Map<String, SseEmitter> sseEmitters = new Hashtable<>();
|
||||
|
||||
public void addSseEmitters(String browserId, SseEmitter sseEmitter) {
|
||||
sseEmitters.put(browserId, sseEmitter);
|
||||
}
|
||||
|
||||
public interface RecordEndEventHandler{
|
||||
void handler(List<RecordItem> recordItems);
|
||||
}
|
||||
|
||||
private Map<String, RecordEndEventHandler> handlerMap = new HashMap<>();
|
||||
@Override
|
||||
public void onApplicationEvent(RecordEndEvent event) {
|
||||
if (logger.isDebugEnabled()) {
|
||||
logger.debug("录像查询完成事件触发,deviceId:{}, channelId: {}, 录像数量{}条", event.getRecordInfo().getDeviceId(),
|
||||
event.getRecordInfo().getChannelId(), event.getRecordInfo().getRecordList().size() );
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
@@ -258,7 +258,7 @@ public interface ISIPCommander {
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
* @param sn
|
||||
*/
|
||||
boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, SipSubscribe.Event errorEvent);
|
||||
boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer Secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent);
|
||||
|
||||
/**
|
||||
* 查询报警信息
|
||||
|
||||
@@ -1195,8 +1195,13 @@ public class SIPCommander implements ISIPCommander {
|
||||
* @param endTime 结束时间,格式要求:yyyy-MM-dd HH:mm:ss
|
||||
*/
|
||||
@Override
|
||||
public boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, SipSubscribe.Event errorEvent) {
|
||||
|
||||
public boolean recordInfoQuery(Device device, String channelId, String startTime, String endTime, int sn, Integer secrecy, String type, SipSubscribe.Event okEvent, SipSubscribe.Event errorEvent) {
|
||||
if (secrecy == null) {
|
||||
secrecy = 0;
|
||||
}
|
||||
if (type == null) {
|
||||
type = "all";
|
||||
}
|
||||
|
||||
try {
|
||||
StringBuffer recordInfoXml = new StringBuffer(200);
|
||||
@@ -1207,9 +1212,9 @@ public class SIPCommander implements ISIPCommander {
|
||||
recordInfoXml.append("<DeviceID>" + channelId + "</DeviceID>\r\n");
|
||||
recordInfoXml.append("<StartTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(startTime) + "</StartTime>\r\n");
|
||||
recordInfoXml.append("<EndTime>" + DateUtil.yyyy_MM_dd_HH_mm_ssToISO8601(endTime) + "</EndTime>\r\n");
|
||||
recordInfoXml.append("<Secrecy>0</Secrecy>\r\n");
|
||||
recordInfoXml.append("<Secrecy> "+ secrecy + " </Secrecy>\r\n");
|
||||
// 大华NVR要求必须增加一个值为all的文本元素节点Type
|
||||
recordInfoXml.append("<Type>all</Type>\r\n");
|
||||
recordInfoXml.append("<Type>" + type+"</Type>\r\n");
|
||||
recordInfoXml.append("</Query>\r\n");
|
||||
|
||||
String tm = Long.toString(System.currentTimeMillis());
|
||||
@@ -1220,7 +1225,7 @@ public class SIPCommander implements ISIPCommander {
|
||||
Request request = headerProvider.createMessageRequest(device, recordInfoXml.toString(),
|
||||
"z9hG4bK-ViaRecordInfo-" + tm, "fromRec" + tm, null, callIdHeader);
|
||||
|
||||
transmitRequest(device, request, errorEvent);
|
||||
transmitRequest(device, request, errorEvent, okEvent);
|
||||
} catch (SipException | ParseException | InvalidArgumentException e) {
|
||||
e.printStackTrace();
|
||||
return false;
|
||||
|
||||
@@ -102,7 +102,7 @@ public class SIPCommanderFroPlatform implements ISIPCommanderForPlatform {
|
||||
|
||||
sipSubscribe.addErrorSubscribe(callIdHeader.getCallId(), (event)->{
|
||||
if (event != null) {
|
||||
logger.info("向上级平台 [ {} ] 注册发生错误: {} ",
|
||||
logger.info("向上级平台 [ {} ] 注册发上错误: {} ",
|
||||
parentPlatform.getServerGBId(),
|
||||
event.msg);
|
||||
}
|
||||
|
||||
@@ -4,11 +4,14 @@ import com.genersoft.iot.vmp.conf.SipConfig;
|
||||
import com.genersoft.iot.vmp.gb28181.bean.*;
|
||||
import com.genersoft.iot.vmp.gb28181.event.EventPublisher;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.callback.DeferredResultHolder;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommander;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.cmd.impl.SIPCommanderFroPlatform;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.SIPRequestProcessorParent;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.IMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.QueryMessageHandler;
|
||||
import com.genersoft.iot.vmp.gb28181.utils.DateUtil;
|
||||
import com.genersoft.iot.vmp.storager.IVideoManagerStorager;
|
||||
import com.genersoft.iot.vmp.storager.dao.dto.ChannelSourceInfo;
|
||||
import com.genersoft.iot.vmp.vmanager.gb28181.platform.bean.ChannelReduce;
|
||||
import org.dom4j.Element;
|
||||
import org.slf4j.Logger;
|
||||
@@ -40,6 +43,9 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
|
||||
@Autowired
|
||||
private SIPCommanderFroPlatform cmderFroPlatform;
|
||||
|
||||
@Autowired
|
||||
private SIPCommander commander;
|
||||
|
||||
@Autowired
|
||||
private SipConfig config;
|
||||
|
||||
@@ -65,19 +71,36 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
|
||||
// 回复200 OK
|
||||
responseAck(evt, Response.OK);
|
||||
Element snElement = rootElement.element("SN");
|
||||
String sn = snElement.getText();
|
||||
int sn = Integer.parseInt(snElement.getText());
|
||||
Element deviceIDElement = rootElement.element("DeviceID");
|
||||
String channelId = deviceIDElement.getText();
|
||||
Element startTimeElement = rootElement.element("StartTime");
|
||||
String startTime = startTimeElement.getText();
|
||||
Element endTimeElement = rootElement.element("EndTime");
|
||||
String endTime = endTimeElement.getText();
|
||||
// Element secrecyElement = rootElement.element("Secrecy");
|
||||
// int secrecy = Integer.parseInt(secrecyElement.getText());
|
||||
// Element typeElement = rootElement.element("Type");
|
||||
// String type = typeElement.getText();
|
||||
Element secrecyElement = rootElement.element("Secrecy");
|
||||
int secrecy = Integer.parseInt(secrecyElement.getText());
|
||||
Element typeElement = rootElement.element("Type");
|
||||
String type = typeElement.getText();
|
||||
// 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务
|
||||
List<ChannelSourceInfo> channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId);
|
||||
if (channelSources.get(0).getCount() > 0) { // 国标
|
||||
// 向国标设备请求录像数据
|
||||
Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
|
||||
commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime),
|
||||
DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> {
|
||||
// 查询成功
|
||||
|
||||
}),(eventResult -> {
|
||||
// 查询失败
|
||||
|
||||
}));
|
||||
|
||||
}else if (channelSources.get(0).getCount() > 0) { // 直播流
|
||||
// TODO
|
||||
}else { // 错误的请求
|
||||
|
||||
}
|
||||
} catch (SipException e) {
|
||||
e.printStackTrace();
|
||||
} catch (InvalidArgumentException e) {
|
||||
|
||||
Reference in New Issue
Block a user