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) {