hanzhengyi 2 лет назад
Сommit
7b00854096
28 измененных файлов с 569 добавлено и 0 удалено
  1. 8 0
      .idea/.gitignore
  2. 18 0
      .idea/compiler.xml
  3. 6 0
      .idea/encodings.xml
  4. 20 0
      .idea/jarRepositories.xml
  5. 14 0
      .idea/misc.xml
  6. 57 0
      pom.xml
  7. 21 0
      src/main/java/com/usky/Application.java
  8. 236 0
      src/main/java/com/usky/api/HkVideoApi.java
  9. 98 0
      src/main/java/com/usky/controller/web/party/HkVideoController.java
  10. 78 0
      src/main/java/com/usky/utils/StringUtils.java
  11. 2 0
      src/main/resources/application.properties
  12. 2 0
      target/classes/application.properties
  13. BIN
      target/classes/com/usky/Application.class
  14. BIN
      target/classes/com/usky/api/HkVideoApi$1.class
  15. BIN
      target/classes/com/usky/api/HkVideoApi$2.class
  16. BIN
      target/classes/com/usky/api/HkVideoApi$3.class
  17. BIN
      target/classes/com/usky/api/HkVideoApi$4.class
  18. BIN
      target/classes/com/usky/api/HkVideoApi.class
  19. BIN
      target/classes/com/usky/controller/web/party/HkVideoController.class
  20. BIN
      target/classes/com/usky/utils/StringUtils.class
  21. 3 0
      target/maven-archiver/pom.properties
  22. 0 0
      target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst
  23. 4 0
      target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst
  24. 0 0
      target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst
  25. 0 0
      target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst
  26. BIN
      target/ysPark-1.0-SNAPSHOT.jar
  27. BIN
      target/ysPark-1.0-SNAPSHOT.jar.original
  28. 2 0
      ysPark.iml

+ 8 - 0
.idea/.gitignore

@@ -0,0 +1,8 @@
+# Default ignored files
+/shelf/
+/workspace.xml
+# Datasource local storage ignored files
+/../../../../:\文档和图片\ysPark\.idea/dataSources/
+/dataSources.local.xml
+# Editor-based HTTP Client requests
+/httpRequests/

+ 18 - 0
.idea/compiler.xml

@@ -0,0 +1,18 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="CompilerConfiguration">
+    <annotationProcessing>
+      <profile name="Maven default annotation processors profile" enabled="true">
+        <sourceOutputDir name="target/generated-sources/annotations" />
+        <sourceTestOutputDir name="target/generated-test-sources/test-annotations" />
+        <outputRelativeToContentRoot value="true" />
+        <module name="ysPark" />
+      </profile>
+    </annotationProcessing>
+  </component>
+  <component name="JavacSettings">
+    <option name="ADDITIONAL_OPTIONS_OVERRIDE">
+      <module name="ysPark" options="-parameters" />
+    </option>
+  </component>
+</project>

+ 6 - 0
.idea/encodings.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="Encoding">
+    <file url="file://$PROJECT_DIR$/src/main/java" charset="UTF-8" />
+  </component>
+</project>

+ 20 - 0
.idea/jarRepositories.xml

@@ -0,0 +1,20 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="RemoteRepositoriesConfiguration">
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Central Repository" />
+      <option name="url" value="https://repo.maven.apache.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="central" />
+      <option name="name" value="Maven Central repository" />
+      <option name="url" value="https://repo1.maven.org/maven2" />
+    </remote-repository>
+    <remote-repository>
+      <option name="id" value="jboss.community" />
+      <option name="name" value="JBoss Community repository" />
+      <option name="url" value="https://repository.jboss.org/nexus/content/repositories/public/" />
+    </remote-repository>
+  </component>
+</project>

+ 14 - 0
.idea/misc.xml

@@ -0,0 +1,14 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project version="4">
+  <component name="ExternalStorageConfigurationManager" enabled="true" />
+  <component name="MavenProjectsManager">
+    <option name="originalFiles">
+      <list>
+        <option value="$PROJECT_DIR$/pom.xml" />
+      </list>
+    </option>
+  </component>
+  <component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" project-jdk-name="1.8" project-jdk-type="JavaSDK">
+    <output url="file://$PROJECT_DIR$/out" />
+  </component>
+</project>

