|
|
@@ -4,11 +4,11 @@ import cn.hutool.core.bean.BeanUtil;
|
|
|
import cn.hutool.core.collection.CollUtil;
|
|
|
import cn.hutool.core.util.StrUtil;
|
|
|
import com.baomidou.mybatisplus.core.conditions.query.LambdaQueryWrapper;
|
|
|
-import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.github.pagehelper.PageHelper;
|
|
|
import com.github.pagehelper.PageInfo;
|
|
|
import com.middle.platform.common.core.exception.BusinessException;
|
|
|
+import com.middle.platform.common.core.modle.BasePara;
|
|
|
import com.middle.platform.manage.api.feign.DeviceApi;
|
|
|
import com.middle.platform.manage.api.pojo.DevicesNameVo;
|
|
|
import com.middle.platform.manage.api.pojo.DevicesVo;
|
|
|
@@ -58,37 +58,36 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
|
|
|
* @author Aick Spt
|
|
|
* @date 2024-05-08 18:44
|
|
|
*/
|
|
|
- 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<>();
|
|
|
+ public PageRes<DevicesPathVo> getDevicePathList(BasePara basePara) {
|
|
|
+ //根据设备名称模糊筛选设备,获得设备id列表
|
|
|
List<Long> ids = new ArrayList<>();
|
|
|
- for (SDevice sDevice1 : sDevices) {
|
|
|
- ids.add(sDevice1.getDeviceId());
|
|
|
+ //如果有设备,需要先查出设备id
|
|
|
+ if (StrUtil.isNotBlank(basePara.getKeywords())) {
|
|
|
+ DevicesNameVo devicesNameVo = new DevicesNameVo();
|
|
|
+ devicesNameVo.setKeywords(basePara.getKeywords());
|
|
|
+ List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
|
|
|
+ for (DevicesVo devicesVo : devicesVos) {
|
|
|
+ ids.add(devicesVo.getId());
|
|
|
+ }
|
|
|
}
|
|
|
- //根据设备id查询设备表,获取到设备id和设备name
|
|
|
- DevicesNameVo devicesNameVo = new DevicesNameVo();
|
|
|
- devicesNameVo.setIds(ids);
|
|
|
- devicesNameVo.setKeywords(keywords);
|
|
|
- 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;
|
|
|
- }
|
|
|
+ PageHelper.startPage(basePara.getPage(), basePara.getPageSize());
|
|
|
+ List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<SDevice>()
|
|
|
+ .in(CollUtil.isNotEmpty(ids), SDevice::getDeviceId, ids));
|
|
|
+
|
|
|
+ if (Objects.isNull(sDevices)) {
|
|
|
+ return new PageRes<>();
|
|
|
+ }
|
|
|
+ PageInfo<SDevice> pageInfo = new PageInfo<>(sDevices);
|
|
|
+ List<DevicesPathVo> res = new ArrayList<>();
|
|
|
+ for (SDevice sDevice : sDevices) {
|
|
|
+ DevicesPathVo devicesPathVo = BeanUtil.toBean(sDevice, DevicesPathVo.class);
|
|
|
+ DevicesVo devicesVo = deviceApi.queryDevice(sDevice.getDeviceId());
|
|
|
+ if (Objects.nonNull(devicesVo)) {
|
|
|
+ devicesPathVo.setName(devicesVo.getName());
|
|
|
}
|
|
|
+ res.add(devicesPathVo);
|
|
|
}
|
|
|
- return devicesPathVos;
|
|
|
+ return PageRes.build(pageInfo, res);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
@@ -122,8 +121,14 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
|
|
|
if (Objects.isNull(sDevice)) {
|
|
|
throw new BusinessException("视频流不存在");
|
|
|
}
|
|
|
- BeanUtil.copyProperties(streamUpdateRes, sDevice);
|
|
|
- return sDeviceMapper.updateById(sDevice);
|
|
|
+ SDevice sDevice1 = new SDevice();
|
|
|
+ sDevice1.setId(streamUpdateRes.getId());
|
|
|
+ sDevice1.setDeviceId(streamUpdateRes.getDeviceId());
|
|
|
+ sDevice1.setCover(streamUpdateRes.getCover());
|
|
|
+// sDevice1.setPath("");
|
|
|
+// sDevice1.setTarget("");
|
|
|
+ sDevice1.setType(streamUpdateRes.getType());
|
|
|
+ return sDeviceMapper.updateById(sDevice1);
|
|
|
}
|
|
|
|
|
|
public int updateStatus(StreamUpdateStatusRes streamUpdateStatusRes) {
|
|
|
@@ -141,7 +146,7 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
|
|
|
if (Objects.isNull(sDevice)) {
|
|
|
throw new BusinessException("视频流不存在");
|
|
|
}
|
|
|
- return VideoPathUtil.videoUrl(streamMediaProperties.getUrl(),sDevice.getPath());
|
|
|
+ return VideoPathUtil.videoUrl(streamMediaProperties.getUrl(), sDevice.getPath());
|
|
|
}
|
|
|
|
|
|
// /**
|
|
|
@@ -211,10 +216,9 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
|
|
|
}
|
|
|
|
|
|
PageInfo<SDevice> pageInfo = new PageInfo<>(sDevices);
|
|
|
- StreamPageRes streamPageRes = new StreamPageRes();
|
|
|
List<StreamPageRes> streamPageRes2 = new ArrayList<>();
|
|
|
for (SDevice sDevice : sDevices) {
|
|
|
- BeanUtil.copyProperties(sDevice, streamPageRes);
|
|
|
+ StreamPageRes streamPageRes = BeanUtil.toBean(sDevice, StreamPageRes.class);
|
|
|
DevicesVo devicesVo = deviceApi.queryDevice(sDevice.getDeviceId());
|
|
|
if (Objects.nonNull(devicesVo)) {
|
|
|
streamPageRes.setDeviceName(devicesVo.getName());
|