Kaynağa Gözat

开发调取天网相机接口

gao.qiang 8 ay önce
ebeveyn
işleme
9aa7fb6fe2

+ 44 - 0
business-service/src/main/java/com/ozs/utils/CameraUtil.java

@@ -1108,6 +1108,50 @@ ffmpeg -i "concat:1.ts|2.ts" -c copy output.mp4
 
     }
 
+    public static String getCameraPreviewURL() {
+
+        /**
+         * STEP1:设置平台参数,根据实际情况,设置host appkey appsecret 三个参数.
+         */
+        ArtemisConfig.host = host; // 平台的ip端口
+        ArtemisConfig.appKey = appKey;  // 密钥appkey
+        ArtemisConfig.appSecret = appSecret;// 密钥appSecret
+
+        /**
+         * STEP2:设置OpenAPI接口的上下文
+         */
+        final String ARTEMIS_PATH = "/artemis";
+
+        /**
+         * STEP3:设置接口的URI地址
+         */
+        final String previewURLsApi = ARTEMIS_PATH+"/api/resource/v1/camera/advance/cameraList";
+        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", 999);
+        String body = jsonBody.toJSONString();
+        /**
+         * STEP6:调用接口
+         */
+        String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType , null);// post请求application/json类型参数
+        log.info("GetCameraPreviewURL----->"+result);
+        return result;
+    }
+
     /**
      * 天网接口
      *

+ 7 - 24
vehicle-sdk/src/main/java/com/ozs/controller/upload/GeoHazardMonitorTokenController.java

@@ -1466,18 +1466,14 @@ public class GeoHazardMonitorTokenController {
                 }
                 baseVideoTrainsService.save(baseVideoTrains);
                 log.info("---------data---结果-------" + respHeartbeatVo);
-                if (ObjectUtils.isEmpty(respHeartbeatVo.getPreAlarmList())) {
-                    if (!ObjectUtils.isEmpty(respHeartbeatVo.getCameraList())) {
-                        if (respHeartbeatVo.getCameraList().get(0).getCameraCode().equals("")) {
-                            AjaxResults1 = new AjaxResults(1, "该里程无摄像机", respHeartbeatVo);
-                        }else {
-                            AjaxResults1 = new AjaxResults(1, "ok", respHeartbeatVo);
-                        }
+                if (!ObjectUtils.isEmpty(respHeartbeatVo.getCameraList())) {
+                    if (respHeartbeatVo.getCameraList().get(0).getCameraCode().equals("")) {
+                        AjaxResults1 = new AjaxResults(1, "该里程无摄像机", respHeartbeatVo);
                     } else {
-                        AjaxResults1 = new AjaxResults(0, "视频加载中", respHeartbeatVo);
+                        AjaxResults1 = new AjaxResults(1, "ok", respHeartbeatVo);
                     }
                 } else {
-                    AjaxResults1 = new AjaxResults(1, "ok", respHeartbeatVo);
+                    AjaxResults1 = new AjaxResults(0, "视频加载中", respHeartbeatVo);
                 }
                 long end = System.currentTimeMillis();
                 log.info("结束心跳时间: " + sdf.format(new Date(end)));
@@ -2205,21 +2201,8 @@ public class GeoHazardMonitorTokenController {
      *
      * @return
      */
-    @PostMapping("/api/ttt")
+    @GetMapping("/api/ttt")
     public void ttt() {
-        String urLs = cameraUtil.playbackURLs("12a38b545afb4e3cb22f962ceac914cf", "5", "5");
-//                        if (urLs.contains("无视频")) {
-//                            return urLs;
-//                        }
-        String playback = CameraUtil.startRecording("12a38b545afb4e3cb22f962ceac914cf", "playback");
-//                        if (!"ok".equals(playback)){
-//                            return "暂无视频-" + finalCode; 
-//                        }
-        SimpleDateFormat sdf = new SimpleDateFormat("yyyy-MM-dd");
-        // 使用SimpleDateFormat将Date对象格式化为指定样式的字符串
-        String formattedDate = sdf.format(new Date());
-        log.info("-----formattedDate-----------" + formattedDate);
-        String records = cameraUtil.getQueryRecords("12a38b545afb4e3cb22f962ceac914cf" + "/playback", formattedDate);
-        log.info("-----records-----------" + records);
+        String cameraPreviewURL = cameraUtil.getCameraPreviewURL();
     }
 }