From c47d47d62ebc8cc67e2b5ae702fb87d6b5361bc5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 31 Dec 2024 11:14:15 +0800 Subject: [PATCH] =?UTF-8?q?fix(=E6=88=90=E6=9C=AC=E5=88=86=E6=9E=90):=20?= =?UTF-8?q?=E8=AE=A1=E7=AE=97=E9=AB=98=E4=BB=B7=E5=80=BC=E5=A4=96=E8=B4=AD?= =?UTF-8?q?=E4=BB=B6=E6=B7=BB=E5=8A=A0null=E5=88=A4=E6=96=AD=EF=BC=8C?= =?UTF-8?q?=E5=9B=A0=E4=B8=BA=E5=A6=82=E6=9E=9C=E6=98=AFT=E9=A1=B9?= =?UTF-8?q?=E7=9A=84=E8=AF=9D=E6=98=AF=E6=B2=A1=E6=9C=89=E7=BC=93=E5=AD=98?= =?UTF-8?q?=E6=95=B0=E6=8D=AE=E7=9A=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/ProductCostAnalysisService.java | 36 ++++++++++--------- 1 file changed, 20 insertions(+), 16 deletions(-) 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); } }); }