Authored by 胡古飞

fix GoodProductListService

... ... @@ -7,6 +7,7 @@ import java.util.HashMap;
import java.util.Iterator;
import java.util.List;
import java.util.Map;
import java.util.Random;
import javax.annotation.PostConstruct;
... ... @@ -33,6 +34,7 @@ import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.alibaba.fastjson.JSON;
import com.alibaba.fastjson.JSONArray;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.ISearchConstants;
... ... @@ -47,7 +49,6 @@ import com.yoho.search.service.service.base.ProductIndexBaseService;
import com.yoho.search.service.service.helper.FunctionScoreSearchHelper;
import com.yoho.search.service.service.helper.SearchCommonHelper;
import com.yoho.search.service.service.helper.SearchServiceHelper;
import com.yoho.search.service.service.helper.SearchSortHelper;
import com.yoho.search.service.servicenew.IGoodProductsService;
import com.yoho.search.service.vo.GoodProductBO;
import com.yoho.search.service.vo.SearchApiResult;
... ... @@ -62,8 +63,6 @@ public class GoodProductListService implements IGoodProductsService {
@Autowired
private SearchServiceHelper searchServiceHelper;
@Autowired
private SearchSortHelper searchSortHelper;
@Autowired
private SearchCommonHelper searchCommonHelper;
@Autowired
private FunctionScoreSearchHelper functionScoreSearchHelper;
... ... @@ -86,11 +85,11 @@ public class GoodProductListService implements IGoodProductsService {
private static final String collect_product_skn = "collect_product_skn";
private List<String> stringToList(String source, String split) {
List<String> result = new ArrayList<String>();
if (StringUtils.isBlank(source)) {
return result;
return new ArrayList<String>();
}
for (String part : source.split(",")) {
List<String> result = new ArrayList<String>();
for (String part : source.split(split)) {
result.add(part);
}
return result;
... ... @@ -154,11 +153,6 @@ public class GoodProductListService implements IGoodProductsService {
final String indexName = ISearchConstants.INDEX_NAME_PRODUCT_INDEX;
JSONObject cacheObject = searchCacheService.getJSONObjectFromCache(productListSearchCache, indexName, searchParam);
if (cacheObject != null) {
JSONArray product_list = cacheObject.getJSONArray("product_list");
if (product_list != null) {
// Collections.shuffle(product_list);
// cacheObject.put("product_list", product_list);
}
return new SearchApiResult().setData(cacheObject);
}
// 6)查询ES
... ... @@ -380,9 +374,10 @@ public class GoodProductListService implements IGoodProductsService {
}
}
List<String> results = new ArrayList<String>();
Random random = new Random();
for (int i = 0; i < maxSknCount; i++) {
for (GoodProductBO goodProductBO : goodProductLists) {
int randomCount = 1 + (int) (Math.random() * 2);
int randomCount = 1 + random.nextInt(2);
results.addAll(goodProductBO.randomGetProductSkn(randomCount));
}
}
... ... @@ -430,7 +425,7 @@ public class GoodProductListService implements IGoodProductsService {
if (jsonArray == null) {
return new ArrayList<T>();
}
return JSONObject.parseArray(jsonArray.toJSONString(), clazz);
return JSON.parseArray(jsonArray.toJSONString(), clazz);
}
/**
... ... @@ -453,12 +448,5 @@ public class GoodProductListService implements IGoodProductsService {
}
return result;
}
public static List<String> getNewList(List<String> oldList) {
List<String> newList = new ArrayList<String>();
for (String element : oldList) {
newList.add(element);
}
return newList;
}
}
... ...