Browse Source

add: 视频回放接口

zhongwei
liwen 8 months ago
parent
commit
7103827474
  1. 36
      hzims-service-api/hzims-operational-api/src/main/java/com/hnac/hzims/operational/video/dto/VideoPlaybackDTO.java
  2. 39
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java
  3. 18
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/controller/VideoPlatformController.java
  4. 7
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/IVideoPlatformService.java
  5. 2
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoConfigServiceImpl.java
  6. 11
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/video/service/impl/VideoPlatformServiceImpl.java

36
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;
}

39
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<String, String> path = new HashMap<String, String>(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");
}
}
}

18
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<String> videoPlayback(VideoPlaybackDTO dto) {
String url = videoPlatformService.getVideoPlayback(dto);
return R.data(url);
}
}

7
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<VideoPlatformEntity> {
/**
* 查询视频回放
* @param dto 视频回放dto类
* @return 回放片段url
*/
String getVideoPlayback(VideoPlaybackDTO dto);
}

2
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 {

11
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<VideoPlatformMapper, VideoPlatformEntity> 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;
}
}

Loading…
Cancel
Save