sptkw 1 год назад
Родитель
Сommit
3835549b2e
13 измененных файлов с 239 добавлено и 3 удалено
  1. 12 0
      iot-module/iot-module-manage/iot-module-manage-api/src/main/java/com/middle/platform/manage/api/feign/DeviceApi.java
  2. 30 0
      iot-module/iot-module-manage/iot-module-manage-api/src/main/java/com/middle/platform/manage/api/pojo/DevicesVo.java
  3. 9 0
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/api/DeviceApiImpl.java
  4. 5 0
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/mapper/IotDeviceMapper.java
  5. 13 0
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotDeviceService.java
  6. 13 0
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml
  7. 4 0
      iot-module/iot-module-stream/iot-module-stream-biz/pom.xml
  8. 79 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/streamPageRes.java
  9. 21 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/entity/StreamType.java
  10. 6 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/mapper/SDeviceMapper.java
  11. 3 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/pojo/StreamPage.java
  12. 29 3
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/impl/StreamMediaServiceImpl.java
  13. 15 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/resources/mapper/SDeviceMapper.xml

+ 12 - 0
iot-module/iot-module-manage/iot-module-manage-api/src/main/java/com/middle/platform/manage/api/feign/DeviceApi.java

@@ -4,10 +4,13 @@ import com.middle.platform.common.core.constant.RpcConstants;
 import com.middle.platform.manage.api.enums.ApiConstants;
 import com.middle.platform.manage.api.pojo.DeviceDetailVo;
 import com.middle.platform.manage.api.pojo.DeviceVo;
+import com.middle.platform.manage.api.pojo.DevicesVo;
 import org.springframework.cloud.openfeign.FeignClient;
 import org.springframework.web.bind.annotation.GetMapping;
 import org.springframework.web.bind.annotation.RequestParam;
 
+import java.util.List;
+
 /**
  * @author xucaiqin
  * @date 2023-12-17 11:09:05
@@ -34,4 +37,13 @@ public interface DeviceApi {
     @GetMapping(prefix + "/deviceDetail")
     DeviceDetailVo deviceDetail(@RequestParam("id") Long id);
 
+
+    /**
+     * 查询设备
+     * @author Aick Spt
+     * @date 2024-05-06 11:44
+     */
+    List<DevicesVo> devicesQuery(@RequestParam("keyword") String keyword);
+
+
 }

+ 30 - 0
iot-module/iot-module-manage/iot-module-manage-api/src/main/java/com/middle/platform/manage/api/pojo/DevicesVo.java

@@ -0,0 +1,30 @@
+package com.middle.platform.manage.api.pojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 设备
+ *
+ * @author xucaiqin
+ * @date 2023-12-23 14:04:27
+ */
+@Getter
+@Setter
+public class DevicesVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = -510946656997873695L;
+
+    /**
+     * 设备id
+     */
+    private Long id;
+    /**
+     * 设备名称
+     */
+    private String name;
+}

+ 9 - 0
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/api/DeviceApiImpl.java

@@ -4,11 +4,13 @@ import cn.hutool.core.bean.BeanUtil;
 import com.middle.platform.manage.api.feign.DeviceApi;
 import com.middle.platform.manage.api.pojo.DeviceDetailVo;
 import com.middle.platform.manage.api.pojo.DeviceVo;
+import com.middle.platform.manage.api.pojo.DevicesVo;
 import com.middle.platform.manage.biz.domain.vo.IotDeviceDetailVo;
 import com.middle.platform.manage.biz.service.IotDeviceService;
 import lombok.RequiredArgsConstructor;
 import org.springframework.web.bind.annotation.RestController;
 
+import java.util.List;
 import java.util.Objects;
 
 /**
@@ -33,4 +35,11 @@ public class DeviceApiImpl implements DeviceApi {
         }
         return null;
     }
+
+    @Override
+    public List<DevicesVo> devicesQuery(String keyword) {
+        return iotDeviceService.devicesQuery(keyword);
+    }
+
+
 }

+ 5 - 0
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/mapper/IotDeviceMapper.java

@@ -2,6 +2,7 @@ package com.middle.platform.manage.biz.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
 import com.middle.platform.manage.api.pojo.DeviceVo;
+import com.middle.platform.manage.api.pojo.DevicesVo;
 import com.middle.platform.manage.biz.domain.req.DevicePage;
 import com.middle.platform.manage.biz.domain.req.TypeStatisticsReq;
 import com.middle.platform.manage.biz.domain.vo.*;
@@ -63,4 +64,8 @@ public interface IotDeviceMapper extends BaseMapper<IotDevice> {
     List<IotDeviceDownVo> list(@Param("productId") Long productId);
 
     void updateStatus(IotDeviceVo iotDevice);
+
+    List<DevicesVo> devicesQuery(@Param("keyword") String keyword);
+
+
 }

+ 13 - 0
iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotDeviceService.java

@@ -11,6 +11,7 @@ import com.middle.platform.common.core.exception.BusinessException;
 import com.middle.platform.data.api.feign.TdApi;
 import com.middle.platform.excel.core.util.ExcelUtils;
 import com.middle.platform.manage.api.pojo.DeviceVo;
+import com.middle.platform.manage.api.pojo.DevicesVo;
 import com.middle.platform.manage.biz.domain.req.DevicePage;
 import com.middle.platform.manage.biz.domain.req.IotDeviceFlag;
 import com.middle.platform.manage.biz.domain.req.IotDevicePara;
@@ -330,4 +331,16 @@ public class IotDeviceService {
     public Object list(Long productId) {
         return iotDeviceMapper.list(productId);
     }
+
+
+    /**
+     * 根据设备名字模糊筛选
+     * @author Aick Spt
+     * @date 2024-05-07 17:03
+     */
+    public List<DevicesVo> devicesQuery(String keyword) {
+        return iotDeviceMapper.devicesQuery(keyword);
+    }
+
+
 }

+ 13 - 0
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml

@@ -212,4 +212,17 @@
             online_time= #{onlineTime,jdbcType=TIMESTAMP}
         WHERE id = #{id,jdbcType=BIGINT}
     </update>