+ 57 - 0
pom.xml

@@ -0,0 +1,57 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<project xmlns="http://maven.apache.org/POM/4.0.0"
+         xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+    <modelVersion>4.0.0</modelVersion>
+
+    <groupId>org.example</groupId>
+    <artifactId>ysPark</artifactId>
+    <version>1.0-SNAPSHOT</version>
+
+    <parent>
+        <groupId>org.springframework.boot</groupId>
+        <artifactId>spring-boot-starter-parent</artifactId>
+        <version>2.2.8.RELEASE</version>
+        <relativePath></relativePath>
+    </parent>
+
+    <!--    导入动态web场景启动器    -->
+
+    <dependencies>
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-web</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>com.alibaba</groupId>
+            <artifactId>fastjson</artifactId>
+            <version>1.2.35</version>
+        </dependency>
+        <dependency>
+            <groupId>com.hikvision.ga</groupId>
+            <artifactId>artemis-http-client</artifactId>
+            <version>1.1.3</version>
+            <exclusions>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-core</artifactId>
+                </exclusion>
+                <exclusion>
+                    <groupId>ch.qos.logback</groupId>
+                    <artifactId>logback-classic</artifactId>
+                </exclusion>
+            </exclusions>
+        </dependency>
+    </dependencies>
+
+    <!--添加maven插件,项目的打包工具,打成jar包,否则在打包运行时报错   -->
+
+    <build>
+        <plugins>
+            <plugin>
+                <groupId>org.springframework.boot</groupId>
+                <artifactId>spring-boot-maven-plugin</artifactId>
+            </plugin>
+        </plugins>
+    </build>
+</project>

+ 21 - 0
src/main/java/com/usky/Application.java

@@ -0,0 +1,21 @@
+package com.usky;
+
+import org.springframework.boot.SpringApplication;
+import org.springframework.boot.autoconfigure.SpringBootApplication;
+import org.springframework.scheduling.annotation.EnableScheduling;
+
+/**
+ * @author han
+ * @version v1.0
+ * @date 2023/10/29 13:27
+ * @description TODO
+ **/
+@SpringBootApplication
+@EnableScheduling
+public class Application {
+    public static void main(String[] args) {
+        SpringApplication.run(Application.class, args);
+
+    }
+
+}

+ 236 - 0
src/main/java/com/usky/api/HkVideoApi.java

