diff --git a/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java b/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java index b591e08e..58847955 100644 --- a/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java +++ b/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java @@ -192,25 +192,29 @@ public class ProductCostAnalysisService { private void buildHighValuePurchasedParts(Long parentRowId, HighValuePurchasedPartsVO pvo, BigDecimal num, BigDecimal price, List datas) { List children = ebomService.getChildren(parentRowId); - children.parallelStream().forEach(child -> { + children.forEach(child -> { EBomCostCacheDTO ccost = datas.stream().filter(d -> StrUtil.equals(d.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null); BigDecimal tnum = child.getNum().multiply(num); - if (ccost.isPurchasedParts() && ccost.getTotalCost().compareTo(price) >= 0) { - MaterialCostVO cvo; - cvo = pvo.getCosts().stream().filter(v -> StrUtil.equals(v.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null); - if (Objects.isNull(cvo)) { - cvo = new MaterialCostVO(); - cvo.setMaterialNo(child.getMaterialNo()); - cvo.setPrice(ccost.getTotalCost()); - cvo.setNum(tnum); - pvo.getCosts().add(cvo); - } else { - cvo.setNum(cvo.getNum().add(tnum)); + if (Objects.isNull(ccost)) { + log.error("没有找到{}的缓存数据", child.getMaterialNo()); + } else { + if (ccost.isPurchasedParts() && ccost.getTotalCost().compareTo(price) >= 0) { + MaterialCostVO cvo; + cvo = pvo.getCosts().stream().filter(v -> StrUtil.equals(v.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null); + if (Objects.isNull(cvo)) { + cvo = new MaterialCostVO(); + cvo.setMaterialNo(child.getMaterialNo()); + cvo.setPrice(ccost.getTotalCost()); + cvo.setNum(tnum); + pvo.getCosts().add(cvo); + } else { + cvo.setNum(cvo.getNum().add(tnum)); + } + } + EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo()); + if (Objects.nonNull(cparent)) { + buildHighValuePurchasedParts(cparent.getRowId(), pvo, tnum, price, datas); } - } - EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo()); - if (Objects.nonNull(cparent)) { - buildHighValuePurchasedParts(cparent.getRowId(), pvo, tnum, price, datas); } }); }