1、设备详情安防页面数据第二版

2、增加监控获取连接地址
This commit is contained in:
wyw
2024-08-14 15:47:24 +08:00
parent 67a44caf49
commit 7356e2d199
8 changed files with 382 additions and 71 deletions

View File

@ -0,0 +1,50 @@
package com.fastbee.iot.domain;
import lombok.Data;
/**
* 设备参数设置对象 device_param_config
*
* @author mafa
* @date 2023-08-22
*/
@Data
public class JiankongDeviceParam
{
private static final long serialVersionUID = 1L;
/** 设备id */
private Long deviceId;
/** ezopen协议地址的本地录像/云存储录像回放开始时间,示例2019-12-01 00:00:00 */
private String startTime;
/** ezopen协议地址的本地录像/云存储录像回放开始时间,示例2019-12-01 00:00:00 */
private String stopTime;
/** ezopen协议地址的类型1-预览2-本地录像回放3-云存储录像回放非必选默认为1 */
private String type;
/** ezopen协议地址的设备的视频加密密码 */
private String code;
/** 流播放协议1-ezopen、2-hls、3-rtmp、4-flv默认为1 */
private String protocol;
/** 视频清晰度1-高清主码流、2-流畅(子码流) */
private String quality;
/** 云台操作命令0-上1-下2-左3-右4-左上5-左下6-右上7-右下8-放大9-缩小10-近焦距11-远焦距 */
private String direction;
/** 云台操作命令:速度 */
private String speed;
/** 云台操作命令:传了一直动 不传移动一格 */
private String notStop;
}

View File

