Showing
1 changed file
with
22 additions
and
23 deletions
@@ -77,30 +77,29 @@ public class CollageService extends BaseService { | @@ -77,30 +77,29 @@ public class CollageService extends BaseService { | ||
77 | List<Integer> productSknList = new ArrayList<>(searchResult.getResultList().size()); | 77 | List<Integer> productSknList = new ArrayList<>(searchResult.getResultList().size()); |
78 | List<Map<String, Object>> collageIndexResultList = getIndexMap(searchResult.getResultList(), productSknList); | 78 | List<Map<String, Object>> collageIndexResultList = getIndexMap(searchResult.getResultList(), productSknList); |
79 | List<Map<String, Object>> sknInfoList = sknReturnInfoCacheBean.queryProductListBySkn(productSknList, productSknList.size()); | 79 | List<Map<String, Object>> sknInfoList = sknReturnInfoCacheBean.queryProductListBySkn(productSknList, productSknList.size()); |
80 | - if (CollectionUtils.isEmpty(sknInfoList)) { | ||
81 | - return searchApiResult.setCode(500); | ||
82 | - } | ||
83 | - Map<Integer, Map<String, Object>> sknInfoMap = new LinkedHashMap<>(sknInfoList.size()); | ||
84 | - sknInfoList.forEach(p -> sknInfoMap.put(MapUtils.getInteger(p, "product_skn"), p)); | ||
85 | - collageIndexResultList.forEach(p -> { | ||
86 | - Integer productSkn = MapUtils.getInteger(p, "product_skn"); | ||
87 | - Map<String, Object> sknMap = sknInfoMap.get(productSkn); | ||
88 | - p.put("product_name", MapUtils.getString(sknMap, "product_name", "")); | ||
89 | - p.put("sales_price", MapUtils.getDoubleValue(sknMap, "sales_price")); | ||
90 | - p.put("market_price", MapUtils.getDoubleValue(sknMap, "market_price")); | ||
91 | - p.put("sales_num", MapUtils.getIntValue(sknMap, "sales_num")); | ||
92 | - p.put("default_images", MapUtils.getString(sknMap, "default_images")); | ||
93 | - }); | ||
94 | - Map<Map<String, Object>, Integer> salesNumSknInfoMap = collageIndexResultList.stream().collect(Collectors.toMap(p -> p, p -> MapUtils.getInteger(p, "sales_num"))); | ||
95 | - Map<Map<String, Object>, Integer> finalMap = new LinkedHashMap<>(salesNumSknInfoMap.size()); | ||
96 | - salesNumSknInfoMap.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEachOrdered(e -> finalMap.put(e.getKey(), e.getValue())); | ||
97 | - List<Map<String, Object>> finalList = new ArrayList<>(finalMap.size()); | ||
98 | - Iterator iterator = finalMap.entrySet().iterator(); | ||
99 | - while (iterator.hasNext()) { | ||
100 | - Map.Entry entry = (Map.Entry) iterator.next(); | ||
101 | - finalList.add((Map<String, Object>) entry.getKey()); | 80 | + List<Map<String, Object>> finalList = new ArrayList<>(); |
81 | + if (CollectionUtils.isNotEmpty(sknInfoList)) { | ||
82 | + Map<Integer, Map<String, Object>> sknInfoMap = new LinkedHashMap<>(sknInfoList.size()); | ||
83 | + sknInfoList.forEach(p -> sknInfoMap.put(MapUtils.getInteger(p, "product_skn"), p)); | ||
84 | + collageIndexResultList.forEach(p -> { | ||
85 | + Integer productSkn = MapUtils.getInteger(p, "product_skn"); | ||
86 | + Map<String, Object> sknMap = sknInfoMap.get(productSkn); | ||
87 | + p.put("product_name", MapUtils.getString(sknMap, "product_name", "")); | ||
88 | + p.put("sales_price", MapUtils.getDoubleValue(sknMap, "sales_price")); | ||
89 | + p.put("market_price", MapUtils.getDoubleValue(sknMap, "market_price")); | ||
90 | + p.put("sales_num", MapUtils.getIntValue(sknMap, "sales_num")); | ||
91 | + p.put("default_images", MapUtils.getString(sknMap, "default_images")); | ||
92 | + }); | ||
93 | + Map<Map<String, Object>, Integer> salesNumSknInfoMap = collageIndexResultList.stream().collect(Collectors.toMap(p -> p, p -> MapUtils.getInteger(p, "sales_num"))); | ||
94 | + Map<Map<String, Object>, Integer> finalMap = new LinkedHashMap<>(salesNumSknInfoMap.size()); | ||
95 | + salesNumSknInfoMap.entrySet().stream().sorted(Map.Entry.comparingByValue()).forEachOrdered(e -> finalMap.put(e.getKey(), e.getValue())); | ||
96 | + Iterator iterator = finalMap.entrySet().iterator(); | ||
97 | + while (iterator.hasNext()) { | ||
98 | + Map.Entry entry = (Map.Entry) iterator.next(); | ||
99 | + finalList.add((Map<String, Object>) entry.getKey()); | ||
100 | + } | ||
101 | + Collections.reverse(finalList); | ||
102 | } | 102 | } |
103 | - Collections.reverse(finalList); | ||
104 | // 4.构造返回结果并加入缓存 | 103 | // 4.构造返回结果并加入缓存 |
105 | JSONObject dataMap = new JSONObject(); | 104 | JSONObject dataMap = new JSONObject(); |
106 | dataMap.put("total", searchResult.getTotal()); | 105 | dataMap.put("total", searchResult.getTotal()); |
-
Please register or login to post a comment