diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java index 2c119351..92e6a623 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewMbomParentService.java @@ -4,6 +4,7 @@ import cn.hutool.core.collection.CollUtil; import cn.hutool.core.collection.CollectionUtil; import cn.hutool.core.date.DateUtil; import cn.hutool.core.date.LocalDateTimeUtil; +import cn.hutool.core.util.ObjectUtil; import cn.hutool.core.util.RandomUtil; import cn.hutool.core.util.StrUtil; import cn.hutool.extra.spring.SpringUtil; @@ -13,6 +14,7 @@ import com.google.common.collect.ImmutableList; import com.nflg.product.base.core.conmon.util.SessionUtil; import com.nflg.product.bomnew.constant.BomConstant; import com.nflg.product.bomnew.constant.EBomConstant; +import com.nflg.product.bomnew.constant.EBomSuperMaterialStatusEnum; import com.nflg.product.bomnew.constant.MBomConstantEnum; import com.nflg.product.bomnew.mapper.master.BomNewMbomParentMapper; import com.nflg.product.bomnew.pojo.dto.BomNewMBomChildDTO; @@ -197,8 +199,64 @@ public class BomNewMbomParentService extends ServiceImpl list=queryDetail(0l,parentVO.getRowId()); - list.add(0,parentVO); + + //查找超级物料 + List superList=list.stream().filter(item-> ObjectUtil.equal(item.getSuperMaterialStatus(), EBomSuperMaterialStatusEnum.SUPER_MATERIAL_1.getValue())).collect(Collectors.toList()); + + if(CollUtil.isNotEmpty(superList)) { + List delList=new ArrayList<>(); + //超级物料提层 + for (BomNewMbomMiddleVO item : + superList) { + BomNewMbomMiddleVO parent=list.stream().filter(u->ObjectUtil.equal(item.getParentRowId(),u.getRowId())).collect(Collectors.toList()).get(0); + //超级物料上一级是根忽略 + if(parent.getParentRowId().longValue()==0){ + continue; + } + + Long grandparentRowId=parent.getParentRowId(); + //提层 + item.setParentRowId(grandparentRowId); + delList.add(parent); + } + + //删除提层被替换的 + if(CollUtil.isNotEmpty(delList)){ + List rowIds=new ArrayList<>(); + List tmpId=new ArrayList<>(); + List nextTmpId=new ArrayList<>(); + Map> mapList = list.stream().collect(Collectors.groupingBy(BomNewMbomMiddleVO::getParentRowId)); + delList.forEach( + item->{ + tmpId.clear(); + tmpId.add(item.getRowId()); + while (!tmpId.isEmpty()){ + nextTmpId.clear(); + for(Long id:tmpId){ + if(CollUtil.isNotEmpty(mapList.get(id))) { + nextTmpId.addAll(mapList.get(id).stream().map(BomNewMbomMiddleVO::getRowId).collect(Collectors.toList())); + } + } + rowIds.addAll(tmpId); + tmpId.clear(); + tmpId.addAll(nextTmpId); + + } + } + ); + + for (Long id: + rowIds) { + list.removeIf(u->ObjectUtil.equal(u.getRowId(),id)); + } + + } + + } + + + ImportSapParamDTO result=new ImportSapParamDTO(); result.setT1(new ArrayList<>()); result.setZID(RandomUtil.randomNumbers(5)); @@ -251,6 +309,7 @@ public class BomNewMbomParentService extends ServiceImpl