@ -0,0 +1,132 @@
package com.fastbee.iot.haikang;
import cn.hutool.http.HttpUtil;
import cn.hutool.json.JSONObject;
import java.util.HashMap;
import java.util.Map;
/**
* 点点控api界面
*/
public class HaikangYingshiApi {
/**
* @return
*/
public static JSONObject getToken(Map<String, Object> params) {
String url = UrlConstant.getToken;//指定URL
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/x-www-form-urlencoded");
String result = HttpUtil.createPost(url).addHeaders(headers).form(params).execute().body();
JSONObject jsonObject = new JSONObject(result);
// System.out.println("jsonObject = " + jsonObject);
// Map<String,Object> data =null;
// if (jsonObject.get("code").equals("200")) {
// data= (Map<String,Object>) jsonObject.get("data");
// }
return jsonObject;
}
/**
* @param params accessToken String 授权过程获取的access_token Y
* deviceSerial String 直播源例如427734222均采用英文符号限制50个 Y
* channelNo Integer 通道号,非必选默认为1 N
* code String ezopen协议地址的设备的视频加密密码 N
* expireTime Integer 过期时长单位秒针对hls/rtmp设置有效期相对时间30秒-720天 N
* protocol Integer 流播放协议1-ezopen、2-hls、3-rtmp、4-flv默认为1 N
* quality Integer 视频清晰度1-高清主码流、2-流畅(子码流) N
* startTime String ezopen协议地址的本地录像/云存储录像回放开始时间,示例2019-12-01 00:00:00 N
* stopTime String ezopen协议地址的本地录像/云存储录像回放开始时间,示例2019-12-01 00:00:00 N
* type String ezopen协议地址的类型1-预览2-本地录像回放3-云存储录像回放非必选默认为1 N
* supportH265 Integer 是否要求播放视频为H265编码格式,1表示需要0表示不要求 N
* gbchannel String 国标设备的通道编号视频通道编号ID N
* @return
*/
public static JSONObject getAddress(Map<String, Object> params) {
// accessToken=at.dunwhxt2azk02hcn7phqygsybbw0wv6p&deviceSerial=C78957921&channelNo=1
String url = UrlConstant.address;//指定URL
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/x-www-form-urlencoded");
String result = HttpUtil.createPost(url).addHeaders(headers).form(params).execute().body();
JSONObject jsonObject = new JSONObject(result);
// System.out.println("result = " + result);
// Map<String,Object> data =(Map<String,Object>) jsonObject.get("data");
return jsonObject;
}
/**
* @param params accessToken String 授权过程获取的access_token Y
* deviceSerial String 设备序列号,存在英文字母的设备序列号,字母需为大写 Y
* channelNo int 通道号 Y
* direction int 操作命令0-上1-下2-左3-右4-左上5-左下6-右上7-右下8-放大9-缩小10-近焦距11-远焦距 Y
* speed int 云台速度0-慢1-适中2-快海康设备参数不可为0
* @return
*/
public static JSONObject startMove(Map<String, Object> params) {
// accessToken=at.dunwhxt2azk02hcn7phqygsybbw0wv6p&deviceSerial=C78957921&channelNo=1
String url = UrlConstant.startyuntai;//指定URL
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/x-www-form-urlencoded");
String result = HttpUtil.createPost(url).addHeaders(headers).form(params).execute().body();
JSONObject jsonObject = new JSONObject(result);
return jsonObject;
}
/**
* @param params accessToken String 授权过程获取的access_token Y
* deviceSerial String 设备序列号,存在英文字母的设备序列号,字母需为大写 Y
* channelNo int 通道号 Y
* direction int 操作命令0-上1-下2-左3-右4-左上5-左下6-右上7-右下8-放大9-缩小10-近焦距11-远焦距 Y
* @return
*/
public static JSONObject stopMove(Map<String, Object> params) {
// accessToken=at.dunwhxt2azk02hcn7phqygsybbw0wv6p&deviceSerial=C78957921&channelNo=1
String url = UrlConstant.stopyuntai;//指定URL
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/x-www-form-urlencoded");
String result = HttpUtil.createPost(url).addHeaders(headers).form(params).execute().body();
JSONObject jsonObject = new JSONObject(result);
return jsonObject;
}
/**
* @param params accessToken String 授权过程获取的access_token Y
* deviceSerial String 设备序列号,存在英文字母的设备序列号,字母需为大写 Y
* channelNo int 通道号 Y
* direction int 操作命令0-上1-下2-左3-右4-左上5-左下6-右上7-右下8-放大9-缩小10-近焦距11-远焦距 Y
* @return
*/
public static JSONObject getDeviceInfo(Map<String, Object> params) {
// accessToken=at.dunwhxt2azk02hcn7phqygsybbw0wv6p&deviceSerial=C78957921&channelNo=1
String url = UrlConstant.deviceInfo;//指定URL
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/x-www-form-urlencoded");
String result = HttpUtil.createPost(url).addHeaders(headers).form(params).execute().body();
JSONObject jsonObject = new JSONObject(result);
return jsonObject;
}
/**
* @param params accessToken String 授权过程获取的access_token Y
* deviceSerial String 直播源例如427734222均采用英文符号限制50个 Y
* channelNo Integer 通道号,非必选默认为1 N
* @return
*/
public static JSONObject capture(Map<String, Object> params) {
// accessToken=at.dunwhxt2azk02hcn7phqygsybbw0wv6p&deviceSerial=C78957921&channelNo=1
String url = UrlConstant.capture;//指定URL
HashMap<String, String> headers = new HashMap<>();//存放请求头,可以存放多个请求头
headers.put("Content-Type", "application/x-www-form-urlencoded");
String result = HttpUtil.createPost(url).addHeaders(headers).form(params).execute().body();
JSONObject jsonObject = new JSONObject(result);
// System.out.println("result = " + result);
// Map<String,Object> data =(Map<String,Object>) jsonObject.get("data");
return jsonObject;
}
}

View File

@ -0,0 +1,28 @@
package com.fastbee.iot.haikang;
/**
* 点点控
*/
public class UrlConstant {
public static String appKey = "be85054cf4504710861fad77ec4e4af9";
public static String appSecret = "104f39e29f9847e5d819a99c1c32fc88";
//获取 token
public static String getToken = "https://open.ys7.com/api/lapp/token/get";
//获取 直播地址
public static String address = "https://open.ys7.com/api/lapp/v2/live/address/get";
//开始云台
public static String startyuntai = "https://open.ys7.com/api/lapp/device/ptz/start";
//停止云台
public static String stopyuntai = "https://open.ys7.com/api/lapp/device/ptz/stop";
//设备信息
public static String deviceInfo = "https://open.ys7.com/api/lapp/device/info";
//设备抓拍图片
public static String capture = "https://open.ys7.com/api/lapp/device/capture";
//关闭设备视频加密
public static String deviceEncryptOff = "https://open.ys7.com/api/lapp/device/encrypt/off";
}

View File

@ -6,6 +6,7 @@ import com.fastbee.common.core.thingsModel.ThingsModelSimpleItem;
import com.fastbee.common.enums.DeviceStatus;
import com.fastbee.iot.domain.Device;
import com.fastbee.iot.domain.DeviceGroup;
import com.fastbee.iot.domain.JiankongDeviceParam;
import com.fastbee.iot.model.*;
import com.fastbee.iot.model.ThingsModels.ThingsModelShadow;
import com.fastbee.iot.model.ThingsModels.ThingsModelValueItem;
@ -334,5 +335,5 @@ public interface IDeviceService
ArrayList<Object> getDeviceLogAllCurves(Long deviceId, String beginTime, String endTime);
Map<String, Object> getvideourl(JiankongDeviceParam jiankongDeviceParam);
}

