sptkw 1 год назад
Родитель
Сommit
6783d07640
21 измененных файлов с 449 добавлено и 36 удалено
  1. 7 1
      iot-module/iot-module-manage/iot-module-manage-api/src/main/java/com/middle/platform/manage/api/feign/DeviceApi.java
  2. 32 0
      iot-module/iot-module-manage/iot-module-manage-api/src/main/java/com/middle/platform/manage/api/pojo/DevicesNameVo.java
  3. 3 2
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/api/DeviceApiImpl.java
  4. 2 1
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/mapper/IotDeviceMapper.java
  5. 3 2
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/java/com/middle/platform/manage/biz/service/IotDeviceService.java
  6. 21 16
      iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml
  7. 16 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/config/FeignConfig.java
  8. 57 3
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/controller/IndexController.java
  9. 3 2
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/controller/RecordController.java
  10. 39 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/req/StreamAddRes.java
  11. 47 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/req/StreamUpdateRes.java
  12. 31 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/req/StreamUpdateStatusRes.java
  13. 35 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/DevicesPathVo.java
  14. 1 1
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/StreamPageRes.java
  15. 1 1
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/entity/SDevice.java
  16. 3 2
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/mapper/SDeviceMapper.java
  17. 18 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/pojo/StreamRecordPage.java
  18. 1 1
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/ApiProxy.java
  19. 20 0
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/StreamMediaService.java
  20. 108 3
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/impl/StreamMediaServiceImpl.java
  21. 1 1
      iot-module/iot-module-stream/iot-module-stream-biz/src/main/resources/mapper/SDeviceMapper.xml

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

@@ -4,9 +4,12 @@ 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.DevicesNameVo;
 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.PostMapping;
+import org.springframework.web.bind.annotation.RequestBody;
 import org.springframework.web.bind.annotation.RequestParam;
 
 import java.util.List;
@@ -43,7 +46,10 @@ public interface DeviceApi {
      * @author Aick Spt
      * @date 2024-05-06 11:44
      */
-    List<DevicesVo> devicesQuery(@RequestParam("keyword") String keyword);
+    @PostMapping(prefix + "/devicesQuery")
+    List<DevicesVo> devicesQuery(@RequestBody DevicesNameVo devicesNameVo);
+
+
 
 
 }

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

@@ -0,0 +1,32 @@
+package com.middle.platform.manage.api.pojo;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+import java.util.List;
+
+/**
+ * 设备
+ *
+ * @author xucaiqin
+ * @date 2023-12-23 14:04:27
+ */
+@Getter
+@Setter
+public class DevicesNameVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1015455615318488202L;
+
+    /**
+     * 设备id集合
+     */
+    private List<Long> ids;
+
+    /**
+     * 设备名称
+     */
+    private String keywords;
+}

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

@@ -4,6 +4,7 @@ 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.DevicesNameVo;
 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;
@@ -37,8 +38,8 @@ public class DeviceApiImpl implements DeviceApi {
     }
 
     @Override
