feat(pbom): 重写复制功能

This commit is contained in:
曹鹏飞 2024-06-06 09:46:10 +08:00
parent aa3c3f5d37
commit aea94aa852
1 changed files with 26 additions and 9 deletions

View File

@ -1353,9 +1353,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
, sourceFacCode);
if (CollUtil.isNotEmpty(ps)) {
ps.forEach(p -> {
BomNewPbomParentEntity np = copyParent(p, targetFacCode);
BomNewPbomParentEntity np = copyParent(p, targetFacCode, dtoParent);
if (Objects.nonNull(np)) {
dtoParent.addToAdd(np);
// dtoParent.addToAdd(np);
List<BomNewPbomChildEntity> ccs = copyChildren(p.getRowId(), targetFacCode, np.getRowId());
np.setBomExist(CollUtil.isNotEmpty(ccs) ? 1 : 0);
if (CollUtil.isNotEmpty(ccs)) {
@ -1367,13 +1367,30 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
}
}
private BomNewPbomParentEntity copyParent(BomNewPbomParentEntity parent, String targetFacCode) {
if (!lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.WAIT_PUBLISH.getValue())
.exists()) {
//工作表不存在记录则添加
return buildPbomParent(parent, targetFacCode, parent.getCurrentVersion(), 0);
private BomNewPbomParentEntity copyParent(BomNewPbomParentEntity parent, String targetFacCode, PbomSaveDTO<BomNewPbomParentEntity> dtoParent) {
BomNewPbomParentEntity p = dtoParent.getDataForAdd()
.stream()
.filter(f -> StrUtil.equals(f.getMaterialNo(), parent.getMaterialNo()))
.findFirst()
.orElse(null);
if (Objects.isNull(p)) {
p = lambdaQuery()
.eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
.eq(BomNewPbomParentEntity::getFacCode, targetFacCode)
.orderByDesc(BomNewPbomParentEntity::getCurrentVersion)
.last(" limit 1")
.one();
if (Objects.isNull(p)) {
//不存在则添加
p = buildPbomParent(parent, targetFacCode, parent.getCurrentVersion(), 0);
dtoParent.addToAdd(p);
return p;
} else if (p.getStatus() >= PBomStatusEnum.PUBLISH.getValue()) {
//如果是已发布状态则创建一个升级大版本的
p = buildPbomParent(parent, targetFacCode, VersionUtil.getNextVersion(p.getCurrentVersion()), 0);
dtoParent.addToAdd(p);
return p;
}
}
return null;
}