优化更新全部商品索引时的性能
This commit is contained in:
parent
c093261369
commit
210d56447c
@ -431,6 +431,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
*/
|
||||
@Override
|
||||
public void updateEsGoodsIndexAllByList(BasePromotions promotion, String key) {
|
||||
ThreadUtil.execAsync(() -> {
|
||||
List<EsGoodsIndex> goodsIndices = new ArrayList<>();
|
||||
//如果storeId不为空,则表示是店铺活动
|
||||
if (promotion.getStoreId() != null && !promotion.getStoreId().equals(PromotionTools.PLATFORM_ID)) {
|
||||
@ -449,6 +450,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
List<String> skuIds = goodsIndices.stream().map(EsGoodsIndex::getId).collect(Collectors.toList());
|
||||
this.updateEsGoodsIndexPromotions(skuIds, promotion, key);
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -482,6 +484,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
*/
|
||||
@Override
|
||||
public void deleteEsGoodsPromotionByPromotionKey(String promotionsKey) {
|
||||
ThreadUtil.execAsync(() -> {
|
||||
BulkRequest bulkRequest = new BulkRequest();
|
||||
for (EsGoodsIndex goodsIndex : this.goodsIndexRepository.findAll()) {
|
||||
UpdateRequest updateRequest = this.removePromotionByPromotionKey(goodsIndex, promotionsKey);
|
||||
@ -490,6 +493,7 @@ public class EsGoodsIndexServiceImpl extends BaseElasticsearchService implements
|
||||
}
|
||||
}
|
||||
this.executeBulkUpdateRequest(bulkRequest);
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
|
Loading…
x
Reference in New Issue
Block a user