|
|
|
@ -238,7 +238,7 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
|
topProdMaterialBomVo.setMaterialTypeId(1L);
|
|
|
|
|
prodMaterialBomVos.add(topProdMaterialBomVo);
|
|
|
|
|
|
|
|
|
|
List<Long> tempList = prodMaterialBomVos.stream().map(ProdMaterialBomVo::getMaterialBomId).collect(Collectors.toList());
|
|
|
|
|
List<Long> tempList = prodMaterialBomVos.stream().map(ProdMaterialBomVo::getMaterialBomId).toList();
|
|
|
|
|
for (ProdMaterialBomVo prodMaterialBomVo : prodMaterialBomVos) {
|
|
|
|
|
// 如果是顶级节点, 遍历该父节点的所有子节点
|
|
|
|
|
if (!tempList.contains(prodMaterialBomVo.getParentId())) {
|
|
|
|
@ -267,33 +267,29 @@ public class ProdMaterialBomServiceImpl implements IProdMaterialBomService {
|
|
|
|
|
/**
|
|
|
|
|
* 递归列表
|
|
|
|
|
*/
|
|
|
|
|
private void recursionFn(List<ProdMaterialBomVo> list, ProdMaterialBomVo t) {
|
|
|
|
|
// 得到子节点列表
|
|
|
|
|
List<ProdMaterialBomVo> childList = getChildList(list, t);
|
|
|
|
|
t.setChildren(childList);
|
|
|
|
|
for (ProdMaterialBomVo tChild : childList) {
|
|
|
|
|
if (hasChild(list, tChild)) {
|
|
|
|
|
recursionFn(list, tChild);
|
|
|
|
|
private void recursionFn(List<ProdMaterialBomVo> list, ProdMaterialBomVo parent) {
|
|
|
|
|
// 获取子节点
|
|
|
|
|
List<ProdMaterialBomVo> childList = getChildList(list, parent);
|
|
|
|
|
parent.setChildren(childList);
|
|
|
|
|
|
|
|
|
|
// 递归处理子节点
|
|
|
|
|
for (ProdMaterialBomVo child : childList) {
|
|
|
|
|
// 确保子节点继承 BOM 版本信息
|
|
|
|
|
if (StringUtils.isBlank(child.getMaterialBomVersion()) && StringUtils.isNotBlank(parent.getMaterialBomVersion())) {
|
|
|
|
|
child.setMaterialBomVersion(parent.getMaterialBomVersion());
|
|
|
|
|
}
|
|
|
|
|
recursionFn(list, child);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 得到子节点列表
|
|
|
|
|
*/
|
|
|
|
|
private List<ProdMaterialBomVo> getChildList(List<ProdMaterialBomVo> list, ProdMaterialBomVo t) {
|
|
|
|
|
List<ProdMaterialBomVo> tlist = new ArrayList<ProdMaterialBomVo>();
|
|
|
|
|
Iterator<ProdMaterialBomVo> it = list.iterator();
|
|
|
|
|
while (it.hasNext()) {
|
|
|
|
|
ProdMaterialBomVo n = (ProdMaterialBomVo) it.next();
|
|
|
|
|
if(StringUtils.isNotBlank(t.getMaterialBomVersion())){
|
|
|
|
|
n.setMaterialBomVersion(t.getMaterialBomVersion());
|
|
|
|
|
}
|
|
|
|
|
if (StringUtils.isNotNull(n.getParentId()) && n.getParentId().longValue() == t.getMaterialBomId().longValue()) {
|
|
|
|
|
tlist.add(n);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return tlist;
|
|
|
|
|
private List<ProdMaterialBomVo> getChildList(List<ProdMaterialBomVo> list, ProdMaterialBomVo parent) {
|
|
|
|
|
return list.stream()
|
|
|
|
|
.filter(n -> StringUtils.isNotNull(n.getParentId()) &&
|
|
|
|
|
n.getParentId().equals(parent.getMaterialBomId()))
|
|
|
|
|
.collect(Collectors.toList());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|