From 7103827474becf49bd23df0478ab1d6b1d56ede7 Mon Sep 17 00:00:00 2001 From: liwen Date: Wed, 10 Apr 2024 14:34:43 +0800 Subject: [PATCH] =?UTF-8?q?add:=20=E8=A7=86=E9=A2=91=E5=9B=9E=E6=94=BE?= =?UTF-8?q?=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../operational/video/dto/VideoPlaybackDTO.java | 36 ++++++++++++++++++++ .../station/utils/ArtemisPostUtils.java | 39 ++++++++++++++++++++++ .../video/controller/VideoPlatformController.java | 18 +++++----- .../video/service/IVideoPlatformService.java | 7 ++++ .../video/service/impl/VideoConfigServiceImpl.java | 2 +- .../service/impl/VideoPlatformServiceImpl.java | 11 ++++++ 6 files changed, 102 insertions(+), 11 deletions(-) create mode 100644 hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/video/dto/VideoPlaybackDTO.java diff --git a/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/video/dto/VideoPlaybackDTO.java b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/video/dto/VideoPlaybackDTO.java new file mode 100644 index 0000000..0d2085b --- /dev/null +++ b/hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/video/dto/VideoPlaybackDTO.java @@ -0,0 +1,36 @@ +package com.hnac.hzims.operational.video.dto; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; +import lombok.Data; + +import javax.validation.constraints.NotNull; + +@Data +@ApiModel(value = "视频回放dto类") +public class VideoPlaybackDTO { + + @NotNull + @ApiModelProperty("监控点唯一标识") + private String cameraIndexCode; + + @NotNull + @ApiModelProperty("开始查询时间") + private String beginTime; + + @NotNull + @ApiModelProperty("结束查询时间") + private String endTime; + + @NotNull + @ApiModelProperty("http请求地址") + private String host; + + @NotNull + @ApiModelProperty("密钥id") + private String appKey; + + @NotNull + @ApiModelProperty("密钥") + private String appSecret; +} diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java index 2b12fc2..31509db 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java @@ -214,4 +214,43 @@ public class ArtemisPostUtils { return url; } } + + /** + * 获取视频回放url + * @param host + * @param appKey + * @param appSecret + * @param cameraIndexCode + * @param beginTime + * @param endTime + * @return + */ + public static String getVideoPlaybackURL(String host, String appKey, String appSecret, String cameraIndexCode, String beginTime, String endTime) { + ArtemisConfig.host = host; + ArtemisConfig.appKey = appKey; + ArtemisConfig.appSecret = appSecret; + // 设置接口的URI地址 + String ARTEMIS_PATH = "/artemis"; + String getCamsApi = ARTEMIS_PATH + "/api/video/v2/cameras/playbackURLs"; + Map path = new HashMap(2) {{this.put("https://", getCamsApi);}}; + // 设置参数提交类型 + String contentType = "application/json"; + // 组装请求参数 + JSONObject jsonObject = new JSONObject(); + jsonObject.put("cameraIndexCode", cameraIndexCode); + jsonObject.put("recordLocation", 1); + jsonObject.put("protocol", "rtsp"); + jsonObject.put("beginTime", beginTime); + jsonObject.put("endTime", endTime); + String body = jsonObject.toJSONString(); + // 调用接口 + String result = ArtemisHttpUtil.doPostStringArtemis(path, body, null, null, contentType, null); + if (result == null || result.equals("")) { + return null; + } else { + JSONObject json = JSONObject.parseObject(result); + json = JSONObject.parseObject(json.getString("data")); + return json.getString("url"); + } + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/controller/VideoPlatformController.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/controller/VideoPlatformController.java index 964e085..f5acc95 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/controller/VideoPlatformController.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/controller/VideoPlatformController.java @@ -1,15 +1,12 @@ package com.hnac.hzims.operational.video.controller; - -import com.alibaba.fastjson.JSON; -import com.alibaba.fastjson.JSONObject; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.hnac.hzims.common.invalid.Create; import com.hnac.hzims.common.invalid.Update; -import com.hnac.hzims.common.logs.utils.StringUtils; import com.hnac.hzims.common.support.constants.Order; import com.hnac.hzims.common.support.utils.Condition; import com.hnac.hzims.operational.OperationalConstants; +import com.hnac.hzims.operational.video.dto.VideoPlaybackDTO; import com.hnac.hzims.operational.video.entity.VideoPlatformEntity; import com.hnac.hzims.operational.video.service.IVideoPlatformService; import com.hnac.hzinfo.log.annotation.Business; @@ -21,18 +18,12 @@ import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperationSupport; import io.swagger.annotations.ApiParam; import lombok.AllArgsConstructor; -import okhttp3.MediaType; import org.springblade.core.boot.ctrl.BladeController; -import org.springblade.core.log.exception.ServiceException; import org.springblade.core.tool.api.R; -import org.springblade.core.tool.utils.DateUtil; import org.springblade.core.tool.utils.Func; import org.springframework.validation.annotation.Validated; import org.springframework.web.bind.annotation.*; -import java.nio.charset.StandardCharsets; -import java.time.ZonedDateTime; -import java.time.format.DateTimeFormatter; import java.util.*; @RestController @@ -89,4 +80,11 @@ public class VideoPlatformController extends BladeController { return R.status(videoPlatformService.removeByIds(Func.toLongList(",",ids))); } + @GetMapping("/videoPlayback") + @ApiOperation(value = "视频回放") + @ApiOperationSupport(order = 6) + public R videoPlayback(VideoPlaybackDTO dto) { + String url = videoPlatformService.getVideoPlayback(dto); + return R.data(url); + } } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/IVideoPlatformService.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/IVideoPlatformService.java index 843f25e..d1434b6 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/IVideoPlatformService.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/IVideoPlatformService.java @@ -1,8 +1,15 @@ package com.hnac.hzims.operational.video.service; +import com.hnac.hzims.operational.video.dto.VideoPlaybackDTO; import com.hnac.hzims.operational.video.entity.VideoPlatformEntity; import org.springblade.core.mp.base.BaseService; public interface IVideoPlatformService extends BaseService { + /** + * 查询视频回放 + * @param dto 视频回放dto类 + * @return 回放片段url + */ + String getVideoPlayback(VideoPlaybackDTO dto); } diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoConfigServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoConfigServiceImpl.java index 7452693..574d253 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoConfigServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoConfigServiceImpl.java @@ -9,7 +9,7 @@ import org.springframework.stereotype.Service; * @Author: huangxing * @Date: 2024/04/09 16:21 */ -@Service +//@Service @AllArgsConstructor public class VideoConfigServiceImpl implements IVideoConfigService { diff --git a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoPlatformServiceImpl.java b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoPlatformServiceImpl.java index 179a15f..f636574 100644 --- a/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoPlatformServiceImpl.java +++ b/hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoPlatformServiceImpl.java @@ -1,5 +1,7 @@ package com.hnac.hzims.operational.video.service.impl; +import com.hnac.hzims.operational.station.utils.ArtemisPostUtils; +import com.hnac.hzims.operational.video.dto.VideoPlaybackDTO; import com.hnac.hzims.operational.video.entity.VideoPlatformEntity; import com.hnac.hzims.operational.video.mapper.VideoPlatformMapper; import com.hnac.hzims.operational.video.service.IVideoPlatformService; @@ -9,4 +11,13 @@ import org.springframework.stereotype.Service; @Service public class VideoPlatformServiceImpl extends BaseServiceImpl implements IVideoPlatformService { + /** + * 查询视频回放 + */ + @Override + public String getVideoPlayback(VideoPlaybackDTO dto) { + String url = ArtemisPostUtils.getVideoPlaybackURL(dto.getHost(), dto.getAppKey(), dto.getAppSecret(), dto.getCameraIndexCode(), + dto.getBeginTime(), dto.getEndTime()); + return url; + } }