|
|
package com.yoho.search.service.scene;
|
|
|
|
|
|
import java.util.Collections;
|
|
|
import java.util.List;
|
|
|
import java.util.Map;
|
|
|
import java.util.concurrent.CompletableFuture;
|
|
|
import java.util.concurrent.ExecutorService;
|
|
|
import java.util.concurrent.Executors;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONArray;
|
|
|
import org.apache.commons.lang.StringUtils;
|
|
|
import org.slf4j.Logger;
|
|
|
import org.slf4j.LoggerFactory;
|
...
|
...
|
@@ -88,7 +90,7 @@ public class FuzzySceneService extends AbstractSceneService { |
|
|
// 4、获取自定义标签聚合结果
|
|
|
CompletableFuture<SearchApiResult> customizeTagFuture = CompletableFuture.supplyAsync(() -> sceneAggregationsHelper.secneAggCustomizeTag(this.newParamMap(paramMap)), executor);
|
|
|
// 5、获取促销专题
|
|
|
CompletableFuture<List<Object>> recommendPromotionFuture = CompletableFuture.supplyAsync(() -> recommendService.recommendPromotion(this.newParamMap(paramMap)),
|
|
|
CompletableFuture<SearchApiResult> recommendPromotionFuture = CompletableFuture.supplyAsync(() -> sceneAggregationsHelper.secneAggRecommendPromotion(this.newParamMap(paramMap)),
|
|
|
executor);
|
|
|
|
|
|
// 6、加入建议词
|
...
|
...
|
@@ -103,10 +105,15 @@ public class FuzzySceneService extends AbstractSceneService { |
|
|
}
|
|
|
// 8、组合结果
|
|
|
SearchApiResult customizeTags = customizeTagFuture.get();
|
|
|
List<Object> recommendProducts = recommendPromotionFuture.get();
|
|
|
SearchApiResult recommendProducts = recommendPromotionFuture.get();
|
|
|
JSONObject dataMap = (JSONObject) productListResult.getData();
|
|
|
dataMap.put(CUSTOMIZE_TAG_LIST, customizeTags.getData());
|
|
|
dataMap.put(RECOMMEND_PROMOTION_LIST, recommendProducts);
|
|
|
|
|
|
if (recommendProducts.getData() == null) {
|
|
|
dataMap.put(RECOMMEND_PROMOTION_LIST, Collections.EMPTY_LIST);
|
|
|
} else {
|
|
|
dataMap.put(RECOMMEND_PROMOTION_LIST, subList(recommendProducts.getData(), StringUtils.isBlank(paramMap.get("page")) ? 1 : Integer.parseInt(paramMap.get("page")), 1));
|
|
|
}
|
|
|
return productListResult;
|
|
|
} catch (Exception e) {
|
|
|
logger.error(e.getMessage(), e);
|
...
|
...
|
@@ -171,4 +178,5 @@ public class FuzzySceneService extends AbstractSceneService { |
|
|
// 1.6加入推荐词
|
|
|
dataMap.put("suggestion", searchRecommendService.recommend(searchResult, paramMap));
|
|
|
}
|
|
|
|
|
|
} |
...
|
...
|
|