Authored by hugufei

fix bug

... ... @@ -72,7 +72,7 @@ public class ControllerCostInterceptor implements HandlerInterceptor {
if (cost <= 500) {
return;
}
// 5、打印响应超过500ms的请求与参数
if(searchDynamicConfigService.isControllerCostLogOpen()){
CONTROLLER_COST.info("run more than 500ms ,cost [{}] ms, RequestURL: {}", cost, HttpServletRequestUtils.getRequestUrl(request));
... ...
... ... @@ -9,6 +9,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
import com.yoho.search.service.helper.SearchCommonHelper;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
... ... @@ -48,6 +49,8 @@ public class SortRecallSceneService extends AbstractRecallService {
private RecallServiceHelper recallServiceHelper;
@Autowired
private RecallPersionalHelper recallPersionalHelper;
@Autowired
private SearchCommonHelper searchCommonHelper;
@SearchCacheAble(cacheInMinute = 10, cacheName = "SORT_PAGE_PRODUCT_LIST")
public SearchApiResult recallProductList(Map<String, String> paramMap) {
... ... @@ -56,8 +59,8 @@ public class SortRecallSceneService extends AbstractRecallService {
recallServiceHelper.setLogEnableThreadLocal(paramMap);
// 1)验证查询条数
int page = recallServiceHelper.getPage(paramMap);
int pageSize = recallServiceHelper.getPageSize(paramMap);
int page = searchCommonHelper.getPage(paramMap);
int pageSize = searchCommonHelper.getPageSize(paramMap);
// 2)召回skn以及总数
RecallProductSknList recallProductSknList = recallServiceHelper.doRecallProductSkns(paramMap, this);
... ... @@ -73,7 +76,7 @@ public class SortRecallSceneService extends AbstractRecallService {
dataMap.put("total", recallProductInfoList.getTotal());
dataMap.put("page", page);
dataMap.put("page_size", pageSize);
dataMap.put("page_total", recallServiceHelper.getTotalPage(recallProductInfoList.getTotal(), pageSize));
dataMap.put("page_total", searchCommonHelper.getTotalPage(recallProductInfoList.getTotal(), pageSize));
dataMap.put("product_list", product_list);
return new SearchApiResult().setData(dataMap);
} catch (Exception e) {
... ... @@ -96,7 +99,7 @@ public class SortRecallSceneService extends AbstractRecallService {
// 0、获取用户偏好品牌
UserLikeBrands userLikeBrands = recallPersionalHelper.getSortPageUserLikeBrands(paramMap);
int pageSize = recallServiceHelper.getPageSize(paramMap);
int pageSize = searchCommonHelper.getPageSize(paramMap);
// 1、支持firstProductSkn的召回
recallStrategy.add(new FirstProductSknStrategy(1, recallServiceHelper.getFirstProductSkns(paramMap)));
// 2、支持直通车的召回-随机召回
... ... @@ -218,7 +221,7 @@ public class SortRecallSceneService extends AbstractRecallService {
iterator.remove();
}
// 4、数量截取-保留整数页个商品[只能召回一页,则保留一页]
int pageSize = recallServiceHelper.getPageSize(paramMap);
int pageSize = searchCommonHelper.getPageSize(paramMap);
int count = newProductList.size();
int maxPage = count / pageSize;
if (maxPage == 0) {
... ...
... ... @@ -6,6 +6,7 @@ import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.yoho.search.service.helper.SearchCommonHelper;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.BoolQueryBuilder;
... ... @@ -48,6 +49,8 @@ public class RecallPersionalHelper {
private SearchCommonService searchCommonService;
@Autowired
private RecallServiceHelper recallServiceHelper;
@Autowired
private SearchCommonHelper searchCommonHelper;
/**
* 获取用户偏好品牌 缓存生效的参数为uid和品类参数
... ... @@ -57,7 +60,7 @@ public class RecallPersionalHelper {
*/
@SearchCacheAble(cacheInMinute = 10, cacheName = "SORT_PAGE_USER_BRANDS", returnClass = UserLikeBrands.class, includeParams = { "uid", "msort", "misort", "sort" })
public UserLikeBrands getSortPageUserLikeBrands(Map<String, String> paramMap) {
int uid = recallServiceHelper.getUid(paramMap);
int uid = searchCommonHelper.getUid(paramMap);
List<Integer> brandIds = null;
long begin = System.currentTimeMillis();
if (searchDynamicConfigService.isSortPageRecallUseGlobalBrand()) {
... ... @@ -99,7 +102,6 @@ public class RecallPersionalHelper {
/**
* 使用向量从品牌列表中获取品牌
*
* @param uid
* @param paramMap
* @return
*/
... ...
... ... @@ -245,32 +245,6 @@ public class RecallServiceHelper {
ERROR_LOGGER.error(msg, t);
}
public int getPage(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
}
public int getPageSize(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum"));
}
public long getTotalPage(long total, int size) {
if (size <= 0) {
return total;
} else if (total % size == 0) {
return total / size;
} else {
return total / size + 1;
}
}
public int getUid(Map<String, String> paramMap) {
try {
return MapUtils.getIntValue(paramMap, "uid", 0);
} catch (Exception e) {
return 0;
}
}
public List<String> getFirstProductSkns(Map<String, String> paramMap) {
String firstProductSkns = MapUtils.getString(paramMap, SearchRequestParams.PARAM_SEARCH_FIRST_PRODUCRSKN, "");
String[] firstProductSknArray = firstProductSkns.split(",");
... ... @@ -280,8 +254,9 @@ public class RecallServiceHelper {
/**
* 查询skn信息并按顺序排序
*
* @param querySknList
* @param viewNum
* @param recalledSknList
* @param page
* @param pageSize
* @return
*/
public List<Map<String, Object>> queryProductListWithSort(List<Integer> recalledSknList, int page, int pageSize) {
... ... @@ -322,8 +297,10 @@ public class RecallServiceHelper {
/**
* 按默认方式排序
*
* @param querySknList
* @param viewNum
* @param notProductSkns
* @param paramMap
* @param realPage
* @param pageSize
* @return
* @throws Exception
*/
... ...
... ... @@ -24,6 +24,24 @@ public class SearchCommonHelper {
@Autowired
private SearchServiceConfiger searchServiceConfiger;
public int getPage(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page"));
}
public int getPageSize(Map<String, String> paramMap) {
return StringUtils.isBlank(paramMap.get("viewNum")) ? 60 : Integer.parseInt(paramMap.get("viewNum"));
}
public long getTotalPage(long total, int size) {
if (size <= 0) {
return total;
} else if (total % size == 0) {
return total / size;
} else {
return total / size + 1;
}
}
public int getUid(Map<String, String> paramMap) {
try {
return MapUtils.getIntValue(paramMap, "uid", 0);
... ... @@ -36,23 +54,6 @@ public class SearchCommonHelper {
return this.getUid(paramMap) > 0;
}
public boolean isDebugUser(Map<String, String> paramMap) {
return this.getUid(paramMap) == 13420925;
}
/**
* 是否是模糊搜索页
*
* @param paramMap
* @return
*/
public boolean isFuzzySearchPage(Map<String, String> paramMap) {
String pageId = paramMap.get(SearchRequestParams.PARAM_SEARCH_PAGEID);
if (!SearchPageIdDefine.PAGE_ID_SEARCH.equalsIgnoreCase(pageId)) {
return false;
}
return true;
}
/**
* 是否是默认的模糊搜索
... ...