|
|
@@ -1,17 +1,28 @@
|
|
|
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.res.streamPageRes;
|
|
|
+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;
|
|
|
@@ -23,22 +34,27 @@ import java.util.Objects;
|
|
|
* @date 2024-04-26 11:21:53
|
|
|
*/
|
|
|
@Service
|
|
|
+@Slf4j
|
|
|
@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
|
|
|
- List<DevicesVo> devicesVos = deviceApi.devicesQuery(keywords);
|
|
|
+ DevicesNameVo devicesNameVo = new DevicesNameVo();
|
|
|
+ devicesNameVo.setKeywords(keywords);
|
|
|
+ List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
|
|
|
if (Objects.isNull(devicesVos)) {
|
|
|
throw new BusinessException("查无产品");
|
|
|
}
|
|
|
@@ -47,15 +63,27 @@ public class StreamMediaServiceImpl implements StreamMediaService {
|
|
|
}
|
|
|
streamPage.setDeviceIds(ids);
|
|
|
}
|
|
|
+ log.info("rtmpList:{}", ids);
|
|
|
//数据库查询
|
|
|
- streamPageRes streamPageRes = sDeviceMapper.selectStreamPage(streamPage);
|
|
|
+ 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) {
|
|
|
+ log.info("recordPage in...");
|
|
|
+ //API调用
|
|
|
+ Object o = apiProxy.recordListPage("mp4", streamRecordPage.getPage(), streamRecordPage.getPageSize(), streamRecordPage.getPath());
|
|
|
+ log.info("rtmpList:{}", o);
|
|
|
return new ArrayList<>() {{
|
|
|
add(o);
|
|
|
}};
|
|
|
@@ -90,5 +118,82 @@ public class StreamMediaServiceImpl implements StreamMediaService {
|
|
|
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();
|
|
|
+ }
|
|
|
+
|
|
|
|
|
|
}
|