|
|
@@ -1,33 +1,13 @@
|
|
|
package com.middle.platform.stream.biz.service.impl;
|
|
|
|
|
|
-import cn.hutool.core.bean.BeanUtil;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
-import com.middle.platform.common.core.exception.BusinessException;
|
|
|
-import com.middle.platform.manage.api.feign.DeviceApi;
|
|
|
-import com.middle.platform.manage.api.pojo.DevicesNameVo;
|
|
|
-import com.middle.platform.manage.api.pojo.DevicesVo;
|
|
|
-import com.middle.platform.stream.biz.domain.req.StreamAddRes;
|
|
|
-import com.middle.platform.stream.biz.domain.req.StreamUpdateRes;
|
|
|
-import com.middle.platform.stream.biz.domain.req.StreamUpdateStatusRes;
|
|
|
-import com.middle.platform.stream.biz.domain.res.DevicesPathVo;
|
|
|
-import com.middle.platform.stream.biz.domain.res.StreamPageRes;
|
|
|
-import com.middle.platform.stream.biz.entity.SDevice;
|
|
|
-import com.middle.platform.stream.biz.mapper.SDeviceMapper;
|
|
|
-import com.middle.platform.stream.biz.pojo.PullPara;
|
|
|
-import com.middle.platform.stream.biz.pojo.PushPara;
|
|
|
-import com.middle.platform.stream.biz.pojo.StreamPage;
|
|
|
import com.middle.platform.stream.biz.pojo.StreamRecordPage;
|
|
|
-import com.middle.platform.stream.biz.properties.StreamMediaProperties;
|
|
|
import com.middle.platform.stream.biz.service.ApiProxy;
|
|
|
import com.middle.platform.stream.biz.service.StreamMediaService;
|
|
|
-import jakarta.annotation.Resource;
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
import lombok.extern.slf4j.Slf4j;
|
|
|
import org.springframework.stereotype.Service;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
-import java.util.List;
|
|
|
-import java.util.Objects;
|
|
|
|
|
|
/**
|
|
|
* @author xucaiqin
|
|
|
@@ -38,45 +18,7 @@ import java.util.Objects;
|
|
|
@RequiredArgsConstructor
|
|
|
public class StreamMediaServiceImpl implements StreamMediaService {
|
|
|
private final ApiProxy apiProxy;
|
|
|
- private final SDeviceMapper sDeviceMapper;
|
|
|
- private final StreamMediaProperties streamMediaProperties;
|
|
|
|
|
|
- @Resource
|
|
|
- DeviceApi deviceApi;
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Object> rtmpPage(StreamPage streamPage) {
|
|
|
- log.info("rtmpPage in...");
|
|
|
- //根据设备名称模糊筛选设备,获得设备id列表
|
|
|
- String keywords = streamPage.getKeywords();
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
- if (keywords != null && !keywords.isEmpty()) {
|
|
|
- //如果有设备,需要先查出设备id
|
|
|
- DevicesNameVo devicesNameVo = new DevicesNameVo();
|
|
|
- devicesNameVo.setKeywords(keywords);
|
|
|
- List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
|
|
|
- if (Objects.isNull(devicesVos)) {
|
|
|
- throw new BusinessException("查无产品");
|
|
|
- }
|
|
|
- for (DevicesVo devicesVo : devicesVos) {
|
|
|
- ids.add(devicesVo.getId());
|
|
|
- }
|
|
|
- streamPage.setDeviceIds(ids);
|
|
|
- }
|
|
|
- log.info("rtmpList:{}", ids);
|
|
|
- //数据库查询
|
|
|
- StreamPageRes streamPageRes = sDeviceMapper.selectStreamPage(streamPage);
|
|
|
- if (Objects.isNull(streamPageRes)) {
|
|
|
- throw new BusinessException("查无产品!");
|
|
|
- }
|
|
|
- //API调用
|
|
|
- ArrayList<Object> objects = new ArrayList<>();
|
|
|
- Object o = apiProxy.rtmpList();
|
|
|
- log.info("rtmpList:{}", o);
|
|
|
- return new ArrayList<>() {{
|
|
|
- add(o);
|
|
|
- }};
|
|
|
- }
|
|
|
|
|
|
@Override
|
|
|
public ArrayList<Object> recordPage(StreamRecordPage streamRecordPage) {
|
|
|
@@ -89,111 +31,7 @@ public class StreamMediaServiceImpl implements StreamMediaService {
|
|
|
}};
|
|
|
}
|
|
|
|
|
|
- @Override
|
|
|
- public List<Object> rtmpPull(PullPara pullPara) {
|
|
|
- //todo 业务功能增加
|
|
|
- Object o = apiProxy.rtmpPull(pullPara.getStreamPath(), pullPara.getTarget(), pullPara.getSave());
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Object> rtspPage(StreamPage streamPage) {
|
|
|
- //todo 查询业务表-拼接数据
|
|
|
- Object o = apiProxy.rtspList();
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Object> rtspPull(PullPara pullPara) {
|
|
|
- //todo 业务功能增加
|
|
|
- Object o = apiProxy.rtspPull(pullPara.getStreamPath(), pullPara.getTarget(), pullPara.getSave());
|
|
|
-
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<Object> rtspPush(PushPara pushPara) {
|
|
|
- return null;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<DevicesVo> getDeviceList(String keywords) {
|
|
|
- DevicesNameVo devicesNameVo = new DevicesNameVo();
|
|
|
- devicesNameVo.setKeywords(keywords);
|
|
|
- return deviceApi.devicesQuery(devicesNameVo);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public List<DevicesPathVo> getDevicePathList(String keywords) {
|
|
|
- //查询出所有已新增在流表里的设备id
|
|
|
- SDevice sDevice = new SDevice();
|
|
|
- sDevice.setDelFlag(0);
|
|
|
- sDevice.setUseFlag(1);
|
|
|
- List<SDevice> sDevices = sDeviceMapper.selectList(new QueryWrapper<>(sDevice));
|
|
|
- //获取到所有sDevices中的设备id,再去查设备表,获取到设备id和设备name
|
|
|
- List<DevicesPathVo> devicesPathVos = new ArrayList<>();
|
|
|
- List<Long> ids = new ArrayList<>();
|
|
|
- for (SDevice sDevice1 : sDevices) {
|
|
|
- ids.add(sDevice1.getDeviceId());
|
|
|
- }
|
|
|
- //根据设备id查询设备表,获取到设备id和设备name
|
|
|
- DevicesNameVo devicesNameVo = new DevicesNameVo();
|
|
|
- devicesNameVo.setIds(ids);
|
|
|
- List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
|
|
|
- //获取到设备id和设备name,再去查设备表,获取到设备id和设备path
|
|
|
- DevicesPathVo devicesPathVo = new DevicesPathVo();
|
|
|
- for (DevicesVo devicesVo : devicesVos) {
|
|
|
- devicesPathVo.setId(devicesVo.getId());
|
|
|
- devicesPathVo.setName(devicesVo.getName());
|
|
|
- for (SDevice sDevice2 : sDevices) {
|
|
|
- if (Objects.equals(sDevice2.getDeviceId(), devicesVo.getId())) {
|
|
|
- devicesPathVo.setPath(sDevice2.getPath());
|
|
|
- devicesPathVos.add(devicesPathVo);
|
|
|
- break;
|
|
|
- }
|
|
|
- }
|
|
|
- }
|
|
|
- return devicesPathVos;
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public int add(StreamAddRes streamAddRes) {
|
|
|
- SDevice sDevice = new SDevice();
|
|
|
- BeanUtil.copyProperties(streamAddRes, sDevice);
|
|
|
- return sDeviceMapper.insert(sDevice);
|
|
|
- }
|
|
|
-
|
|
|
-
|
|
|
- @Override
|
|
|
- public int update(StreamUpdateRes streamUpdateRes) {
|
|
|
- SDevice sDevice = sDeviceMapper.selectById(streamUpdateRes.getId());
|
|
|
- if (Objects.isNull(sDevice)) {
|
|
|
- throw new BusinessException("视频流不存在");
|
|
|
- }
|
|
|
- BeanUtil.copyProperties(streamUpdateRes, sDevice);
|
|
|
- return sDeviceMapper.updateById(sDevice);
|
|
|
- }
|
|
|
|
|
|
- @Override
|
|
|
- public int updateStatus(StreamUpdateStatusRes streamUpdateStatusRes) {
|
|
|
- SDevice sDevice = sDeviceMapper.selectById(streamUpdateStatusRes.getId());
|
|
|
- if (Objects.isNull(sDevice)) {
|
|
|
- throw new BusinessException("视频流不存在");
|
|
|
- }
|
|
|
- BeanUtil.copyProperties(streamUpdateStatusRes, sDevice);
|
|
|
- return sDeviceMapper.updateById(sDevice);
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public String getVideoUrl(Long id) {
|
|
|
- SDevice sDevice = sDeviceMapper.selectById(id);
|
|
|
- if (Objects.isNull(sDevice)) {
|
|
|
- throw new BusinessException("视频流不存在");
|
|
|
- }
|
|
|
- return streamMediaProperties.getUrl() + sDevice.getPath();
|
|
|
- }
|
|
|
|
|
|
|
|
|
}
|