Authored by hugufei

fix bug

package com.yoho.search.service.scene.pages;
import com.alibaba.fastjson.JSONObject;
import com.yoho.search.base.utils.SearchPageIdDefine;
import com.yoho.search.common.utils.SearchApiResultUtils;
import com.yoho.search.models.SearchApiResult;
import com.yoho.search.service.scene.pages.entrance.ProductListSwitchService;
import com.yoho.search.service.scene.pages.selections.PageAggregationHelper;
import com.yoho.search.service.scene.pages.selections.PageSelectionsBrandsService;
import com.yoho.search.service.scene.pages.selections.PageSelectionsService;
import org.slf4j.Logger;
... ... @@ -12,6 +14,9 @@ import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import java.util.Map;
import java.util.concurrent.CompletableFuture;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
@Service
public class CommonPageSceneService extends AbstractPageSceneService {
... ... @@ -24,6 +29,10 @@ public class CommonPageSceneService extends AbstractPageSceneService {
private PageSelectionsService pageSelectionsService;
@Autowired
private PageSelectionsBrandsService scenePageSelectionsBrandsService;
@Autowired
private PageAggregationHelper pageAggregationHelper;
private ExecutorService executorService = Executors.newFixedThreadPool(20);
@Override
public String pageId() {
... ... @@ -41,7 +50,14 @@ public class CommonPageSceneService extends AbstractPageSceneService {
// 1、添加默认参数
this.addParamsToParamMap(paramMap);
// 2、返回商品列表
return sceneProductListService.productList(paramMap);
CompletableFuture<SearchApiResult> productListFuture = CompletableFuture.supplyAsync(() -> sceneProductListService.productList(this.newParamMap(paramMap)), executorService);
CompletableFuture<SearchApiResult> customizeTagFuture = CompletableFuture.supplyAsync(() -> pageAggregationHelper.sceneAggCustomizeTag(this.newParamMap(paramMap)),
executorService);
SearchApiResult productList = productListFuture.get();
SearchApiResult customizeTags = customizeTagFuture.get();
JSONObject jsonObject = (JSONObject) productList.getData();
jsonObject.put(CUSTOMIZE_TAG_LIST, customizeTags.getData());
return productList;
} catch (Exception e) {
return SearchApiResultUtils.errorSearchApiResult(logger, paramMap, e);
}
... ...
... ... @@ -44,7 +44,7 @@ public class SortPageSceneService extends AbstractPageSceneService {
paramMap.put(SearchRequestParams.PARAM_SEARCH_CONTAIN_GLOBAL, "Y");// 包含全球购
}
private ExecutorService executorService = Executors.newFixedThreadPool(100);
private ExecutorService executorService = Executors.newFixedThreadPool(20);
private boolean checkParam(Map<String, String> paramMap) {
if (StringUtils.isNotBlank(paramMap.get(SearchRequestParams.PARAM_SEARCH_MAXSORT))) {
... ...