root 2 年之前
父节点
当前提交
0c03bd1299

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

@@ -34,8 +34,9 @@ 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 = "http://222.84.250.39:9800";
-        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 String VCM_URI = "https://172.169.10.253:18531";
     public final static int SUCCESS_STATUS_CODE = 200;
     public final static int SUCCESS_CODE = 0;
 

+ 3 - 2
src/main/java/com/zhiqiyun/open/core/schedule/AutoRefreshVideoSchedule.java

@@ -1,5 +1,6 @@
 package com.zhiqiyun.open.core.schedule;
 
+import com.zhiqiyun.open.core.video.VideoAnalysisService;
 import com.zhiqiyun.open.core.video.VideoDockingService;
 import lombok.extern.slf4j.Slf4j;
 import org.springframework.beans.factory.annotation.Autowired;
@@ -17,7 +18,7 @@ import org.springframework.stereotype.Component;
 public class AutoRefreshVideoSchedule {
 
     @Autowired
-    private VideoDockingService videoDockingService;
+    private VideoAnalysisService videoAnalysisService;
 
     @Value("${spring.profiles.active}")
     private String active;
@@ -27,6 +28,6 @@ public class AutoRefreshVideoSchedule {
         if ("dev".equals(active)) {
             return;
         }
-//        videoDockingService.refreshValidToken();
+        videoAnalysisService.refreshValidToken();
     }
 }

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

@@ -33,23 +33,4 @@ public interface VideoAnalysisService {
      * @param paramValues paramValues
      */
     void cameraList(Map<String, String> paramValues) throws Exception;
-
-    /**
-     * 批量创建智能分析任务
-     */
-    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;
 }

+ 12 - 220
src/main/java/com/zhiqiyun/open/core/video/impl/VideoAnalysisServiceImpl.java

@@ -2,7 +2,6 @@ package com.zhiqiyun.open.core.video.impl;
 
 import com.alibaba.fastjson.JSONObject;
 import com.google.common.collect.Maps;
-import com.zhiqiyun.open.core.models.hwVideo.DeviceList;
 import com.zhiqiyun.open.core.video.VideoAnalysisService;
 import com.zhiqiyun.open.exception.ServiceException;
 import lombok.extern.slf4j.Slf4j;
@@ -10,21 +9,17 @@ 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;
 import org.apache.http.impl.client.CloseableHttpClient;
-import org.springframework.beans.factory.annotation.Autowired;
 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;
 
