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