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 9223ed8e..fa6ae997 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 @@ -38,6 +38,7 @@ public class BomNewEbomExportToSAP { private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd"); private final List children = new ArrayList<>(); + private final Set liPIds = new HashSet<>(); private final static Logger LOGGER = LoggerFactory.getLogger(BomNewEbomExportToSAP.class); @@ -133,6 +134,14 @@ public class BomNewEbomExportToSAP { sapErrorMsgEntity.setCreatedTime(LocalDateTime.now()); bomNewSapErrorMsgService.saveOrUpdate(sapErrorMsgEntity); } + + if (CollUtil.isEmpty(liErrMsg) && CollUtil.isNotEmpty(liPIds)) { + bomNewEbomParentService.lambdaUpdate() + .in(BomNewEbomParentEntity::getRowId, liPIds) + .set(BomNewEbomParentEntity::getSapTime, LocalDateTime.now()) + .set(BomNewEbomParentEntity::getSapState, SapStatusEnum.PUB_SUCCESS.getValue()) + .update(); + } } private void addToT1(T1ExtDTO dto) { @@ -173,8 +182,8 @@ public class BomNewEbomExportToSAP { .orderByDesc(BomNewEbomParentEntity::getCurrentVersion) .last(" limit 1") .one(); - if (Objects.nonNull(p)) { - LOGGER.debug("BomNewEbomParentEntity:" + JSON.toJSONString(p)); + if (Objects.nonNull(p) && p.getSapState() >= SapStatusEnum.PUB_ERROR.getValue()) { + liPIds.add(p.getRowId()); } return p; } 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 06826265..9b72bd04 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 @@ -46,6 +46,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd"); private final Map> cmap = new HashMap<>(); private final List children = new ArrayList<>(); + private final Set liPIds = new HashSet<>(); private final static Logger LOGGER = LoggerFactory.getLogger(BomNewPbomExportToSAPImpl.class); @@ -166,11 +167,19 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { sapErrorMsgEntity.setCreatedTime(LocalDateTime.now()); bomNewSapErrorMsgService.saveOrUpdate(sapErrorMsgEntity); } + + if (CollUtil.isEmpty(liErrMsg) && CollUtil.isNotEmpty(liPIds)) { + bomNewPbomParentService.lambdaUpdate() + .in(BomNewPbomParentEntity::getRowId, liPIds) + .set(BomNewPbomParentEntity::getSapTime, LocalDateTime.now()) + .set(BomNewPbomParentEntity::getSapState, SapStatusEnum.PUB_SUCCESS.getValue()) + .update(); + } } private void updateSapState(Long rootBomRowId, SapStatusEnum sapState) { bomNewPbomParentService.lambdaUpdate() - .in(BomNewPbomParentEntity::getRowId, rootBomRowId) + .eq(BomNewPbomParentEntity::getRowId, rootBomRowId) .set(BomNewPbomParentEntity::getSapTime, LocalDateTime.now()) .set(BomNewPbomParentEntity::getSapState, sapState.getValue()) .update(); @@ -278,7 +287,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { } private BomNewPbomParentEntity getParent(BomNewPbomChildEntity child) { - return bomNewPbomParentService.lambdaQuery() + BomNewPbomParentEntity parent = bomNewPbomParentService.lambdaQuery() .eq(BomNewPbomParentEntity::getMaterialNo, child.getMaterialNo()) .ge(BomNewPbomParentEntity::getStatus, PBomStatusEnum.PUBLISH.getValue()) .eq(BomNewPbomParentEntity::getFacCode, child.getFacCode()) @@ -286,6 +295,10 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP { .orderByDesc(BomNewPbomParentEntity::getCurrentVersion) .last(" limit 1") .one(); + if (Objects.nonNull(parent) && parent.getSapState() >= SapStatusEnum.PUB_ERROR.getValue()) { + liPIds.add(parent.getRowId()); + } + return parent; } /**