Authored by hugufei

删除无用代码

... ... @@ -15,7 +15,6 @@ import org.springframework.web.bind.annotation.ResponseBody;
import com.yoho.search.common.utils.HttpServletRequestUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.searchlike.SearchLikeInShopService;
import com.yoho.search.service.scene.searchlike.SearchLikeNotInShopService;
import com.yoho.search.service.scene.searchlike.SearchLikeSceneService;
import com.yoho.search.service.service.IProductListWithSupplyService;
import com.yoho.search.service.service.ISimilarProductService;
... ... @@ -34,8 +33,6 @@ public class SearchLikeSecneController {
@Autowired
private SearchLikeInShopService searchLikeInShopService;
@Autowired
private SearchLikeNotInShopService searchLikeNotInShopService;
@Autowired
private IProductListWithSupplyService productListWithSupplyService;
@Autowired
private ISimilarProductService similarProductService;
... ... @@ -69,12 +66,9 @@ public class SearchLikeSecneController {
@ResponseBody
public SearchApiResult searchLikeNotInShop(HttpServletRequest request) {
Map<String, String> paramMap = HttpServletRequestUtils.transParamType(request);
if (searchDynamicConfigService.isSearchLikeSimilarSknOpen()) {
return bigdataSimilarSknService.searchLikeSimilarSknNotInShop(paramMap);
}
return searchLikeNotInShopService.searchLikeNotInShop(paramMap);
return bigdataSimilarSknService.searchLikeSimilarSknNotInShop(paramMap);
}
/**
* 获取商品列表,支持如果传入skn无效,补充相似skn
*/
... ...
... ... @@ -80,13 +80,6 @@ public class SearchDynamicConfigService {
}
/**
* 商品详情页-店铺外推荐同品类的比例
*/
public int getSearchLikeNotInShopSameSortPercent() {
return configReader.getInt("search.searchlike.not_in_shop.same_sort_percent", 60);
}
/**
* 个性化限流配置
*/
public PersionalRateLimitConfig getPersionalRateLimitConfig(String rateLimitName, PersionalRateLimit persionalRateLimit) {
... ... @@ -129,12 +122,6 @@ public class SearchDynamicConfigService {
return configReader.getBoolean("search.persional.newstrategy.first_page_cache.open", false);
}
/**
* 新的的召回策略-最多预测的品牌品类
*/
public int directTrainIndexInterval() {
return configReader.getInt("search.persional.newstrategy.directtrain.index.interval", 4);
}
/**
* 相关推荐否使用个性化-【双11关闭】
... ... @@ -144,13 +131,6 @@ public class SearchDynamicConfigService {
}
/**
* 找相似是否使用bigdatasimilarskn
*/
public boolean isSearchLikeSimilarSknOpen() {
return configReader.getBoolean("search.searchlike.similarskn", true);
}
/**
* 超时日志是否打开
*/
public boolean isControllerCostLogOpen() {
... ... @@ -158,13 +138,6 @@ public class SearchDynamicConfigService {
}
/**
* 推荐品牌是否要使用大数据的推荐
*/
public boolean isRecommendBrandUserPersonalOpen() {
return configReader.getBoolean("search.recommendbrand.userPersonal.open", false);
}
/**
* A策略是否打开
*/
public boolean isAStrategyOpen() {
... ... @@ -178,7 +151,6 @@ public class SearchDynamicConfigService {
return configReader.getBoolean("search.persional.abTest.b.strategy.open", true);
}
/**
* 全球购查新索引
*/
... ...
package com.yoho.search.service.scene.searchlike;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.CollectionUtils;
import com.yoho.search.common.cache.aop.SearchCacheAble;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.base.SearchDynamicConfigService;
import com.yoho.search.service.base.SearchRequestParams;
import com.yoho.search.service.base.index.ProductIndexBaseService;
import com.yoho.search.service.helper.ProductListHelper;
import org.apache.commons.lang.StringUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
/**
* 店铺外找相似
*
* @author gufei.hu
*
*/
@Service
public class SearchLikeNotInShopService{
private static final Logger logger = LoggerFactory.getLogger(SearchLikeNotInShopService.class);
@Autowired
private SearchLikeHelper searchLikeHelper;
@Autowired
private ProductIndexBaseService productIndexBaseService;
@Autowired
private SearchDynamicConfigService searchDynamicConfigService;
@Autowired
private ProductListHelper productListHelper;
/**
* 店铺外推荐
*
* @param paramMap
* @return
*/
@SearchCacheAble(cacheInMinute = 600, cacheName = "SEARCH_LIKE_NOT_IN_SHOP", includeParams = { "product_skn", "viewNum" })
public SearchApiResult searchLikeNotInShop(Map<String, String> paramMap) {
try {
// 1、获取参数
String productSkn = paramMap.get(SearchRequestParams.PARAM_SEARCH_PRODUCT_SKN);
if (StringUtils.isBlank(productSkn)) {
return new SearchApiResult().setCode(400).setMessage("请输入SKN");
}
// 2、检测分页参数【默认30条,最多60条】
int pageSize = searchLikeHelper.getPageSize(paramMap);
// 2、获取当前查询的SKN的基本信息
JSONObject productInfoInEs = searchLikeHelper.getProductInfoInEs(productSkn);
if (productInfoInEs == null) {
return new SearchApiResult().setCode(400).setMessage("SKN不存在");
}
// 3、设置SearchParams
List<SearchParam> searchParams = new ArrayList<SearchParam>();
int sameSortCount = searchDynamicConfigService.getSearchLikeNotInShopSameSortPercent() * pageSize / 100;
searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), sameSortCount, true));
searchParams.add(this.builderSearchParam(productInfoInEs, Arrays.asList(productSkn), pageSize - sameSortCount, false));
// 4、获取搜索结果[截取条数]
List<Map<String, Object>> tempProductList = searchLikeHelper.queryProductList(searchParams);
if (tempProductList.size() > pageSize) {
tempProductList = CollectionUtils.safeSubList(tempProductList,0, pageSize);
}
// 5、构造真实返回结果
List<Map<String, Object>> productListResults = new ArrayList<Map<String, Object>>();
if (!tempProductList.isEmpty()) {
productListResults = productListHelper.buildReturnInfoByEsSourceList(tempProductList);
}
JSONObject result = new JSONObject();
result.put("page", 1);
result.put("page_total", 1);
result.put("page_size", pageSize);
result.put("total", productListResults.size());
result.put("product_info", searchLikeHelper.genProductInfoResult(productInfoInEs));
result.put("product_list", productListResults);
// 8、结果加入缓存
return new SearchApiResult().setData(result);
} catch (Exception e) {
logger.error(e.getMessage(), e);
return new SearchApiResult().setData(null).setMessage("searchLikeNotInShop Exception").setCode(500);
}
}
private SearchParam builderSearchParam(JSONObject productInfoInEs, List<String> notProductSkns, int pageSize, boolean inSameSort) {
return searchLikeHelper.builderSearchLikeNotInShopCharactersSearchParam(productInfoInEs, notProductSkns, pageSize,inSameSort);
}
}