/*企业视频监控及回放
* 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 = EquipmentId();
String type = Type();
String startTime = StartTime();
String stopTime = StopTime();
String head="=";
String url="";
String accessToken=getVideoToken();
if (startTime!=null){
url="=" + accessToken +"&deviceSerial="+equipmentId + "&type="+ type+
"&startTime=" + startTime + "&stopTime=" + stopTime;
}else {
url="=" + 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 = Body().getJSONObject("data");
String url1 = String("url");
String result=head+url1+"&accessToken="+accessToken;
return result;
}
/**
* 获取监控token,过期时间为七天
*/
public String getVideoToken() {
String url = "";
String params = "appKey=123456";
String result = "";
try {
String s = HttpUtils.sendPost2(url, params);
JSONObject jsonObject = JSONObject.parseObject(s);
String code = (String) ("code");
String msg = (String) ("msg");
Map<String, String> data = (Map<String, String>) ("data");
String accessToken = ("accessToken");
if ("200".equals(code)) {
result = accessToken;
} else {
result = "-1";//获取token错误
}
} catch (Exception e) {
e.printStackTrace();
}
return result ;
}
本文发布于:2024-01-29 01:46:12,感谢您对本站的认可!
本文链接:https://www.4u4v.net/it/170646397611829.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
留言与评论(共有 0 条评论) |