|
@@ -143,7 +143,14 @@ public class XxlJobService {
|
|
|
}
|
|
|
}
|
|
|
if (CollectionUtil.isNotEmpty(saveList)) {
|
|
|
- crawlerBaseMapper.batchInsertLongArticlesRootSourceId(saveList);
|
|
|
+ List<String> rootSourceIds = saveList.stream().map(LongArticlesRootSourceId::getRootSourceId).distinct().collect(Collectors.toList());
|
|
|
+ List<LongArticlesRootSourceId> existList = longArticlesRootSourceIdRepository.getByRootSourceIdIn(rootSourceIds);
|
|
|
+ for (LongArticlesRootSourceId existItem : existList) {
|
|
|
+ saveList.removeIf(item -> item.getRootSourceId().equals(existItem.getRootSourceId()));
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(saveList)) {
|
|
|
+ crawlerBaseMapper.batchInsertLongArticlesRootSourceId(saveList);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error processCrawlerEachData: {}", JSONObject.toJSONString(longArticlesVideo), e);
|
|
@@ -194,7 +201,14 @@ public class XxlJobService {
|
|
|
saveList.add(saveItem);
|
|
|
}
|
|
|
if (CollectionUtil.isNotEmpty(saveList)) {
|
|
|
- crawlerBaseMapper.batchInsertLongArticlesRootSourceId(saveList);
|
|
|
+ List<String> rootSourceIds = saveList.stream().map(LongArticlesRootSourceId::getRootSourceId).distinct().collect(Collectors.toList());
|
|
|
+ List<LongArticlesRootSourceId> existList = longArticlesRootSourceIdRepository.getByRootSourceIdIn(rootSourceIds);
|
|
|
+ for (LongArticlesRootSourceId existItem : existList) {
|
|
|
+ saveList.removeIf(item -> item.getRootSourceId().equals(existItem.getRootSourceId()));
|
|
|
+ }
|
|
|
+ if (CollectionUtil.isNotEmpty(saveList)) {
|
|
|
+ crawlerBaseMapper.batchInsertLongArticlesRootSourceId(saveList);
|
|
|
+ }
|
|
|
}
|
|
|
} catch (Exception e) {
|
|
|
log.error("Error processArticleEachData: {}", JSONObject.toJSONString(longArticlesMatchVideo), e);
|