浏览代码

回放修改2.5

wwh 2 年之前
父节点
当前提交
e0e3aba9ec

+ 58 - 54
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/VideoRecorControllerSg.java

@@ -3,6 +3,7 @@ package com.huimv.video.dhicc.test.controller;
 //拿视频回放
 
 
+import cn.hutool.core.util.ObjectUtil;
 import com.alibaba.fastjson.JSONArray;
 import com.dahuatech.icc.exception.ClientException;
 import com.huimv.video.dhicc.result.R;
@@ -71,62 +72,65 @@ public class VideoRecorControllerSg {
         System.out.println(jsonObject2);
         JSONArray jsonArray = JSONArray.parseArray(jsonObject2.get("records").toString());
         System.out.println(jsonArray);
-        com.alibaba.fastjson.JSONObject json = (com.alibaba.fastjson.JSONObject) jsonArray.get(0);
-        System.out.println(json);
-
-        Map<String, Object> value = new HashMap<>();
-        value.put("recordType", json.get("recordType"));
-        value.put("streamType", json.get("streamType"));
-        value.put("recordSource",json.get("recordSource"));
-        value.put("channelId", channelId);
-        value.put("endTime", json.get("startTime"));
-        value.put("startTime", json.get("endTime"));
-        if (farmId == 1) {
-            System.out.println("曙光");
-            VideoRecordRequestSg requestSg = new VideoRecordRequestSg(oauthConfigBaseInfo);
-            requestSg.setData(value);
-            Object jsonObject1 = requestSg.doAction();
-            System.out.println(jsonObject1);
-            String action = (String) JSONObject.fromObject(jsonObject1).get("url");
-            String token = (String) JSONObject.fromObject(jsonObject1).get("token");
-            String[] split = action.split("\\|");// |需要转义符
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("url", split[1] + "?token=" + token + "&trackID=701");
-            return R.ok().put("data", jsonObject);
-        } else if (farmId == 22) {
-            System.out.println("海宁");
-            VideoRecordRequestHn requestHn = new VideoRecordRequestHn(oauthConfigBaseInfo02);
-            requestHn.setClientMac("30:9c:23:79:40:08");
-            requestHn.setClientPushId("");
-            requestHn.setProject("PSDK");
-            requestHn.setMethod("SS.Playback.StartPlaybackByTime");
-            requestHn.setData(value);
-            Object jsonObject1 = requestHn.doAction();
-            String action = (String) JSONObject.fromObject(jsonObject1).get("url");
-            String token = (String) JSONObject.fromObject(jsonObject1).get("token");
-            String[] split = action.split("\\|");// |需要转义符
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("url", split[1] + "?token=" + token + "&trackID=701");
-            return R.ok().put("data", jsonObject);
-        } else if (farmId == 21) {
-            System.out.println("苍南");
-            VideoRecordRequestCn requestCn = new VideoRecordRequestCn(oauthConfigBaseInfo03);
-            requestCn.setClientMac("30:9c:23:79:40:08");
-            requestCn.setClientPushId("");
-            requestCn.setProject("PSDK");
-            requestCn.setMethod("SS.Playback.StartPlaybackByTime");
-            requestCn.setData(value);
-            Object jsonObject1 = requestCn.doAction();
-            String action = (String) JSONObject.fromObject(jsonObject1).get("url");
-            String token = (String) JSONObject.fromObject(jsonObject1).get("token");
-            String[] split = action.split("\\|");// |需要转义符
-            JSONObject jsonObject = new JSONObject();
-            jsonObject.put("url", split[1] + "?token=" + token + "&trackID=701");
-            return R.ok().put("data", jsonObject);
+        if (ObjectUtil.isEmpty(jsonArray)) {
+            return R.error("没有录像回放");
         } else {
-            return R.error();
+            com.alibaba.fastjson.JSONObject json = (com.alibaba.fastjson.JSONObject) jsonArray.get(0);
+            System.out.println(json);
+
+            Map<String, Object> value = new HashMap<>();
+            value.put("recordType", json.get("recordType"));
+            value.put("streamType", json.get("streamType"));
+            value.put("recordSource", json.get("recordSource"));
+            value.put("channelId", channelId);
+            value.put("endTime", json.get("startTime"));
+            value.put("startTime", json.get("endTime"));
+            if (farmId == 1) {
+                System.out.println("曙光");
+                VideoRecordRequestSg requestSg = new VideoRecordRequestSg(oauthConfigBaseInfo);
+                requestSg.setData(value);
+                Object jsonObject1 = requestSg.doAction();
+                System.out.println(jsonObject1);
+                String action = (String) JSONObject.fromObject(jsonObject1).get("url");
+                String token = (String) JSONObject.fromObject(jsonObject1).get("token");
+                String[] split = action.split("\\|");// |需要转义符
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("url", split[1] + "?token=" + token + "&trackID=701");
+                return R.ok().put("data", jsonObject);
+            } else if (farmId == 22) {
+                System.out.println("海宁");
+                VideoRecordRequestHn requestHn = new VideoRecordRequestHn(oauthConfigBaseInfo02);
+                requestHn.setClientMac("30:9c:23:79:40:08");
+                requestHn.setClientPushId("");
+                requestHn.setProject("PSDK");
+                requestHn.setMethod("SS.Playback.StartPlaybackByTime");
+                requestHn.setData(value);
+                Object jsonObject1 = requestHn.doAction();
+                String action = (String) JSONObject.fromObject(jsonObject1).get("url");
+                String token = (String) JSONObject.fromObject(jsonObject1).get("token");
+                String[] split = action.split("\\|");// |需要转义符
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("url", split[1] + "?token=" + token + "&trackID=701");
+                return R.ok().put("data", jsonObject);
+            } else if (farmId == 21) {
+                System.out.println("苍南");
+                VideoRecordRequestCn requestCn = new VideoRecordRequestCn(oauthConfigBaseInfo03);
+                requestCn.setClientMac("30:9c:23:79:40:08");
+                requestCn.setClientPushId("");
+                requestCn.setProject("PSDK");
+                requestCn.setMethod("SS.Playback.StartPlaybackByTime");
+                requestCn.setData(value);
+                Object jsonObject1 = requestCn.doAction();
+                String action = (String) JSONObject.fromObject(jsonObject1).get("url");
+                String token = (String) JSONObject.fromObject(jsonObject1).get("token");
+                String[] split = action.split("\\|");// |需要转义符
+                JSONObject jsonObject = new JSONObject();
+                jsonObject.put("url", split[1] + "?token=" + token + "&trackID=701");
+                return R.ok().put("data", jsonObject);
+            } else {
+                return R.error();
+            }
         }
-
     }
 
 

+ 1 - 0
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/request/Video/VideoRecordQueryRequestSg.java

@@ -38,6 +38,7 @@ public class VideoRecordQueryRequestSg extends BaseRequest<JSONObject> {
      //   System.out.println(res);
         //获取响应
         JSONObject jsonObject = JSONObject.parseObject(res);
+        System.out.println(jsonObject);
         JSONObject data = (JSONObject) jsonObject.get("data");
         // PersonListResponseSg devicePageResponse = JSON.parseObject(res, PersonListResponseSg.class);