From aa335e3fe102422b4df2500a667fa29259bb551a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Mon, 19 Aug 2024 12:42:46 +0800 Subject: [PATCH] =?UTF-8?q?optimize:=20=E5=AF=BC=E5=85=A5=E5=88=B0SAP?= =?UTF-8?q?=E6=88=90=E5=8A=9F=E5=90=8E=EF=BC=8C=E5=A6=82=E6=9E=9C=E4=B8=8B?= =?UTF-8?q?=E7=BA=A7=E8=8A=82=E7=82=B9=E5=AD=98=E5=9C=A8=E5=AF=BC=E5=85=A5?= =?UTF-8?q?=E5=A4=B1=E8=B4=A5=E7=9A=84=E7=8A=B6=E6=80=81=EF=BC=8C=E5=88=99?= =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=AF=BC=E5=85=A5=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bomnew/service/BomNewEbomExportToSAP.java | 13 +++++++++++-- .../service/BomNewPbomExportToSAPImpl.java | 17 +++++++++++++++-- 2 files changed, 26 insertions(+), 4 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 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; } /**