Commit fbba14dabc8d6e8fad2d5963f1317743a49b777b

Authored by xp.Huang
1 parent 7c7e0bc7

perf: 查询设备列表,增加设备传输协议过滤

... ... @@ -33,10 +33,7 @@ import org.thingsboard.server.common.data.yunteng.constant.FastIotConstants;
33 33 import org.thingsboard.server.common.data.yunteng.core.exception.TkDataValidationException;
34 34 import org.thingsboard.server.common.data.yunteng.core.message.ErrorMessage;
35 35 import org.thingsboard.server.common.data.yunteng.dto.*;
36   -import org.thingsboard.server.common.data.yunteng.enums.DataTypeEnum;
37   -import org.thingsboard.server.common.data.yunteng.enums.DeviceState;
38   -import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
39   -import org.thingsboard.server.common.data.yunteng.enums.OrderTypeEnum;
  36 +import org.thingsboard.server.common.data.yunteng.enums.*;
40 37 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
41 38 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
42 39 import org.thingsboard.server.controller.BaseController;
... ... @@ -383,14 +380,16 @@ public class TkDeviceController extends BaseController {
383 380 @ApiParam(value = "设备标签") @RequestParam(value = "deviceLabel", required = false)
384 381 String deviceLabel,
385 382 @ApiParam(value = "设备配置ID") @RequestParam(value = "deviceProfileId", required = false)
386   - String deviceProfileId)
  383 + String deviceProfileId,
  384 + @ApiParam(value = "传输协议类型") @RequestParam(value = "transportType", required = false)
  385 + TransportTypeEnum transportType)
387 386 throws ThingsboardException {
388 387 return tkdeviceService.findDevicesByDeviceTypeAndOrganizationId(
389 388 deviceType,
390 389 getCurrentUser().getCurrentTenantId(),
391 390 organizationId,
392 391 deviceLabel,
393   - deviceProfileId);
  392 + deviceProfileId,transportType);
394 393 }
395 394
396 395
... ...
... ... @@ -348,14 +348,15 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev
348 348 String tenantId,
349 349 String organizationId,
350 350 String deviceLabel,
351   - String deviceProfileId) {
  351 + String deviceProfileId,
  352 + TransportTypeEnum transportTypeEnum) {
352 353 List<String> orgIds = organizationService.organizationAllIds(tenantId, organizationId);
353 354 if (orgIds.isEmpty()) {
354 355 throw new TkDataValidationException(ErrorMessage.ORGANIZATION_NOT_EXTIED.getMessage());
355 356 }
356 357 return baseMapper.findDevicesByDeviceTypeAndOrganizationId(orgIds,
357 358 deviceType==null?null:deviceType.name()
358   - ,deviceLabel,deviceProfileId);
  359 + ,deviceLabel,deviceProfileId,transportTypeEnum);
359 360 }
360 361
361 362 @Override
... ...
... ... @@ -5,6 +5,7 @@ import com.baomidou.mybatisplus.core.metadata.IPage;
5 5 import org.apache.ibatis.annotations.Mapper;
6 6 import org.apache.ibatis.annotations.Param;
7 7 import org.thingsboard.server.common.data.yunteng.dto.*;
  8 +import org.thingsboard.server.common.data.yunteng.enums.TransportTypeEnum;
8 9 import org.thingsboard.server.dao.yunteng.entities.TkDeviceEntity;
9 10
10 11 import java.util.List;
... ... @@ -152,5 +153,6 @@ public interface DeviceMapper extends BaseMapper<TkDeviceEntity> {
152 153 @Param("orgIds")List<String> orgIds,
153 154 @Param("deviceType") String deviceType,
154 155 @Param("deviceLabel") String deviceLabel,
155   - @Param("deviceProfileId") String deviceProfileId);
  156 + @Param("deviceProfileId") String deviceProfileId,
  157 + @Param("transportType")TransportTypeEnum transportType) ;
156 158 }
... ...
... ... @@ -9,6 +9,7 @@ import org.thingsboard.server.common.data.yunteng.dto.SelectItemDTO;
9 9 import org.thingsboard.server.common.data.yunteng.enums.DataTypeEnum;
10 10 import org.thingsboard.server.common.data.yunteng.enums.DeviceState;
11 11 import org.thingsboard.server.common.data.yunteng.enums.DeviceTypeEnum;
  12 +import org.thingsboard.server.common.data.yunteng.enums.TransportTypeEnum;
12 13 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
13 14 import org.thingsboard.server.dao.yunteng.entities.TkDeviceEntity;
14 15
... ... @@ -62,11 +63,12 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> {
62 63 * @return 设备列表
63 64 */
64 65 List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId(
65   - DeviceTypeEnum deviceType,
66   - String tenantId,
67   - String organizationId,
68   - String deviceLabel,
69   - String deviceProfileId);
  66 + DeviceTypeEnum deviceType,
  67 + String tenantId,
  68 + String organizationId,
  69 + String deviceLabel,
  70 + String deviceProfileId,
  71 + TransportTypeEnum transportTypeEnum);
70 72
71 73
72 74 List<DeviceDTO> findDevicesByOrganizationIds(
... ...
... ... @@ -499,6 +499,9 @@
499 499 <if test="deviceProfileId !=null and deviceProfileId !=''">
500 500 AND ifd.device_profile_id = #{deviceProfileId}
501 501 </if>
  502 + <if test="transportType !=null">
  503 + AND dev.transport_type = #{transportType}
  504 + </if>
502 505 and ifd.organization_id in
503 506 <foreach collection="orgIds" item="orgId" open="(" separator="," close=")">
504 507 #{orgId}
... ...