Forráskód Böngészése

视频分页查询

sptkw 1 éve
szülő
commit
ad0b8fb186

+ 1 - 1
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/req/StreamAddRes.java

@@ -34,6 +34,6 @@ public class StreamAddRes {
     /**
      * 视频流类型 1-rtsp 2-rtmp
      */
-    private Boolean type;
+    private int type;
 
 }

+ 7 - 2
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/StreamPageRes.java

@@ -24,6 +24,11 @@ public class StreamPageRes {
      */
     private Long deviceId;
 
+    /**
+     * 设备名称
+     */
+    private String deviceName;
+
     /**
      * 封面地址
      */
@@ -47,12 +52,12 @@ public class StreamPageRes {
     /**
      * 使用状态 1-使用中 2-禁用
      */
-    private Boolean useFlag;
+    private int useFlag;
 
     /**
      * 视频流类型 1-rtsp 2-rtmp
      */
-    private Boolean type;
+    private int type;
 
     /**
      * 创建人

+ 94 - 36
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/SDeviceService.java

@@ -44,6 +44,12 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
     private DeviceApi deviceApi;
 
 
+    /**
+     * 录像回放左边筛选 - 获取设备流标签信息
+     *
+     * @author Aick Spt
+     * @date 2024-05-08 18:44
+     */
     public List<DevicesPathVo> getDevicePathList(String keywords) {
         //查询出所有已新增在流表里的设备id
         SDevice sDevice = new SDevice();
@@ -59,6 +65,7 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         //根据设备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();
@@ -76,10 +83,27 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         return devicesPathVos;
     }
 
+    /**
+     * 新增流视频信息
+     *
+     * @author Aick Spt
+     * @date 2024-05-08 20:05
+     */
     public int add(StreamAddRes streamAddRes) {
         SDevice sDevice = new SDevice();
         BeanUtil.copyProperties(streamAddRes, sDevice);
-        return sDeviceMapper.insert(sDevice);
+        int insert = sDeviceMapper.insert(sDevice);
+        //这里需要拉流一下
+        if (insert > 0) {
+            //视频流类型 1-rtsp 2-rtmp
+            if (streamAddRes.getType() == 1) {
+                apiProxy.rtspPull(sDevice.getPath(), sDevice.getTarget(), "");
+            }
+            if (streamAddRes.getType() == 2) {
+                apiProxy.rtmpPull(sDevice.getPath(), sDevice.getTarget(), "");
+            }
+        }
+        return insert;
     }
 
     public int update(StreamUpdateRes streamUpdateRes) {
@@ -108,48 +132,82 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         return streamMediaProperties.getUrl() + sDevice.getPath();
     }
 
+//    /**
+//     * rtmp列表查询
+//     *
+//     * @param streamPage
+//     * @return
+//     */
+//    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);
+//        }};
+//    }
+
     /**
-     * rtmp列表查询
+     * 分页查询
      *
-     * @param streamPage
-     * @return
+     * @author Aick Spt
+     * @date 2024-05-09 09:10
      */
-    public List<Object> rtmpPage(StreamPage streamPage) {
-        log.info("rtmpPage in...");
+    public Object pageQuery(VideoPage videoPage) {
+        PageHelper.startPage(videoPage.getPage(), videoPage.getPageSize());
         //根据设备名称模糊筛选设备,获得设备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("查无产品");
-            }
+        //如果有设备,需要先查出设备id
+        DevicesNameVo devicesNameVo = new DevicesNameVo();
+        devicesNameVo.setKeywords(videoPage.getKeywords());
+        List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
+        if (Objects.isNull(devicesVos)) {
+            throw new BusinessException("查无产品");
+        }
+        for (DevicesVo devicesVo : devicesVos) {
+            ids.add(devicesVo.getId());
+        }
+        log.info("ids : {}", ids);
+        List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<SDevice>().in(SDevice::getDeviceId, ids));
+        if (Objects.isNull(sDevices)) {
+            throw new BusinessException("查无产品");
+        }
+        StreamPageRes streamPageRes = new StreamPageRes();
+        List<StreamPageRes> streamPageRes2 = new ArrayList<>();
+        for (SDevice sDevice : sDevices) {
+            sDevice.setPath(streamMediaProperties.getUrl() + sDevice.getPath());
             for (DevicesVo devicesVo : devicesVos) {
-                ids.add(devicesVo.getId());
+                if (devicesVo.getId().equals(sDevice.getDeviceId())) {
+                    BeanUtil.copyProperties(sDevice, streamPageRes);
+                    streamPageRes.setDeviceName(devicesVo.getName());
+                    streamPageRes2.add(streamPageRes);
+                }
             }
-            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);
-        }};
-    }
-
-    public Object pageQuery(VideoPage videoPage) {
-        PageHelper.startPage(videoPage.getPage(), videoPage.getPageSize());
-        List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<>());
-        return sDevices;
+        return streamPageRes2;
     }
 }

+ 4 - 4
iot-module/iot-module-stream/iot-module-stream-biz/src/main/resources/bootstrap-local.yaml

@@ -3,15 +3,15 @@ spring:
     nacos:
       server-addr: 127.0.0.1:8848
       discovery:
-        namespace: 78524032-ad7a-4724-8f8b-eef5ac08c5b5
+        namespace: 5ba3761b-2ca6-4037-889e-d9354297d356
       config:
         server-addr: 127.0.0.1:8848 # Nacos 服务器地址
-        namespace: 78524032-ad7a-4724-8f8b-eef5ac08c5b5
+        namespace: 5ba3761b-2ca6-4037-889e-d9354297d356
         group: DEFAULT_GROUP # 使用的 Nacos 配置分组,默认为 DEFAULT_GROUP
         name: ${spring.application.name} # 使用的 Nacos 配置集的 dataId,默认为 spring.application.name
         file-extension: yaml # 使用的 Nacos 配置集的 dataId 的文件拓展名,同时也是 Nacos 配置集的配置格式,默认为 properties
-        username: nacos
-        password: nacos
+#        username: nacos
+#        password: nacos
         shared-configs:
           - data-id: common.yaml
             group: common