@@ -0,0 +1,236 @@
+package com.usky.api;
+
+import com.alibaba.fastjson.JSONObject;
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import com.usky.utils.StringUtils;
+
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * 海康视频api
+ * @author han
+ * @date 2023/10/29 13:21
+ */
+
+public class HkVideoApi {
+    static {
+        /**
+         * 添加连接配置
+         */
+        ArtemisConfig.host = "172.20.10.2:443";
+        /**
+         * 密钥appkey
+         */
+        ArtemisConfig.appKey = "21491855";
+        /**
+         * 密钥appSecret
+         */
+        ArtemisConfig.appSecret = "VhhP8pf7vDRdKSKu9edi";
+    }
+
+    /**
+     * 获取监测点信息
+     * @return
+     */
+    public static String getCameraPreviewURL(Integer current,Integer size) {
+        /**
+         * 获取监控点资源接口
+         */
+        /**
+         * STEP2:设置OpenAPI接口的上下文
+         */
+        final String ARTEMIS_PATH = "/artemis";
+        final String url = ARTEMIS_PATH + "/api/resource/v1/cameras";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", url);//根据现场环境部署确认是http还是https
+            }
+        };
+
+        /**
+         * 添加请求参数
+         */
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("pageNo", current);
+        jsonBody.put("pageSize", size);
+        String body = jsonBody.toJSONString();
+        /**
+         * STEP4:设置参数提交方式
+         */
+        String contentType = "application/json";
+        return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
+    }
+
+
+    /**
+     * 获取监测点信息
+     * @return
+     */
+    public static String getNodes(String name,String[] regionIndexCodes,Boolean isSubRegion,Integer pageNo,Integer pageSize,
+                                         String[] authCodes,Object[] expressions,String orderBy,String orderType) {
+        /**
+         * 获取监控点资源接口
+         */
+        /**
+         * STEP2:设置OpenAPI接口的上下文
+         */
+        final String ARTEMIS_PATH = "/artemis";
+        final String url = ARTEMIS_PATH + "/api/resource/v2/camera/search";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", url);//根据现场环境部署确认是http还是https
+            }
+        };
+
+        /**
+         * 添加请求参数
+         */
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("name", name);
+        jsonBody.put("regionIndexCodes", regionIndexCodes);
+        jsonBody.put("isSubRegion", isSubRegion);
+        jsonBody.put("pageNo", pageNo);
+        jsonBody.put("pageSize", pageSize);
+        jsonBody.put("authCodes", authCodes);
+        jsonBody.put("expressions", expressions);
+        jsonBody.put("orderBy", orderBy);
+        jsonBody.put("orderType", orderType);
+        String body = jsonBody.toJSONString();
+        /**
+         * STEP4:设置参数提交方式
+         */
+        String contentType = "application/json";
+        return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
+    }
+
+    /**
+     * 实时视频
+     * @param cameraIndexCode
+     * @param streamType
+     * @param protocol
+     * @param transmode
+     * @param expand
+     * @param streamform
+     * @return
+     */
+    public static String getVideoUrl(String cameraIndexCode, Integer streamType,String protocol,Integer transmode,String expand,
+                                     String streamform){
+        /**
+         * 获取视频资源
+         */
+        /**
+         * STEP2:设置OpenAPI接口的上下文
+         */
+        final String ARTEMIS_PATH = "/artemis";
+        final String url = ARTEMIS_PATH+"/api/video/v1/cameras/previewURLs";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", url);//根据现场环境部署确认是http还是https
+            }
+        };
+        /**
+         * 添加请求参数
+         */
+        JSONObject jsonBody = new JSONObject();
+        if (StringUtils.isNotBlank(cameraIndexCode)){
+            jsonBody.put("cameraIndexCode", cameraIndexCode);
+        }
+        if (null != streamType){
+            jsonBody.put("streamType", streamType);
+        }
+        if (StringUtils.isNotBlank(protocol)){
+            jsonBody.put("protocol", protocol);
+        }
+        if (null != transmode){
+            jsonBody.put("transmode", transmode);
+        }
+        if (StringUtils.isNotBlank(expand)){
+            jsonBody.put("expand", expand);
+        }
+        if (StringUtils.isNotBlank(streamform)){
+            jsonBody.put("streamform", streamform);
+        }
+        String body = jsonBody.toJSONString();
+        /**
+         * STEP4:设置参数提交方式
+         */
+        String contentType = "application/json";
+        return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
+    }
+
+    /**
+     * 视频回放
+     * @param cameraIndexCode
+     * @param recordLocation
+     * @param protocol
+     * @param transmode
+     * @param beginTime
+     * @param endTime
+     * @param uuid
+     * @param expand
+     * @param streamform
+     * @param lockType
+     * @return
+     */
+    public static String getPlayBackUrl(String cameraIndexCode, Integer recordLocation,String protocol,
+                                        Integer transmode,String beginTime, String endTime,
+                                        String uuid,String expand,String streamform,Integer lockType){
+
+        /**
+         * 获取视频资源
+         */
+        /**
+         * STEP2:设置OpenAPI接口的上下文
+         */
+        final String ARTEMIS_PATH = "/artemis";
+        final String url = ARTEMIS_PATH+"/api/video/v2/cameras/playbackURLs";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", url);//根据现场环境部署确认是http还是https
+            }
+        };
+        /**
+         * 添加请求参数
+         */
+        JSONObject jsonBody = new JSONObject();
+
+        if (StringUtils.isNotBlank(cameraIndexCode)){
+            jsonBody.put("cameraIndexCode", cameraIndexCode);
+        }
+        if (null != recordLocation){
+            jsonBody.put("recordLocation", recordLocation);
+        }
+        if (StringUtils.isNotBlank(protocol)){
+            jsonBody.put("protocol", protocol);
+        }
+        if (null != transmode){
+            jsonBody.put("transmode", transmode);
+        }
+        if (StringUtils.isNotBlank(beginTime)){
+            jsonBody.put("beginTime", beginTime);
+        }
+        if (StringUtils.isNotBlank(endTime)){
+            jsonBody.put("endTime", endTime);
+        }
+        if (StringUtils.isNotBlank(uuid)){
+            jsonBody.put("uuid", uuid);
+        }
+        if (StringUtils.isNotBlank(expand)){
+            jsonBody.put("expand", expand);
+        }
+        if (StringUtils.isNotBlank(streamform)){
+            jsonBody.put("streamform", streamform);
+        }
+        if (null != lockType){
+            jsonBody.put("lockType", lockType);
+        }
+        String body = jsonBody.toJSONString();
+        /**
+         * STEP4:设置参数提交方式
+         */
+        String contentType = "application/json";
+        return ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);
+    }
+}

