|
@@ -1934,38 +1934,40 @@ public class ProductServiceImpl implements ProductService { |
|
@@ -1934,38 +1934,40 @@ public class ProductServiceImpl implements ProductService { |
1934
|
return null;
|
1934
|
return null;
|
1935
|
}
|
1935
|
}
|
1936
|
|
1936
|
|
1937
|
- /*List<Integer> sizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList());
|
1937
|
+ List<Integer> sizeIdList = storageList.stream().map(Storage::getSizeId).collect(Collectors.toList());
|
1938
|
List<Size> sizes = sizeMapper.selectByIds(sizeIdList);
|
1938
|
List<Size> sizes = sizeMapper.selectByIds(sizeIdList);
|
1939
|
|
1939
|
|
|
|
1940
|
+ Map<Integer, String> sizeMap = sizes.stream().collect(Collectors.toMap(Size::getId, Size::getSizeName));
|
|
|
1941
|
+
|
1940
|
List<Integer> goodsIdList = storageList.stream().map(Storage::getGoodsId).collect(Collectors.toList());
|
1942
|
List<Integer> goodsIdList = storageList.stream().map(Storage::getGoodsId).collect(Collectors.toList());
|
1941
|
List<Goods> goodsList = goodsMapper.selectByIds(goodsIdList);
|
1943
|
List<Goods> goodsList = goodsMapper.selectByIds(goodsIdList);
|
|
|
1944
|
+ Map<Integer, Goods> goodsMap = goodsList.stream().collect(Collectors.toMap(Goods::getId, a -> a));
|
1942
|
|
1945
|
|
1943
|
List<Integer> productIdList = storageList.stream().map(Storage::getProductId).collect(Collectors.toList());
|
1946
|
List<Integer> productIdList = storageList.stream().map(Storage::getProductId).collect(Collectors.toList());
|
1944
|
List<Product> products = productMapper.selectByIds(productIdList);
|
1947
|
List<Product> products = productMapper.selectByIds(productIdList);
|
|
|
1948
|
+ Map<Integer, Product> productMap = products.stream().collect(Collectors.toMap(Product::getId, a -> a));
|
1945
|
|
1949
|
|
1946
|
StorageDataResp resp = new StorageDataResp();
|
1950
|
StorageDataResp resp = new StorageDataResp();
|
1947
|
storageList.forEach(item -> {
|
1951
|
storageList.forEach(item -> {
|
1948
|
-
|
|
|
1949
|
GoodsSize goodsSize = new GoodsSize();
|
1952
|
GoodsSize goodsSize = new GoodsSize();
|
1950
|
- goodsSize.setSizeId(storage.getSizeId());
|
|
|
1951
|
- if (size != null) {
|
|
|
1952
|
- goodsSize.setSizeName(size.getSizeName());
|
|
|
1953
|
- }
|
1953
|
+ goodsSize.setSizeId(item.getSizeId());
|
|
|
1954
|
+ goodsSize.setSizeName(sizeMap.get(item.getSizeId()));
|
1954
|
resp.setSize(goodsSize);
|
1955
|
resp.setSize(goodsSize);
|
1955
|
|
1956
|
|
|
|
1957
|
+ Goods goods = goodsMap.get(item.getGoodsId());
|
|
|
1958
|
+ if (null != goods) {
|
|
|
1959
|
+ resp.setColorId(goods.getColorId().toString());
|
|
|
1960
|
+ resp.setColorName(StringUtils.isEmpty(goods.getGoodsName()) ? goods.getColorName() : goods.getGoodsName());
|
|
|
1961
|
+ resp.setImageUrl(goods.getColorImage());
|
|
|
1962
|
+ }
|
1956
|
|
1963
|
|
1957
|
-
|
|
|
1958
|
- resp.setColorId(goods.getColorId().toString());
|
|
|
1959
|
- resp.setColorName(StringUtils.isEmpty(goods.getGoodsName()) ? goods.getColorName() : goods.getGoodsName());
|
|
|
1960
|
- resp.setImageUrl(goods.getColorImage());
|
|
|
1961
|
-
|
|
|
1962
|
-
|
1964
|
+ Product product = productMap.get(item.getProductId());
|
1963
|
if (product != null) {
|
1965
|
if (product != null) {
|
1964
|
resp.setProductId(product.getId());
|
1966
|
resp.setProductId(product.getId());
|
1965
|
resp.setProductName(product.getProductName());
|
1967
|
resp.setProductName(product.getProductName());
|
1966
|
resp.setStatus(product.getShelveStatus());
|
1968
|
resp.setStatus(product.getShelveStatus());
|
1967
|
}
|
1969
|
}
|
1968
|
- });*/
|
1970
|
+ });
|
1969
|
|
1971
|
|
1970
|
return respList;
|
1972
|
return respList;
|
1971
|
}
|
1973
|
}
|