Browse Source

雷达关联监控点查询接口 代理

develop
王兴琳 4 months ago
parent
commit
16026ec48a
  1. 30
      zc-business/src/main/java/com/zc/business/controller/VideoController.java
  2. 14
      zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

30
zc-business/src/main/java/com/zc/business/controller/VideoController.java

@ -711,6 +711,7 @@ public class VideoController extends BaseController {
JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo")); JSONObject cameraInfo = JSONObject.parseObject(configService.selectConfigByKey("dc.cameraInfo"));
JSONObject jsonResult = null;
OkHttp okHttp = new OkHttp(); OkHttp okHttp = new OkHttp();
RequestParams requestParams = new RequestParams(); RequestParams requestParams = new RequestParams();
@ -733,7 +734,34 @@ public class VideoController extends BaseController {
.data(requestParams) // 请求参数 .data(requestParams) // 请求参数
.get(); // 请求方法 .get(); // 请求方法
return getJsonResult(response,okHttp); if (response.body() != null) {
jsonResult = JSONObject.parseObject(response.body().string());
if (jsonResult.containsKey("code")) {
if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) {
Map<String,Object> data = jsonResult.getJSONObject("data");
String fileUrl = data.get("fileUrl").toString();
fileUrl = configService.selectConfigByKey("dc.cameraUrl") + fileUrl.substring(UniversalEnum.SEVEN.getNumber());
data.put("fileUrl",fileUrl);
jsonResult.put("data",data);
} else if (UNAUTHORIZED.equals(jsonResult.getInteger("code"))) {
getToken();
okHttp.post();
if (response.body() != null) {
jsonResult = JSONObject.parseObject(response.body().string());
if (HttpStatus.SUCCESS == jsonResult.getInteger("code")) {
Map<String,Object> data = jsonResult.getJSONObject("data");
String fileUrl = data.get("fileUrl").toString();
fileUrl = configService.selectConfigByKey("cameraUrl") + fileUrl.substring(UniversalEnum.SEVEN.getNumber());
data.put("liveUrl",fileUrl);
jsonResult.put("data",data);
}
}
}
}
}
return jsonResult;
} }

14
zc-business/src/main/java/com/zc/business/service/impl/DcWarningServiceImpl.java

@ -1082,16 +1082,16 @@ public class DcWarningServiceImpl implements IDcWarningService {
public String getRadarIncidentVideo(String id) throws Exception { public String getRadarIncidentVideo(String id) throws Exception {
String msg = ""; String msg = "";
HashMap<String, Object> stringObjectHashMap = dcWarningMapper.selectDcWarningById(id); HashMap<String, Object> stringObjectHashMap = dcWarningMapper.selectDcWarningById(id);
// 给定的时间 // 时间
String givenTime = (String) stringObjectHashMap.get("warningTime"); String givenTime = (String) stringObjectHashMap.get("warningTime");
// 定义日期时间格式 // 定义日期时间格式
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss"); DateTimeFormatter formatter = DateTimeFormatter.ofPattern("yyyy-MM-dd HH:mm:ss");
// 解析给定的时间 // 解析时间
LocalDateTime currentTime = LocalDateTime.parse(givenTime, formatter); LocalDateTime currentTime = LocalDateTime.parse(givenTime, formatter);
// 计算 30 秒的时间 // 计算 30 秒的时间
LocalDateTime timeAfter30Seconds = currentTime.plus(Duration.ofSeconds(30)); LocalDateTime timeAfter30Seconds = currentTime.plus(Duration.ofSeconds(-30));
// 格式化时间 // 格式化时间
String formattedTime = timeAfter30Seconds.format(formatter); String formattedTime = timeAfter30Seconds.format(formatter);
@ -1109,7 +1109,7 @@ public class DcWarningServiceImpl implements IDcWarningService {
JsonNode code = jsonNodelist.get(0).get("cameraIndexCode"); JsonNode code = jsonNodelist.get(0).get("cameraIndexCode");
// 使用 textValue() 方法获取纯字符串 // 使用 textValue() 方法获取纯字符串
String codestring = code.textValue(); String codestring = code.textValue();
com.alibaba.fastjson.JSONObject jsonObject = videoController.downloadCameraVideo(codestring, formattedTime, 1); com.alibaba.fastjson.JSONObject jsonObject = videoController.downloadCameraVideo(codestring, formattedTime, 2);
if (jsonObject.get("code").toString().equals("500")) { if (jsonObject.get("code").toString().equals("500")) {
return null; return null;
@ -1136,12 +1136,12 @@ public class DcWarningServiceImpl implements IDcWarningService {
JsonNode paramsNode = otherConfigurationNode.get("params"); JsonNode paramsNode = otherConfigurationNode.get("params");
JsonNode eventsNode = paramsNode.get("events"); JsonNode eventsNode = paramsNode.get("events");
// 假设只有一个事件,我们只处理第一个事件 // 假设只有一个事件,只处理第一个事件
JsonNode eventDataNode = eventsNode.get(0); JsonNode eventDataNode = eventsNode.get(0);
JsonNode dataNode2 = eventDataNode.get("data"); JsonNode dataNode2 = eventDataNode.get("data");
JsonNode vehicleRcogResultNode = dataNode2.get("vehicleRcogResult"); JsonNode vehicleRcogResultNode = dataNode2.get("vehicleRcogResult");
// 假设只有一个 vehicleRcogResult 对象 // vehicleRcogResult 对象
JsonNode targetAttrsNode = vehicleRcogResultNode.get(0).get("targetAttrs"); JsonNode targetAttrsNode = vehicleRcogResultNode.get(0).get("targetAttrs");

Loading…
Cancel
Save