Showing
3 changed files
with
25 additions
and
5 deletions
... | ... | @@ -41,6 +41,7 @@ import org.thingsboard.server.dao.yunteng.service.TkAlarmInfoService; |
41 | 41 | import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService; |
42 | 42 | import org.thingsboard.server.dao.yunteng.service.TkDeviceService; |
43 | 43 | import org.thingsboard.server.dao.yunteng.service.TkOrganizationService; |
44 | +import org.thingsboard.server.dao.yunteng.service.media.TkVideoChannelService; | |
44 | 45 | import org.thingsboard.server.service.gateway_device.GatewayNotificationsService; |
45 | 46 | import org.thingsboard.server.service.security.permission.Operation; |
46 | 47 | import org.thingsboard.server.service.security.permission.Resource; |
... | ... | @@ -63,7 +64,7 @@ public class TkDeviceController extends BaseController { |
63 | 64 | private final TkDeviceProfileService ytDeviceProfileService; |
64 | 65 | private final GatewayNotificationsService gatewayNotificationsService; |
65 | 66 | private final TkAlarmInfoService tkAlarmInfoService ; |
66 | - | |
67 | + private final TkVideoChannelService tkVideoChannelService; | |
67 | 68 | |
68 | 69 | @PostMapping("/batch/update") |
69 | 70 | @ApiOperation("批量修改设备") |
... | ... | @@ -344,13 +345,14 @@ public class TkDeviceController extends BaseController { |
344 | 345 | public void deleteDevices(@Validated({DeleteGroup.class}) @RequestBody DeleteDTO deleteDTO) |
345 | 346 | throws ThingsboardException { |
346 | 347 | String currentTenantId = getCurrentUser().getCurrentTenantId(); |
347 | - List<String> tdIds = tkdeviceService.findTbDeviceIdAndCheckForDelete(currentTenantId, deleteDTO.getIds()); | |
348 | - if(null !=tdIds){ | |
349 | - for (String id : tdIds) { | |
348 | + List<String> tbIds = tkdeviceService.findTbDeviceIdAndCheckForDelete(currentTenantId, deleteDTO.getIds()); | |
349 | + if(null !=tbIds){ | |
350 | + for (String id : tbIds) { | |
350 | 351 | deleteTbDevice(id); |
351 | 352 | deleteAlarm(id); |
352 | 353 | } |
353 | 354 | tkdeviceService.deleteDevices(currentTenantId, deleteDTO.getIds()); |
355 | + tkVideoChannelService.clearDeviceChannelByDeviceIds(currentTenantId,tbIds); | |
354 | 356 | } |
355 | 357 | } |
356 | 358 | ... | ... |
... | ... | @@ -71,12 +71,20 @@ public class TkVideoChannelServiceImpl |
71 | 71 | } |
72 | 72 | |
73 | 73 | @Override |
74 | + @Transactional | |
74 | 75 | public int clearDeviceChannel(String tbDeviceId) { |
75 | 76 | return baseMapper.delete(new LambdaQueryWrapper<TkVideoChannelEntity>() |
76 | 77 | .eq(TkVideoChannelEntity::getDeviceId, tbDeviceId)); |
77 | 78 | } |
78 | 79 | |
79 | 80 | @Override |
81 | + @Transactional | |
82 | + public int clearDeviceChannelByDeviceIds(String tenantId,List<String> tbDeviceIds) { | |
83 | + return baseMapper.delete(new LambdaQueryWrapper<TkVideoChannelEntity>() | |
84 | + .eq(TkVideoChannelEntity::getTenantId,tenantId) | |
85 | + .in(TkVideoChannelEntity::getDeviceId, tbDeviceIds)); | |
86 | + } | |
87 | + @Override | |
80 | 88 | public Map<String, String> findPlayingChannel(String tbDeviceId) { |
81 | 89 | List<TkVideoChannelEntity> channelList = |
82 | 90 | baseMapper.selectList( |
... | ... | @@ -94,6 +102,7 @@ public class TkVideoChannelServiceImpl |
94 | 102 | } |
95 | 103 | |
96 | 104 | @Override |
105 | + @Transactional | |
97 | 106 | public VideoChanelDTO updateChannelInfo(VideoChanelDTO videoChanelDTO) { |
98 | 107 | if (StringUtils.isEmpty(videoChanelDTO.getId())) { |
99 | 108 | throw new TkDataValidationException(ErrorMessage.INVALID_PARAMETER.getMessage()); |
... | ... | @@ -105,6 +114,7 @@ public class TkVideoChannelServiceImpl |
105 | 114 | } |
106 | 115 | |
107 | 116 | @Override |
117 | + @Transactional | |
108 | 118 | public boolean updateVideoChannelStreamId( |
109 | 119 | String streamId, String deviceCode, String channelId) { |
110 | 120 | TkVideoChannelEntity entity = |
... | ... | @@ -124,6 +134,7 @@ public class TkVideoChannelServiceImpl |
124 | 134 | } |
125 | 135 | |
126 | 136 | @Override |
137 | + @Transactional | |
127 | 138 | public void updateVideoChannelState(String tbDeviceId, StatusEnum online) { |
128 | 139 | TkVideoChannelEntity entity = new TkVideoChannelEntity(); |
129 | 140 | entity.setStatus(online); | ... | ... |
... | ... | @@ -28,7 +28,14 @@ public interface TkVideoChannelService extends BaseService<TkVideoChannelEntity> |
28 | 28 | * @param tbDeviceId |
29 | 29 | * @return |
30 | 30 | */ |
31 | - int clearDeviceChannel(String tbDeviceId); /** | |
31 | + int clearDeviceChannel(String tbDeviceId); | |
32 | + /** | |
33 | + * 清除摄像头的视频通道 | |
34 | + * @param tbDeviceIds tb设备ID列表 | |
35 | + * @return 清除结果 | |
36 | + */ | |
37 | + int clearDeviceChannelByDeviceIds(String tenantId,List<String> tbDeviceIds); | |
38 | + /** | |
32 | 39 | * 查询点播中的摄像头通道 |
33 | 40 | * @param tbDeviceId |
34 | 41 | * @return | ... | ... |