Authored by hugufei

bug修复

@@ -38,7 +38,6 @@ public class CustomizeTagBaseService { @@ -38,7 +38,6 @@ public class CustomizeTagBaseService {
38 private final Logger logger = LoggerFactory.getLogger(this.getClass()); 38 private final Logger logger = LoggerFactory.getLogger(this.getClass());
39 private static final String CACHE_KEY = "CacheKey"; 39 private static final String CACHE_KEY = "CacheKey";
40 private static final String POOLID_CUSTOMIZETAG_MAP_CACHE_KEY = "poolIdCustomizeTagMapCacheKey"; 40 private static final String POOLID_CUSTOMIZETAG_MAP_CACHE_KEY = "poolIdCustomizeTagMapCacheKey";
41 - private static final String PRODUCTINDEX_FIELD_POOLIDS = "pool_ids";  
42 41
43 //Guava Cache 42 //Guava Cache
44 LoadingCache<String, JSONObject> customizeTagCache = CacheBuilder.newBuilder() 43 LoadingCache<String, JSONObject> customizeTagCache = CacheBuilder.newBuilder()
@@ -67,13 +66,11 @@ public class CustomizeTagBaseService { @@ -67,13 +66,11 @@ public class CustomizeTagBaseService {
67 //3、遍历product列表,插入customizeTag 66 //3、遍历product列表,插入customizeTag
68 for (Map<String, Object> productMap : productList) { 67 for (Map<String, Object> productMap : productList) {
69 try { 68 try {
70 - String poolIds = MapUtils.getString(productMap, PRODUCTINDEX_FIELD_POOLIDS, ""); 69 + String poolIds = MapUtils.getString(productMap, "pool_ids", "");
71 List<JSONObject> customizeTags = this.buildCustomizeTag(poolIds, customizeTagMap); 70 List<JSONObject> customizeTags = this.buildCustomizeTag(poolIds, customizeTagMap);
72 productMap.put("customize_tag", customizeTags); 71 productMap.put("customize_tag", customizeTags);
73 } catch (Exception e) { 72 } catch (Exception e) {
74 logger.error(e.getMessage(), e); 73 logger.error(e.getMessage(), e);
75 - } finally {  
76 - productMap.remove(PRODUCTINDEX_FIELD_POOLIDS);  
77 } 74 }
78 } 75 }
79 } catch (Exception e) { 76 } catch (Exception e) {
@@ -13,6 +13,7 @@ import com.yoho.search.core.es.model.SearchResult; @@ -13,6 +13,7 @@ import com.yoho.search.core.es.model.SearchResult;
13 import com.yoho.search.core.es.utils.SearchParamUtils; 13 import com.yoho.search.core.es.utils.SearchParamUtils;
14 import com.yoho.search.dal.model.ProductCutpriceConfig; 14 import com.yoho.search.dal.model.ProductCutpriceConfig;
15 import org.apache.commons.collections.MapUtils; 15 import org.apache.commons.collections.MapUtils;
  16 +import org.apache.commons.lang.StringUtils;
16 import org.elasticsearch.index.query.BoolQueryBuilder; 17 import org.elasticsearch.index.query.BoolQueryBuilder;
17 import org.elasticsearch.index.query.QueryBuilders; 18 import org.elasticsearch.index.query.QueryBuilders;
18 import org.elasticsearch.search.builder.SearchSourceBuilder; 19 import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -93,18 +94,16 @@ public class CutpriceConfigIndexBaseService { @@ -93,18 +94,16 @@ public class CutpriceConfigIndexBaseService {
93 94
94 public void fillIsProductCutPrice(List<Map<String, Object>> productList) { 95 public void fillIsProductCutPrice(List<Map<String, Object>> productList) {
95 try { 96 try {
96 - //List<Integer> productCutpriceConfigPoolIds = CUT_PRICE_CONFIG_CACHE.get(CACHE_KEY);  
97 - List<Integer> productCutpriceConfigPoolIds = this.buildCurrentProductCutpricePoolIds();  
98 - if (productCutpriceConfigPoolIds == null || productCutpriceConfigPoolIds.isEmpty()) {  
99 - return;  
100 - } 97 + List<Integer> productCutpriceConfigPoolIds = CUT_PRICE_CONFIG_CACHE.get(CACHE_KEY);
101 for (Map<String, Object> product : productList) { 98 for (Map<String, Object> product : productList) {
102 try { 99 try {
103 - String productPoolIdStr = MapUtils.getString(product, PRODUCTINDEX_FIELD_POOLIDS, ""); 100 + String productPoolIdStr = MapUtils.getString(product, "pool_ids", "");
104 boolean is_product_cutprice = this.isProductCutprice(productCutpriceConfigPoolIds, productPoolIdStr); 101 boolean is_product_cutprice = this.isProductCutprice(productCutpriceConfigPoolIds, productPoolIdStr);
105 product.put("is_product_cutprice", is_product_cutprice ? "Y" : "N"); 102 product.put("is_product_cutprice", is_product_cutprice ? "Y" : "N");
106 } catch (Exception e) { 103 } catch (Exception e) {
107 logger.error(e.getMessage(), e); 104 logger.error(e.getMessage(), e);
  105 + }finally {
  106 + product.remove("pool_ids");
108 } 107 }
109 } 108 }
110 } catch (Exception e) { 109 } catch (Exception e) {
@@ -113,6 +112,12 @@ public class CutpriceConfigIndexBaseService { @@ -113,6 +112,12 @@ public class CutpriceConfigIndexBaseService {
113 } 112 }
114 113
115 private boolean isProductCutprice(List<Integer> currentCutPricePoolIds, String productPoolIdStr) { 114 private boolean isProductCutprice(List<Integer> currentCutPricePoolIds, String productPoolIdStr) {
  115 + if (currentCutPricePoolIds == null || currentCutPricePoolIds.isEmpty()) {
  116 + return false;
  117 + }
  118 + if (StringUtils.isEmpty(productPoolIdStr)) {
  119 + return false;
  120 + }
116 List<Integer> productPoolIdList = ConvertUtils.stringToIntList(productPoolIdStr, ","); 121 List<Integer> productPoolIdList = ConvertUtils.stringToIntList(productPoolIdStr, ",");
117 for (Integer pool : productPoolIdList) { 122 for (Integer pool : productPoolIdList) {
118 if (currentCutPricePoolIds.contains(pool)) { 123 if (currentCutPricePoolIds.contains(pool)) {