Authored by hugufei

去除无用的代码

... ... @@ -3,13 +3,11 @@ package com.yoho.search.service.service.impl;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import javax.annotation.PostConstruct;
import org.apache.commons.collections.MapUtils;
import org.apache.commons.lang.StringUtils;
import org.elasticsearch.index.query.QueryBuilders;
import org.elasticsearch.search.builder.SearchSourceBuilder;
... ... @@ -17,7 +15,6 @@ import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import org.springframework.util.Assert;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONObject;
... ... @@ -166,49 +163,8 @@ public class ProductListServiceImpl implements IProductListService {
return searchDynamicConfigService.isSearchSuggestionTipsOpen();
}
@SuppressWarnings("unused")
private List<Map<String, Object>> moveProductListSort(Map<String, String> paramMap, List<Map<String, Object>> product_list) {
// 判断页面合法性
if (!searchCommonHelper.isSortPageDefault(paramMap)) {
return product_list;
}
String page = paramMap.get("page");
if (StringUtils.isNotBlank(page) && !page.equals("1")) {
return product_list;
}
// 判断总数
int total = product_list.size();
if (total <= 10) {
return product_list;
}
// 计算均价
double totalPrice = 0;
for (Map<String, Object> product : product_list) {
totalPrice += MapUtils.getDoubleValue(product, "sales_price", 0);
}
double averagePrice = totalPrice / total;
List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();
results.add(product_list.get(0));
product_list.remove(0);
Iterator<Map<String, Object>> iterator = product_list.iterator();
int moveCount = 0;
while (iterator.hasNext() && moveCount < 8) {
Map<String, Object> product = iterator.next();
if (MapUtils.getDoubleValue(product, "sales_price", 0) >= averagePrice) {
results.add(product);
moveCount++;
iterator.remove();
}
}
if (!product_list.isEmpty()) {
results.addAll(product_list);
}
return results;
}
@Override
public SearchApiResult productListBySknList(String skns) {
Assert.notNull(skns);
List<String> sknList = Arrays.asList(skns.split(","));
SearchParam searchParam = new SearchParam();
searchParam.setSize(sknList.size());
... ... @@ -217,15 +173,13 @@ public class ProductListServiceImpl implements IProductListService {
if (searchResult == null) {
return new SearchApiResult().setCode(500).setMessage("execption");
}
Map<String, String> productVectorFeatureMap = new HashMap<>(sknList.size());
searchResult.getResultList().forEach(data -> {
productVectorFeatureMap.put("" + data.get("productSkn"), "" + data.get("productFeatureFactor"));
});
return new SearchApiResult().setData(productVectorFeatureMap);
}
@Override
public SearchApiResult getESDsl(Map<String, String> paramMap) {
logger.info("[func=getESDsl][param={}]", paramMap);
... ...