java调用萤石文档视频监控

/*企业视频监控及回放

* equipmentId=E61616319

*type=1 (1是实时,2是回放,回访需要输入开始时间和结束时间)

* startTime=2023-02-12 00:00:00

* stopTime=2023-02-12 23:59:59

* */

@PostMapping("/vedioBack")

@ResponseBody

public String vedioBack(VideoMonitoring videoMonitoring){

String equipmentId = videoMonitoring.getEquipmentId();

String type = videoMonitoring.getType();

String startTime = videoMonitoring.getStartTime();

String stopTime = videoMonitoring.getStopTime();

String head="https://open.ys7.com/ezopen/h5/iframe?url=";

String url="";

String accessToken=getVideoToken();

if (startTime!=null){

url="https://open.ys7.com/api/lapp/v2/live/address/get?accessToken=" + accessToken +"&deviceSerial="+equipmentId + "&type="+ type+

"&startTime=" + startTime + "&stopTime=" + stopTime;

}else {

url="https://open.ys7.com/api/lapp/v2/live/address/get?accessToken=" + accessToken +"&deviceSerial="+equipmentId + "&type="+ type;

}

HttpHeaders httpHeaders = new HttpHeaders();

httpHeaders.add("Content-Type","application/x-www-form-urlencoded");

RestTemplate restTemplate = new RestTemplate();

HttpEntity requestEntity = new HttpEntity<>(httpHeaders);

ResponseEntity<JSONObject> responseEntity = restTemplate.postForEntity(url, requestEntity, JSONObject.class);

JSONObject data = responseEntity.getBody().getJSONObject("data");

String url1 = data.getString("url");

String result=head+url1+"&accessToken="+accessToken;

return result;

}

/**

* 获取监控token,过期时间为七天

*/

public String getVideoToken() {

String url = "https://open.ys7.com/api/lapp/token/get";

String params = "appKey=123456";

String result = "";

try {

String s = HttpUtils.sendPost2(url, params);

JSONObject jsonObject = JSONObject.parseObject(s);

String code = (String) jsonObject.get("code");

String msg = (String) jsonObject.get("msg");

Map<String, String> data = (Map<String, String>) jsonObject.get("data");

String accessToken = data.get("accessToken");

if ("200".equals(code)) {

result = accessToken;

} else {

result = "-1";//获取token错误

}

} catch (Exception e) {

e.printStackTrace();

}

return result ;

}

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值