Authored by saihide

fix

... ... @@ -33,7 +33,7 @@ public class ShopProductCacheBean extends AbstractCacheBean<ShopProductRequest,
private BrandIndexBaseService brandIndexBaseService;
public List<ShopProductResponse> getShopSknByShopId(List<ShopProductRequest> shopSknRequests, String hrShopIds) {
final List<ShopProductRequestResponse> shopSknRequestResponses = new ArrayList<>();
List<ShopProductRequestResponse> shopSknRequestResponses = new ArrayList<>();
for (ShopProductRequest request : shopSknRequests) {
shopSknRequestResponses.add(new ShopProductRequestResponse(request));
}
... ... @@ -64,7 +64,6 @@ public class ShopProductCacheBean extends AbstractCacheBean<ShopProductRequest,
}
//2、执行搜索
List<SearchResult> searchResults = searchCommonService.doMutiSearch(ISearchConstants.INDEX_NAME_PRODUCT_INDEX, searchParams);
Set<Integer> brandIds = new HashSet<>();
for (SearchResult searchResult : searchResults) {
List<Map<String, Object>> resultList = searchResult.getResultList();
... ... @@ -87,13 +86,13 @@ public class ShopProductCacheBean extends AbstractCacheBean<ShopProductRequest,
for (int i = 0; i < missCacheRequests.size(); i++) {
ShopProductRequest request = missCacheRequests.get(i).getRequest();
List<Map<String, Object>> productList = shopProductListMap.get(request.getShopId().toString());
ShopProductResponse response = buildResonse(productList, brandMap, request);
ShopProductResponse response = buildResponse(productList, brandMap, request);
results.put(request, response);
}
return results;
}
private ShopProductResponse buildResonse(List<Map<String, Object>> productList, Map<String, Map<String, Object>> brandMap, ShopProductRequest request) {
private ShopProductResponse buildResponse(List<Map<String, Object>> productList, Map<String, Map<String, Object>> brandMap, ShopProductRequest request) {
ShopProductResponse response = new ShopProductResponse();
List<ShopProductResponse.ShopProduct> shopProductList = new ArrayList<>();
response.setShop_id(request.getShopId());
... ...
... ... @@ -52,7 +52,6 @@ public class HrDistributionController {
}
SearchApiResult searchApiResult = searchHongRenService.productList(paramMap);
return searchApiResult;
}
@RequestMapping(method = RequestMethod.GET, value = "/productListForFuzzy")
... ...
... ... @@ -281,15 +281,7 @@ public class AggregationService extends AbstractCacheAbleService implements Appl
dataMap.put("total", shopIds.size());
dataMap.put("page_total", searchCommonHelper.getTotalPage(shopIds.size(), pageSize));
dataMap.put("shop_product_list", Collections.emptyList());
int fromIndex = pageSize * (page - 1);
if (fromIndex >= shopIds.size()) {
return dataMap;
}
int toIndex = pageSize * page;
if (toIndex > shopIds.size()) {
toIndex = shopIds.size();
}
List<Integer> subShopIds = shopIds.subList(fromIndex, toIndex);
List<Integer> subShopIds = subList(shopIds, pageSize, page);
if (CollectionUtils.isNotEmpty(subShopIds)) {
List<ShopProductRequest> shopProductRequests = subShopIds.stream().map(shopId -> {
return new ShopProductRequest(new ParamQueryFilter(searchParam.getQuery(), (BoolQueryBuilder)searchParam.getFiter()), shopId);
... ... @@ -302,4 +294,17 @@ public class AggregationService extends AbstractCacheAbleService implements Appl
}
return dataMap;
}
private List<Integer> subList(List<Integer> sourceList, int pageSize, int page) {
int fromIndex = pageSize * (page - 1);
if (fromIndex >= sourceList.size()) {
return null;
}
int toIndex = pageSize * page;
if (toIndex > sourceList.size()) {
toIndex = sourceList.size();
}
return sourceList.subList(fromIndex, toIndex);
}
}
... ...
... ... @@ -43,12 +43,12 @@ public class SearchHongRenService extends AbstractSceneService {
paramMap.put("viewNum", "100");
pageSize = 100;
}
SearchApiResult searchApiResult = new SearchApiResult().setCode(200).setMessage("Shop skn List .");
SearchApiResult searchApiResult = new SearchApiResult().setCode(200).setMessage("Shop product List .");
try {
JSONObject dataMap = aggregationService.getShopAndSknAggregationResult(paramMap, page, pageSize, 10000);
searchApiResult.setData(dataMap);
} catch (Exception e) {
return new SearchApiResult().setData(null).setMessage("ShopSknList Exception").setCode(500);
return new SearchApiResult().setData(null).setMessage("ShopProductList Exception").setCode(500);
}
return searchApiResult;
}
... ... @@ -59,7 +59,7 @@ public class SearchHongRenService extends AbstractSceneService {
addParamsToParamMap(paramMap);
return productListSwitchService.productList(newParamMap(paramMap));
} catch (Exception e) {
return new SearchApiResult().setData(null).setMessage("SortProductList Exception").setCode(500);
return new SearchApiResult().setData(null).setMessage("hrSortProductList Exception").setCode(500);
}
}
... ... @@ -81,7 +81,7 @@ public class SearchHongRenService extends AbstractSceneService {
}
return productListResult;
} catch (Exception e) {
return SearchApiResultUtils.errorSearchApiResult("fuzzyProductList", paramMap, e);
return SearchApiResultUtils.errorSearchApiResult("hrfuzzyProductList", paramMap, e);
}
}
... ...