+ 98 - 0
src/main/java/com/usky/controller/web/party/HkVideoController.java

@@ -0,0 +1,98 @@
+package com.usky.controller.web.party;
+
+import com.usky.api.HkVideoApi;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+/**
+ * @author yq
+ * @date 2021/11/23 16:20
+ */
+@RestController
+public class HkVideoController {
+
+    @GetMapping("hello")
+    public String hello() {
+        return "Hello Word";
+    }
+
+    /**
+     * 获取监测点信息
+     * @param current
+     * @param size
+     * @return
+     */
+    @GetMapping("cameraPreviewURL")
+    public String getCameraPreview(@RequestParam Integer current, @RequestParam Integer size) {
+        return HkVideoApi.getCameraPreviewURL(current,size);
+    }
+
+
+    /**
+     * 获取视频信息
+     * @param cameraIndexCode
+     * @param streamType
+     * @param protocol
+     * @param transmode
+     * @param expand
+     * @param streamform
+     * @return
+     */
+    @GetMapping("videoUrl")
+    public String getVideoUrl(@RequestParam String cameraIndexCode,
+                              @RequestParam(required = false) Integer streamType,
+                              @RequestParam(required = false) String protocol,
+                              @RequestParam(required = false) Integer transmode,
+                              @RequestParam(required = false) String expand,
+                              @RequestParam(required = false) String streamform){
+        return HkVideoApi.getVideoUrl(cameraIndexCode,streamType,protocol,transmode,expand,streamform);
+    }
+
+    /**
+     * 查看回放功能
+     * @param cameraIndexCode
+     * @param recordLocation
+     * @param protocol
+     * @param transmode
+     * @param beginTime
+     * @param endTime
+     * @param uuid
+     * @param expand
+     * @param streamform
+     * @param lockType
+     * @return
+     */
+    @GetMapping("playBackUrl")
+    public String getPlayBackUrl(@RequestParam String cameraIndexCode,
+                                 @RequestParam(required = false) Integer recordLocation,
+                                 @RequestParam(required = false) String protocol,
+                                 @RequestParam(required = false) Integer transmode,
+                                 @RequestParam(required = false) String beginTime,
+                                 @RequestParam(required = false)String endTime,
+                                 @RequestParam(required = false) String uuid,
+                                 @RequestParam(required = false) String expand,
+                                 @RequestParam(required = false) String streamform,
+                                 @RequestParam(required = false) Integer lockType){
+        return HkVideoApi.getPlayBackUrl(cameraIndexCode,recordLocation,protocol,transmode,beginTime,endTime,uuid,expand,streamform,lockType);
+    }
+
+
+    /**
+     * 筛选获取监测点信息
+     * @return
+     */
+    @GetMapping("nodes")
+    public String getNodes(@RequestParam(required = false) String name,
+                           @RequestParam(required = false,value = "regionIndexCodes[]") String[] regionIndexCodes,
+                           @RequestParam(required = false) Boolean isSubRegion,
+                           @RequestParam Integer pageNo,
+                           @RequestParam Integer pageSize,
+                           @RequestParam(required = false,value = "authCodes[]") String[] authCodes,
+                           @RequestParam(required = false) String orderBy,
+                           @RequestParam(required = false,value = "expressions[]") String[] expressions,
+                           @RequestParam(required = false) String orderType){
+        return HkVideoApi.getNodes(name, null, isSubRegion, pageNo, pageSize, null, null, orderBy, orderType);
+    }
+
+}

+ 78 - 0
src/main/java/com/usky/utils/StringUtils.java

