Commit df55c83de779aaeb2aea8e917d70fe7da9a76209

Authored by xp.Huang
1 parent 818e8fe4

fix: 删除设备时,删除gbt28181视频配置

@@ -35,10 +35,7 @@ import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils; @@ -35,10 +35,7 @@ import org.thingsboard.server.common.data.yunteng.utils.i18n.MessageUtils;
35 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult; 35 import org.thingsboard.server.common.data.yunteng.utils.tools.ResponseResult;
36 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData; 36 import org.thingsboard.server.common.data.yunteng.utils.tools.TkPageData;
37 import org.thingsboard.server.controller.BaseController; 37 import org.thingsboard.server.controller.BaseController;
38 -import org.thingsboard.server.dao.yunteng.service.TkAlarmInfoService;  
39 -import org.thingsboard.server.dao.yunteng.service.TkDeviceProfileService;  
40 -import org.thingsboard.server.dao.yunteng.service.TkDeviceService;  
41 -import org.thingsboard.server.dao.yunteng.service.TkOrganizationService; 38 +import org.thingsboard.server.dao.yunteng.service.*;
42 import org.thingsboard.server.dao.yunteng.service.media.TkVideoChannelService; 39 import org.thingsboard.server.dao.yunteng.service.media.TkVideoChannelService;
43 import org.thingsboard.server.queue.util.TbCoreComponent; 40 import org.thingsboard.server.queue.util.TbCoreComponent;
44 import org.thingsboard.server.service.entitiy.alarm.TbAlarmService; 41 import org.thingsboard.server.service.entitiy.alarm.TbAlarmService;
@@ -69,6 +66,7 @@ public class TkDeviceController extends BaseController { @@ -69,6 +66,7 @@ public class TkDeviceController extends BaseController {
69 private final TkOrganizationService organizationService; 66 private final TkOrganizationService organizationService;
70 private final CacheUtils cacheUtils; 67 private final CacheUtils cacheUtils;
71 private final TkVideoChannelService tkVideoChannelService; 68 private final TkVideoChannelService tkVideoChannelService;
  69 + private final TkVideoService tkVideoService;
72 @PostMapping("/batch/update") 70 @PostMapping("/batch/update")
73 @ApiOperation("批量修改设备") 71 @ApiOperation("批量修改设备")
74 @PreAuthorize( 72 @PreAuthorize(
@@ -353,6 +351,7 @@ public class TkDeviceController extends BaseController { @@ -353,6 +351,7 @@ public class TkDeviceController extends BaseController {
353 deleteAlarm(id); 351 deleteAlarm(id);
354 } 352 }
355 tkVideoChannelService.clearDeviceChannelByDeviceIds(currentTenantId,tbIds); 353 tkVideoChannelService.clearDeviceChannelByDeviceIds(currentTenantId,tbIds);
  354 + tkVideoService.deleteGBT28181VideosByDeviceIds(currentTenantId,tbIds);
356 } 355 }
357 } 356 }
358 357
@@ -69,18 +69,20 @@ public class ZLMediaKitHookController extends BaseController { @@ -69,18 +69,20 @@ public class ZLMediaKitHookController extends BaseController {
69 String cameraCode = result.get(FastIotConstants.ZLMediaBody.CAMERA_CODE).asText(); 69 String cameraCode = result.get(FastIotConstants.ZLMediaBody.CAMERA_CODE).asText();
70 VideoChanelDTO chanelDTO = 70 VideoChanelDTO chanelDTO =
71 tkVideoChannelService.findVideoChannelById(cameraCode, channelId, null); 71 tkVideoChannelService.findVideoChannelById(cameraCode, channelId, null);
72 - controlService.byeCmdInSsrcTransaction(  
73 - chanelDTO.getTenantId(),  
74 - false,  
75 - chanelDTO.getDeviceId(),  
76 - cameraCode,  
77 - channelId,  
78 - result.get(FastIotConstants.ZLMediaBody.SSRCINFO_STREAM).asText(),  
79 - fromDeviceRpcResponse -> {});  
80 - tkVideoChannelService.updateVideoChannelStreamId(  
81 - null,  
82 - cameraCode,  
83 - channelId); // storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId()); 72 + if(null != chanelDTO){
  73 + controlService.byeCmdInSsrcTransaction(
  74 + chanelDTO.getTenantId(),
  75 + false,
  76 + chanelDTO.getDeviceId(),
  77 + cameraCode,
  78 + channelId,
  79 + result.get(FastIotConstants.ZLMediaBody.SSRCINFO_STREAM).asText(),
  80 + fromDeviceRpcResponse -> {});
  81 + tkVideoChannelService.updateVideoChannelStreamId(
  82 + null,
  83 + cameraCode,
  84 + channelId); // storager.stopPlay(streamInfo.getDeviceID(), streamInfo.getChannelId());
  85 + }
84 } 86 }
85 return result; 87 return result;
86 } 88 }
@@ -253,7 +253,18 @@ public class TkVideoServiceImpl extends AbstractBaseService<TkVideoMapper, TkVid @@ -253,7 +253,18 @@ public class TkVideoServiceImpl extends AbstractBaseService<TkVideoMapper, TkVid
253 return videoDTOList.get(0); 253 return videoDTOList.get(0);
254 } 254 }
255 255
256 - 256 + @Override
  257 + @Transactional
  258 + public boolean deleteGBT28181VideosByDeviceIds(String tenantId, List<String> deviceIds) {
  259 + boolean result = false;
  260 + if(null !=deviceIds && deviceIds.size()>FastIotConstants.MagicNumber.ZERO){
  261 + for (String deviceId : deviceIds) {
  262 + baseMapper.deleteVideosByDeviceIds(tenantId,deviceId);
  263 + }
  264 + result = true;
  265 + }
  266 + return result;
  267 + }
