Pārlūkot izejas kodu

设备改成输入项

xucaiqin 1 gadu atpakaļ
vecāks
revīzija
7645349316

+ 0 - 11
iot-module/iot-module-stream/iot-module-stream-biz/src/main/java/com/middle/platform/stream/biz/controller/VideoController.java

@@ -36,17 +36,6 @@ public class VideoController {
         return Result.ok(sDeviceService.pageQuery(videoPage));
     }
 
-    /**
-     * 获取未关联的设备
-     *
-     * @param name
-     * @return
-     */
-    @GetMapping("/dropdown")
-    public Result<Object> dropdown(String name) {
-        return Result.ok(sDeviceService.dropdown(name));
-    }
-
     /**
      * 新增拉流信息
      *

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

@@ -12,10 +12,10 @@ import lombok.Data;
 public class StreamAddRes {
 
     /**
-     * 设备id
+     * 设备名称
      */
-    @NotNull(message = "所属设备不能为空")
-    private Long deviceId;
+    @NotNull(message = "设备名称不能为空")
+    private String name;
 
     /**
      * 封面地址

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

@@ -15,10 +15,10 @@ public class StreamUpdateRes {
     private Long id;
 
     /**
-     * 设备id
+     * 设备名称
      */
-    @NotNull(message = "所属设备不能为空")
-    private Long deviceId;
+    @NotNull(message = "设备名称不能为空")
+    private String name;
 
     /**
      * 封面地址

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

@@ -19,15 +19,10 @@ public class StreamPageRes {
      */
     private Long id;
 
-    /**
-     * 设备id
-     */
-    private Long deviceId;
-
     /**
      * 设备名称
      */
-    private String deviceName;
+    private String name;
 
     /**
      * 封面地址

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

@@ -23,10 +23,10 @@ public class SDevice extends BaseDO {
     private Long id;
 
     /**
-     * 设备id
+     * 设备名称
      */
-    @TableField(value = "device_id")
-    private Long deviceId;
+    @TableField(value = "name")
+    private String name;
 
     /**
      * 封面地址

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

@@ -1,8 +1,6 @@
 package com.middle.platform.stream.biz.service;
 
 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.extension.service.impl.ServiceImpl;
 import com.github.pagehelper.PageHelper;
@@ -11,8 +9,6 @@ import com.middle.platform.common.core.constant.Global;
 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;
 import com.middle.platform.pagehelper.core.PageRes;
 import com.middle.platform.stream.biz.domain.req.StreamAddRes;
 import com.middle.platform.stream.biz.domain.req.StreamUpdateRes;
@@ -35,7 +31,6 @@ import java.util.ArrayList;
 import java.util.List;
 import java.util.Objects;
 import java.util.Optional;
-import java.util.stream.Collectors;
 
 /**
  * @author xucaiqin
@@ -60,21 +55,10 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
      * @date 2024-05-08 18:44
      */
     public PageRes<DevicesPathVo> getDevicePathList(BasePara basePara) {
-        //根据设备名称模糊筛选设备,获得设备id列表
-        List<Long> ids = new ArrayList<>();
-        //如果有设备,需要先查出设备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());
-            }
-        }
         PageHelper.startPage(basePara.getPage(), basePara.getPageSize());
         List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<SDevice>()
                 .eq(SDevice::getDelFlag, Global.UN_DEL)
-                .in(CollUtil.isNotEmpty(ids), SDevice::getDeviceId, ids));
+                .like(SDevice::getName, basePara.getKeywords()));
 
         if (Objects.isNull(sDevices)) {
             return new PageRes<>();
@@ -82,12 +66,7 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         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);
+            res.add(BeanUtil.toBean(sDevice, DevicesPathVo.class));
         }
         return PageRes.build(pageInfo, res);
     }
@@ -129,7 +108,7 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         }
         SDevice sDevice1 = new SDevice();
         sDevice1.setId(streamUpdateRes.getId());
-        sDevice1.setDeviceId(streamUpdateRes.getDeviceId());
+        sDevice1.setName(streamUpdateRes.getName());
         sDevice1.setCover(streamUpdateRes.getCover());
 //        sDevice1.setPath("");
 //        sDevice1.setTarget("");
@@ -166,45 +145,6 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         return VideoPathUtil.videoUrl(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);
-//        }};
-//    }
-
     /**
      * 分页查询
      *
@@ -212,22 +152,12 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
      * @date 2024-05-09 09:10
      */
     public Object pageQuery(VideoPage videoPage) {
-        //根据设备名称模糊筛选设备,获得设备id列表
-        List<Long> ids = new ArrayList<>();
-        //如果有设备,需要先查出设备id
-        if (StrUtil.isNotBlank(videoPage.getKeywords())) {
-            DevicesNameVo devicesNameVo = new DevicesNameVo();
-            devicesNameVo.setKeywords(videoPage.getKeywords());
-            List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
-            for (DevicesVo devicesVo : devicesVos) {
-                ids.add(devicesVo.getId());
-            }
-        }
         PageHelper.startPage(videoPage.getPage(), videoPage.getPageSize());
         List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<SDevice>()
                 .eq(SDevice::getType, videoPage.getType())
+                .like(SDevice::getName, videoPage.getKeywords())
                 .eq(SDevice::getDelFlag, Global.UN_DEL)
-                .in(CollUtil.isNotEmpty(ids), SDevice::getDeviceId, ids));
+        );
 
         if (Objects.isNull(sDevices)) {
             return new PageRes<>();
@@ -237,10 +167,6 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         List<StreamPageRes> streamPageRes2 = new ArrayList<>();
         for (SDevice sDevice : sDevices) {
             StreamPageRes streamPageRes = BeanUtil.toBean(sDevice, StreamPageRes.class);
-            DevicesVo devicesVo = deviceApi.queryDevice(sDevice.getDeviceId());
-            if (Objects.nonNull(devicesVo)) {
-                streamPageRes.setDeviceName(devicesVo.getName());
-            }
             Optional.ofNullable(dictApi.query(DictType.VIDEO_TYPE, String.valueOf(streamPageRes.getType()))).ifPresent(d -> streamPageRes.setTypeLabel(d.getLabel()));
             Optional.ofNullable(dictApi.query(DictType.USE_FLAG_TYPE, String.valueOf(streamPageRes.getUseFlag()))).ifPresent(d -> streamPageRes.setUseFlagLabel(d.getLabel()));
             Optional.ofNullable(dictApi.query(DictType.SAVE_RULE_TYPE, String.valueOf(streamPageRes.getSaveRule()))).ifPresent(d -> streamPageRes.setSaveRuleLabel(d.getLabel()));
@@ -251,16 +177,6 @@ public class SDeviceService extends ServiceImpl<SDeviceMapper, SDevice> {
         return PageRes.build(pageInfo, streamPageRes2);
     }
 
-    public Object dropdown(String name) {
-        DevicesNameVo devicesNameVo = new DevicesNameVo();
-        devicesNameVo.setKeywords(name);
-        List<DevicesVo> devicesVos = deviceApi.devicesQuery(devicesNameVo);
-        if (CollUtil.isEmpty(devicesVos)) {
-            return new ArrayList<>();
-        }
-        List<SDevice> sDevices = sDeviceMapper.selectList(new LambdaQueryWrapper<SDevice>().eq(SDevice::getDelFlag, Global.UN_DEL));
-        return devicesVos.stream().filter(d -> sDevices.stream().noneMatch(d2 -> Objects.equals(d2.getDeviceId(), d.getId()))).collect(Collectors.toList());
-    }
 
     public Object delete(Long id) {
         SDevice sDevice = new SDevice();

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

@@ -5,7 +5,7 @@
     <!--@mbg.generated-->
     <!--@Table s_device-->
     <id column="id" jdbcType="BIGINT" property="id" />
-    <result column="device_id" jdbcType="BIGINT" property="deviceId" />
+    <result column="name" jdbcType="VARCHAR" property="name" />
     <result column="cover" jdbcType="VARCHAR" property="cover" />
     <result column="path" jdbcType="VARCHAR" property="path" />
     <result column="target" jdbcType="VARCHAR" property="target" />
@@ -21,7 +21,7 @@
   </resultMap>
   <sql id="Base_Column_List">
     <!--@mbg.generated-->
-    id, device_id, cover, `path`, target, save_rule, use_flag, `type`, create_by, create_time, 
+    id, name, cover, `path`, target, save_rule, use_flag, `type`, create_by, create_time,
     update_by, update_time, delete_time, del_flag
   </sql>
 
@@ -39,4 +39,4 @@
           </if>
       </where>
   </select>
-</mapper>
+</mapper>