From b29c68a4ab79456f853811e253b91eb92d8700b6 Mon Sep 17 00:00:00 2001 From: shizisheng Date: Thu, 29 May 2025 15:19:51 +0800 Subject: [PATCH] =?UTF-8?q?1.=E6=98=9F=E9=80=BB=E7=AE=97=E6=B3=95-?= =?UTF-8?q?=E6=9F=A5=E8=AF=A2=E8=AE=BE=E5=A4=87deviceSn-rtmpUrl=E4=BC=98?= =?UTF-8?q?=E5=8C=96=202.=E8=BF=90=E8=A1=8C=E6=97=B6=E5=BC=82=E5=B8=B8?= =?UTF-8?q?=E6=8B=A6=E6=88=AA?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../sample/manage/service/IDeviceService.java | 2 ++ .../service/impl/DeviceServiceImpl.java | 9 ++++++ .../service/impl/EngineRecordServiceImpl.java | 6 ++-- .../impl/SampleEngineRecordServiceImpl.java | 32 +++++++++++++------ .../media/service/impl/FileServiceImpl.java | 2 +- .../system/utils/OssTianyiClientUtils.java | 2 +- 6 files changed, 38 insertions(+), 15 deletions(-) diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/IDeviceService.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/IDeviceService.java index 0c77906..f990a81 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/IDeviceService.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/IDeviceService.java @@ -77,6 +77,8 @@ public interface IDeviceService { */ void spliceDeviceTopo(DeviceDTO device); + String getChildDeviceStreamUrlByDeviceSn(String childDeviceSn); + /** * Query the information of the device according to the sn of the device. * @param sn device sn diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java index 78f0957..b61d6a2 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/DeviceServiceImpl.java @@ -289,6 +289,15 @@ public class DeviceServiceImpl implements IDeviceService { subDevice.setPayloadsList(payloadService.getDevicePayloadEntitiesByDeviceSn(gateway.getChildDeviceSn())); } + @Override + public String getChildDeviceStreamUrlByDeviceSn(String childDeviceSn) { + DeviceDTO subDevice = getDevicesByParams(DeviceQueryParam.builder().deviceSn(childDeviceSn).build()).get(0); + String deviceVideoEnum = DeviceVideoEnum.find(subDevice.getDeviceName()).getDevice(); +// String string = new VideoId(subDevice.getDeviceSn() + SLASH + deviceVideoEnum + SLASH + VideoTypeEnum.NORMAL.getType() + DASH + DeviceTypeVideoEnum.ZERO.getVideoType()).toString(); + String childDeviceUrl = subDevice.getDeviceSn() + DASH + deviceVideoEnum; //1581F6Q8X254K00G085K-81-0-0 + return childDeviceUrl; + } + @Override public Optional getDeviceTopoForPilot(String sn) { if (!StringUtils.hasText(sn)) { diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/EngineRecordServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/EngineRecordServiceImpl.java index 65a91d7..1f94261 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/EngineRecordServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/EngineRecordServiceImpl.java @@ -111,7 +111,7 @@ public class EngineRecordServiceImpl implements IEngineRecordService { //{"code":200,"message":"操作成功","data":[{"scene":"可见光","id":2}]} sceneResponseBody = GetRequest(uri, token); } catch (URISyntaxException e) { - throw new RuntimeException(e); + log.error("星逻算法-场景查询异常",e); } JSONObject jsonObject1 = new JSONObject(sceneResponseBody); // 逐层获取 data -> token @@ -136,7 +136,7 @@ public class EngineRecordServiceImpl implements IEngineRecordService { break; } } catch (URISyntaxException | JsonProcessingException e) { - throw new RuntimeException(e); + log.error("星逻算法-算法列表查询失败",e); } JSONObject jsonObj2 = new JSONObject(); @@ -151,7 +151,7 @@ public class EngineRecordServiceImpl implements IEngineRecordService { try { response = mapper1.readValue(responseBody2, EngineResponse.class); } catch (JsonProcessingException e) { - throw new RuntimeException(e); + log.error("星逻算法-引擎启动失败",e); } objectMap.put("task_id",response.getData().getTask_id()); record.setPushUrl(objectMap.get("push_url").toString()); diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java index 44f9de6..5c3e104 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/manage/service/impl/SampleEngineRecordServiceImpl.java @@ -53,6 +53,9 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService @Autowired private XingluoApiConfig xingluoApiConfig; + @Autowired + private IDeviceService deviceService; + @DubboReference private RemoteConfigService remoteConfigService; @@ -81,7 +84,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService //{"code":200,"message":"操作成功","data":[{"scene":"可见光","id":2}]} sceneResponseBody = GetRequest(uri, token); } catch (URISyntaxException e) { - throw new RuntimeException(e); + log.error("星逻算法-场景查询异常",e); } JSONObject jsonObject1 = new JSONObject(sceneResponseBody); // 逐层获取 data -> token @@ -107,7 +110,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService break; } } catch (URISyntaxException | JsonProcessingException e) { - throw new RuntimeException(e); + log.error("星逻算法-算法列表查询失败",e); } } @@ -133,8 +136,16 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService String taskId = ""; String missionBatch = ""; String deviceSn = MapUtil.getStr(objectMap, "deviceSn", ""); + //获取rtmpUrl + String rtmpUrl = ""; + DeviceDTO deviceDTO = deviceService.getDeviceBySn(deviceSn).orElse(null); + if (deviceDTO != null) { + String childDeviceRtmpUrl = deviceService.getChildDeviceStreamUrlByDeviceSn(deviceDTO.getChildDeviceSn()); + rtmpUrl = childDeviceRtmpUrl; + } //查询用户开通的场景 + Object rtmpUrlParam = objectMap.get("rtmpUrl"); if (StringUtils.isNotEmpty(token)){ JSONObject jsonObj2 = new JSONObject(); String type = objectMap.get("type").toString(); @@ -144,8 +155,8 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService jsonObj2.put("callback_url", xingluoApiConfig.getEngineCallbackUrl());//"http://121.237.178.63:11100/sample/manage/api/v1/saEngineRecord/some" jsonObj2.put("extra_type_list",new JSONArray(list)); // jsonObj2.put("input_url","http://"+ip+":19008/live/livesteam/"+objectMap.get("rtmpUrl")+".flv"); - jsonObj2.put("input_url", "rtmp://"+ip+"/live/livesteam/"+objectMap.get("rtmpUrl"));//预览接口必须要传rtmp,不能是flv - String pushUrl = "rtmp://" + ip + "/live/livesteam/" + objectMap.get("rtmpUrl") + "ai1"; + jsonObj2.put("input_url", "rtmp://"+ip+"/live/livesteam/"+ rtmpUrl);//预览接口必须要传rtmp,不能是flv + String pushUrl = "rtmp://" + ip + "/live/livesteam/" + rtmpUrl + "ai1"; jsonObj2.put("push_url", pushUrl); //推流接口有时候不稳定,需要检查SRS服务 // jsonObj2.put("play_url", objectMap.get("play_url")); //play_url不必传, play和push是一对, play 其实是冗余的, 方便记录更详细的日志 /** @@ -160,10 +171,10 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService try { response = mapper1.readValue(responseBody2, EngineResponse.class); if (response.getCode() != 200){ - throw new RuntimeException("第三方接口调用失败!"); + log.error("第三方接口调用失败!"); } } catch (JsonProcessingException e) { - throw new RuntimeException(e); + log.error("星逻算法-引擎启动失败",e); } taskId = response.getData().getTask_id(); missionBatch = response.getData().getMission_batch(); @@ -171,7 +182,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService objectMap.put("task_id",response.getData().getTask_id()); record.setDeviceSn(deviceSn); record.setExtraType(objectMap.get("type").toString()); - record.setPushUrl(objectMap.get("rtmpUrl").toString()); + record.setPushUrl(rtmpUrl.toString()); record.setTaskId(taskId); //MapUtil.getStr(objectMap,"task_id","") record .setMissionBatch(missionBatch); record.setPushUrl(pushUrl); @@ -183,7 +194,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService engineRecordMapper.insert(record); Map map = new HashMap(); - map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+objectMap.get("rtmpUrl")+"ai1"); + map.put("push_url", "http://"+ip+":1985/rtc/v1/whep/?app=live/livesteam&stream="+ rtmpUrl +"ai1"); map.put("task_id", taskId);//objectMap.get("task_id") //添加任务id和jobid关联关系 @@ -280,7 +291,7 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService if (response.getStatusLine().getStatusCode() == 200) { return responseBody; } else { - throw new RuntimeException("第三方接口调用失败!"); + log.error("第三方接口调用失败!"); } } } catch (Exception e) { @@ -307,7 +318,8 @@ public class SampleEngineRecordServiceImpl implements ISampleEngineRecordService if (response.getStatusLine().getStatusCode() == 200){ return responseBody; }else { - throw new RuntimeException("第三方接口调用失败!"); + log.error("星逻算法-第三方接口调用失败"); +// throw new RuntimeException("第三方接口调用失败!"); } } } catch (Exception e) { diff --git a/dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/FileServiceImpl.java b/dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/FileServiceImpl.java index a2e6113..ded38bf 100644 --- a/dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/FileServiceImpl.java +++ b/dk-modules/sample/src/main/java/org/dromara/sample/media/service/impl/FileServiceImpl.java @@ -195,7 +195,7 @@ public class FileServiceImpl implements IFileService { MinioUtil.copyFile(originFileUrl,originFileUrl,sourceBucket,targetBucket);//列表图片 MinioUtil.copyFile(originFileUrl,originFileUrl,sourceBucket,MinIOConstants.BUCKET_ALERT);//预览图片 } catch (Exception e) { - throw new RuntimeException(e); + e.printStackTrace(); } diff --git a/dk-modules/system/src/main/java/org/dromara/system/utils/OssTianyiClientUtils.java b/dk-modules/system/src/main/java/org/dromara/system/utils/OssTianyiClientUtils.java index 9c557e8..6ea15ae 100644 --- a/dk-modules/system/src/main/java/org/dromara/system/utils/OssTianyiClientUtils.java +++ b/dk-modules/system/src/main/java/org/dromara/system/utils/OssTianyiClientUtils.java @@ -121,7 +121,7 @@ public class OssTianyiClientUtils { .build() ); } catch (Exception e) { - throw new RuntimeException(e); + e.printStackTrace(); } // FileUtil.writeFromStream(inputStream, new File(downloadPath)); return inputStream;