|
|
|
@ -10,7 +10,6 @@ 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.toolkit.Wrappers; |
|
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; |
|
|
|
|
import com.google.common.collect.Lists; |
|
|
|
|
import com.hnac.hzims.operational.config.HikPathConfiguration; |
|
|
|
|
import com.hnac.hzims.operational.station.StationConstants; |
|
|
|
@ -50,308 +49,309 @@ import java.util.stream.Collectors;
|
|
|
|
|
@Slf4j |
|
|
|
|
public class StationVideoTypeServiceImpl extends BaseServiceImpl<StationVideoTypeMapper, StationVideoTypeEntity> implements IStationVideoTypeService { |
|
|
|
|
|
|
|
|
|
private final HikPathConfiguration pathConfiguration; |
|
|
|
|
private final BladeLogger logger; |
|
|
|
|
private final HikPathConfiguration pathConfiguration; |
|
|
|
|
private final BladeLogger logger; |
|
|
|
|
|
|
|
|
|
@Value("${url.video.login}") |
|
|
|
|
private String videoLoginUrl; |
|
|
|
|
@Value("${hzims.video.random-code}") |
|
|
|
|
private String definitionCode; |
|
|
|
|
/** |
|
|
|
|
* 获取海康视频接口 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String getHikVideo(){ |
|
|
|
|
List<StationVideoTypeEntity> stationVideoTypeEntityList = this.list(); |
|
|
|
|
List<Long> ids = new ArrayList<>(); |
|
|
|
|
stationVideoTypeEntityList.forEach(stationVideoTypeEntity -> { |
|
|
|
|
if(ObjectUtil.isNotEmpty(stationVideoTypeEntity.getIsHikvideo()) && stationVideoTypeEntity.getIsHikvideo() == 1){ |
|
|
|
|
try{ |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewURL(stationVideoTypeEntity.getVideoHost(), |
|
|
|
|
stationVideoTypeEntity.getAppKey(),stationVideoTypeEntity.getAppSecret() |
|
|
|
|
,stationVideoTypeEntity.getPointCode(), DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE, |
|
|
|
|
stationVideoTypeEntity.getType()),0)); |
|
|
|
|
ids.add(stationVideoTypeEntity.getId()); |
|
|
|
|
} |
|
|
|
|
catch (Exception e){ |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
String result = ids.stream().map(id -> { |
|
|
|
|
return id+""; |
|
|
|
|
}).collect(Collectors.joining(",")); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
@Value("${url.video.login}") |
|
|
|
|
private String videoLoginUrl; |
|
|
|
|
@Value("${hzims.video.random-code}") |
|
|
|
|
private String definitionCode; |
|
|
|
|
@Value("${url.video.left}") |
|
|
|
|
private List<String> videoLeft; |
|
|
|
|
@Value("${url.video.right}") |
|
|
|
|
private List<String> videoRight; |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<StationEntity> getStationsByVideo() { |
|
|
|
|
return this.baseMapper.getStationsByVideo(); |
|
|
|
|
} |
|
|
|
|
/** |
|
|
|
|
* 获取海康视频接口 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public String getHikVideo() { |
|
|
|
|
List<StationVideoTypeEntity> stationVideoTypeEntityList = this.list(); |
|
|
|
|
List<Long> ids = new ArrayList<>(); |
|
|
|
|
stationVideoTypeEntityList.forEach(stationVideoTypeEntity -> { |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationVideoTypeEntity.getIsHikvideo()) && stationVideoTypeEntity.getIsHikvideo() == 1) { |
|
|
|
|
try { |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewURL(stationVideoTypeEntity.getVideoHost(), |
|
|
|
|
stationVideoTypeEntity.getAppKey(), stationVideoTypeEntity.getAppSecret() |
|
|
|
|
, stationVideoTypeEntity.getPointCode(), DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE, |
|
|
|
|
stationVideoTypeEntity.getType()), 0)); |
|
|
|
|
ids.add(stationVideoTypeEntity.getId()); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
}); |
|
|
|
|
String result = ids.stream().map(id -> { |
|
|
|
|
return id + ""; |
|
|
|
|
}).collect(Collectors.joining(",")); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<StationVideoTypeVO> getStationVideoOrderBySort(StationVideoTypeDTO req, Query query) { |
|
|
|
|
StationVideoTypeEntity stationVideoTypeEntity = BeanUtil.copy(req,StationVideoTypeEntity.class); |
|
|
|
|
QueryWrapper<StationVideoTypeEntity> queryWrapper = com.hnac.hzims.common.utils.Condition.getQueryWrapper(new StationVideoTypeEntity(),stationVideoTypeEntity,false, "vt"); |
|
|
|
|
IPage<StationVideoTypeVO> result = this.baseMapper.getStationVideoOrderBySort(queryWrapper,Condition.getPage(query)); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<StationEntity> getStationsByVideo() { |
|
|
|
|
return this.baseMapper.getStationsByVideo(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public IPage<StationVideoTypeEntity> getStationVideoOrderByName(StationVideoTypeVO req, Query query) { |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getVideoOwerType())&&req.getVideoOwerType().equals(1)) { |
|
|
|
|
req.setVideoType("6"); |
|
|
|
|
} |
|
|
|
|
Wrapper<StationVideoTypeEntity> queryWrapper = new LambdaQueryWrapper<StationVideoTypeEntity>() {{ |
|
|
|
|
if (CollectionUtil.isNotEmpty(req.getStationIds())) { |
|
|
|
|
in(StationVideoTypeEntity::getStationId, req.getStationIds()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStationId())) { |
|
|
|
|
eq(StationVideoTypeEntity::getStationId, req.getStationId()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStatus())) { |
|
|
|
|
eq(StationVideoTypeEntity::getStatus, req.getStatus()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getVideoOwerType())) { |
|
|
|
|
eq(StationVideoTypeEntity::getVideoOwerType, req.getVideoOwerType()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getVideoType())) { |
|
|
|
|
eq(StationVideoTypeEntity::getVideoType, req.getVideoType()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getName())) { |
|
|
|
|
eq(StationVideoTypeEntity::getName, req.getName()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStationId())&&ObjectUtil.isEmpty(req.getVideoType())&&ObjectUtil.isNotEmpty(req.getVideoOwerType())&&req.getVideoOwerType().equals(2)) { |
|
|
|
|
List<String> stringList = Arrays.asList("1", "2", "3", "4", "5"); |
|
|
|
|
in(StationVideoTypeEntity::getVideoType,stringList); |
|
|
|
|
} |
|
|
|
|
eq(StationVideoTypeEntity::getIsDeleted, 0); |
|
|
|
|
orderBy(true,true,StationVideoTypeEntity::getStationSort); |
|
|
|
|
orderBy(true,true,StationVideoTypeEntity::getSort); |
|
|
|
|
}}; |
|
|
|
|
@Override |
|
|
|
|
public IPage<StationVideoTypeVO> getStationVideoOrderBySort(StationVideoTypeDTO req, Query query) { |
|
|
|
|
StationVideoTypeEntity stationVideoTypeEntity = BeanUtil.copy(req, StationVideoTypeEntity.class); |
|
|
|
|
QueryWrapper<StationVideoTypeEntity> queryWrapper = com.hnac.hzims.common.utils.Condition.getQueryWrapper(new StationVideoTypeEntity(), stationVideoTypeEntity, false, "vt"); |
|
|
|
|
IPage<StationVideoTypeVO> result = this.baseMapper.getStationVideoOrderBySort(queryWrapper, Condition.getPage(query)); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
IPage<StationVideoTypeEntity> result = this.page(Condition.getPage(query),queryWrapper); |
|
|
|
|
@Override |
|
|
|
|
public IPage<StationVideoTypeEntity> getStationVideoOrderByName(StationVideoTypeVO req, Query query) { |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getVideoOwerType()) && req.getVideoOwerType().equals(1)) { |
|
|
|
|
req.setVideoType("6"); |
|
|
|
|
} |
|
|
|
|
Wrapper<StationVideoTypeEntity> queryWrapper = new LambdaQueryWrapper<StationVideoTypeEntity>() {{ |
|
|
|
|
if (CollectionUtil.isNotEmpty(req.getStationIds())) { |
|
|
|
|
in(StationVideoTypeEntity::getStationId, req.getStationIds()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStationId())) { |
|
|
|
|
eq(StationVideoTypeEntity::getStationId, req.getStationId()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStatus())) { |
|
|
|
|
eq(StationVideoTypeEntity::getStatus, req.getStatus()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getVideoOwerType())) { |
|
|
|
|
eq(StationVideoTypeEntity::getVideoOwerType, req.getVideoOwerType()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getVideoType())) { |
|
|
|
|
eq(StationVideoTypeEntity::getVideoType, req.getVideoType()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getName())) { |
|
|
|
|
eq(StationVideoTypeEntity::getName, req.getName()); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(req.getStationId()) && ObjectUtil.isEmpty(req.getVideoType()) && ObjectUtil.isNotEmpty(req.getVideoOwerType()) && req.getVideoOwerType().equals(2)) { |
|
|
|
|
List<String> stringList = Arrays.asList("1", "2", "3", "4", "5"); |
|
|
|
|
in(StationVideoTypeEntity::getVideoType, stringList); |
|
|
|
|
} |
|
|
|
|
eq(StationVideoTypeEntity::getIsDeleted, 0); |
|
|
|
|
orderBy(true, true, StationVideoTypeEntity::getStationSort); |
|
|
|
|
orderBy(true, true, StationVideoTypeEntity::getSort); |
|
|
|
|
}}; |
|
|
|
|
|
|
|
|
|
if (CollectionUtil.isNotEmpty(result.getRecords())){ |
|
|
|
|
for (StationVideoTypeEntity video : result.getRecords()) { |
|
|
|
|
try { |
|
|
|
|
video.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(video.getVideoHost(), video.getAppKey(), video.getAppSecret(), video.getPointCode(), 1)); |
|
|
|
|
} |
|
|
|
|
catch(Exception e) { |
|
|
|
|
log.error("视频点位【"+video.getName()+"】获取地址失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
IPage<StationVideoTypeEntity> result = this.page(Condition.getPage(query), queryWrapper); |
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<StationVideoTypeEntity> getVideoByIdsAndType(String ids,String type) { |
|
|
|
|
List<Long> idList = Func.toLongList(",",ids); |
|
|
|
|
List<StationVideoTypeEntity> result = idList.stream().parallel().map(id -> this.getById(id)).filter(ObjectUtil::isNotEmpty).filter(entity -> entity.getIsHikvideo() == 1) |
|
|
|
|
.map(entity -> { |
|
|
|
|
String address = null; |
|
|
|
|
try { |
|
|
|
|
address = ArtemisPostUtils.getCameraPreviewURL( |
|
|
|
|
entity.getVideoHost(), entity.getAppKey(), entity.getAppSecret(), entity.getPointCode(), type, 0 |
|
|
|
|
); |
|
|
|
|
entity.setLiveSourceAddress(address); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
entity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
return entity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(result.getRecords())) { |
|
|
|
|
for (StationVideoTypeEntity video : result.getRecords()) { |
|
|
|
|
try { |
|
|
|
|
video.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(video.getVideoHost(), video.getAppKey(), video.getAppSecret(), video.getPointCode(), 1)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("视频点位【" + video.getName() + "】获取地址失败"); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<StationVideoTypeEntity> getVideoByIds(String ids,String randomCode) { |
|
|
|
|
Assert.isTrue(StringUtil.isNoneBlank(randomCode) && randomCode.equals(definitionCode),()->{ |
|
|
|
|
throw new ServiceException("视频随机码为空或不正确"); |
|
|
|
|
}); |
|
|
|
|
Assert.isTrue(StringUtil.isNoneBlank(ids),()->{ |
|
|
|
|
throw new ServiceException("视频配置ID不能为空"); |
|
|
|
|
}); |
|
|
|
|
List<StationVideoTypeEntity> result = Arrays.stream(ids.split(",")).filter(ObjectUtil::isNotEmpty).map(id -> this.getById(id)).map(entity -> { |
|
|
|
|
String address; |
|
|
|
|
try { |
|
|
|
|
address = ArtemisPostUtils.getCameraPreviewURL( |
|
|
|
|
entity.getVideoHost(), |
|
|
|
|
entity.getAppKey(), |
|
|
|
|
entity.getAppSecret(), |
|
|
|
|
entity.getPointCode(), |
|
|
|
|
DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE,entity.getType()), 0 |
|
|
|
|
); |
|
|
|
|
entity.setLiveSourceAddress(address); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
entity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
return entity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public String getVideoReviewerToken() { |
|
|
|
|
String result = HttpUtil.post(videoLoginUrl, ""); |
|
|
|
|
JSONObject resultObject = JSONObject.parseObject(result); |
|
|
|
|
String data = resultObject.getString("data"); |
|
|
|
|
String access_token = JSONObject.parseObject(data).getString("access_token"); |
|
|
|
|
log.info("视频查看人员登陆token为:{}",access_token); |
|
|
|
|
return access_token; |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<StationVideoTypeEntity> getVideoByIdsAndType(String ids, String type) { |
|
|
|
|
List<Long> idList = Func.toLongList(",", ids); |
|
|
|
|
List<StationVideoTypeEntity> result = idList.stream().parallel().map(id -> this.getById(id)).filter(ObjectUtil::isNotEmpty).filter(entity -> entity.getIsHikvideo() == 1) |
|
|
|
|
.map(entity -> { |
|
|
|
|
String address = null; |
|
|
|
|
try { |
|
|
|
|
address = ArtemisPostUtils.getCameraPreviewURL( |
|
|
|
|
entity.getVideoHost(), entity.getAppKey(), entity.getAppSecret(), entity.getPointCode(), type, 0 |
|
|
|
|
); |
|
|
|
|
entity.setLiveSourceAddress(address); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
entity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
return entity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<JSONObject> getHikVisionStations() { |
|
|
|
|
Assert.isTrue(StringUtil.isNotBlank(pathConfiguration.getStationsPath()),()->{ |
|
|
|
|
throw new ServiceException("nacos中未配置海康威视请求地址!"); |
|
|
|
|
}); |
|
|
|
|
HttpResponse response; |
|
|
|
|
try { |
|
|
|
|
response = HttpUtil.createGet(pathConfiguration.getStationsPath()).execute(); |
|
|
|
|
} |
|
|
|
|
catch(Exception e) { |
|
|
|
|
logger.error("getHikVisionStations",e.getMessage()); |
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
// throw new ServiceException(e.getMessage());
|
|
|
|
|
} |
|
|
|
|
if(HttpServletResponse.SC_OK == response.getStatus()) { |
|
|
|
|
return JSONArray.parseArray(response.body(),JSONObject.class); |
|
|
|
|
} |
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<StationVideoTypeEntity> getVideoByIds(String ids, String randomCode) { |
|
|
|
|
Assert.isTrue(StringUtil.isNoneBlank(randomCode) && randomCode.equals(definitionCode), () -> { |
|
|
|
|
throw new ServiceException("视频随机码为空或不正确"); |
|
|
|
|
}); |
|
|
|
|
Assert.isTrue(StringUtil.isNoneBlank(ids), () -> { |
|
|
|
|
throw new ServiceException("视频配置ID不能为空"); |
|
|
|
|
}); |
|
|
|
|
List<StationVideoTypeEntity> result = Arrays.stream(ids.split(",")).filter(ObjectUtil::isNotEmpty).map(id -> this.getById(id)).map(entity -> { |
|
|
|
|
String address; |
|
|
|
|
try { |
|
|
|
|
address = ArtemisPostUtils.getCameraPreviewURL( |
|
|
|
|
entity.getVideoHost(), |
|
|
|
|
entity.getAppKey(), |
|
|
|
|
entity.getAppSecret(), |
|
|
|
|
entity.getPointCode(), |
|
|
|
|
DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE, entity.getType()), 0 |
|
|
|
|
); |
|
|
|
|
entity.setLiveSourceAddress(address); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
entity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
return entity; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
return result; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public Map<HikDeviceResp, List<HikMonitorResp>> getMonitorsByStation(String stationId) { |
|
|
|
|
Assert.isTrue(StringUtil.isNotBlank(pathConfiguration.getMonitorsPath()),()->{ |
|
|
|
|
throw new ServiceException("nacos中未配置海康威视请求地址!"); |
|
|
|
|
}); |
|
|
|
|
HttpResponse response; |
|
|
|
|
try{ |
|
|
|
|
response = HttpUtil.createGet(pathConfiguration.getMonitorsPath()+"/"+stationId).execute(); |
|
|
|
|
} |
|
|
|
|
catch (RuntimeException e) { |
|
|
|
|
throw new ServiceException(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
Assert.isTrue(HttpServletResponse.SC_OK == response.getStatus(),()->{ |
|
|
|
|
throw new ServiceException("调用获取海康威视站点下监测点列表接口失败!"); |
|
|
|
|
}); |
|
|
|
|
List<HikMonitorResp> monitorList = JSONArray.parseArray(response.body(), HikMonitorResp.class); |
|
|
|
|
logger.info("HikVideo:monitor:info",JSON.toJSONString(monitorList)); |
|
|
|
|
return monitorList.stream().collect(Collectors.groupingBy(HikMonitorResp::getDevice)); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public String getVideoReviewerToken() { |
|
|
|
|
String result = HttpUtil.post(videoLoginUrl, ""); |
|
|
|
|
JSONObject resultObject = JSONObject.parseObject(result); |
|
|
|
|
String data = resultObject.getString("data"); |
|
|
|
|
String access_token = JSONObject.parseObject(data).getString("access_token"); |
|
|
|
|
log.info("视频查看人员登陆token为:{}", access_token); |
|
|
|
|
return access_token; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<StationVideoTypeEntity> getVideoCount(String code,List<String> videoType,String videoOwerType) { |
|
|
|
|
LambdaQueryWrapper<StationVideoTypeEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
if (StringUtil.isNotBlank(code)) { |
|
|
|
|
queryWrapper.eq(StationVideoTypeEntity::getStationId, code); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(videoType)) { |
|
|
|
|
queryWrapper.in(StationVideoTypeEntity::getVideoType, videoType); |
|
|
|
|
} |
|
|
|
|
if (StringUtil.isNotBlank(videoOwerType)) { |
|
|
|
|
queryWrapper.eq(StationVideoTypeEntity::getVideoOwerType, videoOwerType); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(this.baseMapper.selectCount(queryWrapper))){ |
|
|
|
|
List<StationVideoTypeEntity> stationVideoTypeEntities = this.baseMapper.selectList(queryWrapper); |
|
|
|
|
return stationVideoTypeEntities; |
|
|
|
|
}else { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<JSONObject> getHikVisionStations() { |
|
|
|
|
Assert.isTrue(StringUtil.isNotBlank(pathConfiguration.getStationsPath()), () -> { |
|
|
|
|
throw new ServiceException("nacos中未配置海康威视请求地址!"); |
|
|
|
|
}); |
|
|
|
|
HttpResponse response; |
|
|
|
|
try { |
|
|
|
|
response = HttpUtil.createGet(pathConfiguration.getStationsPath()).execute(); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
logger.error("getHikVisionStations", e.getMessage()); |
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
// throw new ServiceException(e.getMessage());
|
|
|
|
|
} |
|
|
|
|
if (HttpServletResponse.SC_OK == response.getStatus()) { |
|
|
|
|
return JSONArray.parseArray(response.body(), JSONObject.class); |
|
|
|
|
} |
|
|
|
|
return Lists.newArrayList(); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public StationVideoTypeEntity getById(Long id,int streamType){ |
|
|
|
|
StationVideoTypeEntity stationVideoTypeEntity = this.getById(id); |
|
|
|
|
if(ObjectUtil.isNotEmpty(stationVideoTypeEntity.getIsHikvideo()) && stationVideoTypeEntity.getIsHikvideo() == 1){ |
|
|
|
|
try{ |
|
|
|
|
/**视频监控秘钥**/ |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewURL( |
|
|
|
|
stationVideoTypeEntity.getVideoHost() |
|
|
|
|
, stationVideoTypeEntity.getAppKey() |
|
|
|
|
, stationVideoTypeEntity.getAppSecret() |
|
|
|
|
, stationVideoTypeEntity.getPointCode() |
|
|
|
|
, DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE,stationVideoTypeEntity.getType()) |
|
|
|
|
, streamType |
|
|
|
|
)); |
|
|
|
|
} |
|
|
|
|
catch (Exception e){ |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return stationVideoTypeEntity; |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public Map<HikDeviceResp, List<HikMonitorResp>> getMonitorsByStation(String stationId) { |
|
|
|
|
Assert.isTrue(StringUtil.isNotBlank(pathConfiguration.getMonitorsPath()), () -> { |
|
|
|
|
throw new ServiceException("nacos中未配置海康威视请求地址!"); |
|
|
|
|
}); |
|
|
|
|
HttpResponse response; |
|
|
|
|
try { |
|
|
|
|
response = HttpUtil.createGet(pathConfiguration.getMonitorsPath() + "/" + stationId).execute(); |
|
|
|
|
} catch (RuntimeException e) { |
|
|
|
|
throw new ServiceException(e.getMessage()); |
|
|
|
|
} |
|
|
|
|
Assert.isTrue(HttpServletResponse.SC_OK == response.getStatus(), () -> { |
|
|
|
|
throw new ServiceException("调用获取海康威视站点下监测点列表接口失败!"); |
|
|
|
|
}); |
|
|
|
|
List<HikMonitorResp> monitorList = JSONArray.parseArray(response.body(), HikMonitorResp.class); |
|
|
|
|
logger.info("HikVideo:monitor:info", JSON.toJSONString(monitorList)); |
|
|
|
|
return monitorList.stream().collect(Collectors.groupingBy(HikMonitorResp::getDevice)); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<VideoMonitorVO> getVideoMonitor() { |
|
|
|
|
List<VideoMonitorVO> videoMonitorVOList = this.baseMapper.getVideoMonitor(); |
|
|
|
|
if(CollectionUtil.isEmpty(videoMonitorVOList)){ |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return videoMonitorVOList.stream().map(item->{ |
|
|
|
|
if(CollectionUtil.isEmpty(item.getChildren())){ |
|
|
|
|
return item; |
|
|
|
|
} |
|
|
|
|
item.setChildren(item.getChildren().stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StationVideoTypeVO::getName))), ArrayList::new))); |
|
|
|
|
return item; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<StationVideoTypeEntity> getVideoCount(String code, List<String> videoType, String videoOwerType) { |
|
|
|
|
LambdaQueryWrapper<StationVideoTypeEntity> queryWrapper = new LambdaQueryWrapper<>(); |
|
|
|
|
if (StringUtil.isNotBlank(code)) { |
|
|
|
|
queryWrapper.eq(StationVideoTypeEntity::getStationId, code); |
|
|
|
|
} |
|
|
|
|
if (CollectionUtil.isNotEmpty(videoType)) { |
|
|
|
|
queryWrapper.in(StationVideoTypeEntity::getVideoType, videoType); |
|
|
|
|
} |
|
|
|
|
if (StringUtil.isNotBlank(videoOwerType)) { |
|
|
|
|
queryWrapper.eq(StationVideoTypeEntity::getVideoOwerType, videoOwerType); |
|
|
|
|
} |
|
|
|
|
if (ObjectUtil.isNotEmpty(this.baseMapper.selectCount(queryWrapper))) { |
|
|
|
|
List<StationVideoTypeEntity> stationVideoTypeEntities = this.baseMapper.selectList(queryWrapper); |
|
|
|
|
return stationVideoTypeEntities; |
|
|
|
|
} else { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<VideoMonitorVO> getVideoMonitor(String type) { |
|
|
|
|
List<StationEntity> agencyStationList = this.baseMapper.getAgencyStationsByVideo(type); |
|
|
|
|
if(CollectionUtil.isEmpty(agencyStationList)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return agencyStationList.stream() |
|
|
|
|
.map(stationEntity -> BeanUtil.copy(stationEntity,VideoMonitorVO.class)) |
|
|
|
|
.map(videoMonitorVO -> { |
|
|
|
|
LambdaQueryWrapper<StationVideoTypeEntity> qw = Wrappers.<StationVideoTypeEntity>lambdaQuery() |
|
|
|
|
.eq(StationVideoTypeEntity::getStationId, videoMonitorVO.getCode()) |
|
|
|
|
.orderByAsc(StationVideoTypeEntity::getSort); |
|
|
|
|
if(StringUtil.isNotBlank(type)) { |
|
|
|
|
qw.eq(StationVideoTypeEntity::getVideoType,type); |
|
|
|
|
} |
|
|
|
|
List<StationVideoTypeVO> children = JSONArray.parseArray(JSONArray.toJSONString(this.list(qw)),StationVideoTypeVO.class); |
|
|
|
|
videoMonitorVO.setChildren(children); |
|
|
|
|
return videoMonitorVO; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public StationVideoTypeEntity getById(Long id, int streamType) { |
|
|
|
|
StationVideoTypeEntity stationVideoTypeEntity = this.getById(id); |
|
|
|
|
if (ObjectUtil.isNotEmpty(stationVideoTypeEntity.getIsHikvideo()) && stationVideoTypeEntity.getIsHikvideo() == 1) { |
|
|
|
|
try { |
|
|
|
|
/**视频监控秘钥**/ |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewURL( |
|
|
|
|
stationVideoTypeEntity.getVideoHost() |
|
|
|
|
, stationVideoTypeEntity.getAppKey() |
|
|
|
|
, stationVideoTypeEntity.getAppSecret() |
|
|
|
|
, stationVideoTypeEntity.getPointCode() |
|
|
|
|
, DictCache.getValue(StationConstants.STATION_VIDEO_TYPE_CODE, stationVideoTypeEntity.getType()) |
|
|
|
|
, streamType |
|
|
|
|
)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
stationVideoTypeEntity.setLiveSourceAddress(null); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return stationVideoTypeEntity; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 水利监控视频 |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public WaterMonitorVideoVo waterMonitorVideo() { |
|
|
|
|
WaterMonitorVideoVo video = new WaterMonitorVideoVo(); |
|
|
|
|
List<StationVideoTypeEntity> left = this.list(Wrappers.<StationVideoTypeEntity>lambdaQuery(). |
|
|
|
|
in(StationVideoTypeEntity::getId,Arrays.asList(28483776900235440L,28483776900235463L, 28483776900235466L))); |
|
|
|
|
if(CollectionUtil.isNotEmpty(left)){ |
|
|
|
|
video.setLeft(left.stream().peek(item->{ |
|
|
|
|
try { |
|
|
|
|
item.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(item.getVideoHost(), item.getAppKey(), item.getAppSecret(), item.getPointCode(), 1)); |
|
|
|
|
} |
|
|
|
|
catch(Exception e) { |
|
|
|
|
log.error("视频点位【"+item.getPointCode()+"】获取地址失败"); |
|
|
|
|
} |
|
|
|
|
@Override |
|
|
|
|
public List<VideoMonitorVO> getVideoMonitor() { |
|
|
|
|
List<VideoMonitorVO> videoMonitorVOList = this.baseMapper.getVideoMonitor(); |
|
|
|
|
if (CollectionUtil.isEmpty(videoMonitorVOList)) { |
|
|
|
|
return new ArrayList<>(); |
|
|
|
|
} |
|
|
|
|
return videoMonitorVOList.stream().map(item -> { |
|
|
|
|
if (CollectionUtil.isEmpty(item.getChildren())) { |
|
|
|
|
return item; |
|
|
|
|
} |
|
|
|
|
item.setChildren(item.getChildren().stream().collect(Collectors.collectingAndThen(Collectors.toCollection(() -> new TreeSet<>(Comparator.comparing(StationVideoTypeVO::getName))), ArrayList::new))); |
|
|
|
|
return item; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
@Override |
|
|
|
|
public List<VideoMonitorVO> getVideoMonitor(String type) { |
|
|
|
|
List<StationEntity> agencyStationList = this.baseMapper.getAgencyStationsByVideo(type); |
|
|
|
|
if (CollectionUtil.isEmpty(agencyStationList)) { |
|
|
|
|
return null; |
|
|
|
|
} |
|
|
|
|
return agencyStationList.stream() |
|
|
|
|
.map(stationEntity -> BeanUtil.copy(stationEntity, VideoMonitorVO.class)) |
|
|
|
|
.map(videoMonitorVO -> { |
|
|
|
|
LambdaQueryWrapper<StationVideoTypeEntity> qw = Wrappers.<StationVideoTypeEntity>lambdaQuery() |
|
|
|
|
.eq(StationVideoTypeEntity::getStationId, videoMonitorVO.getCode()) |
|
|
|
|
.orderByAsc(StationVideoTypeEntity::getSort); |
|
|
|
|
if (StringUtil.isNotBlank(type)) { |
|
|
|
|
qw.eq(StationVideoTypeEntity::getVideoType, type); |
|
|
|
|
} |
|
|
|
|
List<StationVideoTypeVO> children = JSONArray.parseArray(JSONArray.toJSONString(this.list(qw)), StationVideoTypeVO.class); |
|
|
|
|
videoMonitorVO.setChildren(children); |
|
|
|
|
return videoMonitorVO; |
|
|
|
|
}).collect(Collectors.toList()); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
* 水利监控视频 |
|
|
|
|
* |
|
|
|
|
* @return |
|
|
|
|
*/ |
|
|
|
|
@Override |
|
|
|
|
public WaterMonitorVideoVo waterMonitorVideo() { |
|
|
|
|
WaterMonitorVideoVo video = new WaterMonitorVideoVo(); |
|
|
|
|
List<StationVideoTypeEntity> left = this.list(Wrappers.<StationVideoTypeEntity>lambdaQuery(). |
|
|
|
|
in(StationVideoTypeEntity::getId, videoLeft)); |
|
|
|
|
if (CollectionUtil.isNotEmpty(left)) { |
|
|
|
|
video.setLeft(left.stream().peek(item -> { |
|
|
|
|
try { |
|
|
|
|
item.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(item.getVideoHost(), item.getAppKey(), item.getAppSecret(), item.getPointCode(), 1)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("视频点位【" + item.getPointCode() + "】获取地址失败"); |
|
|
|
|
} |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
List<StationVideoTypeEntity> right = this.list(Wrappers.<StationVideoTypeEntity>lambdaQuery(). |
|
|
|
|
in(StationVideoTypeEntity::getId,Arrays.asList(28483776900235468L,28483776900235467L,28483776900235472L))); |
|
|
|
|
if(CollectionUtil.isNotEmpty(right)){ |
|
|
|
|
video.setRight(right.stream().peek(item->{ |
|
|
|
|
try { |
|
|
|
|
item.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(item.getVideoHost(), item.getAppKey(), item.getAppSecret(), item.getPointCode(), 1)); |
|
|
|
|
} |
|
|
|
|
catch(Exception e) { |
|
|
|
|
log.error("视频点位【"+item.getPointCode()+"】获取地址失败"); |
|
|
|
|
} |
|
|
|
|
List<StationVideoTypeEntity> right = this.list(Wrappers.<StationVideoTypeEntity>lambdaQuery(). |
|
|
|
|
in(StationVideoTypeEntity::getId, videoRight)); |
|
|
|
|
if (CollectionUtil.isNotEmpty(right)) { |
|
|
|
|
video.setRight(right.stream().peek(item -> { |
|
|
|
|
try { |
|
|
|
|
item.setLiveSourceAddress(ArtemisPostUtils.getCameraPreviewFlvURL(item.getVideoHost(), item.getAppKey(), item.getAppSecret(), item.getPointCode(), 1)); |
|
|
|
|
} catch (Exception e) { |
|
|
|
|
log.error("视频点位【" + item.getPointCode() + "】获取地址失败"); |
|
|
|
|
} |
|
|
|
|
}).collect(Collectors.toList())); |
|
|
|
|
} |
|
|
|
|
return video; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
return video; |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|