浏览代码

回放修改2.7

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

+ 92 - 65
huimv-farm-video/src/main/java/com/huimv/video/dhicc/test/controller/VideoRecorControllerSg.java

@@ -14,10 +14,7 @@ import com.huimv.video.dhicc.result.R;
 import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
 import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
 import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo03;
-import com.huimv.video.dhicc.test.request.Video.VideoRecordQueryRequestSg;
-import com.huimv.video.dhicc.test.request.Video.VideoRecordRequestCn;
-import com.huimv.video.dhicc.test.request.Video.VideoRecordRequestHn;
-import com.huimv.video.dhicc.test.request.Video.VideoRecordRequestSg;
+import com.huimv.video.dhicc.test.request.Video.*;
 import net.sf.json.JSONObject;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.RequestBody;
@@ -50,16 +47,15 @@ public class VideoRecorControllerSg {
     @RequestMapping("/getVideoRecord")
     public R getVideoRecord(@RequestBody Map<String, Object> params1) throws ClientException, ParseException {
         String happendTime = (String) params1.get("happendTime");
-        String channelId = (String) params1.get("nodeCode");
         Integer farmId = (Integer) params1.get("farmId");
         String channelName = (String) params1.get("channelName");
 
         LambdaQueryWrapper<IccChannel> wrapper3 = Wrappers.lambdaQuery();
         wrapper3.eq(IccChannel::getChannelName, channelName);
+        wrapper3.eq(IccChannel::getRemark, farmId);
         IccChannel iccChannel = iccChannelMapper.selectOne(wrapper3);
         System.out.println(iccChannel);
 
-
         //开始结束时间代为处理
         DateFormat fmt = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
         //格式化传入的时间---拿传入时间前后五分钟的视频
@@ -77,72 +73,103 @@ public class VideoRecorControllerSg {
         test.put("endTime", after);
         test.put("streamType", "0");
         test.put("recordType", "0");
-        VideoRecordQueryRequestSg queryRequestSg = new VideoRecordQueryRequestSg(oauthConfigBaseInfo);
-        queryRequestSg.setData(test);
-        System.out.println(queryRequestSg);
-        com.alibaba.fastjson.JSONObject jsonObject2 = queryRequestSg.doAction();
-        System.out.println(jsonObject2);
-        JSONArray jsonArray = JSONArray.parseArray(jsonObject2.get("records").toString());
-        System.out.println(jsonArray);
-        if (ObjectUtil.isEmpty(jsonArray)) {
-            return R.error("没有录像回放");
-        } else {
+        if (farmId == 1) {
+            System.out.println("曙光");
+            VideoRecordQueryRequestSg queryRequestSg = new VideoRecordQueryRequestSg(oauthConfigBaseInfo);
+            queryRequestSg.setData(test);
+            System.out.println(queryRequestSg);
+            com.alibaba.fastjson.JSONObject jsonObject2 = queryRequestSg.doAction();
+            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", json.get("channelId"));
+            value.put("endTime", json.get("endTime"));
+            value.put("startTime", json.get("startTime"));
+
+            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("海宁");
+            VideoRecordQueryRequestHn queryRequestHn = new VideoRecordQueryRequestHn(oauthConfigBaseInfo02);
+            queryRequestHn.setData(test);
+            System.out.println(queryRequestHn);
+            com.alibaba.fastjson.JSONObject jsonObject2 = queryRequestHn.doAction();
+            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);
-            } else {
-                return R.error();
-            }
+            value.put("channelId", json.get("channelId"));
+            value.put("endTime", json.get("endTime"));
+            value.put("startTime", json.get("startTime"));
+
+            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("苍南");
+            VideoRecordQueryRequestCn queryRequestCn = new VideoRecordQueryRequestCn(oauthConfigBaseInfo03);
+            queryRequestCn.setData(test);
+            System.out.println(queryRequestCn);
+            com.alibaba.fastjson.JSONObject jsonObject2 = queryRequestCn.doAction();
+            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", json.get("channelId"));
+            value.put("endTime", json.get("endTime"));
+            value.put("startTime", json.get("startTime"));
+
+            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();
         }
+
     }
 
 

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

@@ -0,0 +1,62 @@
+package com.huimv.video.dhicc.test.request.Video;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo03;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.request.BaseRequest;
+import com.huimv.video.dhicc.test.request.BaseRequest03;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+public class VideoRecordQueryRequestCn extends BaseRequest03<JSONObject> {
+
+
+    private Map<String,Object> data;
+
+
+    public VideoRecordQueryRequestCn() {
+    }
+
+    public VideoRecordQueryRequestCn(OauthConfigBaseInfo03 oauthConfigBaseInfo) {
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.CHANNEL_URL_VIDEO_QUERY, true);
+    }
+
+    @Override
+    public JSONObject doAction() {
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader()) : HttpsURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader());
+     //   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);
+
+        return data;
+    }
+
+    private void setBody() {
+        //设置请求参数
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", this.data);
+        this.setBody(JSON.toJSONString(map));
+
+    }
+
+
+    public boolean isEnableHttpTest() {
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}

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

@@ -0,0 +1,62 @@
+package com.huimv.video.dhicc.test.request.Video;
+
+import com.alibaba.fastjson.JSON;
+import com.alibaba.fastjson.JSONObject;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo;
+import com.huimv.video.dhicc.test.config.OauthConfigBaseInfo02;
+import com.huimv.video.dhicc.test.constant.Constant;
+import com.huimv.video.dhicc.test.request.BaseRequest;
+import com.huimv.video.dhicc.test.request.BaseRequest02;
+import com.huimv.video.dhicc.test.utils.HttpURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.HttpsURLConnectionUtil;
+import com.huimv.video.dhicc.test.utils.UrlUtil;
+import lombok.Data;
+
+import java.util.HashMap;
+import java.util.Map;
+
+@Data
+public class VideoRecordQueryRequestHn extends BaseRequest02<JSONObject> {
+
+
+    private Map<String,Object> data;
+
+
+    public VideoRecordQueryRequestHn() {
+    }
+
+    public VideoRecordQueryRequestHn(OauthConfigBaseInfo02 oauthConfigBaseInfo) {
+        super(oauthConfigBaseInfo, Constant.HTTP_POST, oauthConfigBaseInfo.getHttpConfigInfo().getPrefixUrl() + Constant.CHANNEL_URL_VIDEO_QUERY, true);
+    }
+
+    @Override
+    public JSONObject doAction() {
+        //重置url信息,替换版本号
+        this.setUrl(UrlUtil.dealVersion(this.getUrl()));
+        //设置请求参数
+        setBody();
+        //发送请求
+        String res = isEnableHttpTest() ? HttpURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader()) : HttpsURLConnectionUtil.doPost(this.getUrl(), this.getBody(), this.getHeader());
+     //   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);
+
+        return data;
+    }
+
+    private void setBody() {
+        //设置请求参数
+        Map<String, Object> map = new HashMap<>();
+        map.put("data", this.data);
+        this.setBody(JSON.toJSONString(map));
+
+    }
+
+
+    public boolean isEnableHttpTest() {
+        return super.getOauthConfigBaseInfo().getHttpConfigInfo().isEnableHttpTest();
+    }
+}