...
|
...
|
@@ -7,7 +7,11 @@ import com.yoho.search.consumer.service.logicService.cache.BasicDataCacheService |
|
|
import com.yoho.search.consumer.service.logicService.ufo.yoho.*;
|
|
|
import com.yoho.search.consumer.service.utils.IdCheckUtils;
|
|
|
import com.yoho.search.dal.*;
|
|
|
import com.yoho.search.dal.model.*;
|
|
|
import com.yoho.search.dal.model.Brand;
|
|
|
import com.yoho.search.dal.model.ufo_product.*;
|
|
|
import com.yoho.search.dal.model.ufo_product.Goods;
|
|
|
import com.yoho.search.dal.model.ufo_product.Product;
|
|
|
import com.yoho.search.dal.model.ufo_product.Size;
|
|
|
import org.apache.commons.collections.CollectionUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -81,30 +85,30 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { |
|
|
* 全量构建
|
|
|
*/
|
|
|
public List<ProductIndexBO> buildProductIndexBOList(int start, int limit) {
|
|
|
List<UfoProduct> ufoProductList = ufoProductMapper.selectPageLists(start, limit);
|
|
|
if (CollectionUtils.isEmpty(ufoProductList)) {
|
|
|
List<Product> productList = ufoProductMapper.selectPageLists(start, limit);
|
|
|
if (CollectionUtils.isEmpty(productList)) {
|
|
|
return new ArrayList<>();
|
|
|
}
|
|
|
return buildProductIndexBOList(ufoProductList);
|
|
|
return buildProductIndexBOList(productList);
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 增量构建
|
|
|
*/
|
|
|
public ProductIndexBO buildProductIndexBOIncrease(Integer id) {
|
|
|
UfoProduct ufoProduct = ufoProductMapper.selectByPrimaryKey(id);
|
|
|
if (ufoProduct == null) {
|
|
|
Product product = ufoProductMapper.selectByPrimaryKey(id);
|
|
|
if (product == null) {
|
|
|
return null;
|
|
|
}
|
|
|
List<UfoProduct> ufoProductList = new ArrayList<>(Arrays.asList(ufoProduct));
|
|
|
List<ProductIndexBO> productIndexBOList = buildProductIndexBOList(ufoProductList);
|
|
|
List<Product> productList = new ArrayList<>(Arrays.asList(product));
|
|
|
List<ProductIndexBO> productIndexBOList = buildProductIndexBOList(productList);
|
|
|
if (CollectionUtils.isEmpty(productIndexBOList)) {
|
|
|
return null;
|
|
|
}
|
|
|
return productIndexBOList.get(0);
|
|
|
}
|
|
|
|
|
|
private List<ProductIndexBO> buildProductIndexBOList(List<UfoProduct> ufoProductList) {
|
|
|
private List<ProductIndexBO> buildProductIndexBOList(List<Product> productList) {
|
|
|
List<ProductIndexBO> productIndexBOList = new ArrayList<>();
|
|
|
try {
|
|
|
//缓存中获取所有基础数据
|
...
|
...
|
@@ -112,30 +116,30 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { |
|
|
Map<Integer, ProductSort> yohoSortMap = basicDataCacheService.getProductSort();
|
|
|
Map<String, ProductColor> yohoColorNameMap = basicDataCacheService.getColorNameMap();
|
|
|
Map<String, List<Size>> yohoSizeNameMap = basicDataCacheService.getSizeNameMap();
|
|
|
Map<Short, UfoBrand> ufoBrandMap = basicDataCacheService.getUfoBrand();
|
|
|
Map<Short, UfoBrandSeries> ufoBrandSeriesMap = basicDataCacheService.getUfoBrandSeries();
|
|
|
Map<Short, UfoSize> ufoSizeMap = basicDataCacheService.getUfoSize();
|
|
|
Map<Short, com.yoho.search.dal.model.ufo_product.Brand> ufoBrandMap = basicDataCacheService.getUfoBrand();
|
|
|
Map<Short, BrandSeries> ufoBrandSeriesMap = basicDataCacheService.getUfoBrandSeries();
|
|
|
Map<Short, Size> ufoSizeMap = basicDataCacheService.getUfoSize();
|
|
|
Map<Integer, Integer> ufoBrandRelation = basicDataCacheService.getUfoBrandRelationMap();
|
|
|
Map<Integer, UfoSearchSortRelation> ufoSortRelationMap = basicDataCacheService.getUfoSortRelationMap();
|
|
|
Map<Integer, SearchSortRelation> ufoSortRelationMap = basicDataCacheService.getUfoSortRelationMap();
|
|
|
|
|
|
List<Integer> ufoProductIdList = ufoProductList.stream().map(UfoProduct::getId).collect(Collectors.toList());
|
|
|
List<Integer> ufoProductIdList = productList.stream().map(Product::getId).collect(Collectors.toList());
|
|
|
//去查这一批ufo商品的goods,转换为map
|
|
|
List<UfoGoods> ufoGoodsList = ufoGoodsMapper.selectByProductIdList(ufoProductIdList);
|
|
|
Map<Integer, List<UfoGoods>> ufoGoodsMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(ufoGoodsList)) {
|
|
|
ufoGoodsMap = ufoGoodsList.stream().collect(Collectors.groupingBy(UfoGoods::getProductId));
|
|
|
List<com.yoho.search.dal.model.ufo_product.Goods> goodsList = ufoGoodsMapper.selectByProductIdList(ufoProductIdList);
|
|
|
Map<Integer, List<Goods>> ufoGoodsMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(goodsList)) {
|
|
|
ufoGoodsMap = goodsList.stream().collect(Collectors.groupingBy(Goods::getProductId));
|
|
|
}
|
|
|
//去查这一批ufo商品的storage,转换为map
|
|
|
List<UfoStorage> ufoStorageList = ufoStorageMapper.selectByProductIdList(ufoProductIdList);
|
|
|
Map<Integer, List<UfoStorage>> ufoStorageMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(ufoStorageList)) {
|
|
|
ufoStorageMap = ufoStorageList.stream().collect(Collectors.groupingBy(UfoStorage::getProductId));
|
|
|
List<Storage> storageList = ufoStorageMapper.selectByProductIdList(ufoProductIdList);
|
|
|
Map<Integer, List<Storage>> ufoStorageMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(storageList)) {
|
|
|
ufoStorageMap = storageList.stream().collect(Collectors.groupingBy(Storage::getProductId));
|
|
|
}
|
|
|
//去查这一批ufo商品的storage_price,转换为map
|
|
|
List<UfoStoragePrice> ufoStoragePriceList = ufoStoragePriceMapper.selectByProductIdList(ufoProductIdList);
|
|
|
Map<Integer, List<UfoStoragePrice>> ufoStoragePriceMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(ufoStoragePriceList)) {
|
|
|
ufoStoragePriceMap = ufoStoragePriceList.stream().collect(Collectors.groupingBy(UfoStoragePrice::getProductId));
|
|
|
List<StoragePrice> storagePriceList = ufoStoragePriceMapper.selectByProductIdList(ufoProductIdList);
|
|
|
Map<Integer, List<StoragePrice>> ufoStoragePriceMap = new HashMap<>();
|
|
|
if (CollectionUtils.isNotEmpty(storagePriceList)) {
|
|
|
ufoStoragePriceMap = storagePriceList.stream().collect(Collectors.groupingBy(StoragePrice::getProductId));
|
|
|
}
|
|
|
//去查这一批ufo商品的ufo_score_product_rule Set
|
|
|
List<Integer> ufoScoreProductRuleList = ufoScoreProductRuleMapper.selectByIdList(ufoProductIdList);
|
...
|
...
|
@@ -144,26 +148,26 @@ public class UfoToYohoIndexBuilder extends IIndexBuilder { |
|
|
ufoScoreProductRuleSet = ufoScoreProductRuleList.stream().collect(Collectors.toSet());
|
|
|
}
|
|
|
|
|
|
for (UfoProduct ufoProduct : ufoProductList) {
|
|
|
for (Product product : productList) {
|
|
|
//不合法id直接丢掉
|
|
|
if (!IdCheckUtils.isUfoIdLegal(ufoProduct.getId())) {
|
|
|
if (!IdCheckUtils.isUfoIdLegal(product.getId())) {
|
|
|
continue;
|
|
|
}
|
|
|
ProductIndexBO productIndexBO = new ProductIndexBO();
|
|
|
//一般字段
|
|
|
ufoToYohoGeneralService.build(productIndexBO, ufoProduct, ufoBrandSeriesMap);
|
|
|
ufoToYohoGeneralService.build(productIndexBO, product, ufoBrandSeriesMap);
|
|
|
//品牌
|
|
|
ufoToYohoBrandService.build(productIndexBO, ufoProduct, yohoBrandMap, ufoBrandMap, ufoBrandRelation);
|
|
|
ufoToYohoBrandService.build(productIndexBO, product, yohoBrandMap, ufoBrandMap, ufoBrandRelation);
|
|
|
//品类
|
|
|
ufoToYohoSortService.build(productIndexBO, ufoProduct, yohoSortMap, ufoSortRelationMap);
|
|
|
ufoToYohoSortService.build(productIndexBO, product, yohoSortMap, ufoSortRelationMap);
|
|
|
//颜色
|
|
|
ufoToYohoColorService.build(productIndexBO, ufoProduct, yohoColorNameMap, ufoGoodsMap);
|
|
|
ufoToYohoColorService.build(productIndexBO, product, yohoColorNameMap, ufoGoodsMap);
|
|
|
//尺码
|
|
|
ufoToYohoSizeService.build(productIndexBO, ufoProduct, ufoSizeMap, yohoSizeNameMap, ufoStorageMap);
|
|
|
ufoToYohoSizeService.build(productIndexBO, product, ufoSizeMap, yohoSizeNameMap, ufoStorageMap);
|
|
|
//价格
|
|
|
ufoToYohoPriceService.build(productIndexBO, ufoProduct, ufoStoragePriceMap,ufoStorageMap);
|
|
|
ufoToYohoPriceService.build(productIndexBO, product, ufoStoragePriceMap,ufoStorageMap);
|
|
|
//直通车
|
|
|
productIndexBO.setToAddScore(ufoScoreProductRuleSet.contains(ufoProduct.getId()) ? "Y" : "N");
|
|
|
productIndexBO.setToAddScore(ufoScoreProductRuleSet.contains(product.getId()) ? "Y" : "N");
|
|
|
productIndexBOList.add(productIndexBO);
|
|
|
}
|
|
|
return productIndexBOList;
|
...
|
...
|
|