diff --git a/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java b/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java index 3a68a320..a79cf56d 100644 --- a/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java +++ b/nflg_project_dev/nflg-technology/src/main/java/com/nflg/product/technology/service/ProductCostAnalysisService.java @@ -48,6 +48,9 @@ public class ProductCostAnalysisService { @Resource private BomCostService bomCostService; + @Resource + private MaterialMainAttrService materialMainAttrService; + public List getBomCostSingleLayer(String materialNo) { List datas = bomCostCalculateService.calculate(materialNo); if (CollectionUtil.isEmpty(datas)) { @@ -57,8 +60,10 @@ public class ProductCostAnalysisService { EBomParentEntity parent = ebomService.getParent(materialNo); BomCostMultilayerVO vo = new BomCostMultilayerVO(); vo.setTotalNum(BigDecimal.ONE); - vo.setHasChildren(true); - buildMultilayerChildren(parent.getRowId(), vo, materials, datas, false); + if (!materialMainAttrService.purchaseTypeIsF(parent.getMaterialNo())) { + vo.setHasChildren(true); + buildMultilayerChildren(parent.getRowId(), vo, materials, datas, false); + } return Convert.toList(BomCostSingleLayerVO.class, vo.getChildren()); } @@ -96,7 +101,9 @@ public class ProductCostAnalysisService { vo.setAuxiliaryManufacturingCost(cost.getAuxiliaryManufacturingCost().setScale(2, RoundingMode.UP).toPlainString()); vo.setTotalAuxiliaryManufacturingCost(cost.getAuxiliaryManufacturingCost().setScale(2, RoundingMode.UP).toPlainString()); } - buildMultilayerChildren(parent.getRowId(), vo, materials, datas, true); + if (!materialMainAttrService.purchaseTypeIsF(parent.getMaterialNo())) { + buildMultilayerChildren(parent.getRowId(), vo, materials, datas, true); + } return vo; } @@ -143,7 +150,7 @@ public class ProductCostAnalysisService { } pvo.getChildren().add(cvo); EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo()); - if (Objects.nonNull(cparent)) { + if (Objects.nonNull(cparent) && !materialMainAttrService.purchaseTypeIsF(cparent.getMaterialNo())) { cvo.setHasChildren(cparent.getBomExist() == 1); if (recursion) { buildMultilayerChildren(cparent.getRowId(), cvo, materials, datas, recursion); @@ -160,32 +167,34 @@ public class ProductCostAnalysisService { } EBomParentEntity parent = ebomService.getParent(materialNo); HighValuePurchasedPartsVO vo = new HighValuePurchasedPartsVO(); - buildHighValuePurchasedParts(parent.getRowId(), vo, BigDecimal.ONE, price, datas); - Set materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet()); - if (CollectionUtil.isNotEmpty(materialNos)) { - List materials = materialMainService.getInfos(materialNos); - Iterator iterator = vo.getCosts().iterator(); - while (iterator.hasNext()) { - MaterialCostVO element = iterator.next(); - EBomDTO cpm = materials.stream().filter(m -> StrUtil.equals(m.getMaterialNo(), element.getMaterialNo())) - .findFirst() - .orElse(null); - if (Objects.nonNull(cpm) && BigDecimalUtil.compareTo(cpm.getMaterialPrice(), price) > 0) { - element.setMaterialDesc(cpm.getMaterialDesc()); - element.setMaterialCategoryName(cpm.getCategoryName()); - element.setMaterialUnit(cpm.getMaterialUnit()); - element.setMaterialRowId(cpm.getMaterialRowId()); - element.setRelCategoryCode(cpm.getRelCategoryCode()); - element.setInventory(cpm.getInventory()); - element.setLeadTime(cpm.getLeadTime()); - element.setPrice(cpm.getMaterialPrice()); - element.setTotalPrice(element.getPrice().multiply(element.getNum())); - } else { - iterator.remove(); + if (!materialMainAttrService.purchaseTypeIsF(materialNo)) { + buildHighValuePurchasedParts(parent.getRowId(), vo, BigDecimal.ONE, price, datas); + Set materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet()); + if (CollectionUtil.isNotEmpty(materialNos)) { + List materials = materialMainService.getInfos(materialNos); + Iterator iterator = vo.getCosts().iterator(); + while (iterator.hasNext()) { + MaterialCostVO element = iterator.next(); + EBomDTO cpm = materials.stream().filter(m -> StrUtil.equals(m.getMaterialNo(), element.getMaterialNo())) + .findFirst() + .orElse(null); + if (Objects.nonNull(cpm) && BigDecimalUtil.compareTo(cpm.getMaterialPrice(), price) > 0) { + element.setMaterialDesc(cpm.getMaterialDesc()); + element.setMaterialCategoryName(cpm.getCategoryName()); + element.setMaterialUnit(cpm.getMaterialUnit()); + element.setMaterialRowId(cpm.getMaterialRowId()); + element.setRelCategoryCode(cpm.getRelCategoryCode()); + element.setInventory(cpm.getInventory()); + element.setLeadTime(cpm.getLeadTime()); + element.setPrice(cpm.getMaterialPrice()); + element.setTotalPrice(element.getPrice().multiply(element.getNum())); + } else { + iterator.remove(); + } } + vo.getCosts().sort(Comparator.comparing(MaterialCostVO::getPrice).reversed()); + vo.setTotalCost(vo.getCosts().stream().map(MaterialCostVO::getTotalPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); } - vo.getCosts().sort(Comparator.comparing(MaterialCostVO::getPrice).reversed()); - vo.setTotalCost(vo.getCosts().stream().map(MaterialCostVO::getTotalPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); } return vo; }