feat(ebom): 修复一个逻辑错误
This commit is contained in:
parent
14ae4b4129
commit
07c0575f0a
|
|
@ -2569,7 +2569,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
BomNewEbomParentEntity root = getById(bomRowId);
|
||||
VUtils.isTure(Objects.isNull(root)).throwMessage("bom不存在");
|
||||
VUtils.isTure(root.getRootIs() != 1 && root.getUserRootIs() != 0).throwMessage("请选择根节点");
|
||||
VUtils.isTure(StrUtil.equals(root.getCreatedBy(), SessionUtil.getUserCode())).throwMessage("不能删除他人的数据");
|
||||
VUtils.isTure(!StrUtil.equals(root.getCreatedBy(), SessionUtil.getUserCode())).throwMessage("不能删除他人的数据");
|
||||
|
||||
delete(root.getRowId());
|
||||
return true;
|
||||
|
|
@ -2583,6 +2583,7 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.stream()
|
||||
.map(BomNewEbomChildEntity::getMaterialNo)
|
||||
.collect(Collectors.toSet());
|
||||
if (CollUtil.isEmpty(materialNos)) return;
|
||||
|
||||
List<BomNewEbomParentEntity> parents = lambdaQuery()
|
||||
.select(BomNewEbomParentEntity::getRowId, BomNewEbomParentEntity::getCreatedBy
|
||||
|
|
@ -2590,6 +2591,8 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.lt(BomNewEbomParentEntity::getStatus, EBomStatusEnum.PUBLISHED.getValue())
|
||||
.in(BomNewEbomParentEntity::getMaterialNo, materialNos)
|
||||
.list();
|
||||
if (CollUtil.isEmpty(parents)) return;
|
||||
|
||||
List<Long> deleteParents = parents.stream()
|
||||
.filter(p -> (StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode())
|
||||
&& (Objects.equals(p.getSource(), EBomSourceEnum.FROM_BOM.getValue()) || Objects.equals(p.getSource(), EBomSourceEnum.FROM_EXCE.getValue())))
|
||||
|
|
@ -2601,6 +2604,18 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
|||
.eq(BomNewEbomChildEntity::getParentRowId, bomRowId));
|
||||
this.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomParentEntity.class)
|
||||
.eq(BomNewEbomParentEntity::getRowId, bomRowId));
|
||||
//将自己手动创建的bom提为用户顶层
|
||||
List<Long> updateParents = parents.stream()
|
||||
.filter(p -> StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode()))
|
||||
.map(BomNewEbomParentEntity::getRowId)
|
||||
.collect(Collectors.toList());
|
||||
updateParents.removeAll(deleteParents);
|
||||
if (CollUtil.isNotEmpty(updateParents)) {
|
||||
this.lambdaUpdate()
|
||||
.set(BomNewEbomParentEntity::getUserRootIs, 1)
|
||||
.set(BomNewEbomParentEntity::getModifyTime, LocalDateTime.now())
|
||||
.in(BomNewEbomParentEntity::getRowId, updateParents);
|
||||
}
|
||||
|
||||
deleteParents.forEach(this::delete);
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue