...
|
...
|
@@ -22,19 +22,19 @@ public class TblProductSkuMapBuilder { |
|
|
|
|
|
public Map<Integer, List<TblProductSku>> build(List<TblProduct> tblProducts) {
|
|
|
Map<Integer, List<TblProductSku>> tblProductSkuMap = new HashMap<>();
|
|
|
List<Integer> productSkns = tblProducts.stream().map(TblProduct::getProductSkn).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(productSkns)) {
|
|
|
List<TblProductSku> tblProductSkus = tblProductSkuService.getBySkns(productSkns);
|
|
|
if (CollectionUtils.isNotEmpty(tblProductSkus)) {
|
|
|
for (TblProductSku tblProductSku : tblProductSkus) {
|
|
|
List<Integer> productSknList = tblProducts.stream().map(TblProduct::getProductSkn).collect(Collectors.toList());
|
|
|
if (CollectionUtils.isNotEmpty(productSknList)) {
|
|
|
List<TblProductSku> tblProductSkuList = tblProductSkuService.getBySkns(productSknList);
|
|
|
if (CollectionUtils.isNotEmpty(tblProductSkuList)) {
|
|
|
for (TblProductSku tblProductSku : tblProductSkuList) {
|
|
|
if (tblProductSkuMap.containsKey(tblProductSku.getProductSkn())) {
|
|
|
List<TblProductSku> skus = tblProductSkuMap.get(tblProductSku.getProductSkn());
|
|
|
skus.add(tblProductSku);
|
|
|
tblProductSkuMap.put(tblProductSku.getProductSkn(), skus);
|
|
|
List<TblProductSku> skuList = tblProductSkuMap.get(tblProductSku.getProductSkn());
|
|
|
skuList.add(tblProductSku);
|
|
|
tblProductSkuMap.put(tblProductSku.getProductSkn(), skuList);
|
|
|
} else {
|
|
|
List<TblProductSku> skus = new ArrayList<>();
|
|
|
skus.add(tblProductSku);
|
|
|
tblProductSkuMap.put(tblProductSku.getProductSkn(), skus);
|
|
|
List<TblProductSku> skuList = new ArrayList<>();
|
|
|
skuList.add(tblProductSku);
|
|
|
tblProductSkuMap.put(tblProductSku.getProductSkn(), skuList);
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
|