Authored by wangnan9279

ufo

... ... @@ -4,6 +4,7 @@ import com.alibaba.fastjson.JSONObject;
import com.yoho.search.aop.cache.SearchCacheAble;
import com.yoho.search.base.utils.ISearchConstants;
import com.yoho.search.common.SearchCommonService;
import com.yoho.search.common.SearchRequestParams;
import com.yoho.search.core.es.model.SearchParam;
import com.yoho.search.core.es.model.SearchResult;
import com.yoho.search.models.SearchApiResult;
... ... @@ -20,6 +21,7 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.*;
import java.util.stream.Collectors;
/**
* @author wangnan
... ... @@ -76,6 +78,19 @@ public class UfoProductListService {
dataMap.put("page_size", pageSize);
dataMap.put("page_total", searchResult.getTotalPage());
dataMap.put(RETURN_LIST_NAME, returnInfoList);
// 如果是纯id过滤,按照id传入顺序排序
if ("Y".equals(paramMap.get(SearchRequestParams.UFOPRODUCTINDEX_PARAM_IS_ID_FILTER))) {
Map<String, Map<String, Object>> productReturnInfoMap = returnInfoList.stream().collect(Collectors.toMap(p -> p.get("id").toString(), p -> p));
List<Map<String, Object>> productReturnInfoListSorted = new ArrayList<>(productReturnInfoMap.size());
List<String> idList = Arrays.asList(paramMap.get(SearchRequestParams.UFOPRODUCTINDEX_PARAM_ID).split(","));
for (String id : idList) {
Map<String, Object> sknInfo = productReturnInfoMap.get(id);
if (sknInfo != null) {
productReturnInfoListSorted.add(sknInfo);
}
}
dataMap.put(RETURN_LIST_NAME, productReturnInfoListSorted);
}
return new SearchApiResult().setData(dataMap);
} catch (Exception e) {
logger.error(e.getMessage(), e);
... ...