Bladeren bron

视频平台数据拉取和推流

root 3 jaren geleden
bovenliggende
commit
0090493e50

+ 3 - 1
src/main/java/com/zhiqiyun/open/camera/config/CameraConfig.java

@@ -32,8 +32,10 @@ import java.util.Set;
 public class CameraConfig {
 
     public final static String USER_NAME = "duijie01";
+    public final static String USER_NAME_Urban = "duijie";
     public final static String PASSWORD = "Huawei@12#$";
-    public final static String VCM_URI = "https://172.169.12.21:443";
+//    public final static String VCM_URI = "http://222.84.250.39:9800";
+        public final static String VCM_URI = "https://172.169.12.21:443";
     public final static int SUCCESS_STATUS_CODE = 200;
     public final static int SUCCESS_CODE = 0;
 

+ 20 - 6
src/main/java/com/zhiqiyun/open/camera/rtsp/RtspPushSrs.java

@@ -19,11 +19,18 @@ import org.bytedeco.javacv.Frame;
 @Slf4j
 public class RtspPushSrs {
 
+//    //内网推流地址
+//    public final static String INTRANET_SRS_PUSH_ADDRESS = "rtmp://116.8.106.156:7011/live/livestream/%s";
+//
+//    //外网拉流地址
+//    public final static String SRS_PUSH_ADDRESS = "http://116.8.106.156:9800/live/livestream/%s.flv";
+
     //内网推流地址
-    public final static String INTRANET_SRS_PUSH_ADDRESS = "rtmp://116.8.106.156:7011/live/livestream/%s";
+    public final static String INTRANET_SRS_PUSH_ADDRESS = "rtmp://192.168.0.187:1935/live/livestream/%s";
 
     //外网拉流地址
-    public final static String SRS_PUSH_ADDRESS = "http://116.8.106.156:9800/live/livestream/%s.flv";
+//    public final static String SRS_PUSH_ADDRESS = "http://222.84.255.194:9800/live/livestream/%s.flv";
+    public final static String SRS_PUSH_ADDRESS = "https://wlapi-pro-smartcity.123cx.com/live/livestream/%s.flv";
 
     /**
      * 读取指定的rtsp视频流,推送到SRS服务器
@@ -103,6 +110,12 @@ public class RtspPushSrs {
         FFmpegFrameRecorder recorder = new FFmpegFrameRecorder(rtmpUrl, frameWidth, frameHeight, audioChannels);
 //        recorder.setInterleaved(true);
 //        recorder.setVideoOption("crf", "28");
+        // https://trac.ffmpeg.org/wiki/StreamingGuide)
+        recorder.setVideoOption("tune", "zerolatency");
+        // ultrafast对CPU消耗最低
+        recorder.setVideoOption("preset", "ultrafast");
+        // Constant Rate Factor (see: https://trac.ffmpeg.org/wiki/Encode/H.264)
+        recorder.setVideoOption("crf", "28");
         // 设置编码格式
         recorder.setVideoCodec(avcodec.AV_CODEC_ID_H264);
         // 设置封装格式
@@ -110,7 +123,7 @@ public class RtspPushSrs {
         // 一秒内的帧数
         recorder.setFrameRate(frameRate);
 //         两个关键帧之间的帧数
-        recorder.setGopSize(frameRate);
+        recorder.setGopSize(frameRate * 2);
         // 设置音频通道数,与视频源的通道数相等
         recorder.setAudioChannels(audioChannels);
         // yuv420p
@@ -146,9 +159,10 @@ public class RtspPushSrs {
 
         // 持续从视频源取帧
         while (null != (frame = grabber.grab())) {
-            RtspTransfer.FRAME_GRABBER_CONCURRENT_HASH_MAP.put(rtspId, grabber);
-            RtspTransfer.FRAME_RECORDER_CONCURRENT_HASH_MAP.put(rtspId, recorder);
-
+            if (videoTS == 0) {
+                RtspTransfer.FRAME_GRABBER_CONCURRENT_HASH_MAP.put(rtspId, grabber);
+                RtspTransfer.FRAME_RECORDER_CONCURRENT_HASH_MAP.put(rtspId, recorder);
+            }
 
             videoTS = 1000 * (System.currentTimeMillis() - startTime);
 //            log.info("持续从视频源取帧 videoTS:{}", videoTS);

+ 15 - 0
src/main/java/com/zhiqiyun/open/core/video/VideoAnalysisService.java

@@ -1,5 +1,6 @@
 package com.zhiqiyun.open.core.video;
 
+import java.io.IOException;
 import java.util.Map;
 
 /**
@@ -37,4 +38,18 @@ public interface VideoAnalysisService {
      * 批量创建智能分析任务
      */
     void startIntelligentAnalysis(String ids) throws Exception;
+
+
+    /**
+     * 查询智能分析任务列表 v1.1
+     */
+    void getIntelligentAnalysisList() throws Exception;
+
+    /**
+     * 数据订阅并获取连接
+     * POST /sdk_service/rest/video-analysis/subscription
+     * 接口ID:45095880
+     * 接口地址:https://www.apifox.cn/web/project/1792116/apis/api-45095880
+     */
+    void subscription() throws Exception;
 }

+ 68 - 0
src/main/java/com/zhiqiyun/open/core/video/VideoDockingUrbanService.java

@@ -0,0 +1,68 @@
+package com.zhiqiyun.open.core.video;
+
+import com.alibaba.fastjson.JSONObject;
+
+import java.util.Map;
+
+/**
+ * @author xin yang
+ * @date 2022/8/4
+ */
+public interface VideoDockingUrbanService {
+
+    /**
+     * 获取用户登录授权token
+     * 30分钟有效期
+     *
+     * @return String
+     * @throws Exception Exception
+     */
+    String getValidToken() throws Exception;
+
+    /**
+     * 刷新用户token,保持用户登录姿态
+     *
+     * @throws Exception Exception
+     */
+    void refreshValidToken() throws Exception;
+
+    /**
+     * 获取设备列表信息
+     *
+     * @param paramValues paramValues
+     * @return JSONObject
+     * @throws Exception Exception
+     */
+    JSONObject loadDeviceList(Map<String, String> paramValues) throws Exception;
+
+    /**
+     * 获取视频 URL 信息
+     *
+     * @param cameraCode 实时浏览或录像的摄像机编码
+     * @return JSONObject
+     * @throws Exception Exception
+     */
+    JSONObject loadVideoRtspUrl(String cameraCode) throws Exception;
+
+    /**
+     * 开始实时浏览
+     *
+     * @param cameraCode cameraCode
+     * @throws Exception Exception
+     */
+    void startRealPlayByIpex(String cameraCode) throws Exception;
+
+    /**
+     * 添加实时智能数据订阅
+     *
+     * @param ids ids
+     */
+    void startIntelligentDataSubscribes(String ids);
+
+    /**
+     * 删除实时智能数据订阅
+     *
+     * @param ids ids
+     */
+    void deleteIntelligentDataSubscribes(String ids) throws Exception;
+}

+ 19 - 5
src/main/java/com/zhiqiyun/open/core/video/impl/VideoAnalysisServiceImpl.java

@@ -15,7 +15,6 @@ import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.assertj.core.util.Lists;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.data.redis.core.BoundValueOperations;
 import org.springframework.data.redis.core.RedisTemplate;
@@ -24,7 +23,6 @@ import org.springframework.stereotype.Service;
 
 import javax.annotation.Resource;
 import java.io.IOException;
-import java.net.URLEncoder;
 import java.util.HashMap;
 import java.util.List;
 import java.util.Map;
@@ -84,15 +82,14 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
     @Override
     public String getValidToken() throws Exception {
         BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(VCM_VIDEO_JSESSIONID_TOKEN);
-        String token = boundValueOperations.get();
+        String token = null;
         if (StringUtils.isBlank(token) || !token.contains("JSESSIONID")) {
             Map<String, Object> paramValues = new HashMap<>(2);
-            paramValues.put("account", "duijie");
+            paramValues.put("account", "duijie01");
             paramValues.put("pwd", PASSWORD);
             CloseableHttpResponse response = httpPost("/sdk_service/rest/users/login/v1.1", paramValues, null);
             getApacheBodyXml(response);
             String setCookie = getApacheHeader(response, "Set-Cookie");
-            //JSESSIONID=7F304CFA74C75A69DBC8F807A136529376F9F4BDFB2E8D94BA5231243BCAA6A4; Path=/; Secure; HttpOnly
             log.info("Set-Cookie JSESSIONID:{}", setCookie);
             if (StringUtils.isBlank(setCookie)) {
                 throw new ServiceException("COOKIE加载失败");
@@ -182,6 +179,23 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
 
     }
 
+    @Override
+    public void getIntelligentAnalysisList() throws Exception {
+        String builder = "<request><page no=\"1\" pageSize=\"100\" pageSort=\"desc\" sortName=\"createDate\"/></request>";
+        CloseableHttpResponse response = httpPostXml("/sdk_service/rest/video-analysis/get_intelligent_analysis_list/v1.1", builder, getValidToken());
+        Map<String, Object> body = getApacheBodyXml(response);
+        log.info("获取到的摄像机列表:{}", JSONObject.toJSONString(body));
+    }
+
+    @Override
+    public void subscription() throws Exception {
+        String builder = "<request><callbackUrl><master>http://171.104.234.207:9800/IntelligentData/DispositionNotifications</master>" +
+                "<slave>http://192.168.0.108:9800/IntelligentData/SubscribeNotifications</slave><authMode>0</authMode></callbackUrl><taskId>62ecbd79d629f802a55395da,62ec985fd629f802a55395d5,62ec83cbd629f802a55395cd,62ebbbb2d629f802a5539551,62ebbbb2d629f802a5539550,62ebbbb2d629f802a553954f,62eb98e6d629f802a5539515</taskId><dataFormat>1</dataFormat></request>";
+        CloseableHttpResponse response = httpPostXml("/sdk_service/rest/video-analysis/subscription", builder, getValidToken());
+        Map<String, Object> body = getApacheBodyXml(response);
+        log.info("获取到的摄像机列表:{}", JSONObject.toJSONString(body));
+    }
+
     /**
      * 获取所有设备信息
      *

+ 50 - 16
src/main/java/com/zhiqiyun/open/core/video/impl/VideoDockingServiceImpl.java

@@ -9,6 +9,7 @@ import org.apache.commons.lang3.StringUtils;
 import org.apache.http.client.config.CookieSpecs;
 import org.apache.http.client.config.RequestConfig;
 import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpDelete;
 import org.apache.http.client.methods.HttpGet;
 import org.apache.http.client.methods.HttpPost;
 import org.apache.http.entity.StringEntity;
@@ -36,10 +37,10 @@ import static com.zhiqiyun.open.camera.config.CameraConfig.*;
 @Service
 public class VideoDockingServiceImpl implements VideoDockingService {
 
-    //    public final static String URI = "http://222.84.250.39:9800";
+    //        public final static String URI = "https://222.84.250.39:9800";
     public final static String URI = "https://172.169.12.21:18531";
 
-    public final static String VIDEO_JSESSIONID_TOKEN = "VIDEO_JSESSIONID_TOKEN";
+    public final static String VIDEO_JSESSIONID_TOKEN = "VIDEO_JSESSIONID_TOKEN:%s";
 
     @Resource
     private RedisTemplate<String, String> redisTemplate;
@@ -49,11 +50,11 @@ public class VideoDockingServiceImpl implements VideoDockingService {
 
     @Override
     public String getValidToken() throws Exception {
-        BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(VIDEO_JSESSIONID_TOKEN);
+        BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(String.format(VIDEO_JSESSIONID_TOKEN, USER_NAME_Urban));
         String token = boundValueOperations.get();
         if (StringUtils.isBlank(token) || !token.contains("JSESSIONID")) {
             Map<String, Object> paramValues = new HashMap<>(2);
-            paramValues.put("userName", USER_NAME);
+            paramValues.put("userName", USER_NAME_Urban);
             paramValues.put("password", PASSWORD);
 
             CloseableHttpResponse response = httpPost("/loginInfo/login/v1.0", paramValues, null);
@@ -75,7 +76,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
 
     @Override
     public void refreshValidToken() throws Exception {
-        BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(VIDEO_JSESSIONID_TOKEN);
+        BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(String.format(VIDEO_JSESSIONID_TOKEN, USER_NAME_Urban));
         String cookie = boundValueOperations.get();
         if (StringUtils.isBlank(cookie)) {
             return;
@@ -146,19 +147,20 @@ public class VideoDockingServiceImpl implements VideoDockingService {
                 Map<String, Object> subscribeObject = Maps.newHashMap();
                 List<Map<String, String>> list = Lists.newArrayList();
                 Map<String, String> data = new HashMap<>(10);
-                data.put("Title", "实时智能数据订阅接口");
+                data.put("SubscribeID", "012314001711022022110215361000001");
+                data.put("Title", "sszndy");
                 data.put("SubscribeDetail", "0");
                 data.put("ResourceClass", "1");
                 data.put("ResourceURI", ids);
                 data.put("ApplicantName", "yzx22");
                 data.put("ApplicantOrg", "hw");
-                data.put("BeginTime", "20210801100000");
-                data.put("EndTime", "20210830094059");
-                data.put("ReceiveAddr", "http://171.104.234.207:9800");
+                data.put("BeginTime", "20221102153600");
+                data.put("EndTime", "20221130094059");
+                data.put("ReceiveAddr", "https://222.84.250.39:9800");
                 data.put("Reason", "hw");
                 data.put("OperateType", "0");
                 data.put("SubscribeStatus", "0");
-                data.put("ResultImageDeclare", "-1");
+                data.put("ResultImageDeclare", "01,04,05,06,07,10");
                 data.put("ResultFeatureDeclare", "-1");
                 data.put("SubscribeDataType", "1");
                 data.put("DeviceCodeType", "0");
@@ -178,11 +180,11 @@ public class VideoDockingServiceImpl implements VideoDockingService {
 
     @Override
     public void deleteIntelligentDataSubscribes(String ids) throws Exception {
-//        Map<String, String> params = Maps.newHashMap();
-//        params.put("IDList", ids);
-//        CloseableHttpResponse response = httpDelete("/IntelligentData/Subscribes", params, getValidToken());
-//        JSONObject body = getApacheBody(response);
-//        log.info("删除实时智能数据订阅:{}", body.toJSONString());
+        Map<String, String> params = Maps.newHashMap();
+        params.put("IDList", ids);
+        CloseableHttpResponse response = httpDelete("/IntelligentData/Subscribes", params, getValidToken());
+        JSONObject body = getApacheBody(response);
+        log.info("删除实时智能数据订阅:{}", body.toJSONString());
     }
 
     /**
@@ -214,7 +216,7 @@ public class VideoDockingServiceImpl implements VideoDockingService {
         }
         httpPost.setConfig(defaultConfig);
         if (paramValues != null && paramValues.size() > 0) {
-            log.info("http post body:", paramValues);
+            log.info("http post body:{}", paramValues);
             httpPost.setEntity(new StringEntity(JSONObject.toJSONString(paramValues)));
         }
         return httpClient.execute(httpPost);
@@ -256,4 +258,36 @@ public class VideoDockingServiceImpl implements VideoDockingService {
         httpGet.setConfig(defaultConfig);
         return httpClient.execute(httpGet);
     }
+
+    /**
+     * 统一DELETE请求方法
+     *
+     * @param uri         uri
+     * @param paramValues paramValues
+     * @return String
+     */
+    public static CloseableHttpResponse httpDelete(String uri, Map<String, String> paramValues, String cookie) throws IOException {
+        // 1. 创建HttpClient
+        CloseableHttpClient httpClient = createSSLClientDefault();
+        String url = String.format("%s" + uri, URI);
+        log.info("REQUEST URI:{},cooke:{}", url, cookie);
+        url = getRequestGetUri(url, paramValues);
+        RequestConfig defaultConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
+
+        // 2. 创建POST请求
+        HttpDelete httpDelete = new HttpDelete(url);
+        httpDelete.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+        httpDelete.setHeader("Connection", "keep-alive");
+        httpDelete.setHeader("Accept", "application/json, text/plain, */*");
+        httpDelete.setHeader("Accept-Encoding", "gzip, deflate, br");
+        httpDelete.setHeader("Sec-Fetch-Site", "same-origin");
+        httpDelete.setHeader("Sec-Fetch-Mode", "cors");
+        httpDelete.setHeader("Sec-Fetch-Dest", "empty");
+        httpDelete.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36");
+        if (StringUtils.isNotBlank(cookie)) {
+            httpDelete.setHeader("Cookie", cookie);
+        }
+        httpDelete.setConfig(defaultConfig);
+        return httpClient.execute(httpDelete);
+    }
 }

+ 259 - 0
src/main/java/com/zhiqiyun/open/core/video/impl/VideoDockingUrbanServiceImpl.java

@@ -0,0 +1,259 @@
+package com.zhiqiyun.open.core.video.impl;
+
+import com.alibaba.fastjson.JSONObject;
+import com.google.common.collect.Maps;
+import com.zhiqiyun.open.core.video.VideoDockingUrbanService;
+import com.zhiqiyun.open.exception.ServiceException;
+import lombok.extern.slf4j.Slf4j;
+import org.apache.commons.lang3.StringUtils;
+import org.apache.http.client.config.CookieSpecs;
+import org.apache.http.client.config.RequestConfig;
+import org.apache.http.client.methods.CloseableHttpResponse;
+import org.apache.http.client.methods.HttpGet;
+import org.apache.http.client.methods.HttpPost;
+import org.apache.http.entity.StringEntity;
+import org.apache.http.impl.client.CloseableHttpClient;
+import org.assertj.core.util.Lists;
+import org.springframework.data.redis.core.BoundValueOperations;
+import org.springframework.data.redis.core.RedisTemplate;
+import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
+import org.springframework.stereotype.Service;
+
+import javax.annotation.Resource;
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.TimeUnit;
+
+import static com.zhiqiyun.open.camera.config.CameraConfig.*;
+
+/**
+ * @author xin yang
+ * @date 2022/8/4
+ */
+@Slf4j
+@Service
+public class VideoDockingUrbanServiceImpl implements VideoDockingUrbanService {
+
+//        public final static String URI = "http://222.84.250.39:9800";
+    public final static String URI = "https://172.169.12.148:18531";
+
+    public final static String VIDEO_JSESSIONID_TOKEN = "VIDEO_JSESSIONID_TOKEN_Urban";
+
+    @Resource
+    private RedisTemplate<String, String> redisTemplate;
+
+    @Resource
+    private ThreadPoolTaskExecutor taskExecutor;
+
+    @Override
+    public String getValidToken() throws Exception {
+        BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(VIDEO_JSESSIONID_TOKEN);
+        String token = boundValueOperations.get();
+        if (StringUtils.isBlank(token) || !token.contains("JSESSIONID")) {
+            Map<String, Object> paramValues = new HashMap<>(2);
+            paramValues.put("userName", USER_NAME_Urban);
+            paramValues.put("password", PASSWORD);
+
+            CloseableHttpResponse response = httpPost("/loginInfo/login/v1.0", paramValues, null);
+            getApacheBody(response);
+            String setCookie = getApacheHeader(response, "Set-Cookie");
+            //JSESSIONID=7F304CFA74C75A69DBC8F807A136529376F9F4BDFB2E8D94BA5231243BCAA6A4; Path=/; Secure; HttpOnly
+            log.info("Set-Cookie JSESSIONID:{}", setCookie);
+            if (StringUtils.isBlank(setCookie)) {
+                throw new ServiceException("COOKIE加载失败");
+            }
+            token = setCookie.split(";")[0];
+            log.info("cookie JSESSIONID:{}", token);
+            if (StringUtils.isNotBlank(token)) {
+                boundValueOperations.set(token, 30, TimeUnit.MINUTES);
+            }
+        }
+        return token;
+    }
+
+    @Override
+    public void refreshValidToken() throws Exception {
+        BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(VIDEO_JSESSIONID_TOKEN);
+        String cookie = boundValueOperations.get();
+        if (StringUtils.isBlank(cookie)) {
+            return;
+        }
+        CloseableHttpResponse response = httpPost("/common/keepAlive", Maps.newHashMap(), cookie);
+        JSONObject body = getApacheBody(response);
+        log.info("用户登录信息保活:{}", body.toJSONString());
+        if (StringUtils.isNotBlank(cookie)) {
+            boundValueOperations.set(cookie, 30, TimeUnit.MINUTES);
+        }
+    }
+
+    @Override
+    public JSONObject loadDeviceList(Map<String, String> paramValues) throws Exception {
+        paramValues.put("deviceType", "33");
+        CloseableHttpResponse response = httpGet("/device/deviceList/v1.0", paramValues, getValidToken());
+        JSONObject body = getApacheBody(response);
+        log.info("获取到的设备列表:{}", body.toJSONString());
+        return body;
+    }
+
+    @Override
+    public JSONObject loadVideoRtspUrl(String cameraCode) throws Exception {
+        Map<String, Object> paramValues = Maps.newHashMap();
+        paramValues.put("cameraCode", cameraCode);
+        Map<String, Object> mediaURLParam = Maps.newHashMap();
+        mediaURLParam.put("broadCastType", 0);
+        mediaURLParam.put("packProtocolType", 1);
+        mediaURLParam.put("protocolType", 2);
+        mediaURLParam.put("serviceType", 1);
+        mediaURLParam.put("streamType", 1);
+        mediaURLParam.put("transMode", 0);
+        mediaURLParam.put("clientType", 5);
+        paramValues.put("mediaURLParam", mediaURLParam);
+        CloseableHttpResponse response = httpPost("/video/rtspurl/v1.0", paramValues, getValidToken());
+        return getApacheBody(response);
+    }
+
+    @Override
+    public void startRealPlayByIpex(String cameraCode) throws Exception {
+        Map<String, Object> paramValues = Maps.newHashMap();
+        paramValues.put("cameraCode", cameraCode);
+        Map<String, Object> realplayParam = Maps.newHashMap();
+        realplayParam.put("streamType", 1);
+        realplayParam.put("protocolType", 1);
+        realplayParam.put("directFirst", 0);
+        realplayParam.put("multiCast", 0);
+        paramValues.put("realplayParam", realplayParam);
+        Map<String, Object> mediaAddrDst = Maps.newHashMap();
+        Map<String, Object> dstIP = Maps.newHashMap();
+        dstIP.put("ipType", 0);
+        dstIP.put("ip", "192.168.0.15");
+        mediaAddrDst.put("dstIP", dstIP);
+        mediaAddrDst.put("audioPort", "40000");
+        mediaAddrDst.put("videoPort", "40000");
+        mediaAddrDst.put("reserve", cameraCode);
+        paramValues.put("mediaAddrDst", mediaAddrDst);
+        paramValues.put("clientType", 1);
+        CloseableHttpResponse response = httpPost("/device/startrealplaybyipex", paramValues, getValidToken());
+        getApacheBody(response);
+    }
+
+    @Override
+    public void startIntelligentDataSubscribes(String ids) {
+        taskExecutor.execute(() -> {
+            try {
+                Map<String, Object> params = Maps.newHashMap();
+                Map<String, Object> subscribeObject = Maps.newHashMap();
+                List<Map<String, String>> list = Lists.newArrayList();
+                Map<String, String> data = new HashMap<>(10);
+                data.put("Title", "实时智能数据订阅接口");
+                data.put("SubscribeDetail", "0");
+                data.put("ResourceClass", "1");
+                data.put("ResourceURI", ids);
+                data.put("ApplicantName", "yzx22");
+                data.put("ApplicantOrg", "hw");
+                data.put("BeginTime", "20210801100000");
+                data.put("EndTime", "20210830094059");
+                data.put("ReceiveAddr", "http://171.104.234.207:9800");
+                data.put("Reason", "hw");
+                data.put("OperateType", "0");
+                data.put("SubscribeStatus", "0");
+                data.put("ResultImageDeclare", "-1");
+                data.put("ResultFeatureDeclare", "-1");
+                data.put("SubscribeDataType", "1");
+                data.put("DeviceCodeType", "0");
+                list.add(data);
+                subscribeObject.put("SubscribeObject", list);
+                params.put("SubscribeListObject", subscribeObject);
+
+                log.info("添加实时智能数据订阅 params:{}", JSONObject.toJSONString(params));
+                CloseableHttpResponse response = httpPost("/IntelligentData/Subscribes", params, getValidToken());
+                JSONObject body = getApacheBody(response);
+                log.info("添加实时智能数据订阅:{}", body.toJSONString());
+            } catch (Exception e) {
+                log.error(e.getMessage(), e);
+            }
+        });
+    }
+
+    @Override
+    public void deleteIntelligentDataSubscribes(String ids) throws Exception {
+//        Map<String, String> params = Maps.newHashMap();
+//        params.put("IDList", ids);
+//        CloseableHttpResponse response = httpDelete("/IntelligentData/Subscribes", params, getValidToken());
+//        JSONObject body = getApacheBody(response);
+//        log.info("删除实时智能数据订阅:{}", body.toJSONString());
+    }
+
+    /**
+     * 统一POST请求方法
+     *
+     * @param uri         uri
+     * @param paramValues paramValues
+     * @return String
+     */
+    private static CloseableHttpResponse httpPost(String uri, Map<String, Object> paramValues, String cookie) throws IOException {
+        // 1. 创建HttpClient
+        CloseableHttpClient httpClient = createSSLClientDefault();
+        String url = String.format("%s" + uri, URI);
+        log.info("REQUEST URI:{},cooke:{}", url, cookie);
+        RequestConfig defaultConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
+
+        // 2. 创建POST请求
+        HttpPost httpPost = new HttpPost(url);
+        httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
+        httpPost.setHeader("Connection", "keep-alive");
+        httpPost.setHeader("Accept", "application/json, text/plain, */*");
+        httpPost.setHeader("Accept-Encoding", "gzip, deflate, br");
+        httpPost.setHeader("Sec-Fetch-Site", "same-origin");
+        httpPost.setHeader("Sec-Fetch-Mode", "cors");
+        httpPost.setHeader("Sec-Fetch-Dest", "empty");
+        httpPost.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36");
+        if (StringUtils.isNotBlank(cookie)) {
+            httpPost.setHeader("Cookie", cookie);
+        }
+        httpPost.setConfig(defaultConfig);
+        if (paramValues != null && paramValues.size() > 0) {
+            log.info("http post body:", paramValues);
+            httpPost.setEntity(new StringEntity(JSONObject.toJSONString(paramValues)));
+        }
+        return httpClient.execute(httpPost);
+    }
+
+    /**
+     * 统一GET请求方法
+     *
+     * @param uri         uri
+     * @param paramValues paramValues
+     * @return String
+     */
+    private static CloseableHttpResponse httpGet(String uri, Map<String, String> paramValues, String cookie) throws IOException {
+        // 1. 创建HttpClient
+        CloseableHttpClient httpClient = createSSLClientDefault();
+        String url = String.format("%s" + uri, URI);
+        log.info("REQUEST URI:{}", url);
+        url = getRequestGetUri(url, paramValues);
+        log.info("REQUEST getRequestGetUri URI:{}", url);
+        RequestConfig defaultConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
+        HttpGet httpGet = new HttpGet(url);
+        httpGet.setHeader("Content-Type", "application/json;charset=UTF-8");
+        httpGet.setHeader("Connection", "keep-alive");
+        httpGet.setHeader("Accept", "application/json, text/plain, */*");
+        httpGet.setHeader("Accept-Encoding", "gzip, deflate, br");
+        httpGet.setHeader("Sec-Fetch-Site", "same-origin");
+        httpGet.setHeader("Sec-Fetch-Mode", "cors");
+        httpGet.setHeader("Sec-Fetch-Dest", "empty");
+        httpGet.setHeader("User-Agent", "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/83.0.4103.116 Safari/537.36");
+        if (StringUtils.isNotBlank(cookie)) {
+            log.info("==============cookie=================={}", cookie);
+            httpGet.setHeader("Cookie", cookie);
+//            CookieStore cookieStore = new BasicCookieStore();
+//            //添加cookie
+//            BasicClientCookie basicClientCookie = new BasicClientCookie(cookies[0], cookies[1]);
+//            cookieStore.addCookie(basicClientCookie);
+        }
+
+        httpGet.setConfig(defaultConfig);
+        return httpClient.execute(httpGet);
+    }
+}

+ 6 - 0
src/main/java/com/zhiqiyun/open/mvc/FundaErrorController.java

@@ -5,6 +5,7 @@ import com.zhiqiyun.open.exception.NoLoginException;
 import com.zhiqiyun.open.exception.NotSufficientFundsException;
 import com.zhiqiyun.open.exception.PermissionDeniedException;
 import com.zhiqiyun.open.mvc.Result;
+import com.zhiqiyun.open.utils.ServletContext;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.boot.web.servlet.error.ErrorController;
 import org.springframework.validation.BindingResult;
@@ -77,6 +78,11 @@ public class FundaErrorController implements ErrorController {
     @ExceptionHandler(Exception.class)
     public Result handleException(Exception ex) {
         log.error("system error", ex);
+        try {
+            log.info("请求报错连接:{}", ServletContext.getRequest().getRequestURI());
+        } catch (Exception e) {
+            e.printStackTrace();
+        }
         return Result.instance(Result.Code.SERVER_ERROR, "系统忙,请稍后再试");
     }
 }

+ 33 - 0
src/main/java/com/zhiqiyun/open/mvc/controller/RtspFlvPlayController.java

@@ -1,16 +1,23 @@
 package com.zhiqiyun.open.mvc.controller;
 
+import com.alibaba.fastjson.JSONObject;
 import com.zhiqiyun.open.core.video.VideoAnalysisService;
 import com.zhiqiyun.open.core.video.VideoDockingService;
+import com.zhiqiyun.open.mvc.Result;
+import com.zhiqiyun.open.router.request.hwVideo.VideoRtsUrlRequest;
 import com.zhiqiyun.open.utils.ServletContext;
 import lombok.extern.slf4j.Slf4j;
+import org.springframework.data.redis.core.RedisTemplate;
 import org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor;
 import org.springframework.stereotype.Controller;
 import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.ResponseBody;
 
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
+import java.util.Map;
 
 /**
  * @author xin yang
@@ -30,15 +37,41 @@ public class RtspFlvPlayController {
     @Resource
     private ThreadPoolTaskExecutor taskExecutor;
 
+    @Resource
+    private RedisTemplate<String, String> redisTemplate;
+
+    @ResponseBody
     @RequestMapping("/SubscribeNotifications")
     public void subscribeNotifications(HttpServletRequest request) throws IOException {
         log.info("======================推送1400数据和智能元数据=========================");
         log.info("=======body:{}", ServletContext.getBody(request.getInputStream()));
     }
 
+    @ResponseBody
     @RequestMapping("/DispositionNotifications")
     public void dispositionNotifications(HttpServletRequest request) throws IOException {
         log.info("======================推送智能告警数据=========================");
         log.info("=======body:{}", ServletContext.getBody(request.getInputStream()));
     }
+
+    @ResponseBody
+    @RequestMapping("/getIntelligentAnalysisList")
+    public void getIntelligentAnalysisList() throws Exception {
+        log.info("======================推送智能告警数据=========================");
+        videoAnalysisService.getIntelligentAnalysisList();
+//        videoDockingService.startIntelligentDataSubscribes("02012185365521170101,02012185362159840101,02012185366266020101,02012185368005900101,02012185369564670101,02012185369303520101,02012185369349130101");
+    }
+
+    @ResponseBody
+    @RequestMapping("/loadDeviceList")
+    public void loadDeviceList(@RequestParam Map<String, String> params) throws Exception {
+        videoDockingService.loadDeviceList(params);
+    }
+
+    @ResponseBody
+    @RequestMapping("/loadVideoRtspUrl")
+    public Result loadVideoRtspUrl(VideoRtsUrlRequest request) throws Exception {
+        JSONObject jsonObject = videoDockingService.loadVideoRtspUrl(request.getCameraCode());
+        return Result.instance(Result.Code.SUCCESS).setData(jsonObject);
+    }
 }

+ 8 - 2
src/main/java/com/zhiqiyun/open/router/apis/HwVideoApi.java

@@ -10,6 +10,7 @@ import com.zhiqiyun.open.camera.rtsp.RtspPushSrs;
 import com.zhiqiyun.open.camera.rtsp.RtspTransfer;
 import com.zhiqiyun.open.core.models.hwVideo.DeviceList;
 import com.zhiqiyun.open.core.video.VideoDockingService;
+import com.zhiqiyun.open.core.video.VideoDockingUrbanService;
 import com.zhiqiyun.open.router.request.hwVideo.LoadVideoPageRequest;
 import com.zhiqiyun.open.router.request.hwVideo.VideoRtsUrlRequest;
 import com.zhiqiyun.open.router.request.hwVideo.VideoRtsUrlResponse;
@@ -34,6 +35,9 @@ public class HwVideoApi {
     private VideoDockingService videoDockingService;
 
     @Autowired
+    private VideoDockingUrbanService videoDockingUrbanService;
+
+    @Autowired
     private ThreadPoolTaskExecutor taskExecutor;
 
     @ServiceMethod(method = "hw.video.find", title = "查询子设备列表")
@@ -42,7 +46,8 @@ public class HwVideoApi {
             Map<String, String> params = Maps.newHashMap();
             params.put("fromIndex", String.valueOf((request.getPage() - 1) * request.getLimit() + 1));
             params.put("toIndex", String.valueOf(request.getPage() * request.getLimit()));
-            JSONObject jsonObject = videoDockingService.loadDeviceList(params);
+            JSONObject jsonObject = request.getLoadType().compareTo(1) == 0 ? videoDockingService.loadDeviceList(params)
+                    : videoDockingUrbanService.loadDeviceList(params);
             JSONObject cameraBriefExInfos = jsonObject.getJSONObject("cameraBriefExInfos");
             int total = cameraBriefExInfos.getIntValue("total");
             JSONObject cameraBriefInfoExList = cameraBriefExInfos.getJSONObject("cameraBriefInfoExList");
@@ -59,7 +64,8 @@ public class HwVideoApi {
     @ServiceMethod(method = "hw.video.url.find", title = "获取视频URL信息")
     public OapResponse loadVideoRtspUrl(@Valid VideoRtsUrlRequest request) throws Exception {
         VideoRtsUrlResponse response = new VideoRtsUrlResponse();
-        JSONObject jsonObject = videoDockingService.loadVideoRtspUrl(request.getCameraCode());
+        JSONObject jsonObject = request.getLoadType().compareTo(1) == 0 ? videoDockingService.loadVideoRtspUrl(request.getCameraCode())
+                : videoDockingUrbanService.loadVideoRtspUrl(request.getCameraCode());
         String rtspUri = jsonObject.getString("rtspURL");
         log.info("获取到监控rtspURI:{}", rtspUri);
         if (StringUtils.isBlank(rtspUri)) return OapResponse.fail("ERROR", "视频流地址获取失败");

+ 9 - 6
src/main/java/com/zhiqiyun/open/router/request/hwVideo/LoadVideoPageRequest.java

@@ -14,11 +14,14 @@ import javax.validation.constraints.NotNull;
 @EqualsAndHashCode(callSuper = true)
 public class LoadVideoPageRequest extends AbstractOapRequest {
 
-	@NotNull
-	@ServiceParamField(describe = "页数")
-	private Integer page = 1;
+    @NotNull
+    @ServiceParamField(describe = "页数")
+    private Integer page = 1;
 
-	@NotNull
-	@ServiceParamField(describe = "每页条数")
-	private Integer limit = 10;
+    @NotNull
+    @ServiceParamField(describe = "每页条数")
+    private Integer limit = 10;
+
+    @ServiceParamField(describe = "加载数据 1、智慧旅游 2、智慧城管")
+    private Integer loadType = 1;
 }

+ 3 - 0
src/main/java/com/zhiqiyun/open/router/request/hwVideo/VideoRtsUrlRequest.java

@@ -18,4 +18,7 @@ public class VideoRtsUrlRequest extends AbstractOapRequest {
 	@NotBlank
 	@ServiceParamField(describe = "实时浏览或录像的摄像机编码")
 	private String cameraCode;
+
+	@ServiceParamField(describe = "加载数据 1、智慧旅游 2、智慧城管")
+	private Integer loadType = 1;
 }

+ 1 - 1
src/main/resources/application-alpha.properties

@@ -12,7 +12,7 @@ spring.redis.database=0
 ####################### uploader config ###############################
 uploader.max-size=20480000
 uploader.file-host=http://47.114.32.188:9800/src
-uploader.allow-file-types=jpg,jpeg,png,gif
+uploader.allow-file-types=jpg,jpeg,png,gif,mp4,mp3,xls,xlsx,pdf
 uploader.save-path=/data/uploads
 ####################### spider config ###############################
 spider.phantomjs_executable_path_property=/data/phantomjs-2.1.1-linux-x86_64/bin/phantomjs

+ 1 - 1
src/main/resources/application-prod.properties

@@ -12,7 +12,7 @@ spring.redis.database=1
 ####################### uploader config ###############################
 uploader.max-size=20480000
 uploader.file-host=https://dbadmin-pro-smartcity.123cx.com/src
-uploader.allow-file-types=jpg,jpeg,png,gif
+uploader.allow-file-types=jpg,jpeg,png,gif,mp4,mp3,xls,xlsx,pdf
 uploader.save-path=/data/data-center/uploads
 ####################### spider config ###############################
 spider.phantomjs_executable_path_property=/data/data-center/phantomjs-2.1.1/bin/phantomjs

+ 1 - 0
src/main/resources/application.properties

@@ -1,6 +1,7 @@
 spring.profiles.active=dev
 server.port=9800
 spring.application.name=zhiqiyun-open-platform
+server.max-http-header-size=102400
 ####################### logger ###############################
 logger.root.level=DEBUG
 logger.root.path=/tmp/