Browse Source

天网测试接口

gao.qiang 1 year ago
parent
commit
0c7cecee2f

+ 5 - 0
vehicle-admin/pom.xml

@@ -35,6 +35,11 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-websocket</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.hikvision.ga</groupId>
+            <artifactId>artemis-http-client</artifactId>
+            <version>1.1.3</version>
+        </dependency>
 
         <!-- swagger3-->
         <!--        <dependency>-->

+ 9 - 0
vehicle-admin/src/main/java/com/ozs/web/controller/accountmanagment/BaseCameraManagementController.java

@@ -24,6 +24,7 @@ import com.ozs.service.*;
 import com.ozs.system.service.DataScoreUtil;
 import com.ozs.system.service.ISysDeptService;
 import com.ozs.web.core.config.CaneraConfig;
+import com.ozs.web.core.config.GetCameraPreviewURL;
 import com.ozs.web.core.util.CameraUtil;
 import io.swagger.annotations.ApiOperation;
 import lombok.extern.slf4j.Slf4j;
@@ -998,5 +999,13 @@ public class BaseCameraManagementController extends BaseController {
             return error("该相机编码在相机台账表中不存在");
         }
     }
+
+    @GetMapping(value = "/getCameraPreviewURL")
+    @ApiOperation("天网接口测试")
+    @Log(title = "相机台账管理", businessType = BusinessType.MESSAGE)
+    public AjaxResult getCameraPreviewURL() {
+        String cameraPreviewURL = GetCameraPreviewURL.getCameraPreviewURL();
+        return AjaxResult.success(cameraPreviewURL);
+    }
 }
 

+ 1 - 1
vehicle-admin/src/main/java/com/ozs/web/core/config/CaneraConfig.java

@@ -47,7 +47,7 @@ public class CaneraConfig {
     @Value("${base.recordUrl:http://183.236.39.220:8083}")
     private String recordUrl;
 
-    @Value("${base.hkUrl:http://10.122.1.22:1443}")
+    @Value("${base.hkUrl:http://10.48.253.21:1443}")
     private String hkUrl;
     
 }

+ 60 - 0
vehicle-admin/src/main/java/com/ozs/web/core/config/GetCameraPreviewURL.java

@@ -0,0 +1,60 @@
+package com.ozs.web.core.config;
+
+import com.alibaba.fastjson2.JSONObject;
+import com.hikvision.artemis.sdk.ArtemisHttpUtil;
+import com.hikvision.artemis.sdk.config.ArtemisConfig;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.context.annotation.Configuration;
+
+import java.util.HashMap;
+import java.util.Map;
+
+
+@Configuration
+@Slf4j
+public class GetCameraPreviewURL {
+    public static String getCameraPreviewURL() {
+
+        /**
+         * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
+         */
+        ArtemisConfig.host = "10.48.253.21:1443"; // 平台的ip端口
+        ArtemisConfig.appKey = "20110033";  // 密钥appkey
+        ArtemisConfig.appSecret = "QoGESFXOYrC68ixIS7wo";// 密钥appSecret
+
+        /**
+         * STEP2:设置OpenAPI接口的上下文
+         */
+        final String ARTEMIS_PATH = "/artemis";
+
+        /**
+         * STEP3:设置接口的URI地址
+         */
+        final String previewURLsApi = ARTEMIS_PATH + "/api/resource/v2/encodeDevice/search";
+        Map<String, String> path = new HashMap<String, String>(2) {
+            {
+                put("https://", previewURLsApi);//根据现场环境部署确认是http还是https
+            }
+        };
+
+        /**
+         * STEP4:设置参数提交方式
+         */
+        String contentType = "application/json";
+
+        /**
+         * STEP5:组装请求参数
+         */
+        JSONObject jsonBody = new JSONObject();
+        jsonBody.put("pageNo", 1);
+        jsonBody.put("pageSize", 10);
+        String body = jsonBody.toJSONString();
+        /**
+         * STEP6:调用接口
+         */
+        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
+        log.info("GetCameraPreviewURL----->"+result);
+        return result;
+    }
+    
+}