257 void saveGbtS(TkVideoGbtDTO dto){ 268 void saveGbtS(TkVideoGbtDTO dto){
258 List<TkVideoGbtDeviceDTO> deviceList = dto.getGbtDeviceDTOS(); 269 List<TkVideoGbtDeviceDTO> deviceList = dto.getGbtDeviceDTOS();
259 deviceList.forEach(device -> { 270 deviceList.forEach(device -> {
@@ -44,4 +44,8 @@ public interface TkVideoMapper extends BaseMapper<TkVideoEntity> { @@ -44,4 +44,8 @@ public interface TkVideoMapper extends BaseMapper<TkVideoEntity> {
44 * @return 44 * @return
45 */ 45 */
46 List<TkVideoDTO> getVideoInfosByOrganizationIds(@Param("tenantId") String tenantId, @Param("organizationIds") List<String> organizationIds); 46 List<TkVideoDTO> getVideoInfosByOrganizationIds(@Param("tenantId") String tenantId, @Param("organizationIds") List<String> organizationIds);
  47 +
  48 +
  49 + int deleteVideosByDeviceIds(@Param("tenantId") String tenantId, @Param("deviceId") String deviceId);
  50 +
47 } 51 }
@@ -122,4 +122,6 @@ public interface TkVideoService extends BaseService<TkVideoEntity> { @@ -122,4 +122,6 @@ public interface TkVideoService extends BaseService<TkVideoEntity> {
122 * @return 视频列表 122 * @return 视频列表
123 */ 123 */
124 List<TkVideoDTO> getVideoList(String organizationId, String tenantId); 124 List<TkVideoDTO> getVideoList(String organizationId, String tenantId);
  125 + boolean deleteGBT28181VideosByDeviceIds(String tenantId,List<String> deviceIds);
  126 +
125 } 127 }
@@ -113,5 +113,10 @@ @@ -113,5 +113,10 @@
113 </if> 113 </if>
114 </where> 114 </where>
115 </select> 115 </select>
116 - 116 + <delete id="deleteVideosByDeviceIds">
  117 + DELETE FROM tk_device_camera
  118 + WHERE
  119 + tenant_id = #{tenantId}
  120 + AND POSITION ( #{deviceId} IN params ) >0
  121 + </delete>
117 </mapper> 122 </mapper>