1、设备详情安防页面数据第二版
2、增加监控获取连接地址
This commit is contained in:
@ -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;
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
}
|
@ -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;
|
||||
}
|
||||
|
||||
}
|
@ -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";
|
||||
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
}
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user