fix(ebom): 删除bom条件判断
This commit is contained in:
parent
f84d4416a4
commit
da4f625170
|
|
@ -2575,26 +2575,30 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
VUtils.isTure(root.getRootIs() != 1 && root.getUserRootIs() != 0).throwMessage("请选择根节点");
|
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());
|
delete(root);
|
||||||
|
|
||||||
CompletableFuture.runAsync(this::updateLastVersionIs);
|
CompletableFuture.runAsync(this::updateLastVersionIs);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void delete(Long bomRowId) {
|
private void delete(BomNewEbomParentEntity parent) {
|
||||||
|
if (!StrUtil.equals(parent.getCreatedBy(), SessionUtil.getUserCode())) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
this.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomParentEntity.class)
|
this.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomParentEntity.class)
|
||||||
.eq(BomNewEbomParentEntity::getRowId, bomRowId));
|
.eq(BomNewEbomParentEntity::getRowId, parent.getRowId()));
|
||||||
|
|
||||||
Set<String> materialNos = ebomChildService.lambdaQuery()
|
Set<String> materialNos = ebomChildService.lambdaQuery()
|
||||||
.select(BomNewEbomChildEntity::getMaterialNo)
|
.select(BomNewEbomChildEntity::getMaterialNo)
|
||||||
.eq(BomNewEbomChildEntity::getParentRowId, bomRowId)
|
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId())
|
||||||
.list()
|
.list()
|
||||||
.stream()
|
.stream()
|
||||||
.map(BomNewEbomChildEntity::getMaterialNo)
|
.map(BomNewEbomChildEntity::getMaterialNo)
|
||||||
.collect(Collectors.toSet());
|
.collect(Collectors.toSet());
|
||||||
|
|
||||||
ebomChildService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomChildEntity.class)
|
ebomChildService.getBaseMapper().delete(Wrappers.lambdaQuery(BomNewEbomChildEntity.class)
|
||||||
.eq(BomNewEbomChildEntity::getParentRowId, bomRowId));
|
.eq(BomNewEbomChildEntity::getParentRowId, parent.getRowId()));
|
||||||
|
|
||||||
if (CollUtil.isEmpty(materialNos)) return;
|
if (CollUtil.isEmpty(materialNos)) return;
|
||||||
|
|
||||||
|
|
@ -2606,23 +2610,21 @@ public class BomNewEbomParentService extends ServiceImpl<BomNewEbomParentMapper,
|
||||||
.list();
|
.list();
|
||||||
if (CollUtil.isEmpty(parents)) return;
|
if (CollUtil.isEmpty(parents)) return;
|
||||||
|
|
||||||
List<Long> deleteParents = parents.stream()
|
List<BomNewEbomParentEntity> deleteParents = parents.stream()
|
||||||
.filter(p -> (StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode())
|
.filter(p -> (StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode())
|
||||||
&& (Objects.equals(p.getSource(), EBomSourceEnum.FROM_BOM.getValue()) || Objects.equals(p.getSource(), EBomSourceEnum.FROM_EXCE.getValue())))
|
&& (Objects.equals(p.getSource(), EBomSourceEnum.FROM_BOM.getValue()) || Objects.equals(p.getSource(), EBomSourceEnum.FROM_EXCE.getValue())))
|
||||||
|| Objects.equals(p.getVirtualPackageIs(), 1))
|
|| Objects.equals(p.getVirtualPackageIs(), 1))
|
||||||
.map(BomNewEbomParentEntity::getRowId)
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
//将自己手动创建的bom提为用户顶层
|
//将自己手动创建的bom提为用户顶层
|
||||||
List<Long> updateParents = parents.stream()
|
List<BomNewEbomParentEntity> updateParents = parents.stream()
|
||||||
.filter(p -> StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode()))
|
.filter(p -> StrUtil.equals(p.getCreatedBy(), SessionUtil.getUserCode()))
|
||||||
.map(BomNewEbomParentEntity::getRowId)
|
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
updateParents.removeAll(deleteParents);
|
updateParents.removeAll(deleteParents);
|
||||||
if (CollUtil.isNotEmpty(updateParents)) {
|
if (CollUtil.isNotEmpty(updateParents)) {
|
||||||
this.lambdaUpdate()
|
this.lambdaUpdate()
|
||||||
.set(BomNewEbomParentEntity::getUserRootIs, 1)
|
.set(BomNewEbomParentEntity::getUserRootIs, 1)
|
||||||
.set(BomNewEbomParentEntity::getModifyTime, LocalDateTime.now())
|
.set(BomNewEbomParentEntity::getModifyTime, LocalDateTime.now())
|
||||||
.in(BomNewEbomParentEntity::getRowId, updateParents);
|
.in(BomNewEbomParentEntity::getRowId, updateParents.stream().map(BomNewEbomParentEntity::getRowId).collect(Collectors.toList()));
|
||||||
}
|
}
|
||||||
|
|
||||||
deleteParents.forEach(this::delete);
|
deleteParents.forEach(this::delete);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue