Authored by hugufei

bug修复

... ... @@ -38,7 +38,6 @@ public class CustomizeTagBaseService {
private final Logger logger = LoggerFactory.getLogger(this.getClass());
private static final String CACHE_KEY = "CacheKey";
private static final String POOLID_CUSTOMIZETAG_MAP_CACHE_KEY = "poolIdCustomizeTagMapCacheKey";
private static final String PRODUCTINDEX_FIELD_POOLIDS = "pool_ids";
//Guava Cache
LoadingCache<String, JSONObject> customizeTagCache = CacheBuilder.newBuilder()
... ... @@ -67,13 +66,11 @@ public class CustomizeTagBaseService {
//3、遍历product列表,插入customizeTag
for (Map<String, Object> productMap : productList) {
try {
String poolIds = MapUtils.getString(productMap, PRODUCTINDEX_FIELD_POOLIDS, "");
String poolIds = MapUtils.getString(productMap, "pool_ids", "");
List<JSONObject> customizeTags = this.buildCustomizeTag(poolIds, customizeTagMap);
productMap.put("customize_tag", customizeTags);
} catch (Exception e) {
logger.error(e.getMessage(), e);
} finally {
productMap.remove(PRODUCTINDEX_FIELD_POOLIDS);
}
}
} catch (Exception e) {
... ...
... ... @@ -13,6 +13,7 @@ import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.core.es.utils.SearchParamUtils;
import com.yoho.search.dal.model.ProductCutpriceConfig;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
... ... @@ -93,18 +94,16 @@ public class CutpriceConfigIndexBaseService {
public void fillIsProductCutPrice(List<Map<String, Object>> productList) {
try {
//List<Integer> productCutpriceConfigPoolIds = CUT_PRICE_CONFIG_CACHE.get(CACHE_KEY);
List<Integer> productCutpriceConfigPoolIds = this.buildCurrentProductCutpricePoolIds();
if (productCutpriceConfigPoolIds == null || productCutpriceConfigPoolIds.isEmpty()) {
return;
}
List<Integer> productCutpriceConfigPoolIds = CUT_PRICE_CONFIG_CACHE.get(CACHE_KEY);
for (Map<String, Object> product : productList) {
try {
String productPoolIdStr = MapUtils.getString(product, PRODUCTINDEX_FIELD_POOLIDS, "");
String productPoolIdStr = MapUtils.getString(product, "pool_ids", "");
boolean is_product_cutprice = this.isProductCutprice(productCutpriceConfigPoolIds, productPoolIdStr);
product.put("is_product_cutprice", is_product_cutprice ? "Y" : "N");
} catch (Exception e) {
logger.error(e.getMessage(), e);
}finally {
product.remove("pool_ids");
}
}
} catch (Exception e) {
... ... @@ -113,6 +112,12 @@ public class CutpriceConfigIndexBaseService {
}
private boolean isProductCutprice(List<Integer> currentCutPricePoolIds, String productPoolIdStr) {
if (currentCutPricePoolIds == null || currentCutPricePoolIds.isEmpty()) {
return false;
}
if (StringUtils.isEmpty(productPoolIdStr)) {
return false;
}
List<Integer> productPoolIdList = ConvertUtils.stringToIntList(productPoolIdStr, ",");
for (Integer pool : productPoolIdList) {
if (currentCutPricePoolIds.contains(pool)) {
... ...