From 04a36e33cb3e3767058fcc116372db627f3caa58 Mon Sep 17 00:00:00 2001 From: luoliming Date: Sat, 10 Aug 2024 17:27:17 +0800 Subject: [PATCH] =?UTF-8?q?1-pbom-=E5=B7=A5=E4=BD=9C=E8=A1=A8=E6=9F=A5?= =?UTF-8?q?=E8=AF=A2=E9=97=AE=E9=A2=98-2?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewPbomParentService.java | 24 ++++++++++++++----- 1 file changed, 18 insertions(+), 6 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 9e1df8ee..6e0c6046 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -139,7 +139,8 @@ public class BomNewPbomParentService extends ServiceImpl parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo)); + List parentMaterialByMaterialNo = new ArrayList<>(getParentMaterialByMaterialNo(materialNo)); + parentMaterialByMaterialNo.add(materialNo); if (CollUtil.isNotEmpty(parentMaterialByMaterialNo)) { String queryFac= StrUtil.isBlank(query.getFacCode())? userRoleService.getUserFactory():query.getFacCode(); @@ -202,15 +203,26 @@ public class BomNewPbomParentService extends ServiceImpl parentNoResult, Set materialNos){ + Set relParentNoSet= getParent(parentNoResult,materialNos); + + while (CollUtil.isNotEmpty(relParentNoSet)){ + + relParentNoSet= getParent(parentNoResult , relParentNoSet); + } + } + + private Set getParent(Set parentNoResult, Set materialNos){ + List childList = pbomChildService.lambdaQuery().in(BomNewPbomChildEntity::getMaterialNo, materialNos).select(BomNewPbomChildEntity::getParentRowId).list(); + parentNoResult.addAll(materialNos); + if(CollUtil.isEmpty(childList)){ + return new HashSet<>(); + } List parentRowIdList = childList.stream().map(u -> u.getParentRowId()).collect(Collectors.toList()); List parentList = this.lambdaQuery().in(BomNewPbomParentEntity::getRowId, parentRowIdList).select(BomNewPbomParentEntity::getMaterialNo).list(); Set parentNoSet = parentList.stream().map(u -> u.getMaterialNo()).collect(Collectors.toSet()); - Set relParentNoSet= Sets.difference(parentNoSet,parentNoResult); - parentNoResult.addAll(materialNos); - while (CollUtil.isNotEmpty(relParentNoSet)){ - getGetParentMaterialByMaterialNoNew(parentNoResult, relParentNoSet); - } + + return Sets.difference(parentNoSet,parentNoResult); } /**