@@ -0,0 +1,78 @@
+package com.usky.utils;
+
+/**
+ * @author barrychen
+ */
+public final class StringUtils extends org.apache.commons.lang3.StringUtils {
+
+    /**
+     * 下划线
+     */
+    private static final char SEPARATOR = '_';
+
+    private StringUtils() {
+    }
+
+    /**
+     * 下划线转驼峰命名
+     */
+    public static String toUnderScoreCase(String str) {
+        if (str == null) {
+            return null;
+        }
+        StringBuilder sb = new StringBuilder();
+        // 前置字符是否大写
+        boolean preCharIsUpperCase = true;
+        // 当前字符是否大写
+        boolean curreCharIsUpperCase = true;
+        // 下一字符是否大写
+        boolean nexteCharIsUpperCase = true;
+        for (int i = 0; i < str.length(); i++) {
+            char c = str.charAt(i);
+            if (i > 0) {
+                preCharIsUpperCase = Character.isUpperCase(str.charAt(i - 1));
+            } else {
+                preCharIsUpperCase = false;
+            }
+
+            curreCharIsUpperCase = Character.isUpperCase(c);
+
+            if (i < (str.length() - 1)) {
+                nexteCharIsUpperCase = Character.isUpperCase(str.charAt(i + 1));
+            }
+
+            if (preCharIsUpperCase && curreCharIsUpperCase && !nexteCharIsUpperCase) {
+                sb.append(SEPARATOR);
+            } else if ((i != 0 && !preCharIsUpperCase) && curreCharIsUpperCase) {
+                sb.append(SEPARATOR);
+            }
+            sb.append(Character.toLowerCase(c));
+        }
+
+        return sb.toString();
+    }
+
+    /**
+     * * 判断一个对象是否为空
+     *
+     * @param object Object
+     * @return true:为空 false:非空
+     */
+    public static boolean isNull(Object object)
+    {
+        return object == null;
+    }
+
+    /**
+     * * 判断一个对象是否非空
+     *
+     * @param object Object
+     * @return true:非空 false:空
+     */
+    public static boolean isNotNull(Object object)
+    {
+        return !isNull(object);
+    }
+
+
+}

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

@@ -0,0 +1,2 @@
+server.port=8082
+server.servlet.context-path=/boBo

+ 2 - 0
target/classes/application.properties

@@ -0,0 +1,2 @@
+server.port=8082
+server.servlet.context-path=/boBo

BIN
target/classes/com/usky/Application.class


BIN
target/classes/com/usky/api/HkVideoApi$1.class


BIN
target/classes/com/usky/api/HkVideoApi$2.class


BIN
target/classes/com/usky/api/HkVideoApi$3.class


BIN
target/classes/com/usky/api/HkVideoApi$4.class


BIN
target/classes/com/usky/api/HkVideoApi.class


BIN
target/classes/com/usky/controller/web/party/HkVideoController.class


BIN
target/classes/com/usky/utils/StringUtils.class


+ 3 - 0
target/maven-archiver/pom.properties

@@ -0,0 +1,3 @@
+version=1.0-SNAPSHOT
+groupId=org.example
+artifactId=ysPark

+ 0 - 0
target/maven-status/maven-compiler-plugin/compile/default-compile/createdFiles.lst


+ 4 - 0
target/maven-status/maven-compiler-plugin/compile/default-compile/inputFiles.lst

@@ -0,0 +1,4 @@
+D:\文档和图片\ysPark\src\main\java\com\usky\api\HkVideoApi.java
+D:\文档和图片\ysPark\src\main\java\com\usky\Application.java
+D:\文档和图片\ysPark\src\main\java\com\usky\controller\web\party\HkVideoController.java
+D:\文档和图片\ysPark\src\main\java\com\usky\utils\StringUtils.java

+ 0 - 0
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/createdFiles.lst


+ 0 - 0
target/maven-status/maven-compiler-plugin/testCompile/default-testCompile/inputFiles.lst


BIN
target/ysPark-1.0-SNAPSHOT.jar


BIN
target/ysPark-1.0-SNAPSHOT.jar.original


+ 2 - 0
ysPark.iml

@@ -0,0 +1,2 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<module type="JAVA_MODULE" version="4" />