Commit 46128e2e authored by 鲁鸿波's avatar 鲁鸿波

更新监控数据,添加日志

parent 8f295b6b
......@@ -490,53 +490,138 @@ public class VideoAlarmController extends SuperController {
}
private BaseResponseList<VideoChannelUrl> getVideoListInfo(Integer mark, String orgId, Page<VideoEquipmentInfo> resultPage) {
log.info("========== 开始获取视频列表信息 ==========");
log.info("【传入参数】mark: {}, orgId: {}, page: {}, size: {}",
mark, orgId, resultPage.getCurrent(), resultPage.getSize());
//根据粮库id查询监控设备信息
QueryWrapper<VideoEquipmentInfo> queryWrapper = new QueryWrapper<>();
//查询盯防数据
if (mark == 1) {
log.info("【查询模式】盯防模式 - 查询用户盯防的设备");
List<String> deviceIdsByUserId = careService.findDeviceIdsByUserId(getUserId());
log.info("【盯防设备】用户盯防的设备ID列表: {}", deviceIdsByUserId);
//如果用户盯防列表是空的,查空数据
if (CollectionUtils.isEmpty(deviceIdsByUserId)) {
log.warn("【盯防设备】用户无盯防设备,返回空数据");
queryWrapper.eq("id", -1);
}else {
queryWrapper.in("id", deviceIdsByUserId);
}
} else {
log.info("【查询模式】普通模式 - 查询所有设备");
}
queryWrapper.eq("org_id", orgId);
queryWrapper.eq("status", "0");
log.info("【查询SQL】条件: org_id={}, status=0", orgId);
// TODO 根据需求修改查询条件及查询参数
Page<VideoEquipmentInfo> list = videoAlarmService.page(resultPage, queryWrapper);
log.info("【查询结果】总数: {}, 当前页记录数: {}", list.getTotal(), list.getRecords().size());
//可以获取所有的空间类型和场所
//判断是否为空
BaseResponseList<VideoChannelUrl> resultList = new BaseResponseList();
List<VideoChannelUrl> lists = new ArrayList<>();
if (!CollectionUtils.isEmpty(list.getRecords())) {
log.info("【开始处理设备】共 {} 个设备", list.getRecords().size());
for (VideoEquipmentInfo videoEquipmentInfo : list.getRecords()) {
log.info("--------------------------------------------------");
log.info("【设备信息】ID: {}, 名称: {}, deviceId: {}, orgId: {}",
videoEquipmentInfo.getId(),
videoEquipmentInfo.getEquipmentName(),
videoEquipmentInfo.getDeviceId(),
videoEquipmentInfo.getOrgId());
VideoChannelUrl res = new VideoChannelUrl();
//根据id获取视频地址信息
if (videoEquipmentInfo != null) {
if (StringUtils.isNotBlank(videoEquipmentInfo.getDeviceId())) {
ResponseEntity<Map> result = restUtil.get(IotUrlAttributes.START_LIVE_STREAM_PARAMETER_PATH + videoEquipmentInfo.getDeviceId(), Map.class);
String requestUrl = IotUrlAttributes.START_LIVE_STREAM_PARAMETER_PATH + videoEquipmentInfo.getDeviceId();
log.info("【调用第三方接口】URL: {}", requestUrl);
log.info("【调用第三方接口】完整地址: http://{}/{}", "threeVideoUrl", requestUrl);
try {
ResponseEntity<Map> result = restUtil.get(requestUrl, Map.class);
log.info("【第三方接口响应】HTTP状态码: {}", result.getStatusCode());
log.info("【第三方接口响应】完整响应体: {}", JSON.toJSONString(result.getBody()));
HttpStatus statusCode = result.getStatusCode();
if (statusCode == HttpStatus.OK) {
Map body = result.getBody();
if ("200".equals(body.get("code").toString())) {
res = JSONObject.parseObject(JSON.toJSONString(body.get("result")), VideoChannelUrl.class);
if (body != null) {
log.info("【第三方接口响应】code: {}", body.get("code"));
log.info("【第三方接口响应】message: {}", body.get("message"));
log.info("【第三方接口响应】result: {}", JSON.toJSONString(body.get("result")));
if (body.get("code") != null && "200".equals(body.get("code").toString())) {
log.info("【第三方接口成功】开始解析视频流地址");
Object resultObj = body.get("result");
if (resultObj != null) {
String resultJson = JSON.toJSONString(resultObj);
log.info("【JSON解析】待解析的JSON: {}", resultJson);
res = JSONObject.parseObject(resultJson, VideoChannelUrl.class);
log.info("【解析结果】HlsUrl: {}", res.getHlsUrl());
log.info("【解析结果】HttpFlvUrl: {}", res.getHttpFlvUrl());
log.info("【解析结果】RtmpUrl: {}", res.getRtmpUrl());
// 检查URL是否为空
if (StringUtils.isBlank(res.getHlsUrl()) && StringUtils.isBlank(res.getHttpFlvUrl())) {
log.warn("【警告】视频URL均为空,可能原因:设备离线或字段名称不匹配");
}
} else {
log.warn("【第三方接口响应】result字段为空");
}
} else {
log.error("【第三方接口失败】返回码不是200,实际返回码: {}", body.get("code"));
log.error("【第三方接口失败】错误信息: {}", body.get("message"));
}
} else {
log.error("【第三方接口响应】body为空");
}
} else {
log.error("【第三方接口失败】HTTP状态码不是200,实际状态码: {}", statusCode);
}
} catch (Exception e) {
log.error("【调用第三方接口异常】deviceId: {}, 异常类型: {}, 异常信息: {}",
videoEquipmentInfo.getDeviceId(), e.getClass().getName(), e.getMessage(), e);
}
} else {
log.warn("【设备deviceId为空】无法调用第三方接口获取视频流");
}
} else {
log.warn("【设备信息为空】跳过处理");
}
int isEye = careService.count(new LambdaQueryWrapper<TVideoEquipmentCare>().eq(TVideoEquipmentCare::getUserId, getUserId()).eq(TVideoEquipmentCare::getDeviceId, videoEquipmentInfo.getId()));
res.setId(videoEquipmentInfo.getId());
res.setDeviceId(videoEquipmentInfo.getDeviceId());
res.setIsEye(isEye);
res.setEquipmentName(videoEquipmentInfo.getEquipmentName());
log.info("【最终返回数据】ID: {}, deviceId: {}, isEye: {}, equipmentName: {}",
res.getId(), res.getDeviceId(), res.getIsEye(), res.getEquipmentName());
log.info("【最终返回数据】HlsUrl: {}, HttpFlvUrl: {}", res.getHlsUrl(), res.getHttpFlvUrl());
lists.add(res);
}
} else {
log.warn("【查询结果为空】没有找到符合条件的设备");
}
resultList.setData(lists);
resultList.setTotal(list.getTotal());
log.info("========== 结束获取视频列表信息 ==========");
log.info("【返回结果】数据条数: {}, 总数: {}", lists.size(), list.getTotal());
return resultList;
}
......
......@@ -161,7 +161,8 @@ ureport:
three:
video:
#url: http://${THREE_VIDEO_IP:app.cfciot.com}:${THREE_VIDEO_PORT:8080}
url: http://iotx.cofcodata.com:12800
#url: http://iotx.cofcodata.com:12800
url: http://10.25.140.9:12800
videoinfo:
url: http://${THREE_VIDEODEVICE_IP:123.125.253.26}:${THREE_VIDEODEVICE_PORT:6006}
username: ${THREE_VIDEODEVICE_USERNAME:anhuan}
......
......@@ -98,7 +98,8 @@ ureport:
three:
video:
#url: http://${THREE_VIDEO_IP:app.cfciot.com}:${THREE_VIDEO_PORT:8080}
url: http://iotx.cofcodata.com:12800
#url: http://iotx.cofcodata.com:12800
url: http://10.25.140.9:12800
videoinfo:
url: http://${THREE_VIDEODEVICE_IP:123.125.253.26}:${THREE_VIDEODEVICE_PORT:6006}
username: ${THREE_VIDEODEVICE_USERNAME:anhuan}
......
......@@ -113,7 +113,8 @@ ureport:
three:
video:
#url: http://10.28.161.85:8080
url: http://10.28.161.84:12800
#url: http://10.28.161.84:12800
url: http://10.25.140.9:12800
videoinfo:
url: http://123.125.253.26:6006
username: anhuan
......
spring:
profiles:
active: dev
active: prod
application:
name: zlmy-boot
servlet:
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment