Authored by hugufei

添加拆分

@@ -48,10 +48,12 @@ public class SearchLikeSecneController { @@ -48,10 +48,12 @@ public class SearchLikeSecneController {
48 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); 48 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
49 int viewNum = MapUtils.getIntValue(paramMap, "viewNum", 10); 49 int viewNum = MapUtils.getIntValue(paramMap, "viewNum", 10);
50 int uid = MapUtils.getIntValue(paramMap, "uid", 0); 50 int uid = MapUtils.getIntValue(paramMap, "uid", 0);
51 - if (uid>0 && uid % 1024 < 512) {  
52 - paramMap.put("use_yoho_image", "true"); 51 + SearchApiResult result;
  52 + if (uid>0 && (uid % 1024 < 512)) {
  53 + result = searchLikeInShopService.searchLikeInShopWithYohoImage(paramMap);
  54 + }else{
  55 + result = searchLikeInShopService.searchLikeInShop(paramMap);
53 } 56 }
54 - SearchApiResult result = searchLikeInShopService.searchLikeInShop(paramMap);  
55 return searchLikeHelper.buildSearchApiResultWithViewNum(result, viewNum); 57 return searchLikeHelper.buildSearchApiResultWithViewNum(result, viewNum);
56 } 58 }
57 59
@@ -61,10 +63,12 @@ public class SearchLikeSecneController { @@ -61,10 +63,12 @@ public class SearchLikeSecneController {
61 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request); 63 Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
62 int viewNum = MapUtils.getIntValue(paramMap, "viewNum", 10); 64 int viewNum = MapUtils.getIntValue(paramMap, "viewNum", 10);
63 int uid = MapUtils.getIntValue(paramMap, "uid", 0); 65 int uid = MapUtils.getIntValue(paramMap, "uid", 0);
64 - if (uid>0 && uid % 1024 < 512) {  
65 - paramMap.put("use_yoho_image", "true"); 66 + SearchApiResult result;
  67 + if (uid>0 && (uid % 1024 < 512)) {
  68 + result = searchLikeNotInShopService.searchLikeSimilarSknNotInShopWithYohoImage(paramMap);
  69 + }else{
  70 + result = searchLikeNotInShopService.searchLikeSimilarSknNotInShop(paramMap);
66 } 71 }
67 - SearchApiResult result = searchLikeNotInShopService.searchLikeSimilarSknNotInShop(paramMap);  
68 return searchLikeHelper.buildSearchApiResultWithViewNum(result, viewNum); 72 return searchLikeHelper.buildSearchApiResultWithViewNum(result, viewNum);
69 } 73 }
70 74
@@ -12,7 +12,6 @@ import com.yoho.search.service.helper.ProductListHelper; @@ -12,7 +12,6 @@ import com.yoho.search.service.helper.ProductListHelper;
12 import com.yoho.search.service.index.BigdataSimilarSknIndexBaseService; 12 import com.yoho.search.service.index.BigdataSimilarSknIndexBaseService;
13 import com.yoho.search.service.index.ProductIndexBaseService; 13 import com.yoho.search.service.index.ProductIndexBaseService;
14 import org.apache.commons.collections.CollectionUtils; 14 import org.apache.commons.collections.CollectionUtils;
15 -import org.apache.commons.collections.MapUtils;  
16 import org.apache.commons.lang.StringUtils; 15 import org.apache.commons.lang.StringUtils;
17 import org.elasticsearch.index.query.BoolQueryBuilder; 16 import org.elasticsearch.index.query.BoolQueryBuilder;
18 import org.elasticsearch.index.query.QueryBuilder; 17 import org.elasticsearch.index.query.QueryBuilder;
@@ -49,14 +48,24 @@ public class SearchLikeInShopService { @@ -49,14 +48,24 @@ public class SearchLikeInShopService {
49 @Autowired 48 @Autowired
50 private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService; 49 private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService;
51 50
  51 +
  52 + @SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_IN_SHOP_NEW", includeParams = {"product_skn"})
  53 + public SearchApiResult searchLikeInShop(Map<String, String> paramMap) {
  54 + return innerSearchLikeInShop(paramMap, false);
  55 + }
  56 +
  57 + @SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_IN_SHOP_NEW_B", includeParams = {"product_skn"})
  58 + public SearchApiResult searchLikeInShopWithYohoImage(Map<String, String> paramMap) {
  59 + return innerSearchLikeInShop(paramMap, true);
  60 + }
  61 +
52 /** 62 /**
53 * 店铺内推荐 63 * 店铺内推荐
54 * 64 *
55 * @param paramMap 65 * @param paramMap
56 * @return 66 * @return
57 */ 67 */
58 - @SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_IN_SHOP_NEW", includeParams = {"product_skn", "use_yoho_image"})  
59 - public SearchApiResult searchLikeInShop(Map<String, String> paramMap) { 68 + private SearchApiResult innerSearchLikeInShop(Map<String, String> paramMap, boolean use_yoho_image) {
60 try { 69 try {
61 // 1、获取参数 70 // 1、获取参数
62 String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN); 71 String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN);
@@ -73,7 +82,6 @@ public class SearchLikeInShopService { @@ -73,7 +82,6 @@ public class SearchLikeInShopService {
73 82
74 //4、获取similarskn 83 //4、获取similarskn
75 BigdataSimilarSknIndexBO bigdataSimilarSkn = bigdataSimilarSknIndexBaseService.querySimilarSkn(productSkn); 84 BigdataSimilarSknIndexBO bigdataSimilarSkn = bigdataSimilarSknIndexBaseService.querySimilarSkn(productSkn);
76 - boolean use_yoho_image = MapUtils.getBooleanValue(paramMap, "use_yoho_image", false);  
77 85
78 // 5、设置SearchParams 86 // 5、设置SearchParams
79 List<SearchParam> searchParams = new ArrayList<SearchParam>(); 87 List<SearchParam> searchParams = new ArrayList<SearchParam>();
@@ -12,7 +12,6 @@ import com.yoho.search.service.helper.ProductListHelper; @@ -12,7 +12,6 @@ import com.yoho.search.service.helper.ProductListHelper;
12 import com.yoho.search.service.index.BigdataSimilarSknIndexBaseService; 12 import com.yoho.search.service.index.BigdataSimilarSknIndexBaseService;
13 import com.yoho.search.service.index.ProductIndexBaseService; 13 import com.yoho.search.service.index.ProductIndexBaseService;
14 import org.apache.commons.collections.CollectionUtils; 14 import org.apache.commons.collections.CollectionUtils;
15 -import org.apache.commons.collections.MapUtils;  
16 import org.apache.commons.lang.StringUtils; 15 import org.apache.commons.lang.StringUtils;
17 import org.elasticsearch.index.query.BoolQueryBuilder; 16 import org.elasticsearch.index.query.BoolQueryBuilder;
18 import org.elasticsearch.index.query.QueryBuilder; 17 import org.elasticsearch.index.query.QueryBuilder;
@@ -44,8 +43,17 @@ public class SearchLikeNotInShopService { @@ -44,8 +43,17 @@ public class SearchLikeNotInShopService {
44 @Autowired 43 @Autowired
45 private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService; 44 private BigdataSimilarSknIndexBaseService bigdataSimilarSknIndexBaseService;
46 45
47 - @SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR_NEW", includeParams = {"product_skn", "use_yoho_image"}) 46 + @SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR_NEW", includeParams = {"product_skn"})
48 public SearchApiResult searchLikeSimilarSknNotInShop(Map<String, String> paramMap) { 47 public SearchApiResult searchLikeSimilarSknNotInShop(Map<String, String> paramMap) {
  48 + return innersearchLikeSimilarSknNotInShop(paramMap, false);
  49 + }
  50 +
  51 + @SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP_SIMILAR_NEW_B", includeParams = {"product_skn"})
  52 + public SearchApiResult searchLikeSimilarSknNotInShopWithYohoImage(Map<String, String> paramMap) {
  53 + return innersearchLikeSimilarSknNotInShop(paramMap, true);
  54 + }
  55 +
  56 + private SearchApiResult innersearchLikeSimilarSknNotInShop(Map<String, String> paramMap, boolean use_yoho_image) {
49 try { 57 try {
50 // 1、获取参数 58 // 1、获取参数
51 String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN); 59 String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN);
@@ -62,7 +70,6 @@ public class SearchLikeNotInShopService { @@ -62,7 +70,6 @@ public class SearchLikeNotInShopService {
62 70
63 //4、获取similarskn 71 //4、获取similarskn
64 BigdataSimilarSknIndexBO bigdataSimilarSkn = bigdataSimilarSknIndexBaseService.querySimilarSkn(productSkn); 72 BigdataSimilarSknIndexBO bigdataSimilarSkn = bigdataSimilarSknIndexBaseService.querySimilarSkn(productSkn);
65 - boolean use_yoho_image = MapUtils.getBooleanValue(paramMap, "use_yoho_image", false);  
66 73
67 //5、构造searchParams 74 //5、构造searchParams
68 List<SearchParam> searchParams = new ArrayList<>(); 75 List<SearchParam> searchParams = new ArrayList<>();
@@ -135,7 +142,7 @@ public class SearchLikeNotInShopService { @@ -135,7 +142,7 @@ public class SearchLikeNotInShopService {
135 * @param productSkns 142 * @param productSkns
136 * @return 143 * @return
137 */ 144 */
138 - private SearchParam builderSimilarSknSearchParam(JSONObject productInfoInEs, List<String> productSkns){ 145 + private SearchParam builderSimilarSknSearchParam(JSONObject productInfoInEs, List<String> productSkns) {
139 // 1、设置SearchParam 146 // 1、设置SearchParam
140 SearchParam searchParam = new SearchParam(); 147 SearchParam searchParam = new SearchParam();
141 // 2)设置query和filter 148 // 2)设置query和filter