fix(成本分析): 采购类型F和E50逻辑调整

This commit is contained in:
曹鹏飞 2025-03-06 16:00:42 +08:00
parent d8eecd5e53
commit 51a55f647c
1 changed files with 37 additions and 28 deletions

View File

@ -48,6 +48,9 @@ public class ProductCostAnalysisService {
@Resource @Resource
private BomCostService bomCostService; private BomCostService bomCostService;
@Resource
private MaterialMainAttrService materialMainAttrService;
public List<BomCostSingleLayerVO> getBomCostSingleLayer(String materialNo) { public List<BomCostSingleLayerVO> getBomCostSingleLayer(String materialNo) {
List<EBomCostCacheDTO> datas = bomCostCalculateService.calculate(materialNo); List<EBomCostCacheDTO> datas = bomCostCalculateService.calculate(materialNo);
if (CollectionUtil.isEmpty(datas)) { if (CollectionUtil.isEmpty(datas)) {
@ -57,8 +60,10 @@ public class ProductCostAnalysisService {
EBomParentEntity parent = ebomService.getParent(materialNo); EBomParentEntity parent = ebomService.getParent(materialNo);
BomCostMultilayerVO vo = new BomCostMultilayerVO(); BomCostMultilayerVO vo = new BomCostMultilayerVO();
vo.setTotalNum(BigDecimal.ONE); vo.setTotalNum(BigDecimal.ONE);
if (!materialMainAttrService.purchaseTypeIsF(parent.getMaterialNo())) {
vo.setHasChildren(true); vo.setHasChildren(true);
buildMultilayerChildren(parent.getRowId(), vo, materials, datas, false); buildMultilayerChildren(parent.getRowId(), vo, materials, datas, false);
}
return Convert.toList(BomCostSingleLayerVO.class, vo.getChildren()); return Convert.toList(BomCostSingleLayerVO.class, vo.getChildren());
} }
@ -96,7 +101,9 @@ public class ProductCostAnalysisService {
vo.setAuxiliaryManufacturingCost(cost.getAuxiliaryManufacturingCost().setScale(2, RoundingMode.UP).toPlainString()); vo.setAuxiliaryManufacturingCost(cost.getAuxiliaryManufacturingCost().setScale(2, RoundingMode.UP).toPlainString());
vo.setTotalAuxiliaryManufacturingCost(cost.getAuxiliaryManufacturingCost().setScale(2, RoundingMode.UP).toPlainString()); vo.setTotalAuxiliaryManufacturingCost(cost.getAuxiliaryManufacturingCost().setScale(2, RoundingMode.UP).toPlainString());
} }
if (!materialMainAttrService.purchaseTypeIsF(parent.getMaterialNo())) {
buildMultilayerChildren(parent.getRowId(), vo, materials, datas, true); buildMultilayerChildren(parent.getRowId(), vo, materials, datas, true);
}
return vo; return vo;
} }
@ -143,7 +150,7 @@ public class ProductCostAnalysisService {
} }
pvo.getChildren().add(cvo); pvo.getChildren().add(cvo);
EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo()); EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo());
if (Objects.nonNull(cparent)) { if (Objects.nonNull(cparent) && !materialMainAttrService.purchaseTypeIsF(cparent.getMaterialNo())) {
cvo.setHasChildren(cparent.getBomExist() == 1); cvo.setHasChildren(cparent.getBomExist() == 1);
if (recursion) { if (recursion) {
buildMultilayerChildren(cparent.getRowId(), cvo, materials, datas, recursion); buildMultilayerChildren(cparent.getRowId(), cvo, materials, datas, recursion);
@ -160,6 +167,7 @@ public class ProductCostAnalysisService {
} }
EBomParentEntity parent = ebomService.getParent(materialNo); EBomParentEntity parent = ebomService.getParent(materialNo);
HighValuePurchasedPartsVO vo = new HighValuePurchasedPartsVO(); HighValuePurchasedPartsVO vo = new HighValuePurchasedPartsVO();
if (!materialMainAttrService.purchaseTypeIsF(materialNo)) {
buildHighValuePurchasedParts(parent.getRowId(), vo, BigDecimal.ONE, price, datas); buildHighValuePurchasedParts(parent.getRowId(), vo, BigDecimal.ONE, price, datas);
Set<String> materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet()); Set<String> materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet());
if (CollectionUtil.isNotEmpty(materialNos)) { if (CollectionUtil.isNotEmpty(materialNos)) {
@ -187,6 +195,7 @@ public class ProductCostAnalysisService {
vo.getCosts().sort(Comparator.comparing(MaterialCostVO::getPrice).reversed()); vo.getCosts().sort(Comparator.comparing(MaterialCostVO::getPrice).reversed());
vo.setTotalCost(vo.getCosts().stream().map(MaterialCostVO::getTotalPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO)); vo.setTotalCost(vo.getCosts().stream().map(MaterialCostVO::getTotalPrice).reduce(BigDecimal::add).orElse(BigDecimal.ZERO));
} }
}
return vo; return vo;
} }