-    public List<DevicesVo> devicesQuery(String keyword) {
-        return iotDeviceService.devicesQuery(keyword);
+    public List<DevicesVo> devicesQuery(DevicesNameVo devicesNameVo)  {
+        return iotDeviceService.devicesQuery(devicesNameVo);
     }
 
 

+ 2 - 1
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.DevicesNameVo;
 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;
@@ -65,7 +66,7 @@ public interface IotDeviceMapper extends BaseMapper<IotDevice> {
 
     void updateStatus(IotDeviceVo iotDevice);
 
-    List<DevicesVo> devicesQuery(@Param("keyword") String keyword);
+    List<DevicesVo> devicesQuery(DevicesNameVo devicesNameVo);
 
 
 }

+ 3 - 2
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.DevicesNameVo;
 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;
@@ -338,8 +339,8 @@ public class IotDeviceService {
      * @author Aick Spt
      * @date 2024-05-07 17:03
      */
-    public List<DevicesVo> devicesQuery(String keyword) {
-        return iotDeviceMapper.devicesQuery(keyword);
+    public List<DevicesVo> devicesQuery(DevicesNameVo devicesNameVo) {
+        return iotDeviceMapper.devicesQuery(devicesNameVo);
     }
 
 

+ 21 - 16
iot-module/iot-module-manage/iot-module-manage-biz/src/main/resources/mapper/IotDeviceMapper.xml

@@ -55,15 +55,15 @@
         </where>
     </select>
 
-<!--    <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">-->
-<!--        select *-->
-<!--        from iot_device id-->
-<!--        <where>-->
-<!--            <if test="keywords != null and keywords != ''">-->
-<!--                and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')-->
-<!--            </if>-->
-<!--        </where>-->
-<!--    </select>-->
+    <!--    <select id="pageQuery" resultType="com.middle.platform.manage.biz.domain.vo.IotDeviceVo">-->
+    <!--        select *-->
+    <!--        from iot_device id-->
+    <!--        <where>-->
+    <!--            <if test="keywords != null and keywords != ''">-->
+    <!--                and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')-->
+    <!--            </if>-->
+    <!--        </where>-->
+    <!--    </select>-->
 
     <select id="queryTotalNumberOfDevices" resultType="int">
         select count(id) as num
@@ -107,7 +107,7 @@
                  inner join iot_product ip on id.product_id = ip.id and ip.del_flag = 0
         <where>
             <if test="isBind != null and isBind">
-                 id.id not in (select ipd.device_id from iot_project_device ipd where ipd.del_flag = 0)
+                    id.id not in (select ipd.device_id from iot_project_device ipd where ipd.del_flag = 0)
             </if>
             <if test="keywords != null and keywords != ''">
                 and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')
@@ -121,7 +121,7 @@
 
     <select id="count" resultType="java.util.Map">
         select count(case when id.status = 1 then 1 end) online,
-               count(1) offline
+               count(1)                                  offline
         from iot_device id
         <where>
             <if test="productId != null">
@@ -213,16 +213,21 @@
         WHERE id = #{id,jdbcType=BIGINT}
     </update>
 
-    <select id="devicesQuery" resultType="com.middle.platform.manage.api.pojo.DevicesVo">
+    <select id="devicesQuery" resultType="com.middle.platform.manage.api.pojo.DevicesNameVo">
         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}, '%')
+              and id.enable_flag = 1
+            <if test="keywords != null and keywords != ''">
+                and id.name like concat('%', #{keywords,jdbcType=VARCHAR}, '%')
+            </if>
+            <if test="ids != null and ids.size() != 0">
+                and id.id in
+                <foreach collection="ids" item="id" open="(" separator="," close=")">
+                    #{id}
+                </foreach>
             </if>
         </where>
     </select>
-
 </mapper>

+ 16 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/config/FeignConfig.java

@@ -0,0 +1,16 @@
+package com.middle.platform.stream.biz.config;
+
+import com.middle.platform.manage.api.feign.DeviceApi;
+import org.springframework.cloud.openfeign.EnableFeignClients;
+import org.springframework.context.annotation.Configuration;
+
+/**
+ * 配置feign接口
+ *
+ * @author xucaiqin
+ * @date 2023-12-19 11:00:25
+ */
+@Configuration
+@EnableFeignClients(clients = {DeviceApi.class})
+public class FeignConfig {
+}

+ 57 - 3
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/controller/IndexController.java

@@ -1,11 +1,19 @@
 package com.middle.platform.stream.biz.controller;
 
+import cn.hutool.core.bean.BeanUtil;
 import com.middle.platform.common.core.utils.DateTimeUtil;
 import com.middle.platform.common.core.utils.Result;
+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.service.StreamMediaService;
+import jakarta.annotation.Resource;
 import org.springframework.beans.factory.annotation.Value;
-import org.springframework.web.bind.annotation.GetMapping;
-import org.springframework.web.bind.annotation.RequestMapping;
-import org.springframework.web.bind.annotation.RestController;
+import org.springframework.web.bind.annotation.*;
+
+import java.util.List;
 
 /**
  * @author xucaiqin
@@ -16,9 +24,55 @@ import org.springframework.web.bind.annotation.RestController;
 public class IndexController {
     @Value("${spring.application.name}")
     private String name;
+    @Resource
+    private StreamMediaService streamMediaService;
 
     @GetMapping("")
     public Result<Object> server() {
         return Result.ok(name + ":" + DateTimeUtil.nowStr());
     }
+
+    @GetMapping(value = "/getDeviceList", path = "获取设备信息")
+    public Result<Object> getDeviceList(@RequestParam("keywords") String keywords) {
+        List<DevicesVo> deviceList = streamMediaService.getDeviceList(keywords);
+        if (!BeanUtil.isEmpty(deviceList)) {
+            return Result.ok(deviceList, "获取成功");
+        } else {
+            return Result.failed("获取失败");
+        }
+    }
+
+    @GetMapping(value = "/getDevicePathList", path = "获取设备流标签信息")
+    public Result<Object> getDevicePathList(@RequestParam("keywords") String keywords) {
+        List<DevicesPathVo> deviceList = streamMediaService.getDevicePathList(keywords);
+        if (!BeanUtil.isEmpty(deviceList)) {
+            return Result.ok(deviceList, "获取成功");
+        } else {
+            return Result.failed("获取失败");
+        }
+    }
+
+    @PostMapping(value = "/add", path = "新增拉流信息")
+    public Result<Object> add(@RequestBody StreamAddRes streamAddRes) {
+        return Result.ok(streamMediaService.add(streamAddRes) != 0 ? "新增成功" : "新增失败");
+    }
+
+    @PostMapping(value = "/update", path = "更新拉流信息")
+    public Result<Object> update(@RequestBody StreamUpdateRes streamUpdateRes) {
+        return Result.ok(streamMediaService.update(streamUpdateRes) != 0 ? "更新成功" : "更新失败");
+    }
+
+    @PostMapping(value = "/updateStatus", path = "更新拉流信息状态")
+    public Result<Object> updateStatus(@RequestBody StreamUpdateStatusRes streamUpdateStatusRes) {
+        return Result.ok(streamMediaService.updateStatus(streamUpdateStatusRes) != 0 ? "更新状态成功" : "更新状态失败");
+    }
+
+    @GetMapping(value = "/getVideoUrl", path = "获取播放信息")
+    public Result<Object> getVideoUrl(@RequestParam("id") Long id) {
+        return Result.ok(streamMediaService.getVideoUrl(id));
+    }
+
+
+
+
 }

+ 3 - 2
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/controller/RecordController.java

@@ -2,6 +2,7 @@ package com.middle.platform.stream.biz.controller;
 
 import com.middle.platform.common.core.utils.Result;
 import com.middle.platform.stream.biz.pojo.StreamPage;
+import com.middle.platform.stream.biz.pojo.StreamRecordPage;
 import com.middle.platform.stream.biz.service.StreamMediaService;
 import jakarta.annotation.Resource;
 import org.springframework.web.bind.annotation.PostMapping;
@@ -20,7 +21,7 @@ public class RecordController {
     private StreamMediaService streamMediaService;
 
     @PostMapping("/page")
-    public Result<Object> page(@RequestBody StreamPage streamPage) {
-        return Result.ok(streamMediaService.rtmpPage(streamPage));
+    public Result<Object> page(@RequestBody StreamRecordPage streamRecordPage) {
+        return Result.ok(streamMediaService.recordPage(streamRecordPage));
     }
 }

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

@@ -0,0 +1,39 @@
+package com.middle.platform.stream.biz.domain.req;
+
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author Aick Spt
+ * @date 2024-05-06 10:31
+ */
+@Slf4j
+@Data
+public class StreamAddRes {
+
+    /**
+     * 设备id
+     */
+    private Long deviceId;
+
+    /**
+     * 封面地址
+     */
+    private String cover;
+
+    /**
+     * 流路径
+     */
+    private String path;
+
+    /**
+     * 目标地址
+     */
+    private String target;
+
+    /**
+     * 视频流类型 1-rtsp 2-rtmp
+     */
+    private Boolean type;
+
+}

+ 47 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/req/StreamUpdateRes.java

@@ -0,0 +1,47 @@
+package com.middle.platform.stream.biz.domain.req;
+
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+
+/**
+ * @author Aick Spt
+ * @date 2024-05-06 10:31
+ */
+@Slf4j
+@Data
+public class StreamUpdateRes {
+
+    @NotBlank(message = "id不能为空")
+    private Long id;
+
+    /**
+     * 设备id
+     */
+    @NotBlank(message = "所属设备-deviceId不能为空")
+    private Long deviceId;
+
+    /**
+     * 封面地址
+     */
+    @NotBlank(message = "封面-cover不能为空")
+    private String cover;
+
+    /**
+     * 流路径
+     */
+    @NotBlank(message = "流标签-path不能为空")
+    private String path;
+
+    /**
+     * 目标地址
+     */
+    @NotBlank(message = "源地址-target不能为空")
+    private String target;
+
+    /**
+     * 视频流类型 1-rtsp 2-rtmp
+     */
+    private int type;
+
+}

+ 31 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/req/StreamUpdateStatusRes.java

@@ -0,0 +1,31 @@
+package com.middle.platform.stream.biz.domain.req;
+
+import jakarta.validation.Valid;
+import jakarta.validation.constraints.NotBlank;
+import lombok.Data;
+import lombok.extern.slf4j.Slf4j;
+import org.springframework.validation.annotation.Validated;
+
+/**
+ * @author Aick Spt
+ * @date 2024-05-06 10:31
+ */
+@Slf4j
+@Data
+public class StreamUpdateStatusRes {
+
+    @NotBlank(message = "id不能为空")
+    private Long id;
+
+    /**
+     * 使用状态 1-使用中 2-禁用
+     */
+    @NotBlank(message = "使用状态不能为空")
+    private int useFlag;
+
+//    /**
+//     * 视频流类型 1-rtsp 2-rtmp
+//     */
+//    private int type;
+
+}

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

@@ -0,0 +1,35 @@
+package com.middle.platform.stream.biz.domain.res;
+
+import lombok.Getter;
+import lombok.Setter;
+
+import java.io.Serial;
+import java.io.Serializable;
+
+/**
+ * 设备以及流标签信息
+ * @author Aick Spt
+ * @date 2024-05-08 10:48
+ */
+@Getter
+@Setter
+public class DevicesPathVo implements Serializable {
+
+    @Serial
+    private static final long serialVersionUID = 1472407611278301516L;
+
+    /**
+     * 设备id
+     */
+    private Long id;
+
+    /**
+     * 设备名称
+     */
+    private String name;
+
+    /**
+     * 流标签
+     */
+    private String path;
+}

+ 1 - 1
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/streamPageRes.java → iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/domain/res/StreamPageRes.java

@@ -11,7 +11,7 @@ import java.time.LocalDateTime;
  */
 @Slf4j
 @Data
-public class streamPageRes {
+public class StreamPageRes {
 
 
     /**

+ 1 - 1
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/entity/SDevice.java

@@ -57,7 +57,7 @@ public class SDevice {
      * 使用状态 1-使用中 2-禁用
      */
     @TableField(value = "use_flag")
-    private Boolean useFlag;
+    private Integer useFlag;
 
     /**
      * 视频流类型 1-rtsp 2-rtmp

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

@@ -1,9 +1,10 @@
 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.domain.res.StreamPageRes;
 import com.middle.platform.stream.biz.entity.SDevice;
 import com.middle.platform.stream.biz.pojo.StreamPage;
+import com.middle.platform.stream.biz.pojo.StreamRecordPage;
 import org.apache.ibatis.annotations.Mapper;
 import org.apache.ibatis.annotations.Param;
 
@@ -14,6 +15,6 @@ import org.apache.ibatis.annotations.Param;
 @Mapper
 public interface SDeviceMapper extends BaseMapper<SDevice> {
 
-     streamPageRes selectStreamPage(@Param("streamPage") StreamPage streamPage);
+     StreamPageRes selectStreamPage(@Param("streamPage") StreamPage streamPage);
 
 }

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

@@ -0,0 +1,18 @@
+package com.middle.platform.stream.biz.pojo;
+
+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
+ */
+@Getter
+@Setter
+public class StreamRecordPage extends BasePara {
+
+    private String path;
+}

+ 1 - 1
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/ApiProxy.java

@@ -181,7 +181,7 @@ public class ApiProxy {
         });
     }
 
-    public Object recordListPage(String type, String pageSize, String pageNum, String streamPath) {
+    public Object recordListPage(String type, int pageSize, int pageNum, String streamPath) {
         String sync = getHttp(ApiInfo.RECORD_LIST_PAGE, new HashMap<>() {{
             put("type", type);
             put("pageSize", pageSize);

+ 20 - 0
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/service/StreamMediaService.java

@@ -1,9 +1,16 @@
 package com.middle.platform.stream.biz.service;
 
+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.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 java.util.ArrayList;
 import java.util.List;
 
 /**
@@ -24,4 +31,17 @@ public interface StreamMediaService {
 
     List<Object> rtmpPull(PullPara pullPara);
 
+
+    List<DevicesVo> getDeviceList(String keywords);
+    List<DevicesPathVo> getDevicePathList(String keywords);
+
+    int add(StreamAddRes streamAddRes);
+
+    int update(StreamUpdateRes streamUpdateRes);
+
+    int updateStatus(StreamUpdateStatusRes streamUpdateStatusRes);
+
+    String getVideoUrl(Long id);
+
+    ArrayList<Object> recordPage(StreamRecordPage streamRecordPage);
 }

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

@@ -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();
+    }
+
 
 }

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

@@ -25,7 +25,7 @@
     update_by, update_time, delete_time, del_flag
   </sql>
 
-  <select id="selectStreamPage" resultType="com.middle.platform.stream.biz.domain.res.streamPageRes">
+  <select id="selectStreamPage" resultType="com.middle.platform.stream.biz.domain.res.StreamPageRes">
       select *
       from s_device
       <where>