...
|
...
|
@@ -23,6 +23,7 @@ import com.yoho.search.dal.model.StorageSku; |
|
|
import com.yoho.search.dal.service.StorageSkuService;
|
|
|
import com.yoho.search.index.model.ESBluk;
|
|
|
import com.yoho.search.index.service.IYohoIndexService;
|
|
|
import com.yoho.search.index.storagesku.IStorageSkuService;
|
|
|
import com.yoho.search.utils.EventReportEnum;
|
|
|
import com.yoho.search.utils.ISearchConstans;
|
|
|
import com.yoho.search.utils.IgnoreSomeException;
|
...
|
...
|
@@ -39,8 +40,12 @@ public class StorageSkuIndexService implements ApplicationEventPublisherAware { |
|
|
private StorageSkuService storageSkuService;
|
|
|
@Autowired
|
|
|
private IYohoIndexService indexService;
|
|
|
// @Autowired
|
|
|
// private Product15DaySalesNumService product15DaySalesNumService;
|
|
|
|
|
|
/**
|
|
|
* 代码构建storagesku服务 -- amos.shan add on 2016-10-28
|
|
|
*/
|
|
|
@Autowired
|
|
|
private IStorageSkuService storageSkuServiceImpl;
|
|
|
|
|
|
// 按Sku更新库存
|
|
|
private ArrayBlockingQueue<Integer> productSkuQueue = new ArrayBlockingQueue<Integer>(200);
|
...
|
...
|
@@ -91,21 +96,33 @@ public class StorageSkuIndexService implements ApplicationEventPublisherAware { |
|
|
// 1、根据sku去取数据库对象
|
|
|
List<Integer> productSkus = this.getElementsFromArrayBlockingQueue(productSkuQueue, 200);
|
|
|
if (!productSkus.isEmpty()) {
|
|
|
storageSkuList.addAll(storageSkuService.selectListProductSkus(productSkus));
|
|
|
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
|
|
|
storageSkuList.addAll(storageSkuServiceImpl.getStorageSkuIndexBySkus(productSkus));
|
|
|
} else {
|
|
|
storageSkuList.addAll(storageSkuService.selectListProductSkus(productSkus));
|
|
|
}
|
|
|
logger.info("doBulkUpdateStorageSkuIndex[getListBySku], storageSkuList size is [{}], cost [{}]ms", storageSkuList.size(), costStatistics.getCost());
|
|
|
}
|
|
|
|
|
|
// 2、根据skc去取数据库对象
|
|
|
List<Integer> goodsIds = this.getElementsFromArrayBlockingQueue(goodsIdQueue, 200);
|
|
|
if (!goodsIds.isEmpty()) {
|
|
|
storageSkuList.addAll(storageSkuService.selectListByGoodsIds(goodsIds));
|
|
|
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
|
|
|
storageSkuList.addAll(storageSkuServiceImpl.getStorageSkuIndexBySkcs(goodsIds));
|
|
|
} else {
|
|
|
storageSkuList.addAll(storageSkuService.selectListByGoodsIds(goodsIds));
|
|
|
}
|
|
|
logger.info("doBulkUpdateStorageSkuIndex[getListBySkc], storageSkuList size is [{}], cost [{}]ms", storageSkuList.size(), costStatistics.getCost());
|
|
|
}
|
|
|
|
|
|
// 3、根据skn去取数据库对象
|
|
|
List<Integer> productIds = this.getElementsFromArrayBlockingQueue(productIdQueue, 200);
|
|
|
if (!productIds.isEmpty()) {
|
|
|
storageSkuList.addAll(storageSkuService.selectListByProductIds(productIds));
|
|
|
if (ISearchConstans.BUILD_STORAGESKUINDEX_USE_CODE) {
|
|
|
storageSkuList.addAll(storageSkuServiceImpl.getStorageSkuIndexBySkns(productIds));
|
|
|
} else {
|
|
|
storageSkuList.addAll(storageSkuService.selectListByProductIds(productIds));
|
|
|
}
|
|
|
logger.info("doBulkUpdateStorageSkuIndex[getListBySkn], storageSkuList size is [{}], cost [{}]ms", storageSkuList.size(), costStatistics.getCost());
|
|
|
}
|
|
|
|
...
|
...
|
@@ -228,7 +245,7 @@ public class StorageSkuIndexService implements ApplicationEventPublisherAware { |
|
|
}
|
|
|
List<ESBluk> results = new ArrayList<ESBluk>();
|
|
|
for (StorageSku storageSku : storageSkuList) {
|
|
|
//特殊处理storageSku的某些字段
|
|
|
// 特殊处理storageSku的某些字段
|
|
|
SpecialDealForIndex.specialDealStorageSku(storageSku);
|
|
|
results.add(new ESBluk(JSONObject.toJSONString(this.beanToMap(storageSku)), storageSku.getProductSku().toString(), indexName, indexName, false));
|
|
|
}
|
...
|
...
|
|