fix(成本分析): 采购类型F和E50逻辑调整
This commit is contained in:
parent
d8eecd5e53
commit
51a55f647c
|
|
@ -48,6 +48,9 @@ public class ProductCostAnalysisService {
|
|||
@Resource
|
||||
private BomCostService bomCostService;
|
||||
|
||||
@Resource
|
||||
private MaterialMainAttrService materialMainAttrService;
|
||||
|
||||
public List<BomCostSingleLayerVO> getBomCostSingleLayer(String materialNo) {
|
||||
List<EBomCostCacheDTO> 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<String> materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet());
|
||||
if (CollectionUtil.isNotEmpty(materialNos)) {
|
||||
List<EBomDTO> materials = materialMainService.getInfos(materialNos);
|
||||
Iterator<MaterialCostVO> 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<String> materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet());
|
||||
if (CollectionUtil.isNotEmpty(materialNos)) {
|
||||
List<EBomDTO> materials = materialMainService.getInfos(materialNos);
|
||||
Iterator<MaterialCostVO> 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;
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue