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

@ -14,6 +14,7 @@ import com.fastbee.common.utils.SecurityUtils;
import com.fastbee.common.utils.StringUtils;
import com.fastbee.common.utils.poi.ExcelUtil;
import com.fastbee.iot.domain.Device;
import com.fastbee.iot.domain.JiankongDeviceParam;
import com.fastbee.iot.model.DeviceAssignmentVO;
import com.fastbee.iot.model.DeviceImportVO;
import com.fastbee.iot.model.DeviceRelateUserInput;
@ -48,8 +49,7 @@ import java.util.stream.Collectors;
@Api(tags = "设备管理")
@RestController
@RequestMapping("/iot/device")
public class DeviceController extends BaseController
{
public class DeviceController extends BaseController {
@Autowired
private IDeviceService deviceService;
@ -63,8 +63,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/list")
@ApiOperation("设备分页列表")
public TableDataInfo list(Device device)
{
public TableDataInfo list(Device device) {
startPage();
// 限制当前用户机构
if (null == device.getDeptId()) {
@ -79,8 +78,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/unAuthlist")
@ApiOperation("设备分页列表")
public TableDataInfo unAuthlist(Device device)
{
public TableDataInfo unAuthlist(Device device) {
startPage();
if (null == device.getDeptId()) {
device.setDeptId(getLoginUser().getDeptId());
@ -94,8 +92,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/listByGroup")
@ApiOperation("查询分组可添加设备分页列表")
public TableDataInfo listByGroup(Device device)
{
public TableDataInfo listByGroup(Device device) {
startPage();
LoginUser loginUser = getLoginUser();
if (null == loginUser.getDeptId()) {
@ -114,8 +111,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/shortList")
@ApiOperation("设备分页简短列表")
public TableDataInfo shortList(Device device)
{
public TableDataInfo shortList(Device device) {
startPage();
LoginUser loginUser = getLoginUser();
if (null == loginUser.getDeptId()) {
@ -141,8 +137,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:list')")
@GetMapping("/all")
@ApiOperation("查询所有设备简短列表")
public TableDataInfo allShortList()
{
public TableDataInfo allShortList() {
Device device = new Device();
device.setDeptId(SecurityUtils.getLoginUser().getUser().getDeptId());
device.setShowChild(true);
@ -156,8 +151,7 @@ public class DeviceController extends BaseController
@Log(title = "设备", businessType = BusinessType.EXPORT)
@PostMapping("/export")
@ApiOperation("导出设备")
public void export(HttpServletResponse response, Device device)
{
public void export(HttpServletResponse response, Device device) {
List<Device> list = deviceService.selectDeviceList(device);
ExcelUtil<Device> util = new ExcelUtil<Device>(Device.class);
util.exportExcel(response, list, "设备数据");
@ -169,8 +163,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:query')")
@GetMapping(value = "/{deviceId}")
@ApiOperation("获取设备详情")
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId)
{
public AjaxResult getInfo(@PathVariable("deviceId") Long deviceId) {
Device device = deviceService.selectDeviceByDeviceId(deviceId);
// 判断当前用户是否有设备分享权限 设备所属机构管理员和设备所属用户有权限
LoginUser loginUser = getLoginUser();
@ -195,8 +188,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:query')")
@GetMapping(value = "/synchronization/{serialNumber}")
@ApiOperation("设备数据同步")
public AjaxResult deviceSynchronization(@PathVariable("serialNumber") String serialNumber)
{
public AjaxResult deviceSynchronization(@PathVariable("serialNumber") String serialNumber) {
return AjaxResult.success(messagePublish.deviceSynchronization(serialNumber));
}
@ -206,8 +198,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:query')")
@GetMapping(value = "/getDeviceBySerialNumber/{serialNumber}")
@ApiOperation("根据设备编号获取设备详情")
public AjaxResult getInfoBySerialNumber(@PathVariable("serialNumber") String serialNumber)
{
public AjaxResult getInfoBySerialNumber(@PathVariable("serialNumber") String serialNumber) {
return AjaxResult.success(deviceService.selectDeviceBySerialNumber(serialNumber));
}
@ -217,8 +208,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:query')")
@GetMapping(value = "/statistic")
@ApiOperation("获取设备统计信息")
public AjaxResult getDeviceStatistic()
{
public AjaxResult getDeviceStatistic() {
return AjaxResult.success(deviceService.selectDeviceStatistic());
}
@ -228,8 +218,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:query')")
@GetMapping(value = "/runningStatus")
@ApiOperation("获取设备详情和运行状态")
public AjaxResult getRunningStatusInfo(Long deviceId)
{
public AjaxResult getRunningStatusInfo(Long deviceId) {
return AjaxResult.success(deviceService.selectDeviceRunningStatusByDeviceId(deviceId));
}
@ -240,8 +229,7 @@ public class DeviceController extends BaseController
@Log(title = "添加设备", businessType = BusinessType.INSERT)
@PostMapping
@ApiOperation("添加设备")
public AjaxResult add(@RequestBody Device device)
{
public AjaxResult add(@RequestBody Device device) {
return AjaxResult.success(deviceService.insertDevice(device));
}
@ -253,8 +241,7 @@ public class DeviceController extends BaseController
@Log(title = "设备关联用户", businessType = BusinessType.UPDATE)
@PostMapping("/relateUser")
@ApiOperation("终端-设备关联用户")
public AjaxResult relateUser(@RequestBody DeviceRelateUserInput deviceRelateUserInput)
{
public AjaxResult relateUser(@RequestBody DeviceRelateUserInput deviceRelateUserInput) {
if (deviceRelateUserInput.getUserId() == 0 || deviceRelateUserInput.getUserId() == null) {
return AjaxResult.error(MessageUtils.message("device.user.id.null"));
}
@ -271,8 +258,7 @@ public class DeviceController extends BaseController
@Log(title = "修改设备", businessType = BusinessType.UPDATE)
@PutMapping
@ApiOperation("修改设备")
public AjaxResult edit(@RequestBody Device device)
{
public AjaxResult edit(@RequestBody Device device) {
return deviceService.updateDevice(device);
}
@ -283,8 +269,7 @@ public class DeviceController extends BaseController
@Log(title = "重置设备状态", businessType = BusinessType.UPDATE)
@PutMapping("/reset/{serialNumber}")
@ApiOperation("重置设备状态")
public AjaxResult resetDeviceStatus(@PathVariable String serialNumber)
{
public AjaxResult resetDeviceStatus(@PathVariable String serialNumber) {
Device device = new Device();
device.setSerialNumber(serialNumber);
return toAjax(deviceService.resetDeviceStatus(device.getSerialNumber()));
@ -313,6 +298,7 @@ public class DeviceController extends BaseController
/**
* 获取设备MQTT连接参数
*
* @param deviceId 设备主键id
* @return
*/
@ -326,8 +312,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:add')")
@ApiOperation("下载设备导入模板")
@PostMapping("/uploadTemplate")
public void uploadTemplate(HttpServletResponse response, @RequestParam(name = "type") Integer type)
{
public void uploadTemplate(HttpServletResponse response, @RequestParam(name = "type") Integer type) {
// 1-设备导入2-设备分配
if (1 == type) {
ExcelUtil<DeviceImportVO> util = new ExcelUtil<>(DeviceImportVO.class);
@ -342,8 +327,7 @@ public class DeviceController extends BaseController
@ApiOperation("批量导入设备")
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PostMapping("/importData")
public AjaxResult importData(@RequestParam("file") MultipartFile file, @RequestParam("productId") Long productId) throws Exception
{
public AjaxResult importData(@RequestParam("file") MultipartFile file, @RequestParam("productId") Long productId) throws Exception {
if (null == file) {
return error(MessageUtils.message("import.failed.file.null"));
}
@ -364,10 +348,7 @@ public class DeviceController extends BaseController
@ApiOperation("批量导入分配设备")
@Log(title = "用户管理", businessType = BusinessType.IMPORT)
@PostMapping("/importAssignmentData")
public AjaxResult importAssignmentData(@RequestParam("file") MultipartFile file,
@RequestParam("productId") Long productId,
@RequestParam("deptId") Long deptId) throws Exception
{
public AjaxResult importAssignmentData(@RequestParam("file") MultipartFile file, @RequestParam("productId") Long productId, @RequestParam("deptId") Long deptId) throws Exception {
if (null == file) {
return error(MessageUtils.message("import.failed.file.null"));
}
@ -386,15 +367,15 @@ public class DeviceController extends BaseController
/**
* 分配设备
*
* @param deptId 机构id
* @param: deviceIds 设备id字符串
* @return com.fastbee.common.core.domain.AjaxResult
* @param: deviceIds 设备id字符串
*/
@PreAuthorize("@ss.hasPermi('iot:device:assignment')")
@ApiOperation("分配设备")
@PostMapping("/assignment")
public AjaxResult assignment(@RequestParam("deptId") Long deptId,
@RequestParam("deviceIds") String deviceIds) {
public AjaxResult assignment(@RequestParam("deptId") Long deptId, @RequestParam("deviceIds") String deviceIds) {
if (null == deptId) {
return error(MessageUtils.message("device.dept.id.null"));
}
@ -406,14 +387,14 @@ public class DeviceController extends BaseController
/**
* 回收设备
* @param: deviceIds 设备id字符串
*
* @return com.fastbee.common.core.domain.AjaxResult
* @param: deviceIds 设备id字符串
*/
@PreAuthorize("@ss.hasPermi('iot:device:recovery')")
@ApiOperation("回收设备")
@PostMapping("/recovery")
public AjaxResult recovery(@RequestParam("deviceIds") String deviceIds,
@RequestParam("recoveryDeptId") Long recoveryDeptId) {
public AjaxResult recovery(@RequestParam("deviceIds") String deviceIds, @RequestParam("recoveryDeptId") Long recoveryDeptId) {
if (StringUtils.isEmpty(deviceIds)) {
return error("请选择设备");
}
@ -426,8 +407,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:batchGenerator')")
@PostMapping("/batchGenerator")
@ApiOperation("批量生成设备编号")
public void batchGeneratorDeviceNum(HttpServletResponse response,
@RequestParam("count") Integer count){
public void batchGeneratorDeviceNum(HttpServletResponse response, @RequestParam("count") Integer count) {
if (count > 200) {
throw new ServiceException("最多只能生成200个");
}
@ -448,8 +428,7 @@ public class DeviceController extends BaseController
@PreAuthorize("@ss.hasPermi('iot:device:query')")
@GetMapping("/listThingsModel")
@ApiOperation("查询变量概况")
public TableDataInfo listThingsModel(Integer pageNum, Integer pageSize, Long deviceId, String modelName, Integer type)
{
public TableDataInfo listThingsModel(Integer pageNum, Integer pageSize, Long deviceId, String modelName, Integer type) {
TableDataInfo rspData = new TableDataInfo();
rspData.setCode(HttpStatus.SUCCESS);
rspData.setMsg("查询成功");
@ -502,4 +481,15 @@ public class DeviceController extends BaseController
return success(data);
}
/**
* 获取视频监控
*
* @param
* @return
*/
@GetMapping("/getvideourl")
public AjaxResult getvideourl(JiankongDeviceParam baseGet) throws Exception {
return AjaxResult.success(deviceService.getvideourl(baseGet));
}
}

View File

@ -1,14 +1,24 @@
package com.fastbee.data.domain.vo;
import com.fastbee.iot.domain.Device;
import com.fastbee.iot.model.anfang.UploadedPhotos;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import java.util.List;
/**
* 安防信息
*/
@Data
public class AnfangInfoVo {
@ApiModelProperty("监控设备")
private Device jiankongDevice;
@ApiModelProperty("门状态:0=正常1=箱门振动2=箱门打开")
private Integer doorStatus;
@ApiModelProperty("柜门ID,控制柜门开启的设备ID")
private String guimenId;
@ApiModelProperty("安防告警列表")
private List<UploadedPhotos>anfangList;
}

View File

@ -7,9 +7,11 @@ import com.fastbee.common.utils.StringUtils;
import com.fastbee.common.utils.StringUtils;
import com.fastbee.data.domain.vo.AnfangInfoVo;
import com.fastbee.data.service.devicedetail.IDeviceDetailService;
import com.fastbee.iot.anfang.service.IUploadedPhotosService;
import com.fastbee.iot.domain.Device;
import com.fastbee.iot.haiwei.service.HaiWeiService;
import com.fastbee.iot.mapper.DeviceMapper;
import com.fastbee.iot.model.anfang.UploadedPhotos;
import com.fastbee.iot.model.haiwei.CmdHaiWeiVo;
import com.fastbee.iot.model.haiwei.dto.CmdHaiWeiDto;
import com.fastbee.iot.service.IDeviceService;
@ -24,6 +26,7 @@ import com.fastbee.xunjian.mapper.XjInspectionRoutesMapper;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import javax.xml.crypto.Data;
import java.util.*;
@Service
@ -41,6 +44,9 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
private XjInspectionRecordsMapper xjInspectionRecordsMapper;
@Autowired
private HaiWeiService haiWeiService;
@Autowired
private IUploadedPhotosService uploadedPhotosService;
public DeviceDetailServiceImpl(DeviceMapper deviceMapper) {
this.deviceMapper = deviceMapper;
}
@ -140,9 +146,33 @@ public class DeviceDetailServiceImpl implements IDeviceDetailService {
if(StringUtils.isNotEmpty(anfangIds)){
Device anfangDevice = iDeviceService.selectDeviceByDeviceId(Long.parseLong(anfangIds));
//获取当前安防告警状态
UploadedPhotos uploadedPhotos = new UploadedPhotos();
uploadedPhotos.setSn(anfangDevice.getSerialNumber());
List<UploadedPhotos> uploadedPhotos1 = uploadedPhotosService.selectUploadedPhotosList(uploadedPhotos);
int doorStatus = 0;//0=正常1=箱门振动2=箱门打开
if(uploadedPhotos1.size() > 0){
UploadedPhotos temp = uploadedPhotos1.get(0);
if(new Date().getTime() - temp.getUploadTime().getTime() < 36000000){
if(temp.getShakeState().equals("1")){
doorStatus = 1;
}
//获取安防历史记录
return null;
if(temp.getDoorState().equals("1")){
doorStatus = 2;
}
}
}
if(uploadedPhotos1.size() > 5){
uploadedPhotos1 = uploadedPhotos1.subList(0,5);
}
anfangInfoVo.setDoorStatus(doorStatus);
anfangInfoVo.setAnfangList(uploadedPhotos1);
}
//安防设备
String guimenIds = devParams.get("guimenIds").toString();
if(StringUtils.isNotEmpty(guimenIds)){
anfangInfoVo.setGuimenId(devParams.get("guimenIds").toString());
}
return anfangInfoVo;
}
@Override
public CommonResult<CmdHaiWeiVo> cmdDevices(CmdHaiWeiDto cmdHaiWeiDto) {

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-ezopen2-hls3-rtmp4-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;
}
}