View File

@ -16,15 +16,13 @@ import com.fastbee.common.core.thingsModel.ThingsModelSimpleItem;
import com.fastbee.common.core.thingsModel.ThingsModelValuesInput;
import com.fastbee.common.enums.*;
import com.fastbee.common.exception.ServiceException;
import com.fastbee.common.utils.CaculateUtils;
import com.fastbee.common.utils.DateUtils;
import com.fastbee.common.utils.SecurityUtils;
import com.fastbee.common.utils.StringUtils;
import com.fastbee.common.utils.*;
import com.fastbee.common.utils.http.HttpUtils;
import com.fastbee.common.utils.ip.IpUtils;
import com.fastbee.common.utils.json.JsonUtils;
import com.fastbee.iot.cache.ITSLCache;
import com.fastbee.iot.domain.*;
import com.fastbee.iot.haikang.HaikangYingshiApi;
import com.fastbee.iot.mapper.*;
import com.fastbee.iot.model.*;
import com.fastbee.iot.model.ThingsModelItem.Datatype;
@ -1668,4 +1666,76 @@ public class DeviceServiceImpl implements IDeviceService {
}
@Override
public Map<String, Object> getvideourl(JiankongDeviceParam jiankongDeviceParam) {
if (jiankongDeviceParam.getDeviceId() == null) {
throw new RuntimeException("请上传设备id");
}
Device device = selectDeviceByDeviceId(jiankongDeviceParam.getDeviceId());
if (device == null) {
throw new RuntimeException("设备未找到");
}
Map devData = DevParamsUtils.getDevParams(device.getDevParams());
if (devData.get("appKey") == null) {
throw new RuntimeException("未绑定设备参数appKey");
}
if (devData.get("appSecret") == null) {
throw new RuntimeException("未绑定设备参数appSecret");
}
if (devData.get("channelNo") == null) {
throw new RuntimeException("未绑定设备参数channelNo");
}
Map<String, Object> map = new HashMap<>();//存放参数
map.put("appKey", devData.get("appKey"));
map.put("appSecret", devData.get("appSecret"));
cn.hutool.json.JSONObject token = HaikangYingshiApi.getToken(map);
if (token != null && token.get("code").equals("200")) {
Map<String, Object> params = new HashMap<>();
// accessToken=at.dunwhxt2azk02hcn7phqygsybbw0wv6p&deviceSerial=C78957921&channelNo=1
token = (cn.hutool.json.JSONObject) token.get("data");
params.put("accessToken", token.get("accessToken"));
params.put("deviceSerial", device.getSerialNumber());
if (StringUtils.isNotEmpty(jiankongDeviceParam.getStartTime())) {
params.put("startTime", jiankongDeviceParam.getStartTime());
}
if (StringUtils.isNotEmpty(jiankongDeviceParam.getStopTime())) {
params.put("stopTime", jiankongDeviceParam.getStopTime());
}
if (StringUtils.isNotEmpty(jiankongDeviceParam.getType())) {
params.put("type", jiankongDeviceParam.getType());
}
if (StringUtils.isNotEmpty(jiankongDeviceParam.getCode())) {
params.put("code", jiankongDeviceParam.getCode());
}
if (StringUtils.isNotEmpty(jiankongDeviceParam.getProtocol())) {
params.put("protocol", jiankongDeviceParam.getProtocol());
}
if (StringUtils.isNotEmpty(jiankongDeviceParam.getQuality())) {
params.put("quality", jiankongDeviceParam.getQuality());
}
cn.hutool.json.JSONObject response = HaikangYingshiApi.getAddress(params);
if (response != null && response.get("code").equals("200")) {
Map data = (cn.hutool.json.JSONObject) response.get("data");
Map<String, Object> reMap = new HashMap<>();
reMap.put("url", data.get("url"));
reMap.put("devName", device.getDeviceName());
reMap.put("accessToken", token.get("accessToken"));
reMap.put("id", device.getDeviceId());
reMap.put("status", device.getStatus() == null || device.getStatus() == 4 ? "离线" : "在线");
return reMap;
} else {
throw new RuntimeException(response.get("msg").toString());
}
} else {
}
return null;
}
}