Showing
5 changed files
with
38 additions
and
55 deletions
@@ -72,7 +72,7 @@ public class ControllerCostInterceptor implements HandlerInterceptor { | @@ -72,7 +72,7 @@ public class ControllerCostInterceptor implements HandlerInterceptor { | ||
72 | if (cost <= 500) { | 72 | if (cost <= 500) { |
73 | return; | 73 | return; |
74 | } | 74 | } |
75 | - | 75 | + |
76 | // 5、打印响应超过500ms的请求与参数 | 76 | // 5、打印响应超过500ms的请求与参数 |
77 | if(searchDynamicConfigService.isControllerCostLogOpen()){ | 77 | if(searchDynamicConfigService.isControllerCostLogOpen()){ |
78 | CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request)); | 78 | CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request)); |
@@ -9,6 +9,7 @@ import java.util.List; | @@ -9,6 +9,7 @@ import java.util.List; | ||
9 | import java.util.Map; | 9 | import java.util.Map; |
10 | import java.util.Set; | 10 | import java.util.Set; |
11 | 11 | ||
12 | +import com.yoho.search.service.helper.SearchCommonHelper; | ||
12 | import org.apache.commons.collections.MapUtils; | 13 | import org.apache.commons.collections.MapUtils; |
13 | import org.apache.commons.lang.StringUtils; | 14 | import org.apache.commons.lang.StringUtils; |
14 | import org.springframework.beans.factory.annotation.Autowired; | 15 | import org.springframework.beans.factory.annotation.Autowired; |
@@ -48,6 +49,8 @@ public class SortRecallSceneService extends AbstractRecallService { | @@ -48,6 +49,8 @@ public class SortRecallSceneService extends AbstractRecallService { | ||
48 | private RecallServiceHelper recallServiceHelper; | 49 | private RecallServiceHelper recallServiceHelper; |
49 | @Autowired | 50 | @Autowired |
50 | private RecallPersionalHelper recallPersionalHelper; | 51 | private RecallPersionalHelper recallPersionalHelper; |
52 | + @Autowired | ||
53 | + private SearchCommonHelper searchCommonHelper; | ||
51 | 54 | ||
52 | @SearchCacheAble(cacheInMinute = 10, cacheName = "SORT_PAGE_PRODUCT_LIST") | 55 | @SearchCacheAble(cacheInMinute = 10, cacheName = "SORT_PAGE_PRODUCT_LIST") |
53 | public SearchApiResult recallProductList(Map<String, String> paramMap) { | 56 | public SearchApiResult recallProductList(Map<String, String> paramMap) { |
@@ -56,8 +59,8 @@ public class SortRecallSceneService extends AbstractRecallService { | @@ -56,8 +59,8 @@ public class SortRecallSceneService extends AbstractRecallService { | ||
56 | recallServiceHelper.setLogEnableThreadLocal(paramMap); | 59 | recallServiceHelper.setLogEnableThreadLocal(paramMap); |
57 | 60 | ||
58 | // 1)验证查询条数 | 61 | // 1)验证查询条数 |
59 | - int page = recallServiceHelper.getPage(paramMap); | ||
60 | - int pageSize = recallServiceHelper.getPageSize(paramMap); | 62 | + int page = searchCommonHelper.getPage(paramMap); |
63 | + int pageSize = searchCommonHelper.getPageSize(paramMap); | ||
61 | 64 | ||
62 | // 2)召回skn以及总数 | 65 | // 2)召回skn以及总数 |
63 | RecallProductSknList recallProductSknList = recallServiceHelper.doRecallProductSkns(paramMap, this); | 66 | RecallProductSknList recallProductSknList = recallServiceHelper.doRecallProductSkns(paramMap, this); |
@@ -73,7 +76,7 @@ public class SortRecallSceneService extends AbstractRecallService { | @@ -73,7 +76,7 @@ public class SortRecallSceneService extends AbstractRecallService { | ||
73 | dataMap.put("total", recallProductInfoList.getTotal()); | 76 | dataMap.put("total", recallProductInfoList.getTotal()); |
74 | dataMap.put("page", page); | 77 | dataMap.put("page", page); |
75 | dataMap.put("page_size", pageSize); | 78 | dataMap.put("page_size", pageSize); |
76 | - dataMap.put("page_total", recallServiceHelper.getTotalPage(recallProductInfoList.getTotal(), pageSize)); | 79 | + dataMap.put("page_total", searchCommonHelper.getTotalPage(recallProductInfoList.getTotal(), pageSize)); |
77 | dataMap.put("product_list", product_list); | 80 | dataMap.put("product_list", product_list); |
78 | return new SearchApiResult().setData(dataMap); | 81 | return new SearchApiResult().setData(dataMap); |
79 | } catch (Exception e) { | 82 | } catch (Exception e) { |
@@ -96,7 +99,7 @@ public class SortRecallSceneService extends AbstractRecallService { | @@ -96,7 +99,7 @@ public class SortRecallSceneService extends AbstractRecallService { | ||
96 | // 0、获取用户偏好品牌 | 99 | // 0、获取用户偏好品牌 |
97 | UserLikeBrands userLikeBrands = recallPersionalHelper.getSortPageUserLikeBrands(paramMap); | 100 | UserLikeBrands userLikeBrands = recallPersionalHelper.getSortPageUserLikeBrands(paramMap); |
98 | 101 | ||
99 | - int pageSize = recallServiceHelper.getPageSize(paramMap); | 102 | + int pageSize = searchCommonHelper.getPageSize(paramMap); |
100 | // 1、支持firstProductSkn的召回 | 103 | // 1、支持firstProductSkn的召回 |
101 | recallStrategy.add(new FirstProductSknStrategy(1, recallServiceHelper.getFirstProductSkns(paramMap))); | 104 | recallStrategy.add(new FirstProductSknStrategy(1, recallServiceHelper.getFirstProductSkns(paramMap))); |
102 | // 2、支持直通车的召回-随机召回 | 105 | // 2、支持直通车的召回-随机召回 |
@@ -218,7 +221,7 @@ public class SortRecallSceneService extends AbstractRecallService { | @@ -218,7 +221,7 @@ public class SortRecallSceneService extends AbstractRecallService { | ||
218 | iterator.remove(); | 221 | iterator.remove(); |
219 | } | 222 | } |
220 | // 4、数量截取-保留整数页个商品[只能召回一页,则保留一页] | 223 | // 4、数量截取-保留整数页个商品[只能召回一页,则保留一页] |
221 | - int pageSize = recallServiceHelper.getPageSize(paramMap); | 224 | + int pageSize = searchCommonHelper.getPageSize(paramMap); |
222 | int count = newProductList.size(); | 225 | int count = newProductList.size(); |
223 | int maxPage = count / pageSize; | 226 | int maxPage = count / pageSize; |
224 | if (maxPage == 0) { | 227 | if (maxPage == 0) { |
@@ -6,6 +6,7 @@ import java.util.HashMap; | @@ -6,6 +6,7 @@ import java.util.HashMap; | ||
6 | import java.util.List; | 6 | import java.util.List; |
7 | import java.util.Map; | 7 | import java.util.Map; |
8 | 8 | ||
9 | +import com.yoho.search.service.helper.SearchCommonHelper; | ||
9 | import org.apache.commons.collections.MapUtils; | 10 | import org.apache.commons.collections.MapUtils; |
10 | import org.apache.commons.lang.StringUtils; | 11 | import org.apache.commons.lang.StringUtils; |
11 | import org.elasticsearch.index.query.BoolQueryBuilder; | 12 | import org.elasticsearch.index.query.BoolQueryBuilder; |
@@ -48,6 +49,8 @@ public class RecallPersionalHelper { | @@ -48,6 +49,8 @@ public class RecallPersionalHelper { | ||
48 | private SearchCommonService searchCommonService; | 49 | private SearchCommonService searchCommonService; |
49 | @Autowired | 50 | @Autowired |
50 | private RecallServiceHelper recallServiceHelper; | 51 | private RecallServiceHelper recallServiceHelper; |
52 | + @Autowired | ||
53 | + private SearchCommonHelper searchCommonHelper; | ||
51 | 54 | ||
52 | /** | 55 | /** |
53 | * 获取用户偏好品牌 缓存生效的参数为uid和品类参数 | 56 | * 获取用户偏好品牌 缓存生效的参数为uid和品类参数 |
@@ -57,7 +60,7 @@ public class RecallPersionalHelper { | @@ -57,7 +60,7 @@ public class RecallPersionalHelper { | ||
57 | */ | 60 | */ |
58 | @SearchCacheAble(cacheInMinute = 10, cacheName = "SORT_PAGE_USER_BRANDS", returnClass = UserLikeBrands.class, includeParams = { "uid", "msort", "misort", "sort" }) | 61 | @SearchCacheAble(cacheInMinute = 10, cacheName = "SORT_PAGE_USER_BRANDS", returnClass = UserLikeBrands.class, includeParams = { "uid", "msort", "misort", "sort" }) |
59 | public UserLikeBrands getSortPageUserLikeBrands(Map<String, String> paramMap) { | 62 | public UserLikeBrands getSortPageUserLikeBrands(Map<String, String> paramMap) { |
60 | - int uid = recallServiceHelper.getUid(paramMap); | 63 | + int uid = searchCommonHelper.getUid(paramMap); |
61 | List<Integer> brandIds = null; | 64 | List<Integer> brandIds = null; |
62 | long begin = System.currentTimeMillis(); | 65 | long begin = System.currentTimeMillis(); |
63 | if (searchDynamicConfigService.isSortPageRecallUseGlobalBrand()) { | 66 | if (searchDynamicConfigService.isSortPageRecallUseGlobalBrand()) { |
@@ -99,7 +102,6 @@ public class RecallPersionalHelper { | @@ -99,7 +102,6 @@ public class RecallPersionalHelper { | ||
99 | /** | 102 | /** |
100 | * 使用向量从品牌列表中获取品牌 | 103 | * 使用向量从品牌列表中获取品牌 |
101 | * | 104 | * |
102 | - * @param uid | ||
103 | * @param paramMap | 105 | * @param paramMap |
104 | * @return | 106 | * @return |
105 | */ | 107 | */ |
@@ -245,32 +245,6 @@ public class RecallServiceHelper { | @@ -245,32 +245,6 @@ public class RecallServiceHelper { | ||
245 | ERROR_LOGGER.error(msg, t); | 245 | ERROR_LOGGER.error(msg, t); |
246 | } | 246 | } |
247 | 247 | ||
248 | - public int getPage(Map<String, String> paramMap) { | ||
249 | - return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); | ||
250 | - } | ||
251 | - | ||
252 | - public int getPageSize(Map<String, String> paramMap) { | ||
253 | - return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum")); | ||
254 | - } | ||
255 | - | ||
256 | - public long getTotalPage(long total, int size) { | ||
257 | - if (size <= 0) { | ||
258 | - return total; | ||
259 | - } else if (total % size == 0) { | ||
260 | - return total / size; | ||
261 | - } else { | ||
262 | - return total / size + 1; | ||
263 | - } | ||
264 | - } | ||
265 | - | ||
266 | - public int getUid(Map<String, String> paramMap) { | ||
267 | - try { | ||
268 | - return MapUtils.getIntValue(paramMap, "uid", 0); | ||
269 | - } catch (Exception e) { | ||
270 | - return 0; | ||
271 | - } | ||
272 | - } | ||
273 | - | ||
274 | public List<String> getFirstProductSkns(Map<String, String> paramMap) { | 248 | public List<String> getFirstProductSkns(Map<String, String> paramMap) { |
275 | String firstProductSkns = MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN, ""); | 249 | String firstProductSkns = MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN, ""); |
276 | String[] firstProductSknArray = firstProductSkns.split(","); | 250 | String[] firstProductSknArray = firstProductSkns.split(","); |
@@ -280,8 +254,9 @@ public class RecallServiceHelper { | @@ -280,8 +254,9 @@ public class RecallServiceHelper { | ||
280 | /** | 254 | /** |
281 | * 查询skn信息并按顺序排序 | 255 | * 查询skn信息并按顺序排序 |
282 | * | 256 | * |
283 | - * @param querySknList | ||
284 | - * @param viewNum | 257 | + * @param recalledSknList |
258 | + * @param page | ||
259 | + * @param pageSize | ||
285 | * @return | 260 | * @return |
286 | */ | 261 | */ |
287 | public List<Map<String, Object>> queryProductListWithSort(List<Integer> recalledSknList, int page, int pageSize) { | 262 | public List<Map<String, Object>> queryProductListWithSort(List<Integer> recalledSknList, int page, int pageSize) { |
@@ -322,8 +297,10 @@ public class RecallServiceHelper { | @@ -322,8 +297,10 @@ public class RecallServiceHelper { | ||
322 | /** | 297 | /** |
323 | * 按默认方式排序 | 298 | * 按默认方式排序 |
324 | * | 299 | * |
325 | - * @param querySknList | ||
326 | - * @param viewNum | 300 | + * @param notProductSkns |
301 | + * @param paramMap | ||
302 | + * @param realPage | ||
303 | + * @param pageSize | ||
327 | * @return | 304 | * @return |
328 | * @throws Exception | 305 | * @throws Exception |
329 | */ | 306 | */ |
@@ -24,6 +24,24 @@ public class SearchCommonHelper { | @@ -24,6 +24,24 @@ public class SearchCommonHelper { | ||
24 | @Autowired | 24 | @Autowired |
25 | private SearchServiceConfiger searchServiceConfiger; | 25 | private SearchServiceConfiger searchServiceConfiger; |
26 | 26 | ||
27 | + public int getPage(Map<String, String> paramMap) { | ||
28 | + return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")); | ||
29 | + } | ||
30 | + | ||
31 | + public int getPageSize(Map<String, String> paramMap) { | ||
32 | + return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum")); | ||
33 | + } | ||
34 | + | ||
35 | + public long getTotalPage(long total, int size) { | ||
36 | + if (size <= 0) { | ||
37 | + return total; | ||
38 | + } else if (total % size == 0) { | ||
39 | + return total / size; | ||
40 | + } else { | ||
41 | + return total / size + 1; | ||
42 | + } | ||
43 | + } | ||
44 | + | ||
27 | public int getUid(Map<String, String> paramMap) { | 45 | public int getUid(Map<String, String> paramMap) { |
28 | try { | 46 | try { |
29 | return MapUtils.getIntValue(paramMap, "uid", 0); | 47 | return MapUtils.getIntValue(paramMap, "uid", 0); |
@@ -36,23 +54,6 @@ public class SearchCommonHelper { | @@ -36,23 +54,6 @@ public class SearchCommonHelper { | ||
36 | return this.getUid(paramMap) > 0; | 54 | return this.getUid(paramMap) > 0; |
37 | } | 55 | } |
38 | 56 | ||
39 | - public boolean isDebugUser(Map<String, String> paramMap) { | ||
40 | - return this.getUid(paramMap) == 13420925; | ||
41 | - } | ||
42 | - | ||
43 | - /** | ||
44 | - * 是否是模糊搜索页 | ||
45 | - * | ||
46 | - * @param paramMap | ||
47 | - * @return | ||
48 | - */ | ||
49 | - public boolean isFuzzySearchPage(Map<String, String> paramMap) { | ||
50 | - String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID); | ||
51 | - if (!SearchPageIdDefine.PAGE_ID_SEARCH.equalsIgnoreCase(pageId)) { | ||
52 | - return false; | ||
53 | - } | ||
54 | - return true; | ||
55 | - } | ||
56 | 57 | ||
57 | /** | 58 | /** |
58 | * 是否是默认的模糊搜索 | 59 | * 是否是默认的模糊搜索 |
-
Please register or login to post a comment