|
@@ -44,6 +44,7 @@ import org.springframework.transaction.annotation.Transactional;
|
|
|
import javax.annotation.Resource;
|
|
|
import java.math.BigDecimal;
|
|
|
import java.util.*;
|
|
|
+import java.util.function.Function;
|
|
|
import java.util.stream.Collectors;
|
|
|
import java.util.stream.Stream;
|
|
|
|
|
@@ -240,20 +241,30 @@ public class StockPreparationServiceImpl implements StockPreparationService {
|
|
|
List<OrderSkuBom> orderSkuBomList = orderSkuBomService.list(q -> q.in(OrderSkuBom::getOrderId, orderIdList));
|
|
|
|
|
|
// 合并sku主材和包材
|
|
|
- List<InOutStorageBom> list = Stream.concat(
|
|
|
- orderSkuList.stream().map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inOutStorageBom;
|
|
|
- }),
|
|
|
- orderSkuBomList.stream().map(item -> {
|
|
|
- InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
- inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
- inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
- return inOutStorageBom;
|
|
|
- })
|
|
|
- ).collect(Collectors.toList());
|
|
|
+ List<InOutStorageBom> list = new ArrayList<>(
|
|
|
+ Stream.concat(
|
|
|
+ orderSkuList.stream().map(item -> {
|
|
|
+ InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
+ return inOutStorageBom;
|
|
|
+ }),
|
|
|
+ orderSkuBomList.stream().map(item -> {
|
|
|
+ InOutStorageBom inOutStorageBom = new InOutStorageBom();
|
|
|
+ inOutStorageBom.setBomSpecId(item.getBomSpecId());
|
|
|
+ inOutStorageBom.setQuantity(item.getQuantity());
|
|
|
+ return inOutStorageBom;
|
|
|
+ })
|
|
|
+ )
|
|
|
+ .collect(Collectors.toMap(
|
|
|
+ InOutStorageBom::getBomSpecId,
|
|
|
+ Function.identity(),
|
|
|
+ (v1, v2) -> {
|
|
|
+ v1.setQuantity(v1.getQuantity().add(v2.getQuantity()));
|
|
|
+ return v1;
|
|
|
+ }
|
|
|
+ )
|
|
|
+ ).values());
|
|
|
|
|
|
List<Long> bomSpecIdList = list.stream().map(InOutStorageBom::getBomSpecId).collect(Collectors.toList());
|
|
|
Map<Long, BomSpecBo> bomSpecBo = skuSpecService.getBomSpecBoByIdList(bomSpecIdList);
|