|
|
@@ -949,9 +949,27 @@ public class ExternalChannelProcessJob {
|
|
|
for (int i = 0; i < records.size(); i += BATCH_INSERT_SIZE) {
|
|
|
int end = Math.min(i + BATCH_INSERT_SIZE, records.size());
|
|
|
List<ExternalChannel> batch = records.subList(i, end);
|
|
|
- int count = externalChannelMapperExt.batchInsertIgnore(batch);
|
|
|
+
|
|
|
+ // 批量查询已存在的rootSourceId,过滤掉已存在的记录
|
|
|
+ List<String> batchRootSourceIds = batch.stream()
|
|
|
+ .map(ExternalChannel::getRootSourceId)
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ List<String> existingIds = externalChannelMapperExt.selectExistingRootSourceIds(batchRootSourceIds);
|
|
|
+ List<ExternalChannel> filteredBatch = batch;
|
|
|
+ if (!CollectionUtils.isEmpty(existingIds)) {
|
|
|
+ filteredBatch = batch.stream()
|
|
|
+ .filter(r -> !existingIds.contains(r.getRootSourceId()))
|
|
|
+ .collect(Collectors.toList());
|
|
|
+ }
|
|
|
+
|
|
|
+ if (CollectionUtils.isEmpty(filteredBatch)) {
|
|
|
+ log.info("渠道{}本批全部已存在, 跳过", channelType);
|
|
|
+ continue;
|
|
|
+ }
|
|
|
+
|
|
|
+ int count = externalChannelMapperExt.batchInsertIgnore(filteredBatch);
|
|
|
insertedCount += count;
|
|
|
- log.info("渠道{}批次插入完成, 本批{}, 累计插入{}", channelType, count, insertedCount);
|
|
|
+ log.info("渠道{}批次插入完成, 本批{}, 过滤已存在{}, 累计插入{}", channelType, filteredBatch.size(), existingIds != null ? existingIds.size() : 0, insertedCount);
|
|
|
}
|
|
|
|
|
|
log.info("渠道{}历史数据初始化完成, 插入{}条", channelType, insertedCount);
|
|
|
@@ -1044,7 +1062,6 @@ public class ExternalChannelProcessJob {
|
|
|
ContentPlatformGzhPlanVideoExample example = new ContentPlatformGzhPlanVideoExample();
|
|
|
example.createCriteria()
|
|
|
.andRootSourceIdLike(prefix + "%")
|
|
|
- .andStatusEqualTo(1)
|
|
|
.andCreateTimestampGreaterThanOrEqualTo(startDate.getTime());
|
|
|
List<ContentPlatformGzhPlanVideo> list = gzhPlanVideoMapper.selectByExample(example);
|
|
|
if (!CollectionUtils.isEmpty(list)) {
|