From b2bb2e0164305ca6957f290f15c18122a5a9d2a2 Mon Sep 17 00:00:00 2001 From: wangguangyuan Date: Thu, 2 Jul 2026 15:52:42 +0800 Subject: [PATCH] =?UTF-8?q?fix:=E6=96=B0=E5=A2=9Eivs=E8=8E=B7=E5=8F=96rtsp?= =?UTF-8?q?Url=E5=9C=B0=E5=9D=80=E6=8E=A5=E5=8F=A3=E7=94=A8=E4=BA=8Esip?= =?UTF-8?q?=E8=A7=86=E9=A2=91=E6=B5=81=E5=AF=B9=E6=8E=A5=EF=BC=8C=E5=8F=8A?= =?UTF-8?q?=E7=9B=B8=E6=9C=BA=E5=9C=A8=E7=BA=BF=E7=8A=B6=E6=80=81=E5=90=8C?= =?UTF-8?q?=E6=AD=A5=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ivs/controller/IvsStreamController.java | 28 +++++++++++++++++++ .../inspect/ivs/view/IvsStreamStartView.java | 1 + .../job/task/PatrolEqpbookChannelTask.java | 17 +++++++++-- .../service/impl/Video2NvrComponent.java | 12 ++++++-- 4 files changed, 53 insertions(+), 5 deletions(-) diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsStreamController.java b/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsStreamController.java index 582bcad..24f2165 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsStreamController.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/controller/IvsStreamController.java @@ -18,6 +18,7 @@ import org.slf4j.LoggerFactory; import org.springframework.beans.factory.annotation.Value; import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RestController; import javax.annotation.Resource; @@ -91,4 +92,31 @@ public class IvsStreamController { log.debug("[GAB] streamId: {}", streamId); return Response.ok(); } + + + @GetMapping({"rtspUrl"}) + public IvsVideoRtspView rtspUrl(@RequestParam("cameraCode") String cameraCode) { + log.info("IVS_STREAM_START rtspUrl param: {}", cameraCode); + IvsVideoRtspVo ivsVideoRtspVo = IvsVideoRtspVo.realStream(cameraCode); + log.info("IVS_STREAM_START rtspUrl ivsVideoRtspVo: {}", ivsVideoRtspVo); + IvsVideoRtspView ivsVideoRtspView; + if (bIvsTestMode) { +// ivsVideoRtspView = IvsVideoRtspView.builder() +// .rtspURL("rtsp://admin:wd19216811@192.168.1.249:554/h264/ch39/main/av_stream") +// .build(); + ivsVideoRtspView = new IvsVideoRtspView(); + ivsVideoRtspView.setRtspURL("rtsp://admin:htjc2018@192.168.1.134:554/cam/realmonitor?channel=3&subtype=0"); + } else { + String label = java.util.UUID.randomUUID().toString().trim().replaceAll(StringUtils.DASH, StringUtils.EMPTY); + ivsVideoRtspView = ivsCommonService.postJson( + label, + ivsVideoRtspVo, + IvsConst.URI_VIDEO_RTSP, + IvsVideoRtspView.class); + } + + log.debug("[IVS] {}", ivsVideoRtspView); + + return ivsVideoRtspView; + } } diff --git a/inspect-ivs/src/main/java/com/inspect/ivs/view/IvsStreamStartView.java b/inspect-ivs/src/main/java/com/inspect/ivs/view/IvsStreamStartView.java index 06fcf9a..3dc5275 100644 --- a/inspect-ivs/src/main/java/com/inspect/ivs/view/IvsStreamStartView.java +++ b/inspect-ivs/src/main/java/com/inspect/ivs/view/IvsStreamStartView.java @@ -86,6 +86,7 @@ public class IvsStreamStartView implements Serializable { this.WEBRTC = ivsVideoRtspView.getWebrtcURL(); this.HLS = ivsVideoRtspView.getHlsURL(); this.FLV = ivsVideoRtspView.getFlvURL(); + this.RTSP = ivsVideoRtspView.getRtspURL(); } public String getStreamID() { diff --git a/inspect-job/src/main/java/com/inspect/job/task/PatrolEqpbookChannelTask.java b/inspect-job/src/main/java/com/inspect/job/task/PatrolEqpbookChannelTask.java index 84c6196..034c150 100644 --- a/inspect-job/src/main/java/com/inspect/job/task/PatrolEqpbookChannelTask.java +++ b/inspect-job/src/main/java/com/inspect/job/task/PatrolEqpbookChannelTask.java @@ -52,15 +52,26 @@ public class PatrolEqpbookChannelTask { // logger.info("同步巡检设备在线状态:{}", result); JSONObject jsonObject = JSONObject.parseObject(result); if (null != jsonObject) { - JSONObject cameraBriefInfos = jsonObject.getJSONObject("cameraBriefInfos"); + JSONObject cameraBriefInfos = null; + if (jsonObject.getJSONObject("cameraBriefInfos") != null) { + cameraBriefInfos = jsonObject.getJSONObject("cameraBriefInfos").getJSONObject("cameraBriefInfoList"); + } + if (cameraBriefInfos == null) { + if (jsonObject.getJSONObject("cameraBriefInfosV2") != null) { + cameraBriefInfos = jsonObject.getJSONObject("cameraBriefInfosV2").getJSONObject("cameraBriefInfoList"); + } + } if (null != cameraBriefInfos) { - JSONArray jsonObjectItems = cameraBriefInfos.getJSONArray("cameraBriefInfoList"); + JSONArray jsonObjectItems = cameraBriefInfos.getJSONArray("cameraBriefInfo"); if (null != jsonObjectItems) { for (EqpBookChannel eqpBookChannel : eqpBookChannels) { for (int i = 0; i < jsonObjectItems.size(); i++) { JSONObject cameraInfo = jsonObjectItems.getJSONObject(i); //cameracode相等 - if (eqpBookChannel.getChannelCode().equals(cameraInfo.getString("code") + "#" + cameraInfo.getString("domainCode"))) { + String code = cameraInfo.getString("code"); + String domainCode = cameraInfo.getString("domainCode"); + String channelCode = eqpBookChannel.getChannelCode(); + if (channelCode.equals(code) || channelCode.equals(code + "#" + domainCode)) { //状态发生改变 修改 if (!eqpBookChannel.getOnlineState().equals(cameraInfo.getString("status")) || !eqpBookChannel.getChannelName().equals(cameraInfo.getString("name"))) { diff --git a/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/service/impl/Video2NvrComponent.java b/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/service/impl/Video2NvrComponent.java index 21ed6c2..cdfb5cc 100644 --- a/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/service/impl/Video2NvrComponent.java +++ b/inspect-main/inspect-main-video/src/main/java/com/inspect/patrol/service/impl/Video2NvrComponent.java @@ -3,6 +3,8 @@ package com.inspect.patrol.service.impl; import com.alibaba.fastjson.JSONObject; import com.inspect.base.core.exception.ServiceException; import com.inspect.base.core.utils.StringUtils; +import com.inspect.base.core.web.domain.AjaxResult; +import com.inspect.base.core.web.page.TableDataInfo; import com.inspect.base.redis.service.RedisService; import com.inspect.patrol.service.BasedataEqpbookService; import org.springframework.beans.factory.annotation.Autowired; @@ -25,11 +27,17 @@ public class Video2NvrComponent { } else { Object value = this.redisService.redisTemplate.opsForHash().get(PATROL_EQP_BOOK_VIDEO_NVR, videoCode); if (value == null) { - Object object = this.basedataEqpbookService.list((new JSONObject()).fluentPut("patrolDeviceCode", videoCode)).getRows().get(0); +// Object object = this.basedataEqpbookService.list((new JSONObject()).fluentPut("patrolDeviceCode", videoCode)).getRows().get(0); + TableDataInfo tableDataInfo = basedataEqpbookService.list((new JSONObject()).fluentPut("patrolDeviceCode", videoCode)); + if (tableDataInfo == null || tableDataInfo.getRows() == null || tableDataInfo.getRows().isEmpty()) { + return ""; + } + Object object = tableDataInfo.getRows().get(0); JSONObject jsonObject = JSONObject.parseObject(JSONObject.toJSONString(object)); + String videoNvrCode = jsonObject.getString("videoNvrCode"); if (StringUtils.isEmpty(videoCode)) { - throw new ServiceException("No NVR bound for this device!"); + return ""; } else { this.redisService.redisTemplate.opsForHash().put(PATROL_EQP_BOOK_VIDEO_NVR, videoCode, videoNvrCode); return videoNvrCode;