Browse Source

Merge remote-tracking branch 'origin/master'

zhongwei
haungxing 1 year ago
parent
commit
d6e33314df
  1. 28
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java
  2. 21
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java
  3. 33
      hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java

28
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/controller/StationVideoTypeController.java

@ -2,10 +2,8 @@ package com.hnac.hzims.operational.station.controller;
import com.alibaba.fastjson.JSONObject; import com.alibaba.fastjson.JSONObject;
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport; import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import com.hnac.hzims.common.logs.annotation.OperationAnnotation; import com.hnac.hzims.common.logs.annotation.OperationAnnotation;
import com.hnac.hzims.common.logs.enums.BusinessType; import com.hnac.hzims.common.logs.enums.BusinessType;
@ -16,16 +14,15 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.response.HikDeviceResp; import com.hnac.hzims.operational.station.response.HikDeviceResp;
import com.hnac.hzims.operational.station.response.HikMonitorResp; import com.hnac.hzims.operational.station.response.HikMonitorResp;
import com.hnac.hzims.operational.station.service.IStationService; import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.service.IStationVideoTypeService;
import com.hnac.hzims.operational.station.utils.ArtemisPostUtils;
import com.hnac.hzims.operational.station.vo.StationVO; import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzims.operational.station.vo.StationVideoTypeVO;
import com.hnac.hzims.operational.station.vo.VideoMonitorVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO;
import com.hnac.hzims.operational.station.wrapper.StationVideoTypeWrapper; import com.hnac.hzims.operational.station.wrapper.StationVideoTypeWrapper;
import com.hnac.hzims.operational.station.service.IStationVideoTypeService;
import com.hnac.hzims.operational.station.vo.StationVideoTypeVO;
import io.swagger.annotations.Api; import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import org.springblade.core.boot.ctrl.BladeController; import org.springblade.core.boot.ctrl.BladeController;
import org.springblade.core.log.annotation.ApiLog; import org.springblade.core.log.annotation.ApiLog;
@ -43,6 +40,7 @@ import javax.validation.Valid;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import java.util.Optional; import java.util.Optional;
import java.util.function.Consumer;
/** /**
* @author hx * @author hx
@ -217,7 +215,23 @@ public class StationVideoTypeController extends BladeController {
public R<List<JSONObject>> getHikVisionStations() { public R<List<JSONObject>> getHikVisionStations() {
return R.data(stationVideoTypeService.getHikVisionStations()); return R.data(stationVideoTypeService.getHikVisionStations());
} }
@ApiLog
@GetMapping("/getHikVideo")
@ApiOperationSupport(order = 120)
@ApiOperation(value = "获取海康视频区域列表", notes = "获取海康视频区域列表")
public R getVideoMonitor(StationVideoTypeEntity req,Query query) {
LambdaQueryWrapper<StationVideoTypeEntity> queryWrapper = com.hnac.hzims.common.utils.Condition.getQueryWrapper(StationVideoTypeEntity.class, req);
IPage<StationVideoTypeEntity> page = stationVideoTypeService.page(com.hnac.hzims.common.utils.Condition.getPage(query), queryWrapper);
Consumer<StationVideoTypeEntity> getFlvVideo = video -> {
try {
video.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(video.getVideoHost(), video.getAppKey(), video.getAppSecret(), video.getPointCode(), 1));
} catch (Exception e) {
video.setLiveSourceAddress(null);
}
};
page.getRecords().forEach(getFlvVideo);
return R.data(page);
}
@ApiLog @ApiLog
@GetMapping("/getMonitorsByStation") @GetMapping("/getMonitorsByStation")
@ApiOperationSupport(order = 130) @ApiOperationSupport(order = 130)

21
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/service/impl/StationVideoTypeServiceImpl.java

@ -1,6 +1,5 @@
package com.hnac.hzims.operational.station.service.impl; package com.hnac.hzims.operational.station.service.impl;
import cn.hutool.core.util.RandomUtil;
import cn.hutool.http.HttpResponse; import cn.hutool.http.HttpResponse;
import cn.hutool.http.HttpUtil; import cn.hutool.http.HttpUtil;
import com.alibaba.fastjson.JSON; import com.alibaba.fastjson.JSON;
@ -10,7 +9,6 @@ import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper; import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.metadata.IPage; import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers; import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hnac.hzims.operational.config.HikPathConfiguration; import com.hnac.hzims.operational.config.HikPathConfiguration;
import com.hnac.hzims.operational.station.StationConstants; import com.hnac.hzims.operational.station.StationConstants;
import com.hnac.hzims.operational.station.dto.StationVideoTypeDTO; import com.hnac.hzims.operational.station.dto.StationVideoTypeDTO;
@ -19,39 +17,28 @@ import com.hnac.hzims.operational.station.entity.StationVideoTypeEntity;
import com.hnac.hzims.operational.station.mapper.StationVideoTypeMapper; import com.hnac.hzims.operational.station.mapper.StationVideoTypeMapper;
import com.hnac.hzims.operational.station.response.HikDeviceResp; import com.hnac.hzims.operational.station.response.HikDeviceResp;
import com.hnac.hzims.operational.station.response.HikMonitorResp; import com.hnac.hzims.operational.station.response.HikMonitorResp;
import com.hnac.hzims.operational.station.service.IStationService;
import com.hnac.hzims.operational.station.service.IStationVideoTypeService; import com.hnac.hzims.operational.station.service.IStationVideoTypeService;
import com.hnac.hzims.operational.station.utils.ArtemisPostUtils; import com.hnac.hzims.operational.station.utils.ArtemisPostUtils;
import com.hnac.hzims.operational.station.vo.StationVO;
import com.hnac.hzims.operational.station.vo.StationVideoTypeVO; import com.hnac.hzims.operational.station.vo.StationVideoTypeVO;
import com.hnac.hzims.operational.station.vo.VideoMonitorVO; import com.hnac.hzims.operational.station.vo.VideoMonitorVO;
import com.hnac.hzims.operational.station.wrapper.StationVideoTypeWrapper;
import com.hnac.hzims.operational.station.wrapper.StationWrapper;
import com.hnac.hzims.operational.util.HttpClientUtils;
import lombok.AllArgsConstructor;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j; import lombok.extern.slf4j.Slf4j;
import org.springblade.core.jwt.JwtUtil;
import org.springblade.core.log.exception.ServiceException; import org.springblade.core.log.exception.ServiceException;
import org.springblade.core.log.logger.BladeLogger; import org.springblade.core.log.logger.BladeLogger;
import org.springblade.core.mp.base.BaseServiceImpl; import org.springblade.core.mp.base.BaseServiceImpl;
import org.springblade.core.mp.support.Condition; import org.springblade.core.mp.support.Condition;
import org.springblade.core.mp.support.Query; import org.springblade.core.mp.support.Query;
import org.springblade.core.tool.api.R;
import org.springblade.core.tool.utils.*; import org.springblade.core.tool.utils.*;
import org.springblade.system.cache.DictCache; import org.springblade.system.cache.DictCache;
import org.springblade.system.entity.Dept;
import org.springblade.system.feign.ISysClient;
import org.springblade.system.user.entity.User;
import org.springblade.system.user.feign.IUserClient;
import org.springframework.beans.factory.annotation.Value; import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service; import org.springframework.stereotype.Service;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import java.sql.Wrapper; import java.util.ArrayList;
import java.util.*; import java.util.Arrays;
import java.util.concurrent.ConcurrentHashMap; import java.util.List;
import java.util.Map;
import java.util.stream.Collectors; import java.util.stream.Collectors;
/** /**

33
hzims-service/operational/src/main/java/com/hnac/hzims/operational/station/utils/ArtemisPostUtils.java

@ -4,10 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.hikvision.artemis.sdk.ArtemisHttpUtil; import com.hikvision.artemis.sdk.ArtemisHttpUtil;
import com.hikvision.artemis.sdk.config.ArtemisConfig; import com.hikvision.artemis.sdk.config.ArtemisConfig;
import java.io.IOException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
import java.util.Map; import java.util.Map;
public class ArtemisPostUtils { public class ArtemisPostUtils {
@ -187,4 +184,34 @@ public class ArtemisPostUtils {
list = json.getJSONArray("data"); list = json.getJSONArray("data");
return list; return list;
}*/ }*/
public static String getCameraPreviewFlvURL(String host, String appKey, String appSecret, String cameraIndexCode, int streamType) {
ArtemisConfig.host = host;
ArtemisConfig.appKey = appKey;
ArtemisConfig.appSecret = appSecret;
String ARTEMIS_PATH = "/artemis";
String getCamsApi = ARTEMIS_PATH+"/api/video/v2/cameras/previewURLs";
Map<String, String> path = new HashMap<String, String>(2) {
{
this.put("https://", getCamsApi);
}
};
String contentType = "application/json";
JSONObject jsonBody = new JSONObject();
jsonBody.put("cameraIndexCode", cameraIndexCode);
jsonBody.put("streamType", 0);
jsonBody.put("protocol", "httpflv");
jsonBody.put("transmode", 1);
String body = jsonBody.toJSONString();
String result = ArtemisHttpUtil.doPostStringArtemis(path, body, (Map)null, (String)null, contentType, (Map)null);
if (null == result && "".equals(result)) {
return null;
} else {
JSONObject json = JSONObject.parseObject(result);
json = JSONObject.parseObject(json.getString("data"));
String url = json.getString("url");
return url;
}
}
} }

Loading…
Cancel
Save