@@ -38,57 +33,21 @@ import static com.zhiqiyun.open.camera.config.CameraConfig.*;
 @Service
 public class VideoAnalysisServiceImpl implements VideoAnalysisService {
 
-    @Autowired
-    private ThreadPoolTaskExecutor taskExecutor;
-
-    private final static int pageSize = 100;
-
     @Resource
     private RedisTemplate<String, String> redisTemplate;
 
-    private final static String LINE_CROSSING = "<run_extradata>" +
-            "    <![CDATA[<vcm_beh_alg_config>" +
-            "        <BEH_GLOBAL_ALARM>" +
-            "            <minSizeWidth>0.01</minSizeWidth>" +
-            "            <minSizeHeight>0.01</minSizeHeight>" +
-            "            <maxSizeWidth>0.9</maxSizeWidth>" +
-            "            <maxSizeHeight>0.9</maxSizeHeight>" +
-            "            <detSensitivity>1</detSensitivity>" +
-            "            <backgroundUpdateRate>1</backgroundUpdateRate>" +
-            "            <shadowRemove>0</shadowRemove>" +
-            "        </BEH_GLOBAL_ALARM>" +
-            "        <BEH_RULE>" +
-            "            <ruleId>0</ruleId>" +
-            "            <ruleType>4</ruleType>" +
-            "            <focusedPart>0</focusedPart>" +
-            "            <alarmThreshold>10</alarmThreshold>" +
-            "            <outCntInitValue>0</outCntInitValue>" +
-            "            <inCntInitValue>0</inCntInitValue>" +
-            "            <autoClearFlag>1</autoClearFlag>" +
-            "            <lineNum>1</lineNum>" +
-            "            <line>" +
-            "                <lineType>1</lineType>" +
-            "                <direct>1</direct>" +
-            "                <point>0.25208,0.15926</point>" +
-            "                <!-- 相对坐标系 -->" +
-            "                <point>0.00000,0.38056</point>" +
-            "            </line>" +
-            "        </BEH_RULE>" +
-            "    </vcm_beh_alg_config>]]>" +
-            "</run_extradata>";
-
     private final static String VCM_VIDEO_JSESSIONID_TOKEN = "VCM_VIDEO_JSESSIONID_TOKEN";
 
     @Override
     public String getValidToken() throws Exception {
         BoundValueOperations<String, String> boundValueOperations = this.redisTemplate.boundValueOps(VCM_VIDEO_JSESSIONID_TOKEN);
-        String token = null;
+        String token = boundValueOperations.get();
         if (StringUtils.isBlank(token) || !token.contains("JSESSIONID")) {
             Map<String, Object> paramValues = new HashMap<>(2);
-            paramValues.put("account", "duijie01");
-            paramValues.put("pwd", PASSWORD);
-            CloseableHttpResponse response = httpPost("/sdk_service/rest/users/login/v1.1", paramValues, null);
-            getApacheBodyXml(response);
+            paramValues.put("userName", "duijie01");
+            paramValues.put("password", PASSWORD);
+            CloseableHttpResponse response = httpPost("/loginInfo/login/v1.0", paramValues, null);
+            getApacheBody(response);
             String setCookie = getApacheHeader(response, "Set-Cookie");
             log.info("Set-Cookie JSESSIONID:{}", setCookie);
             if (StringUtils.isBlank(setCookie)) {
@@ -120,108 +79,11 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
 
     @Override
     public void cameraList(Map<String, String> paramValues) throws Exception {
-        CloseableHttpResponse response = httpGet("/device/deviceList/v1.0?deviceType=32", paramValues, getValidToken());
+        CloseableHttpResponse response = httpGet("/device/deviceList/v1.0?deviceType=1", paramValues, getValidToken());
         JSONObject body = getApacheBody(response);
         log.info("获取到的摄像机列表:{}", body.toJSONString());
     }
 
-    @Override
-    public void startIntelligentAnalysis(String ids) throws Exception {
-//        Map<String, String> params = Maps.newHashMap();
-//        params.put("fromIndex", "1");
-//        params.put("toIndex", "100");
-//        JSONObject jsonObject = videoDockingService.loadDeviceList(params);
-//        JSONObject cameraBriefExInfos = jsonObject.getJSONObject("cameraBriefExInfos");
-//        JSONObject cameraBriefInfoExList = cameraBriefExInfos.getJSONObject("cameraBriefInfoExList");
-//        List<DeviceList> cameraBriefInfoExes = cameraBriefInfoExList.getJSONArray("cameraBriefInfoExes").toJavaList(DeviceList.class);
-        String builder = "<request>" +
-                "    <task_name>testPerson</task_name>" +
-                "    <type>0</type>" +
-                "    <camera_id>" + ids + "</camera_id>" +
-                "    <analyzeMode></analyzeMode>" +
-                "    <priority></priority>" +
-                "    <algorithms>" +
-                "       <algorithm></algorithm>" +
-                "    </algorithms>" +
-                "    <run_extradata>" +
-                "        <![CDATA[<vcm_beh_alg_config>" +
-                "    <BEH_GLOBAL_ALARM>" +
-                "        <minSizeWidth>0.01</minSizeWidth>" +
-                "        <minSizeHeight>0.01</minSizeHeight>" +
-                "        <maxSizeWidth>0.9</maxSizeWidth>" +
-                "        <maxSizeHeight>0.9</maxSizeHeight>" +
-                "        <detSensitivity>1</detSensitivity>" +
-                "        <backgroundUpdateRate>1</backgroundUpdateRate>" +
-                "        <shadowRemove>0</shadowRemove>" +
-                "    </BEH_GLOBAL_ALARM>" +
-                "    <BEH_RULE>" +
-                "        <ruleId>0</ruleId>" +
-                "        <ruleType>4</ruleType>" +
-                "        <focusedPart>0</focusedPart>" +
-                "        <alarmThreshold>10</alarmThreshold>" +
-                "        <outCntInitValue>0</outCntInitValue>" +
-                "        <inCntInitValue>0</inCntInitValue>" +
-                "        <autoClearFlag>1</autoClearFlag>" +
-                "        <lineNum>1</lineNum>" +
-                "        <line>" +
-                "            <lineType>1</lineType>" +
-                "            <direct>1</direct>" +
-                "            <point>0.25208,0.15926</point>" +
-                "            <point>0.00000,0.38056</point>" +
-                "        </line>" +
-                "    </BEH_RULE>" +
-                "</vcm_beh_alg_config>]]>" +
-                "    </run_extradata>" +
-                "</request>";
-        CloseableHttpResponse response = httpPostXml("/sdk_service/rest/video-analysis/start-intelligent-analysis/v1.1", builder, getValidToken());
-        Map<String, Object> body = getApacheBodyXml(response);
-        log.info("获取到的摄像机列表:{}", JSONObject.toJSONString(body));
-
-    }
-
-    @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));
-    }
-
-    /**
-     * 获取所有设备信息
-     *
-     * @param fromIndex   页数
-     * @param deviceLists 数据
-     * @return List<DeviceList>
-     * @throws Exception Exception
-     */
-    private List<DeviceList> loadAllDeviceList(int fromIndex, List<DeviceList> deviceLists) throws Exception {
-//        Map<String, String> params = Maps.newHashMap();
-//        params.put("fromIndex", String.valueOf((fromIndex - 1) * pageSize + 1));
-//        params.put("toIndex", String.valueOf(fromIndex * pageSize));
-//        JSONObject jsonObject = videoDockingService.loadDeviceList(params);
-//        JSONObject cameraBriefExInfos = jsonObject.getJSONObject("cameraBriefExInfos");
-//        JSONObject cameraBriefInfoExList = cameraBriefExInfos.getJSONObject("cameraBriefInfoExList");
-//        List<DeviceList> cameraBriefInfoExes = cameraBriefInfoExList.getJSONArray("cameraBriefInfoExes").toJavaList(DeviceList.class);
-//        if (cameraBriefInfoExes != null && cameraBriefInfoExes.size() > 0) {
-//            deviceLists.addAll(cameraBriefInfoExes);
-//            if (cameraBriefExInfos.size() == pageSize) {
-//                return loadAllDeviceList(fromIndex + 1, deviceLists);
-//            }
-//        }
-//        return deviceLists;
-        return null;
-    }
-
     /**
      * 统一POST请求方法
      *
@@ -234,14 +96,13 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
         CloseableHttpClient httpClient = createSSLClientDefault();
         String url = String.format("%s" + uri, VCM_URI);
         log.info("REQUEST URI:{},cooke:{}", url, cookie);
-//        url += "?" + URLEncoder.encode(postXForm(paramValues), "UTF-8");
-//        log.info("REQUEST getRequestGetUri URI:{}", url);
         RequestConfig defaultConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
+
         // 2. 创建POST请求
         HttpPost httpPost = new HttpPost(url);
-        httpPost.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=utf-8");
+        httpPost.setHeader("Content-Type", "application/json;charset=UTF-8");
         httpPost.setHeader("Connection", "keep-alive");
-        httpPost.setHeader("Accept", "text/plain;charset=utf-8");
+        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");
@@ -252,9 +113,8 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
         }
         httpPost.setConfig(defaultConfig);
         if (paramValues != null && paramValues.size() > 0) {
-            String body = postXForm(paramValues);
-            log.info("http post body:{}", body);
-            httpPost.setEntity(new StringEntity(body));
+            log.info("http post body:{}", paramValues);
+            httpPost.setEntity(new StringEntity(JSONObject.toJSONString(paramValues)));
         }
         return httpClient.execute(httpPost);
     }
@@ -267,7 +127,6 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
      * @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, VCM_URI);
         log.info("REQUEST URI:{}", url);
@@ -275,7 +134,7 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
         log.info("REQUEST getRequestGetUri URI:{}", url);
         RequestConfig defaultConfig = RequestConfig.custom().setCookieSpec(CookieSpecs.STANDARD).build();
         HttpGet httpGet = new HttpGet(url);
-        httpGet.setHeader("Content-Type", "application/x-www-form-urlencoded;charset=UTF-8");
+        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");
@@ -295,71 +154,4 @@ public class VideoAnalysisServiceImpl implements VideoAnalysisService {
         httpGet.setConfig(defaultConfig);
         return httpClient.execute(httpGet);
     }
-
-    /**
-     * 统一POST请求方法
-     *
-     * @param uri     uri
-     * @param postXml postXml
-     * @return String
-     */
-    public static CloseableHttpResponse httpPostXml(String uri, String postXml, String cookie) throws IOException {
-        // 1. 创建HttpClient
-        CloseableHttpClient httpClient = createSSLClientDefault();
-        String url = String.format("%s" + uri, VCM_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/xml;charset=UTF-8");
-        httpPost.setHeader("Connection", "keep-alive");
-        httpPost.setHeader("Accept", "text/plain;charset=UTF-8");
-        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 (StringUtils.isNotBlank(postXml)) {
-            log.info("http post body:{}", postXml);
-            httpPost.setEntity(new StringEntity(postXml));
-        }
-        return httpClient.execute(httpPost);
-    }
-
-    /**
-     * 统一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, VCM_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);
-    }
 }

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

@@ -17,6 +17,7 @@ import org.springframework.web.bind.annotation.ResponseBody;
 import javax.annotation.Resource;
 import javax.servlet.http.HttpServletRequest;
 import java.io.IOException;
+import java.util.HashMap;
 import java.util.Map;
 
 /**
@@ -58,8 +59,7 @@ public class RtspFlvPlayController {
     @RequestMapping("/getIntelligentAnalysisList")
     public void getIntelligentAnalysisList() throws Exception {
         log.info("======================推送智能告警数据 getIntelligentAnalysisList=========================");
-        videoAnalysisService.getIntelligentAnalysisList();
-//        videoDockingService.startIntelligentDataSubscribes("02012185365521170101,02012185362159840101,02012185366266020101,02012185368005900101,02012185369564670101,02012185369303520101,02012185369349130101");
+        videoAnalysisService.cameraList(new HashMap<>(1));
     }
 
     @ResponseBody

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

@@ -1,14 +1,14 @@
 logger.root.level=info
 logger.root.path=/data/logs/
 ####################### mysql ###############################
-spring.datasource.url=jdbc:mysql://116.8.106.156:3306/data_center?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&useSSL=false
+spring.datasource.url=jdbc:mysql://116.8.106.156/liucheng_open?allowMultiQueries=true&useUnicode=true&characterEncoding=utf8&useSSL=false&allowPublicKeyRetrieval=true
 spring.datasource.username=root
 spring.datasource.password=!@#931v3ODUQqakdyIQ
 #######################redis###############################
-spring.redis.host=39.99.217.107
-spring.redis.password=hnylredis@
+spring.redis.host=8.136.137.115
+spring.redis.password=i6f7s5
 spring.redis.port=6379
-spring.redis.database=0
+spring.redis.database=11
 ####################### uploader config ###############################
 uploader.max-size=20480000
 uploader.file-host=http://47.114.32.188:9800/src

+ 2 - 2
src/main/resources/application.properties

@@ -15,8 +15,8 @@ mybatis-plus.config-location=classpath:mybatis/sqlMapConfig.xml
 mybatis-plus.mapper-locations=classpath:mybatis/mappers/*.xml
 mybatis-plus.type-enums-package=com.zhiqiyun.open.core.enmus
 #######################redis###############################
-spring.redis.host=39.99.217.107
-spring.redis.password=hnylredis@
+spring.redis.host=8.136.137.115
+spring.redis.password=i6f7s5
 spring.redis.port=6379
 spring.redis.database=11
 ####################### oap config ###############################