|  | @@ -3,6 +3,7 @@ package com.genersoft.iot.vmp.gb28181.transmit.event.request.impl.message.query.
 | 
	
		
			
				|  |  |  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.event.record.RecordEndEventListener;
 | 
	
		
			
				|  |  |  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;
 | 
	
	
		
			
				|  | @@ -46,6 +47,9 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SIPCommander commander;
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    @Autowired
 | 
	
		
			
				|  |  | +    private RecordEndEventListener recordEndEventListener;
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      @Autowired
 | 
	
		
			
				|  |  |      private SipConfig config;
 | 
	
		
			
				|  |  |  
 | 
	
	
		
			
				|  | @@ -65,49 +69,89 @@ public class RecordInfoQueryMessageHandler extends SIPRequestProcessorParent imp
 | 
	
		
			
				|  |  |      @Override
 | 
	
		
			
				|  |  |      public void handForPlatform(RequestEvent evt, ParentPlatform parentPlatform, Element rootElement) {
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        String key = DeferredResultHolder.CALLBACK_CMD_CATALOG + parentPlatform.getServerGBId();
 | 
	
		
			
				|  |  |          FromHeader fromHeader = (FromHeader) evt.getRequest().getHeader(FromHeader.NAME);
 | 
	
		
			
				|  |  | -        try {
 | 
	
		
			
				|  |  | -            // 回复200 OK
 | 
	
		
			
				|  |  | -            responseAck(evt, Response.OK);
 | 
	
		
			
				|  |  | -            Element snElement = rootElement.element("SN");
 | 
	
		
			
				|  |  | -            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();
 | 
	
		
			
				|  |  | -            // 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务
 | 
	
		
			
				|  |  | -            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 { // 错误的请求
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +        Element snElement = rootElement.element("SN");
 | 
	
		
			
				|  |  | +        int sn = Integer.parseInt(snElement.getText());
 | 
	
		
			
				|  |  | +        Element deviceIDElement = rootElement.element("DeviceID");
 | 
	
		
			
				|  |  | +        String channelId = deviceIDElement.getText();
 | 
	
		
			
				|  |  | +        Element startTimeElement = rootElement.element("StartTime");
 | 
	
		
			
				|  |  | +        String startTime = null;
 | 
	
		
			
				|  |  | +        if (startTimeElement != null) {
 | 
	
		
			
				|  |  | +            startTime = startTimeElement.getText();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Element endTimeElement = rootElement.element("EndTime");
 | 
	
		
			
				|  |  | +        String endTime = null;
 | 
	
		
			
				|  |  | +        if (endTimeElement != null) {
 | 
	
		
			
				|  |  | +            endTime = endTimeElement.getText();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        Element secrecyElement = rootElement.element("Secrecy");
 | 
	
		
			
				|  |  | +        int secrecy = 0;
 | 
	
		
			
				|  |  | +        if (secrecyElement != null) {
 | 
	
		
			
				|  |  | +            secrecy = Integer.parseInt(secrecyElement.getText());
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        String type = "all";
 | 
	
		
			
				|  |  | +        Element typeElement = rootElement.element("Type");
 | 
	
		
			
				|  |  | +        if (typeElement != null) {
 | 
	
		
			
				|  |  | +            type =  typeElement.getText();
 | 
	
		
			
				|  |  | +        }
 | 
	
		
			
				|  |  | +        // 确认是直播还是国标, 国标直接请求下级,直播请求录像管理服务
 | 
	
		
			
				|  |  | +        List<ChannelSourceInfo> channelSources = storager.getChannelSource(parentPlatform.getServerGBId(), channelId);
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        if (channelSources.get(0).getCount() > 0) { // 国标
 | 
	
		
			
				|  |  | +            // 向国标设备请求录像数据
 | 
	
		
			
				|  |  | +            Device device = storager.queryVideoDeviceByPlatformIdAndChannelId(parentPlatform.getServerGBId(), channelId);
 | 
	
		
			
				|  |  | +            DeviceChannel deviceChannel = storager.queryChannelInParentPlatform(parentPlatform.getServerGBId(), channelId);
 | 
	
		
			
				|  |  | +            // 接收录像数据
 | 
	
		
			
				|  |  | +            recordEndEventListener.addEndEventHandler(deviceChannel.getDeviceId(), channelId, (recordInfo)->{
 | 
	
		
			
				|  |  | +                cmderFroPlatform.recordInfo(deviceChannel, parentPlatform, fromHeader.getTag(), recordInfo);
 | 
	
		
			
				|  |  | +            });
 | 
	
		
			
				|  |  | +            commander.recordInfoQuery(device, channelId, DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(startTime),
 | 
	
		
			
				|  |  | +                    DateUtil.ISO8601Toyyyy_MM_dd_HH_mm_ss(endTime), sn, secrecy, type, (eventResult -> {
 | 
	
		
			
				|  |  | +                        // 回复200 OK
 | 
	
		
			
				|  |  | +                        try {
 | 
	
		
			
				|  |  | +                            responseAck(evt, Response.OK);
 | 
	
		
			
				|  |  | +                        } catch (SipException e) {
 | 
	
		
			
				|  |  | +                            e.printStackTrace();
 | 
	
		
			
				|  |  | +                        } catch (InvalidArgumentException e) {
 | 
	
		
			
				|  |  | +                            e.printStackTrace();
 | 
	
		
			
				|  |  | +                        } catch (ParseException e) {
 | 
	
		
			
				|  |  | +                            e.printStackTrace();
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }),(eventResult -> {
 | 
	
		
			
				|  |  | +                        // 查询失败
 | 
	
		
			
				|  |  | +                        try {
 | 
	
		
			
				|  |  | +                            responseAck(evt, eventResult.statusCode, eventResult.msg);
 | 
	
		
			
				|  |  | +                        } catch (SipException e) {
 | 
	
		
			
				|  |  | +                            e.printStackTrace();
 | 
	
		
			
				|  |  | +                        } catch (InvalidArgumentException e) {
 | 
	
		
			
				|  |  | +                            e.printStackTrace();
 | 
	
		
			
				|  |  | +                        } catch (ParseException e) {
 | 
	
		
			
				|  |  | +                            e.printStackTrace();
 | 
	
		
			
				|  |  | +                        }
 | 
	
		
			
				|  |  | +                    }));
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  | +        }else if (channelSources.get(1).getCount() > 0) { // 直播流
 | 
	
		
			
				|  |  | +            // TODO
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                responseAck(evt, Response.NOT_IMPLEMENTED); // 回复未实现
 | 
	
		
			
				|  |  | +            } catch (SipException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            } catch (InvalidArgumentException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            } catch (ParseException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            }
 | 
	
		
			
				|  |  | +        }else { // 错误的请求
 | 
	
		
			
				|  |  | +            try {
 | 
	
		
			
				|  |  | +                responseAck(evt, Response.BAD_REQUEST);
 | 
	
		
			
				|  |  | +            } catch (SipException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            } catch (InvalidArgumentException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  | +            } catch (ParseException e) {
 | 
	
		
			
				|  |  | +                e.printStackTrace();
 | 
	
		
			
				|  |  |              }
 | 
	
		
			
				|  |  | -        } catch (SipException e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  | -        } catch (InvalidArgumentException e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  | -        } catch (ParseException e) {
 | 
	
		
			
				|  |  | -            e.printStackTrace();
 | 
	
		
			
				|  |  |          }
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |      }
 | 
	
		
			
				|  |  |  }
 |