From 14f9e25b4a6e23dbe4c4ca71ed089778ead4f23d Mon Sep 17 00:00:00 2001 From: furongxin <419481438@qq.com> Date: Mon, 17 Jun 2024 15:42:42 +0800 Subject: [PATCH] =?UTF-8?q?=E8=BF=BD=E5=8A=A0=20=E5=B0=8F=E7=A8=8B?= =?UTF-8?q?=E5=BA=8F=20=E8=8E=B7=E5=8F=96=E8=A7=86=E9=A2=91=E6=B5=81?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../controller/admin/hik/HikController.java | 2 +- .../smartfactory/service/hik/HikService.java | 8 +++++ .../service/hik/HikServiceImpl.java | 33 +++++++++++++++++++ 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/hik/HikController.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/hik/HikController.java index 4216373c..9717e0d8 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/hik/HikController.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/controller/admin/hik/HikController.java @@ -39,7 +39,7 @@ public class HikController { @Operation(summary = "视频播放->查询播放地址(微信用)") public CommonResult getMCameraUrl(String cameraCode) { - String url = hikService.getPreviewUrlsApi(cameraCode, 0); + String url = hikService.getPreviewUrlsApiHttps(cameraCode); String fullUrl = String.format("https://api.znkj.ispt.com.cn/demo/mobile_play.html?url=%s",url ); return CommonResult.success(fullUrl); } diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikService.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikService.java index 8a0efd4f..78ac6d2f 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikService.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikService.java @@ -20,6 +20,14 @@ public interface HikService { */ String getPreviewUrlsApi(String cameraCode, Integer streamType); + /** + * 查询播放地址 https + * + * @param cameraCode + * @return + */ + String getPreviewUrlsApiHttps(String cameraCode); + /** * 获取回放流 * diff --git a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikServiceImpl.java b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikServiceImpl.java index 88d7a0d8..01cd30e8 100644 --- a/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikServiceImpl.java +++ b/zn-module-smartfactory/zn-module-smartfactory-biz/src/main/java/cn/iocoder/yudao/module/smartfactory/service/hik/HikServiceImpl.java @@ -66,6 +66,39 @@ public class HikServiceImpl implements HikService { return null; } + @Override + public String getPreviewUrlsApiHttps(String cameraIndexCode) { + final String previewUrlsApi = ArtemisApiConstant.previewUrlsApi; + Map path = new HashMap(1) { + { + put("https://", previewUrlsApi); + } + }; + JSONObject body = new JSONObject(); + body.put("cameraIndexCode", cameraIndexCode); + body.put("streamType", 0); + body.put("protocol", "wss"); + body.put("transmode", 1); + body.put("expand", "streamform=ps"); + try { + String result = ArtemisHttpUtil + .doPostStringArtemis(path, JSONUtil.toJsonStr(body), null, null, "application/json"); + log.info("{}监控查看预览地址返回:{}", JSONUtil.toJsonStr(body), result); + if (StringUtils.isEmpty(result)) { + System.out.println("监控查看预览地址返回为空"); + } + JSONObject json = JSONUtil.parseObj(result); + String url = ""; + if (json.getJSONObject("data") != null) { + url = json.getJSONObject("data").getStr("url"); + } + return url; + } catch (Exception e) { + e.printStackTrace(); + } + return null; + } + @Override public JSONObject getReplayUrl(CameraReplayDTO replayDTO) { final String replayUrlApi = ArtemisApiConstant.replayUrlApi;