处理服务重启或设备重新上线时的订阅,优化通道导入重复的处理
This commit is contained in:
@@ -30,11 +30,15 @@ public class DeviceServiceImpl implements IDeviceService {
|
||||
if (device == null || device.getSubscribeCycleForCatalog() < 0) {
|
||||
return false;
|
||||
}
|
||||
if (dynamicTask.contains(device.getDeviceId())) {
|
||||
logger.info("[添加目录订阅] 设备{}的目录订阅以存在", device.getDeviceId());
|
||||
return false;
|
||||
}
|
||||
logger.info("[添加目录订阅] 设备{}", device.getDeviceId());
|
||||
// 添加目录订阅
|
||||
CatalogSubscribeTask catalogSubscribeTask = new CatalogSubscribeTask(device, sipCommander);
|
||||
catalogSubscribeTask.run();
|
||||
// 提前开始刷新订阅
|
||||
// TODO 使用jain sip的当时刷新订阅
|
||||
int subscribeCycleForCatalog = device.getSubscribeCycleForCatalog();
|
||||
// 设置最小值为30
|
||||
subscribeCycleForCatalog = Math.max(subscribeCycleForCatalog, 30);
|
||||
|
||||
@@ -14,15 +14,23 @@ import java.util.Set;
|
||||
|
||||
public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPushExcelDto> {
|
||||
|
||||
private ErrorDataHandler errorDataHandler;
|
||||
private IStreamPushService pushService;
|
||||
private String defaultMediaServerId;
|
||||
private List<StreamPushItem> streamPushItems = new ArrayList<>();
|
||||
private Set<String> streamPushStreamSet = new HashSet<>();
|
||||
private Set<String> streamPushGBSet = new HashSet<>();
|
||||
private List<String> errorStreamList = new ArrayList<>();
|
||||
private List<String> errorGBList = new ArrayList<>();
|
||||
|
||||
public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId) {
|
||||
public StreamPushUploadFileHandler(IStreamPushService pushService, String defaultMediaServerId, ErrorDataHandler errorDataHandler) {
|
||||
this.pushService = pushService;
|
||||
this.defaultMediaServerId = defaultMediaServerId;
|
||||
this.errorDataHandler = errorDataHandler;
|
||||
}
|
||||
|
||||
public interface ErrorDataHandler{
|
||||
void handle(List<String> streams, List<String> gbId);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -32,9 +40,16 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
|
||||
|| StringUtils.isEmpty(streamPushExcelDto.getGbId())) {
|
||||
return;
|
||||
}
|
||||
if (streamPushGBSet.contains(streamPushExcelDto.getGbId())) {
|
||||
errorGBList.add(streamPushExcelDto.getGbId());
|
||||
}
|
||||
if (streamPushStreamSet.contains(streamPushExcelDto.getApp() + streamPushExcelDto.getStream())) {
|
||||
errorStreamList.add(streamPushExcelDto.getApp() + "/" + streamPushExcelDto.getStream());
|
||||
}
|
||||
if (streamPushGBSet.contains(streamPushExcelDto.getGbId()) || streamPushStreamSet.contains(streamPushExcelDto.getApp() + streamPushExcelDto.getStream())) {
|
||||
return;
|
||||
}
|
||||
|
||||
StreamPushItem streamPushItem = new StreamPushItem();
|
||||
streamPushItem.setApp(streamPushExcelDto.getApp());
|
||||
streamPushItem.setStream(streamPushExcelDto.getStream());
|
||||
@@ -60,8 +75,11 @@ public class StreamPushUploadFileHandler extends AnalysisEventListener<StreamPus
|
||||
@Override
|
||||
public void doAfterAllAnalysed(AnalysisContext analysisContext) {
|
||||
// 这里也要保存数据,确保最后遗留的数据也存储到数据库
|
||||
pushService.batchAdd(streamPushItems);
|
||||
if (streamPushItems.size() > 0) {
|
||||
pushService.batchAdd(streamPushItems);
|
||||
}
|
||||
streamPushGBSet.clear();
|
||||
streamPushStreamSet.clear();
|
||||
errorDataHandler.handle(errorStreamList, errorGBList);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user