Authored by hugufei

去除无用的代码

@@ -3,13 +3,11 @@ package com.yoho.search.service.service.impl; @@ -3,13 +3,11 @@ package com.yoho.search.service.service.impl;
3 import java.util.ArrayList; 3 import java.util.ArrayList;
4 import java.util.Arrays; 4 import java.util.Arrays;
5 import java.util.HashMap; 5 import java.util.HashMap;
6 -import java.util.Iterator;  
7 import java.util.List; 6 import java.util.List;
8 import java.util.Map; 7 import java.util.Map;
9 8
10 import javax.annotation.PostConstruct; 9 import javax.annotation.PostConstruct;
11 10
12 -import org.apache.commons.collections.MapUtils;  
13 import org.apache.commons.lang.StringUtils; 11 import org.apache.commons.lang.StringUtils;
14 import org.elasticsearch.index.query.QueryBuilders; 12 import org.elasticsearch.index.query.QueryBuilders;
15 import org.elasticsearch.search.builder.SearchSourceBuilder; 13 import org.elasticsearch.search.builder.SearchSourceBuilder;
@@ -17,7 +15,6 @@ import org.slf4j.Logger; @@ -17,7 +15,6 @@ import org.slf4j.Logger;
17 import org.slf4j.LoggerFactory; 15 import org.slf4j.LoggerFactory;
18 import org.springframework.beans.factory.annotation.Autowired; 16 import org.springframework.beans.factory.annotation.Autowired;
19 import org.springframework.stereotype.Service; 17 import org.springframework.stereotype.Service;
20 -import org.springframework.util.Assert;  
21 18
22 import com.alibaba.fastjson.JSON; 19 import com.alibaba.fastjson.JSON;
23 import com.alibaba.fastjson.JSONObject; 20 import com.alibaba.fastjson.JSONObject;
@@ -166,49 +163,8 @@ public class ProductListServiceImpl implements IProductListService { @@ -166,49 +163,8 @@ public class ProductListServiceImpl implements IProductListService {
166 return searchDynamicConfigService.isSearchSuggestionTipsOpen(); 163 return searchDynamicConfigService.isSearchSuggestionTipsOpen();
167 } 164 }
168 165
169 - @SuppressWarnings("unused")  
170 - private List<Map<String, Object>> moveProductListSort(Map<String, String> paramMap, List<Map<String, Object>> product_list) {  
171 - // 判断页面合法性  
172 - if (!searchCommonHelper.isSortPageDefault(paramMap)) {  
173 - return product_list;  
174 - }  
175 - String page = paramMap.get("page");  
176 - if (StringUtils.isNotBlank(page) && !page.equals("1")) {  
177 - return product_list;  
178 - }  
179 - // 判断总数  
180 - int total = product_list.size();  
181 - if (total <= 10) {  
182 - return product_list;  
183 - }  
184 - // 计算均价  
185 - double totalPrice = 0;  
186 - for (Map<String, Object> product : product_list) {  
187 - totalPrice += MapUtils.getDoubleValue(product, "sales_price", 0);  
188 - }  
189 - double averagePrice = totalPrice / total;  
190 - List<Map<String, Object>> results = new ArrayList<Map<String, Object>>();  
191 - results.add(product_list.get(0));  
192 - product_list.remove(0);  
193 - Iterator<Map<String, Object>> iterator = product_list.iterator();  
194 - int moveCount = 0;  
195 - while (iterator.hasNext() && moveCount < 8) {  
196 - Map<String, Object> product = iterator.next();  
197 - if (MapUtils.getDoubleValue(product, "sales_price", 0) >= averagePrice) {  
198 - results.add(product);  
199 - moveCount++;  
200 - iterator.remove();  
201 - }  
202 - }  
203 - if (!product_list.isEmpty()) {  
204 - results.addAll(product_list);  
205 - }  
206 - return results;  
207 - }  
208 -  
209 @Override 166 @Override
210 public SearchApiResult productListBySknList(String skns) { 167 public SearchApiResult productListBySknList(String skns) {
211 - Assert.notNull(skns);  
212 List<String> sknList = Arrays.asList(skns.split(",")); 168 List<String> sknList = Arrays.asList(skns.split(","));
213 SearchParam searchParam = new SearchParam(); 169 SearchParam searchParam = new SearchParam();
214 searchParam.setSize(sknList.size()); 170 searchParam.setSize(sknList.size());
@@ -217,15 +173,13 @@ public class ProductListServiceImpl implements IProductListService { @@ -217,15 +173,13 @@ public class ProductListServiceImpl implements IProductListService {
217 if (searchResult == null) { 173 if (searchResult == null) {
218 return new SearchApiResult().setCode(500).setMessage("execption"); 174 return new SearchApiResult().setCode(500).setMessage("execption");
219 } 175 }
220 -  
221 Map<String, String> productVectorFeatureMap = new HashMap<>(sknList.size()); 176 Map<String, String> productVectorFeatureMap = new HashMap<>(sknList.size());
222 searchResult.getResultList().forEach(data -> { 177 searchResult.getResultList().forEach(data -> {
223 productVectorFeatureMap.put("" + data.get("productSkn"), "" + data.get("productFeatureFactor")); 178 productVectorFeatureMap.put("" + data.get("productSkn"), "" + data.get("productFeatureFactor"));
224 }); 179 });
225 -  
226 return new SearchApiResult().setData(productVectorFeatureMap); 180 return new SearchApiResult().setData(productVectorFeatureMap);
227 } 181 }
228 - 182 +
229 @Override 183 @Override
230 public SearchApiResult getESDsl(Map<String, String> paramMap) { 184 public SearchApiResult getESDsl(Map<String, String> paramMap) {
231 logger.info("[func=getESDsl][param={}]", paramMap); 185 logger.info("[func=getESDsl][param={}]", paramMap);