Browse Source

'设备管理-照明开关状态控制、设备管理-监控系统实时视频预览取流、设备管理-监控系统云台操作和设备管理-门禁系统门禁点反控四个接口'

james 2 years ago
parent
commit
6ec996e72f

+ 153 - 0
service-park/service-park-biz/src/main/java/com/usky/park/controller/web/DeviceHttpController.java

@@ -0,0 +1,153 @@
+package com.usky.park.controller.web;
+
+
+import com.alibaba.nacos.common.utils.StringUtils;
+import com.usky.common.core.exception.BusinessException;
+import com.usky.common.core.util.HttpUtils;
+import org.springframework.web.bind.annotation.GetMapping;
+import org.springframework.web.bind.annotation.RequestMapping;
+import org.springframework.web.bind.annotation.RequestParam;
+import org.springframework.web.bind.annotation.RestController;
+
+import java.io.IOException;
+import java.util.Date;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * @author zyj
+ * @date 2023/2/24 14:52:05
+ */
+@RestController
+@RequestMapping("deviceHttp")
+public class DeviceHttpController {
+
+
+    public static final String light_url = "http://172.17.35.51:15224";
+    public static final String video_url = "http://172.17.35.51:15225";
+    public static final String video1_url = "http://172.17.35.51:15226";
+    public static final String guard_url = "http://172.17.35.51:15227";
+
+    /**
+     * 设备管理-照明开关状态控制
+     *
+     * @param deviceId  设备Id
+     * @param switchStatus  开关状态(0 关 1 开)
+     * @return
+     */
+    @GetMapping("lightControl")
+    public static String lightControl(@RequestParam(value = "deviceId") String deviceId,
+                                      @RequestParam(value = "switchStatus") Integer switchStatus){
+        String result;
+        Map<String,Object> map = new HashMap<>();
+        map.put("jsonrpc","2.0");
+        map.put("method","lightControl");
+        Map<String,Object> map1 = new HashMap<>();
+        map1.put("device_id",deviceId);
+        map1.put("switch_status",switchStatus);
+        map.put("params",map1);
+        map.put("id",3);
+        try {
+            result  = HttpUtils.postJson(light_url,map,null);
+        } catch (IOException e) {
+            throw new BusinessException("设备管理-照明开关状态控制http调用异常"+e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 设备管理-监控系统实时视频预览取流
+     *
+     * @param deviceId  设备Id
+     * @param streamType  码流类型,0:主码流 1:子码流 2:第三码流 参数不填,默认为主码流
+     * @param protocol  取流协议(应用层协议),“rtsp”:RTSP协议,“rtmp”:RTMP协议,“hls”:HLS协议(HLS协议只支持海康SDK协议、EHOME协议、GB28181协议、ONVIF协议接入的设备;只支持H264视频编码和AAC音频编码),参数不填,默认为RTSP协议
+     * @param transmode  传输协议(传输层协议),0:UDP 1:TCP 默认是TCP 注: GB28181 2011及以前版本只支持UDP传输
+     * @return
+     */
+    @GetMapping("videoUrl")
+    public static String videoUrl(@RequestParam(value = "deviceId") String deviceId,
+                                  @RequestParam(value = "streamType") Integer streamType,
+                                  @RequestParam(value = "protocol") String protocol,
+                                  @RequestParam(value = "transmode") Integer transmode){
+        String result;
+        Map<String,Object> map = new HashMap<>();
+        map.put("jsonrpc","2.0");
+        map.put("method","videoUrl");
+        Map<String,Object> map1 = new HashMap<>();
+        map1.put("device_id",deviceId);
+        map1.put("streamType",streamType);
+        map1.put("protocol",protocol);
+        map1.put("transmode",transmode);
+        map.put("params",map1);
+        map.put("id",3);
+        try {
+            result  = HttpUtils.postJson(video_url,map,null);
+        } catch (IOException e) {
+            throw new BusinessException("设备管理-监控系统实时视频预览取流http调用异常"+e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 设备管理-监控系统云台操作
+     *
+     * @param deviceId  设备Id
+     * @param action  0-开始 1-停止 注:GOTO_PRESET命令下填任意值均可转到预置点,建议填0即可
+     * @param command  不区分大小写 说明: LEFT 左转 RIGHT右转 UP 上转 DOWN 下转 ZOOM_IN 焦距变大 ZOOM_OUT 焦距变小 LEFT_UP 左上 LEFT_DOWN 左下 RIGHT_UP 右上 RIGHT_DOWN 右下 FOCUS_NEAR 焦点前移 FOCUS_FAR 焦点后移 IRIS_ENLARGE 光圈扩大 IRIS_REDUCE 光圈缩小 WIPER_SWITCH 接通雨刷开关 START_RECORD_TRACK 开始记录轨迹 STOP_RECORD_TRACK 停止记录轨迹 START_TRACK 开始轨迹 STOP_TRACK 停止轨迹 以下命令presetIndex不可 为空: GOTO_PRESET到预置点
+     * @param speed  云台速度,取值范围为1-100,默认50
+     * @param presetIndex 预置点编号,整数,通常在300以内
+     * @return
+     */
+    @GetMapping("videoControl")
+    public static String videoControl(@RequestParam(value = "deviceId") String deviceId,
+                                    @RequestParam(value = "action") Integer action,
+                                    @RequestParam(value = "command") String command,
+                                    @RequestParam(value = "speed") Integer speed,
+                                     @RequestParam(value = "presetIndex") Integer presetIndex){
+        String result;
+        Map<String,Object> map = new HashMap<>();
+        map.put("jsonrpc","2.0");
+        map.put("method","videoControl");
+        Map<String,Object> map1 = new HashMap<>();
+        map1.put("device_id",deviceId);
+        map1.put("action",action);
+        map1.put("command",command);
+        map1.put("speed",speed);
+        map1.put("presetIndex",presetIndex);
+        map.put("params",map1);
+        map.put("id",3);
+        try {
+            result  = HttpUtils.postJson(video1_url,map,null);
+        } catch (IOException e) {
+            throw new BusinessException("设备管理-监控系统云台操作http调用异常"+e.getMessage());
+        }
+        return result;
+    }
+
+    /**
+     * 设备管理-门禁系统门禁点反控
+     *
+     * @param deviceId  设备Id
+     * @param controlType  0-常开 1-门闭 2-门开 3-常闭
+     * @return
+     */
+    @GetMapping("guardControl")
+    public static String guardControl(@RequestParam(value = "deviceId") String deviceId,
+                                      @RequestParam(value = "controlType") Integer controlType){
+        String result;
+        Map<String,Object> map = new HashMap<>();
+        map.put("jsonrpc","2.0");
+        map.put("method","guardControl");
+        Map<String,Object> map1 = new HashMap<>();
+        map1.put("device_id",deviceId);
+        map1.put("controlType",controlType);
+        map.put("params",map1);
+        map.put("id",3);
+        try {
+            result  = HttpUtils.postJson(guard_url,map,null);
+        } catch (IOException e) {
+            throw new BusinessException("设备管理-门禁系统门禁点反控http调用异常"+e.getMessage());
+        }
+        return result;
+    }
+}