feat(pbom): 重写复制功能
This commit is contained in:
parent
aa3c3f5d37
commit
aea94aa852
|
|
@ -1353,9 +1353,9 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
, sourceFacCode);
|
, sourceFacCode);
|
||||||
if (CollUtil.isNotEmpty(ps)) {
|
if (CollUtil.isNotEmpty(ps)) {
|
||||||
ps.forEach(p -> {
|
ps.forEach(p -> {
|
||||||
BomNewPbomParentEntity np = copyParent(p, targetFacCode);
|
BomNewPbomParentEntity np = copyParent(p, targetFacCode, dtoParent);
|
||||||
if (Objects.nonNull(np)) {
|
if (Objects.nonNull(np)) {
|
||||||
dtoParent.addToAdd(np);
|
// dtoParent.addToAdd(np);
|
||||||
List<BomNewPbomChildEntity> ccs = copyChildren(p.getRowId(), targetFacCode, np.getRowId());
|
List<BomNewPbomChildEntity> ccs = copyChildren(p.getRowId(), targetFacCode, np.getRowId());
|
||||||
np.setBomExist(CollUtil.isNotEmpty(ccs) ? 1 : 0);
|
np.setBomExist(CollUtil.isNotEmpty(ccs) ? 1 : 0);
|
||||||
if (CollUtil.isNotEmpty(ccs)) {
|
if (CollUtil.isNotEmpty(ccs)) {
|
||||||
|
|
@ -1367,13 +1367,30 @@ public class BomNewPbomParentService extends ServiceImpl<BomNewPbomParentMapper,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private BomNewPbomParentEntity copyParent(BomNewPbomParentEntity parent, String targetFacCode) {
|
private BomNewPbomParentEntity copyParent(BomNewPbomParentEntity parent, String targetFacCode, PbomSaveDTO<BomNewPbomParentEntity> dtoParent) {
|
||||||
if (!lambdaQuery()
|
BomNewPbomParentEntity p = dtoParent.getDataForAdd()
|
||||||
.eq(BomNewPbomParentEntity::getMaterialNo, parent.getMaterialNo())
|
.stream()
|
||||||
.eq(BomNewPbomParentEntity::getStatus, PBomStatusEnum.WAIT_PUBLISH.getValue())
|
.filter(f -> StrUtil.equals(f.getMaterialNo(), parent.getMaterialNo()))
|
||||||
.exists()) {
|
.findFirst()
|
||||||
//工作表不存在记录,则添加
|
.orElse(null);
|
||||||
return buildPbomParent(parent, targetFacCode, parent.getCurrentVersion(), 0);
|
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;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue