Commit 31331cee6b294fe79a9cbee599f481e45f33b43b
1 parent
bd4b3f47
fix: delete getGatewayDevices and add query params deviceProfileId for getDevices API
Showing
3 changed files
with
21 additions
and
22 deletions
@@ -336,20 +336,6 @@ public class TkDeviceController extends BaseController { | @@ -336,20 +336,6 @@ public class TkDeviceController extends BaseController { | ||
336 | sendDeleteNotificationMsg(getTenantId(), deviceId, relatedEdgeIds); | 336 | sendDeleteNotificationMsg(getTenantId(), deviceId, relatedEdgeIds); |
337 | } | 337 | } |
338 | 338 | ||
339 | - @GetMapping("/list/{deviceType}") | ||
340 | - @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN'},{})") | ||
341 | - @ApiOperation("获取特定设备类型的所有设备") | ||
342 | - public List<DeviceDTO> getGatewayDevices( | ||
343 | - @ApiParam(value = "设备类型") @PathVariable("deviceType") DeviceTypeEnum deviceType, | ||
344 | - @ApiParam(value = "组织ID") @RequestParam(value = "organizationId", required = false) | ||
345 | - String organizationId, | ||
346 | - @ApiParam(value = "设备标签") @RequestParam(value = "deviceLabel", required = false) | ||
347 | - String deviceLabel) | ||
348 | - throws ThingsboardException { | ||
349 | - return tkdeviceService.findDevicesByDeviceTypeAndOrganizationId( | ||
350 | - deviceType, getCurrentUser().getCurrentTenantId(), organizationId, deviceLabel); | ||
351 | - } | ||
352 | - | ||
353 | @GetMapping("/list") | 339 | @GetMapping("/list") |
354 | @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})") | 340 | @PreAuthorize("@check.checkPermissions({'TENANT_ADMIN','CUSTOMER_USER'},{})") |
355 | @ApiOperation("获取满足条件的所有设备") | 341 | @ApiOperation("获取满足条件的所有设备") |
@@ -359,10 +345,12 @@ public class TkDeviceController extends BaseController { | @@ -359,10 +345,12 @@ public class TkDeviceController extends BaseController { | ||
359 | @ApiParam(value = "组织ID") @RequestParam(value = "organizationId", required = false) | 345 | @ApiParam(value = "组织ID") @RequestParam(value = "organizationId", required = false) |
360 | String organizationId, | 346 | String organizationId, |
361 | @ApiParam(value = "设备标签") @RequestParam(value = "deviceLabel", required = false) | 347 | @ApiParam(value = "设备标签") @RequestParam(value = "deviceLabel", required = false) |
362 | - String deviceLabel) | 348 | + String deviceLabel, |
349 | + @ApiParam(value = "设备配置ID") @RequestParam(value = "deviceProfileId", required = false) | ||
350 | + String deviceProfileId) | ||
363 | throws ThingsboardException { | 351 | throws ThingsboardException { |
364 | return tkdeviceService.findDevicesByDeviceTypeAndOrganizationId( | 352 | return tkdeviceService.findDevicesByDeviceTypeAndOrganizationId( |
365 | - deviceType, getCurrentUser().getCurrentTenantId(), organizationId, deviceLabel); | 353 | + deviceType, getCurrentUser().getCurrentTenantId(), organizationId, deviceLabel,deviceProfileId); |
366 | } | 354 | } |
367 | 355 | ||
368 | @GetMapping("/list/master/{organizationId}") | 356 | @GetMapping("/list/master/{organizationId}") |
@@ -248,7 +248,11 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | @@ -248,7 +248,11 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | ||
248 | 248 | ||
249 | @Override | 249 | @Override |
250 | public List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId( | 250 | public List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId( |
251 | - DeviceTypeEnum deviceType, String tenantId, String organizationId, String deviceLabel) { | 251 | + DeviceTypeEnum deviceType, |
252 | + String tenantId, | ||
253 | + String organizationId, | ||
254 | + String deviceLabel, | ||
255 | + String deviceProfileId) { | ||
252 | List<String> orgIds = organizationAllIds(tenantId, organizationId); | 256 | List<String> orgIds = organizationAllIds(tenantId, organizationId); |
253 | if (orgIds.isEmpty()) { | 257 | if (orgIds.isEmpty()) { |
254 | throw new YtDataValidationException(ErrorMessage.ORGANIZATION_NOT_EXTIED.getMessage()); | 258 | throw new YtDataValidationException(ErrorMessage.ORGANIZATION_NOT_EXTIED.getMessage()); |
@@ -258,6 +262,10 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | @@ -258,6 +262,10 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | ||
258 | new LambdaQueryWrapper<TkDeviceEntity>() | 262 | new LambdaQueryWrapper<TkDeviceEntity>() |
259 | .eq(deviceType != null, TkDeviceEntity::getDeviceType, deviceType) | 263 | .eq(deviceType != null, TkDeviceEntity::getDeviceType, deviceType) |
260 | .eq(deviceLabel != null, TkDeviceEntity::getLabel, deviceLabel) | 264 | .eq(deviceLabel != null, TkDeviceEntity::getLabel, deviceLabel) |
265 | + .eq( | ||
266 | + StringUtils.isNotEmpty(deviceProfileId), | ||
267 | + TkDeviceEntity::getDeviceProfileId, | ||
268 | + deviceProfileId) | ||
261 | .in(TkDeviceEntity::getOrganizationId, orgIds)), | 269 | .in(TkDeviceEntity::getOrganizationId, orgIds)), |
262 | DeviceDTO.class); | 270 | DeviceDTO.class); |
263 | } | 271 | } |
@@ -506,7 +514,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | @@ -506,7 +514,7 @@ public class TkDeviceServiceImpl extends AbstractBaseService<DeviceMapper, TkDev | ||
506 | JacksonUtil.toJsonNode( | 514 | JacksonUtil.toJsonNode( |
507 | "{\"avatar\": \"\",\"longitude\": \"\",\"latitude\": \"\",\"address\": \"\"}")); | 515 | "{\"avatar\": \"\",\"longitude\": \"\",\"latitude\": \"\",\"address\": \"\"}")); |
508 | 516 | ||
509 | - DeviceProfileDTO profileDTO = tkProfileMapper.selectDetail(gateway.getTenantId(),tbProfileId); | 517 | + DeviceProfileDTO profileDTO = tkProfileMapper.selectDetail(gateway.getTenantId(), tbProfileId); |
510 | slaveDevice.setProfileId(profileDTO.getTbProfileId()); | 518 | slaveDevice.setProfileId(profileDTO.getTbProfileId()); |
511 | slaveDevice.setDeviceProfileId(profileDTO.getId()); | 519 | slaveDevice.setDeviceProfileId(profileDTO.getId()); |
512 | slaveDevice.setGatewayId(gateway.getId()); | 520 | slaveDevice.setGatewayId(gateway.getId()); |
@@ -29,7 +29,6 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | @@ -29,7 +29,6 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | ||
29 | /** | 29 | /** |
30 | * 验证表单数据有效性 | 30 | * 验证表单数据有效性 |
31 | * | 31 | * |
32 | - * @param ytDevice | ||
33 | */ | 32 | */ |
34 | void validateFormData(String currentTenantId, DeviceDTO ytDevice); | 33 | void validateFormData(String currentTenantId, DeviceDTO ytDevice); |
35 | 34 | ||
@@ -50,7 +49,11 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | @@ -50,7 +49,11 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | ||
50 | * @return 设备列表 | 49 | * @return 设备列表 |
51 | */ | 50 | */ |
52 | List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId( | 51 | List<DeviceDTO> findDevicesByDeviceTypeAndOrganizationId( |
53 | - DeviceTypeEnum deviceType, String tenantId, String organizationId, String deviceLabel); | 52 | + DeviceTypeEnum deviceType, |
53 | + String tenantId, | ||
54 | + String organizationId, | ||
55 | + String deviceLabel, | ||
56 | + String deviceProfileId); | ||
54 | 57 | ||
55 | /** | 58 | /** |
56 | * 通过设备ID和租户ID判断该设备是否存在 | 59 | * 通过设备ID和租户ID判断该设备是否存在 |
@@ -85,7 +88,6 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | @@ -85,7 +88,6 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | ||
85 | * | 88 | * |
86 | * @param tbDeviceId TB设备主键 | 89 | * @param tbDeviceId TB设备主键 |
87 | * @param created 告警状态:0正常,1告警 | 90 | * @param created 告警状态:0正常,1告警 |
88 | - * @return | ||
89 | */ | 91 | */ |
90 | boolean freshAlarmStatus(EntityId tbDeviceId, Integer created); | 92 | boolean freshAlarmStatus(EntityId tbDeviceId, Integer created); |
91 | 93 | ||
@@ -156,7 +158,8 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | @@ -156,7 +158,8 @@ public interface TkDeviceService extends BaseService<TkDeviceEntity> { | ||
156 | * @param gatewayId 网关设备TB平台的ID | 158 | * @param gatewayId 网关设备TB平台的ID |
157 | * @return | 159 | * @return |
158 | */ | 160 | */ |
159 | - boolean saveSlaveDevice(String slaveId, String slaveName, String tbProfileId,String gatewayId, Long createTime); | 161 | + boolean saveSlaveDevice( |
162 | + String slaveId, String slaveName, String tbProfileId, String gatewayId, Long createTime); | ||
160 | 163 | ||
161 | /** | 164 | /** |
162 | * 通过设备ids查询设备信息列表 | 165 | * 通过设备ids查询设备信息列表 |