From e823ed6e53ae6e4ca5e03a86ebbd2509aed20f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=9B=B9=E9=B9=8F=E9=A3=9E?= Date: Thu, 6 Jun 2024 08:34:03 +0800 Subject: [PATCH] =?UTF-8?q?feat(pbom):=20=E9=87=8D=E5=86=99=E5=A4=8D?= =?UTF-8?q?=E5=88=B6=E5=8A=9F=E8=83=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../service/BomNewPbomParentService.java | 47 +++++++++++++------ 1 file changed, 33 insertions(+), 14 deletions(-) diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java index 265a918f..f28af6d1 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewPbomParentService.java @@ -34,6 +34,7 @@ import com.nflg.product.bomnew.util.*; import lombok.extern.slf4j.Slf4j; import nflg.product.common.constant.STATE; import nflg.product.common.vo.ResultVO; +import org.springframework.beans.BeanUtils; import org.springframework.beans.factory.annotation.Qualifier; import org.springframework.stereotype.Service; import org.springframework.transaction.annotation.Transactional; @@ -1240,6 +1241,7 @@ public class BomNewPbomParentService extends ServiceImpl dtoParent = new PbomSaveDTO<>(); PbomSaveDTO dtoChild = new PbomSaveDTO<>(); @@ -1267,7 +1269,7 @@ public class BomNewPbomParentService extends ServiceImpl cs = copyChildren(source.getRowId(), param.getTargetFacCode(), top.getRowId()); + top.setBomExist(CollUtil.isNotEmpty(cs) ? 1 : 0); if (CollUtil.isNotEmpty(cs)) { dtoChild.addToAdd(cs); if (param.getCopyType() == 1) { //多层复制模式 - copy(cs, param.getTargetFacCode(), dtoParent, dtoChild); + copy(cs, source.getFacCode(), param.getTargetFacCode(), dtoParent, dtoChild); } } } + } else { + BomNewPbomParentEntity top = buildPbomParent(source, param.getTargetFacCode(), "A00", 1); + dtoParent.addToAdd(top); + //复制子级 + List cs = copyChildren(source.getRowId(), param.getTargetFacCode(), top.getRowId()); + if (CollUtil.isNotEmpty(cs)) { + dtoChild.addToAdd(cs); + if (param.getCopyType() == 1) { + //多层复制模式 + copy(cs, source.getFacCode(), param.getTargetFacCode(), dtoParent, dtoChild); + } + } } } else { //正式表已存在记录 - BomNewPbomParentEntity top = buildPbomParent(source, param.getTargetFacCode(), VersionUtil.getNextVersion(old.getCurrentVersion())); + BomNewPbomParentEntity top = buildPbomParent(source, param.getTargetFacCode(), VersionUtil.getNextVersion(old.getCurrentVersion()), 1); dtoParent.addToAdd(top); + old.setLastVersionIs(0); + dtoParent.addToUpdate(old); //复制子级 List cs = copyChildren(source.getRowId(), param.getTargetFacCode(), top.getRowId()); if (CollUtil.isNotEmpty(cs)) { dtoChild.addToAdd(cs); if (param.getCopyType() == 1) { //多层复制模式 - copy(cs, param.getTargetFacCode(), dtoParent, dtoChild); + copy(cs, source.getFacCode(), param.getTargetFacCode(), dtoParent, dtoChild); } } } @@ -1330,19 +1347,20 @@ public class BomNewPbomParentService extends ServiceImpl cs, String targetFacCode + private void copy(List cs, String sourceFacCode, String targetFacCode , PbomSaveDTO dtoParent, PbomSaveDTO dtoChild) { List ps = getLatestParents(cs.stream().map(BomNewPbomChildEntity::getMaterialNo).collect(Collectors.toSet()) - , targetFacCode); + , sourceFacCode); if (CollUtil.isNotEmpty(ps)) { ps.forEach(p -> { BomNewPbomParentEntity np = copyParent(p, targetFacCode); if (Objects.nonNull(np)) { dtoParent.addToAdd(np); List ccs = copyChildren(p.getRowId(), targetFacCode, np.getRowId()); + np.setBomExist(CollUtil.isNotEmpty(ccs) ? 1 : 0); if (CollUtil.isNotEmpty(ccs)) { dtoChild.addToAdd(ccs); - copy(ccs, targetFacCode, dtoParent, dtoChild); + copy(ccs, sourceFacCode, targetFacCode, dtoParent, dtoChild); } } }); @@ -1350,12 +1368,12 @@ public class BomNewPbomParentService extends ServiceImpl