...
|
...
|
@@ -13,10 +13,7 @@ import com.yoho.search.consumer.service.logicService.ProductIndexBOToMapService; |
|
|
import com.yoho.search.consumer.service.logicService.ProductSknCodeService;
|
|
|
import com.yoho.search.consumer.service.logicService.productIndex.IndexFieldBuilder;
|
|
|
import com.yoho.search.dal.ProductMapper;
|
|
|
import com.yoho.search.dal.model.Brand;
|
|
|
import com.yoho.search.dal.model.Product;
|
|
|
import com.yoho.search.dal.model.ProductSort;
|
|
|
import com.yoho.search.dal.model.Shops;
|
|
|
import com.yoho.search.dal.model.*;
|
|
|
|
|
|
import org.apache.commons.collections.MapUtils;
|
|
|
import org.slf4j.Logger;
|
...
|
...
|
@@ -56,10 +53,12 @@ public class ProductIndexIndexBuilder extends IIndexBuilder implements Applicati |
|
|
private static Map<Integer, ProductSort> productSortMap = new HashMap<>();
|
|
|
private static Map<Integer, Brand> brandMap = new HashMap<>();
|
|
|
private static Map<Integer, Shops> shopMap = new HashMap<>();
|
|
|
private static Map<Integer, CsBrandKeyword> csBrandKeywordMap = new HashMap<>();
|
|
|
private static String CACHE_KEY = "productIndexIndexBuilder_cache";
|
|
|
private static String SORT_CACHE_KEY = "sort_cache_key";
|
|
|
private static String BRAND_CACHE_KEY = "brand_cache_key";
|
|
|
private static String SHOP_CACHE_KEY = "shop_cache_key";
|
|
|
private static String CSBRANDKEYWORD_CACHE_KEY = "csbrandkeyword_cache_key";
|
|
|
|
|
|
//guava本地缓存保存sort,brand,shop数据
|
|
|
LoadingCache<String, JSONObject> cache = CacheBuilder.newBuilder()
|
...
|
...
|
@@ -73,6 +72,7 @@ public class ProductIndexIndexBuilder extends IIndexBuilder implements Applicati |
|
|
jsonObject.put(SORT_CACHE_KEY, cacheDataService.getProductSortMap());
|
|
|
jsonObject.put(BRAND_CACHE_KEY, cacheDataService.getBrandMap());
|
|
|
jsonObject.put(SHOP_CACHE_KEY, cacheDataService.getShopMap());
|
|
|
jsonObject.put(CSBRANDKEYWORD_CACHE_KEY, cacheDataService.getCsBrandKeywordMap());
|
|
|
cacheLogger.info("[ProductIndexIndexBuilder][set data to cache end]");
|
|
|
return jsonObject;
|
|
|
}
|
...
|
...
|
@@ -172,11 +172,12 @@ public class ProductIndexIndexBuilder extends IIndexBuilder implements Applicati |
|
|
productSortMap = (Map<Integer, ProductSort>) jsonObject.get(SORT_CACHE_KEY);
|
|
|
brandMap = (Map<Integer, Brand>) jsonObject.get(BRAND_CACHE_KEY);
|
|
|
shopMap = (Map<Integer, Shops>) jsonObject.get(SHOP_CACHE_KEY);
|
|
|
csBrandKeywordMap = (Map<Integer, CsBrandKeyword>) jsonObject.get(CSBRANDKEYWORD_CACHE_KEY);
|
|
|
logger.info("[fun=getProductIBOs][get sort/brand/shop data from cache][cost: {}]", System.currentTimeMillis() - begin);
|
|
|
} catch (ExecutionException e) {
|
|
|
cacheLogger.error(e.getMessage());
|
|
|
}
|
|
|
List<ProductIBO> productIBOs = productILogicService.buildProductIBO(products, productSortMap, brandMap, shopMap);
|
|
|
List<ProductIBO> productIBOs = productILogicService.buildProductIBO(products, productSortMap, brandMap, shopMap, csBrandKeywordMap);
|
|
|
logger.info("[fun=getProductIBOs][build productIBOs success][cost: {}]", System.currentTimeMillis() - begin);
|
|
|
return productIBOs;
|
|
|
}
|
...
|
...
|
|