From ae1d544aa170a2eb12a58a5e5131490d151d6b56 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Tue, 4 Jun 2024 10:01:37 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E5=AF=BC=E5=85=A5sap=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/service/BomNewEbomExportToSAP.java | 1 + .../service/BomNewPbomExportToSAPImpl.java | 61 ++++++++++--------- 2 files changed, 34 insertions(+), 28 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java index f31604bf..2709312e 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomExportToSAP.java @@ -212,6 +212,7 @@ public class BomNewEbomExportToSAP { , BomNewEbomChildEntity::getMaterialUnit, BomNewEbomChildEntity::getMaterialDesc , BomNewEbomChildEntity::getVirtualPartType, BomNewEbomChildEntity::getProjectType) .eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId()) + .orderByAsc(BomNewEbomChildEntity::getOrderNumber) .list(); } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java index d3b73f0e..7ac63fc8 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomExportToSAPImpl.java @@ -162,35 +162,39 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { return; } for (BomNewPbomChildEntity it : cc) { - if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) { - if (Objects.nonNull(cRowId)) { - T1ExtDTO cct = cmap.get(cRowId).stream() - .filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc())) - || (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo()))) - .findFirst() - .orElse(null); - if (Objects.isNull(cct)) { - LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc()); - cct = convert(it, p.getMaterialNo(), false); - cmap.get(cRowId).add(cct); - children.add(cct); - } else { - //合并计算数量 - cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString()); - LOGGER.debug("{} 物料提层到顶级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc()); - } + handlerItem(cRowId, it, p, c, ignore); + } + } + + private void handlerItem(Long cRowId, BomNewPbomChildEntity it, BomNewPbomParentEntity p, BomNewPbomChildEntity c, boolean ignore) { + if (Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) { + if (Objects.nonNull(cRowId)) { + T1ExtDTO cct = cmap.get(cRowId).stream() + .filter(ct -> (StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getPOTX1(), it.getMaterialDesc())) + || (!StrUtil.equals(ct.getPOSTP(), BomConstant.PROJECT_TYPE_TEMPORARY, true) && StrUtil.equals(ct.getIDNRK(), it.getMaterialNo()))) + .findFirst() + .orElse(null); + if (Objects.isNull(cct)) { + LOGGER.debug("{} 物料提层到顶级发货包 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc()); + cct = convert(it, p.getMaterialNo(), false); + cmap.get(cRowId).add(cct); + children.add(cct); + } else { + //合并计算数量 + cct.setMENGE(new BigDecimal(cct.getMENGE()).add(it.getNum()).toString()); + LOGGER.debug("{} 物料提层到顶级发货包且合并 编号:{},父级编号:{},数量:{},合并后总数:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), cct.getMENGE(), it.getMaterialDesc()); } - } else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) { - LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc()); - children.add(convert(it, p.getMaterialNo(), ignore)); - } - BomNewPbomParentEntity cp = getParent(it); - if (!ignore && cp.getUserRootIs() == 1) { - ignore = true; - } - if (Objects.nonNull(cp)) { - buildChildrenForSap(cRowId, cp, it, ignore); } + } else if (!Objects.equals(it.getVirtualPartType(), VirtualPackageTypeEnum.DIRECT_DELIVERY_PACKAGE.getValue())) { + LOGGER.debug("{} 添加物料 编号:{},父级编号:{},数量:{},描述:{}", TAG, it.getMaterialNo(), p.getMaterialNo(), it.getNum().toString(), it.getMaterialDesc()); + children.add(convert(it, p.getMaterialNo(), ignore)); + } + BomNewPbomParentEntity cp = getParent(it); + if (!ignore && cp.getUserRootIs() == 1) { + ignore = true; + } + if (Objects.nonNull(cp)) { + buildChildrenForSap(cRowId, cp, it, ignore); } } @@ -200,6 +204,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { , BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc , BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType) .eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId()) + .orderByAsc(BomNewPbomChildEntity::getOrderNumber) .list(); } @@ -207,7 +212,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { return bomNewPbomParentService.lambdaQuery() .eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo()) .eq(!is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.FACTORY_CONFIRM.getValue()) - .eq(is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) + .ge(is21, BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) .eq(BomNewPbomParentEntity::getFacCode, child.getFacCode()) .ne(BomNewPbomParentEntity::getCreatedBy, "admin") .orderByDesc(BomNewPbomParentEntity::getCurrentVersion)