From 00a6d47e32c0cf405ca875de1f97d3fbd5d70562 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Mon, 11 Nov 2024 12:19:25 +0800 Subject: [PATCH] =?UTF-8?q?fix(pbom):=20=E4=BF=AE=E5=A4=8D=E5=9B=A0child?= =?UTF-8?q?=E8=A1=A8=E7=89=A9=E6=96=99=E5=88=86=E7=B1=BB=E7=BC=96=E7=A0=81?= =?UTF-8?q?=E4=B8=8E=E4=B8=BB=E7=89=A9=E6=96=99=E7=9A=84=E7=89=A9=E6=96=99?= =?UTF-8?q?=E5=88=86=E7=B1=BB=E7=BC=96=E7=A0=81=E4=B8=8D=E4=B8=80=E8=87=B4?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E5=AF=BC=E5=85=A5=E5=88=B0SAP=E7=9A=84?= =?UTF-8?q?=E6=8E=92=E5=BA=8F=E5=8F=B7=E9=94=99=E8=AF=AF=E7=9A=84=E9=97=AE?= =?UTF-8?q?=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewPbomExportToSAPImpl.java | 30 ++++++++++++++++--- 1 file changed, 26 insertions(+), 4 deletions(-) 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 522ddd72..cbd68204 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 @@ -18,6 +18,7 @@ import com.nflg.product.bomnew.pojo.dto.sap.impart2.T1ExtDTO; import com.nflg.product.bomnew.pojo.entity.BomNewPbomChildEntity; import com.nflg.product.bomnew.pojo.entity.BomNewPbomParentEntity; import com.nflg.product.bomnew.pojo.entity.BomNewSapErrorMsgEntity; +import com.nflg.product.bomnew.pojo.vo.BaseMaterialVO; import com.nflg.product.bomnew.pojo.vo.OperationErrorMsgVO; import com.nflg.product.bomnew.util.BomUtil; import com.nflg.product.bomnew.util.SapErrorMsgUtil; @@ -55,6 +56,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { private final BomNewPbomParentService bomNewPbomParentService = SpringUtil.getBean(BomNewPbomParentService.class); private final BomNewPbomChildService bomNewPbomChildService = SpringUtil.getBean(BomNewPbomChildService.class); private final BomNewSapErrorMsgService bomNewSapErrorMsgService = SpringUtil.getBean(BomNewSapErrorMsgService.class); + private final MaterialMainService materialMainService = SpringUtil.getBean(MaterialMainService.class); private final SapErrorMsgUtil sapErrorMsgUtil = SpringUtil.getBean(SapErrorMsgUtil.class); public BomNewPbomExportToSAPImpl(boolean isForSale) { @@ -66,10 +68,10 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { BomNewPbomParentEntity root = bomNewPbomParentService.getById(rootBomRowId); is21 = root.getMaterialNo().startsWith("21"); is31 = root.getMaterialNo().startsWith("31"); - List rcs = bomNewPbomChildService.lambdaQuery() + List rcs = syncMaterial(bomNewPbomChildService.lambdaQuery() .eq(BomNewPbomChildEntity::getParentRowId, root.getRowId()) .orderByAsc(BomNewPbomChildEntity::getOrderNumber) - .list(); + .list()); // if (root.getMaterialNo().startsWith("31")) { // List unVirtualParts = rcs.stream() // .filter(c -> Objects.equals(c.getVirtualPartType(), VirtualPackageTypeEnum.UN_VIRTUAL_PACKAGE.getValue()) @@ -354,7 +356,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { } private List getChildren(BomNewPbomParentEntity parent) { - return bomNewPbomChildService.lambdaQuery() + return syncMaterial(bomNewPbomChildService.lambdaQuery() .select(BomNewPbomChildEntity::getMaterialNo, BomNewPbomChildEntity::getNum , BomNewPbomChildEntity::getMaterialUnit, BomNewPbomChildEntity::getMaterialDesc , BomNewPbomChildEntity::getVirtualPartType, BomNewPbomChildEntity::getProjectType @@ -363,7 +365,27 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { ,BomNewPbomChildEntity::getSourceParentMaterialNo) .eq(BomNewPbomChildEntity::getParentRowId, parent.getRowId()) .orderByAsc(BomNewPbomChildEntity::getOrderNumber) - .list(); + .list()); + } + + private List syncMaterial(List children) { + if (CollUtil.isNotEmpty(children)) { + List materialVOS = materialMainService.getMaterialBaseInfo(children.stream() + .filter(f -> !StrUtil.equalsIgnoreCase(BomConstant.PROJECT_TYPE_TEMPORARY, f.getProjectType())) + .map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toList())); + children.forEach(c -> { + if (!StrUtil.equalsIgnoreCase(BomConstant.PROJECT_TYPE_TEMPORARY, c.getProjectType())) { + BaseMaterialVO materialVO = materialVOS.stream() + .filter(m -> StrUtil.equals(m.getMaterialNo(), c.getMaterialNo())) + .findFirst() + .orElse(null); + if (Objects.nonNull(materialVO)) { + c.setMaterialCategoryCode(materialVO.getMaterialCategoryCode()); + } + } + }); + } + return children; } private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) {