+
+    <select id="devicesQuery" resultType="com.middle.platform.manage.api.pojo.DevicesVo">
+        select id.id, id.name
+        from iot_device id
+        <where>
+            id.del_flag = 0
+            and id.enable_flag = 1
+            <if test="keyword != null and keyword != ''">
+                and id.name like concat('%', #{keyword,jdbcType=VARCHAR}, '%')
+            </if>
+        </where>
+    </select>
+
 </mapper>

+ 4 - 0
iot-module/iot-module-stream/iot-module-stream-biz/pom.xml

@@ -53,6 +53,10 @@
             <groupId>com.middle.platform</groupId>
             <artifactId>iot-starter-redis</artifactId>
         </dependency>
+        <dependency>
+            <groupId>com.middle.platform</groupId>
+            <artifactId>iot-module-manage-api</artifactId>
+        </dependency>
 
 
     </dependencies>

+ 79 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/streamPageRes.java

@@ -0,0 +1,79 @@
+package com.middle.platform.stream.biz.domain.res;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+import java.time.LocalDateTime;
+
+/**
+ * @author Aick Spt
+ * @date 2024-05-06 10:31
+ */
+@Slf4j
+@Data
+public class streamPageRes {
+
+
+    /**
+     * id
+     */
+    private Long id;
+
+    /**
+     * 设备id
+     */
+    private Long deviceId;
+
+    /**
+     * 封面地址
+     */
+    private String cover;
+
+    /**
+     * 流路径
+     */
+    private String path;
+
+    /**
+     * 目标地址
+     */
+    private String target;
+
+    /**
+     * 分片存储规则 1-1小时
+     */
+    private Boolean saveRule;
+
+    /**
+     * 使用状态 1-使用中 2-禁用
+     */
+    private Boolean useFlag;
+
+    /**
+     * 视频流类型 1-rtsp 2-rtmp
+     */
+    private Boolean type;
+
+    /**
+     * 创建人
+     */
+    private Long createBy;
+
+    /**
+     * 创建时间
+     */
+    private LocalDateTime createTime;
+
+    /**
+     * 更新人
+     */
+    private Long updateBy;
+
+    /**
+     * 更新时间
+     */
+    private LocalDateTime updateTime;
+
+
+
+}

+ 21 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/entity/StreamType.java

@@ -0,0 +1,21 @@
+package com.middle.platform.stream.biz.entity;
+
+/**
+ * @author Aick Spt
+ * @desc: 枚举流类型
+ * @date 2024-04-30 14:05
+ */
+@SuppressWarnings("all")
+public class StreamType {
+
+    /**
+     * 视频流类型:rtsp
+     */
+    public static final int RTSP = 1;
+
+    /**
+     * 视频流类型:rtmp
+     */
+    public static final int RTMP = 2;
+
+}

+ 6 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/mapper/SDeviceMapper.java

@@ -1,8 +1,11 @@
 package com.middle.platform.stream.biz.mapper;
 
 import com.baomidou.mybatisplus.core.mapper.BaseMapper;
+import com.middle.platform.stream.biz.domain.res.streamPageRes;
 import com.middle.platform.stream.biz.entity.SDevice;
+import com.middle.platform.stream.biz.pojo.StreamPage;
 import org.apache.ibatis.annotations.Mapper;
+import org.apache.ibatis.annotations.Param;
 
 /**
 * @date 2024-05-06 09:54:48
@@ -10,4 +13,7 @@ import org.apache.ibatis.annotations.Mapper;
 */
 @Mapper
 public interface SDeviceMapper extends BaseMapper<SDevice> {
+
+     streamPageRes selectStreamPage(@Param("streamPage") StreamPage streamPage);
+
 }

+ 3 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/pojo/StreamPage.java

@@ -4,6 +4,8 @@ import com.middle.platform.common.core.modle.BasePara;
 import lombok.Getter;
 import lombok.Setter;
 
+import java.util.List;
+
 /**
  * @author xucaiqin
  * @date 2024-04-28 14:26:41
@@ -11,4 +13,5 @@ import lombok.Setter;
 @Getter
 @Setter
 public class StreamPage extends BasePara {
+    List<Long> deviceIds;
 }

+ 29 - 3
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/impl/StreamMediaServiceImpl.java

@@ -1,15 +1,22 @@
 package com.middle.platform.stream.biz.service.impl;
 
+import com.middle.platform.common.core.exception.BusinessException;
+import com.middle.platform.manage.api.feign.DeviceApi;
+import com.middle.platform.manage.api.pojo.DevicesVo;
+import com.middle.platform.stream.biz.domain.res.streamPageRes;
+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.service.ApiProxy;
 import com.middle.platform.stream.biz.service.StreamMediaService;
+import jakarta.annotation.Resource;
 import lombok.RequiredArgsConstructor;
 import org.springframework.stereotype.Service;
 
 import java.util.ArrayList;
 import java.util.List;
+import java.util.Objects;
 
 /**
  * @author xucaiqin
@@ -19,17 +26,36 @@ import java.util.List;
 @RequiredArgsConstructor
 public class StreamMediaServiceImpl implements StreamMediaService {
     private final ApiProxy apiProxy;
+    private final SDeviceMapper sDeviceMapper;
+
+    @Resource
+    DeviceApi deviceApi;
 
     @Override
     public List<Object> rtmpPage(StreamPage streamPage) {
         //根据设备名称模糊筛选设备,获得设备id列表
         String keywords = streamPage.getKeywords();
-        //
+        List<Long> ids = new ArrayList<>();
+        if (keywords != null && !keywords.isEmpty()) {
+            //如果有设备,需要先查出设备id
+            List<DevicesVo> devicesVos = deviceApi.devicesQuery(keywords);
+            if (Objects.isNull(devicesVos)) {
+                throw new BusinessException("查无产品");
+            }
+            for (DevicesVo devicesVo : devicesVos) {
+                ids.add(devicesVo.getId());
+            }
+            streamPage.setDeviceIds(ids);
+        }
+        //数据库查询
+        streamPageRes streamPageRes = sDeviceMapper.selectStreamPage(streamPage);
+        if (Objects.isNull(streamPageRes)) {
+            throw new BusinessException("查无产品!");
+        }
+        //API调用
         ArrayList<Object> objects = new ArrayList<>();
-
         Object o = apiProxy.rtmpList();
 
-
         return new ArrayList<>() {{
             add(o);
         }};

+ 15 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/resources/mapper/SDeviceMapper.xml

@@ -24,4 +24,19 @@
     id, device_id, cover, `path`, target, save_rule, use_flag, `type`, create_by, create_time, 
     update_by, update_time, delete_time, del_flag
   </sql>
+
+  <select id="selectStreamPage" resultType="com.middle.platform.stream.biz.domain.res.streamPageRes">
+      select *
+      from s_device
+      <where>
+          del_flag = 0
+            and use_flag = 1
+          <if test="streamPage.deviceIds != null and streamPage.deviceIds.size() > 0">
+              and device_id in
+              <foreach collection="streamPage.deviceIds" item="id" open="(" separator="," close=")">
+                  #{id}
+              </foreach>
+          </if>
+      </where>
+  </select>
 </mapper>