Browse Source

开发产品命令表-列表、产品命令表-新增、产品命令表-修改和产品命令表-删除四个接口,以及在iot服务模块中新增下发门禁开门接口

james 5 months ago
parent
commit
d779e061e7

+ 11 - 0
service-iot/service-iot-biz/pom.xml

@@ -19,6 +19,11 @@
             <artifactId>service-backend-api</artifactId>
             <version>0.0.1</version>
         </dependency>
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>data-transfer-api</artifactId>
+            <version>0.0.1</version>
+        </dependency>
 
         <dependency>
             <groupId>com.usky</groupId>
@@ -26,6 +31,12 @@
             <version>0.0.1</version>
         </dependency>
 
+        <dependency>
+            <groupId>com.usky</groupId>
+            <artifactId>data-transfer-api</artifactId>
+            <version>0.0.1</version>
+        </dependency>
+
         <dependency>
             <groupId>cn.afterturn</groupId>
             <artifactId>easypoi-spring-boot-starter</artifactId>

+ 97 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/controller/web/DeviceHttpController.java

@@ -1,13 +1,24 @@
 package com.usky.iot.controller.web;
 
+import com.alibaba.fastjson.JSON;
 import com.usky.common.core.bean.ApiResult;
+import com.usky.common.core.exception.BusinessException;
+import com.usky.common.core.util.HttpUtils;
+import com.usky.common.core.util.StringUtils;
+import com.usky.common.security.utils.SecurityUtils;
 import com.usky.iot.service.BaseAlarmService;
 import com.usky.iot.service.DmpDataInfoService;
 import com.usky.iot.service.DmpDeviceStatusService;
 import com.usky.backend.domain.request.DmpDeviceDataRequestVO;
+import com.usky.transfer.RemoteTransferService;
+import org.apache.catalina.security.SecurityUtil;
 import org.springframework.beans.factory.annotation.Autowired;
 import org.springframework.web.bind.annotation.*;
 
+import java.io.IOException;
+import java.util.HashMap;
+import java.util.Map;
+
 /**
  * @author zyj
  * @date 2023/6/8 13:52:05
@@ -22,6 +33,9 @@ public class DeviceHttpController {
     @Autowired
     private DmpDataInfoService dmpDataInfoService;
 
+    @Autowired
+    private RemoteTransferService remoteTransferService;
+
     @GetMapping(value = "/status")
     public ApiResult<Void> status(){
         baseAlarmService.status();
@@ -39,5 +53,88 @@ public class DeviceHttpController {
         return ApiResult.success();
     }
 
+    /**
+     * 下发门禁开门
+     */
+    @GetMapping("/doorControl")
+    public ApiResult<Map<String,Object>> control(@RequestParam("productCode") String productCode,
+                                                 @RequestParam("deviceId") String deviceId,
+                                                 @RequestParam("commandCode") String commandCode,
+                                                 @RequestParam("commandValue") String commandValue){
+        Integer tenantId = SecurityUtils.getTenantId();
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("method","control");
+        Map<String,Object> map1 = new HashMap<>();
+        map1.put("device_id",deviceId);
+        map1.put("commandCode",commandCode);
+        map1.put("commandValue",commandValue);
+        map.put("params",map1);
+
+        return ApiResult.success(remoteTransferService.deviceControl(productCode,deviceId,JSON.toJSONString(map),tenantId));
+    }
+
+
+    /**
+     * 设备管理-海康监控系统实时视频预览取流
+     *
+     * @param productCode 产品编码
+     * @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("/hikVideoStream")
+    public ApiResult<Map<String, Object>> hikVideoStream(@RequestParam("productCode") String productCode,
+                                                         @RequestParam("deviceId") String deviceId,
+                                                         @RequestParam("streamType") Integer streamType,
+                                                         @RequestParam("protocol") String protocol,
+                                                         @RequestParam("transmode") Integer transmode){
+        Integer tenantId = SecurityUtils.getTenantId();
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("method","streamControl");
+        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);
+
+        return ApiResult.success(remoteTransferService.deviceControl(productCode,deviceId, JSON.toJSONString(map),tenantId));
+    }
+
+    /**
+     * 获取海康系统行车记录数据
+     * @param startTime
+     * @param endTime
+     * @param pageNo
+     * @param pageSize
+     * @return
+     */
+    @GetMapping("driverRecordList")
+    public ApiResult<Map<String,Object>> driverRecordList(@RequestParam(value = "startTime",required = false) String startTime,
+                                                          @RequestParam(value = "endTime",required = false) String endTime,
+                                                          @RequestParam(value = "pageNo") Integer pageNo,
+                                                          @RequestParam(value = "pageSize") Integer pageSize){
+        Integer tenantId = SecurityUtils.getTenantId();
+
+        Map<String,Object> map = new HashMap<>();
+        map.put("method","driverRecordControl");
+        Map<String,Object> map1 = new HashMap<>();
+        if(StringUtils.isNotBlank(startTime)){
+            map1.put("startTime",startTime);
+        }
+        if(StringUtils.isNotBlank(endTime)){
+            map1.put("endTime",endTime);
+        }
+        map1.put("pageNo",pageNo);
+        map1.put("pageSize",pageSize);
+        map.put("params",map1);
+
+        return ApiResult.success(remoteTransferService.deviceControl("501_HGHK","0001",JSON.toJSONString(map),tenantId));
+    }
+
 
 }

+ 38 - 0
service-iot/service-iot-biz/src/main/java/com/usky/iot/service/vo/DmpProductCommandRequestVO.java

@@ -0,0 +1,38 @@
+package com.usky.iot.service.vo;
+
+import lombok.Data;
+
+import java.io.Serializable;
+
+@Data
+public class DmpProductCommandRequestVO implements Serializable {
+
+    /**
+     * 页数
+     */
+    private Integer current;
+    /**
+     * 条数
+     */
+    private Integer size;
+
+    /**
+     * 产品编码
+     */
+    private String productCode;
+
+    /**
+     * 命令编码
+     */
+    private String commandCode;
+
+    /**
+     * 命令名称
+     */
+    private String commandName;
+
+    /**
+     * 命令描述
+     */
+    private String commandDescribe;
+}