optimize: 导入到SAP成功后,如果下级节点存在导入失败的状态,则修改为导入成功

This commit is contained in:
曹鹏飞 2024-08-19 12:42:46 +08:00
parent 89dab0d841
commit aa335e3fe1
2 changed files with 26 additions and 4 deletions

View File

@ -38,6 +38,7 @@ public class BomNewEbomExportToSAP {
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
private final List<T1ExtDTO> children = new ArrayList<>();
private final Set<Long> 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;
}

View File

@ -46,6 +46,7 @@ public class BomNewPbomExportToSAPImpl implements IBomNewPbomExportToSAP {
private final String dateYMD = DateUtil.format(new Date(), "yyyyMMdd");
private final Map<Long, List<T1ExtDTO>> cmap = new HashMap<>();
private final List<T1ExtDTO> children = new ArrayList<>();
private final Set<Long> 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;
}
/**