diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java index 819a5e9a..1438e820 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/BomNewEbomParentService.java @@ -1400,11 +1400,37 @@ public class BomNewEbomParentService extends ServiceImpl checkBom = new ArrayList<>(); - List tmp1 = dto.getDatas().stream().filter(item -> Objects.nonNull(item.getRowId()) && item.getRowId() > 0).collect(Collectors.toList()); + List childList=getChild(dto.getParent().getBomRowId()); + + List tmp1 = dto.getDatas().stream().filter(item -> (Objects.nonNull(item.getRowId()) && item.getRowId() > 0)).collect(Collectors.toList()); + + //相同rowid 不同物料号 + List union = tmp1.stream().filter(u->{ + return childList.stream().filter(e-> + Objects.equals(u.getRowId(),e.getRowId() ) + && !Objects.equals(u.getMaterialNo(),e.getMaterialNo()) + ).count()>0; + }).collect(Collectors.toList()); + + //相同rowid 相同物料号 + List union2 = tmp1.stream().filter(u->{ + return childList.stream().filter(e-> + Objects.equals(u.getRowId(),e.getRowId() ) + && Objects.equals(u.getMaterialNo(),e.getMaterialNo()) + ).count()>0; + }).collect(Collectors.toList()); + + + + + List tmp2 = dto.getDatas().stream().filter(item -> Objects.isNull(item.getRowId()) || item.getRowId() == 0).collect(Collectors.toList()); SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(tmp2, ""); + SpringUtil.getBean(MaterialMainService.class).intiMaterialInfo(union, ""); + + String[] ignore = new String[]{ "projectType", @@ -1414,38 +1440,84 @@ public class BomNewEbomParentService extends ServiceImpl returnList=new ArrayList<>(); + + Map> groupList=childList.stream().collect(Collectors.groupingBy(BomNewEbomParentVO::getRowId)); + if(CollectionUtil.isNotEmpty(union)){ + union.forEach(item->{ + if(item.getMaterialUnit().contains("KG")){ + item.setUnitWeight(null); + }else{ +// if(StrUtil.isNotBlank(item.getMaterialUnit())) { +// item.setUnitWeight(NumberUtil.toBigDecimal(item.getMaterialUnit().toString())); +// } + } + + + item.setTotalWeight(NumberUtil.mul(item.getUnitWeight(), item.getNum())); + if(Objects.isNull(item.getMaterialNo())) { + BeanUtil.copyProperties(item,groupList.get(item.getRowId()).get(0)); + } + }); + returnList.addAll(union); + } + + if(CollectionUtil.isNotEmpty(union2)){ + union2.forEach(item->{ + if(Objects.isNull(item.getMaterialNo())) { + BeanUtil.copyProperties(item,groupList.get(item.getRowId()).get(0)); + } + }); + returnList.addAll(union2); + } + + + + if (CollectionUtil.isNotEmpty(tmp2)) { for (BomNewEbomParentVO vo : - dto.getDatas()) { + tmp2) { if (Objects.isNull(vo.getRowId()) || vo.getRowId() == 0) { vo.setDeviseUserCode(SessionUtil.getUserCode()); vo.setDeviseName(SessionUtil.getRealName()); vo.setCreatedBy(SessionUtil.getUserCode()); - if (vo.getUnitWeight() == null || BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) { - vo.setUnitWeight(vo.getMaterialWeight()); +// if (vo.getUnitWeight() == null || BigDecimal.ZERO.compareTo(vo.getUnitWeight()) >= 0) { +// vo.setUnitWeight(vo.getMaterialWeight()); +// } + + if(vo.getMaterialUnit().contains("KG")){ + vo.setUnitWeight(null); + }else{ + // vo.setUnitWeight(NumberUtil.toBigDecimal( vo.getMaterialUnit() )); } + + vo.setTotalWeight(NumberUtil.mul(vo.getUnitWeight(), vo.getNum())); } } + + returnList.addAll(tmp2); } - return dto.getDatas(); + + + return returnList; } diff --git a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java index 7a0abab8..ae45cc4f 100644 --- a/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java +++ b/nflg_project_dev/nflg-bom-new/src/main/java/com/nflg/product/bomnew/service/domain/EBom/CheckEBomException.java @@ -191,10 +191,15 @@ public class CheckEBomException { return; } for (BomNewEbomParentVO exItem : list) { - List warnList = allBomDetail.stream().filter(u -> exItem.getBomRowId() > 0 && u.getLevelNumber().compareTo(exItem.getLevelNumber()) < 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); - warnList.forEach(k -> { - k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); - }); + + try { + List warnList = allBomDetail.stream().filter(u -> exItem.getBomRowId() != null && exItem.getBomRowId() > 0 && u.getLevelNumber().compareTo(exItem.getLevelNumber()) < 0 && EBomExceptionStatusEnum.OK.equalsValue(u.getExceptionStatus())).collect(Collectors.toList()); + warnList.forEach(k -> { + k.setExceptionStatus(EBomExceptionStatusEnum.EXCEPT_NO_14.getValue()); + }); + }catch ( Exception e){ + e.printStackTrace(); + } }