fix(成本分析): 采购类型F和E50逻辑调整
This commit is contained in:
parent
d8eecd5e53
commit
51a55f647c
|
|
@ -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);
|
||||||
vo.setHasChildren(true);
|
if (!materialMainAttrService.purchaseTypeIsF(parent.getMaterialNo())) {
|
||||||
buildMultilayerChildren(parent.getRowId(), vo, materials, datas, false);
|
vo.setHasChildren(true);
|
||||||
|
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());
|
||||||
}
|
}
|
||||||
buildMultilayerChildren(parent.getRowId(), vo, materials, datas, true);
|
if (!materialMainAttrService.purchaseTypeIsF(parent.getMaterialNo())) {
|
||||||
|
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,32 +167,34 @@ public class ProductCostAnalysisService {
|
||||||
}
|
}
|
||||||
EBomParentEntity parent = ebomService.getParent(materialNo);
|
EBomParentEntity parent = ebomService.getParent(materialNo);
|
||||||
HighValuePurchasedPartsVO vo = new HighValuePurchasedPartsVO();
|
HighValuePurchasedPartsVO vo = new HighValuePurchasedPartsVO();
|
||||||
buildHighValuePurchasedParts(parent.getRowId(), vo, BigDecimal.ONE, price, datas);
|
if (!materialMainAttrService.purchaseTypeIsF(materialNo)) {
|
||||||
Set<String> materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet());
|
buildHighValuePurchasedParts(parent.getRowId(), vo, BigDecimal.ONE, price, datas);
|
||||||
if (CollectionUtil.isNotEmpty(materialNos)) {
|
Set<String> materialNos = vo.getCosts().stream().map(MaterialCostVO::getMaterialNo).collect(Collectors.toSet());
|
||||||
List<EBomDTO> materials = materialMainService.getInfos(materialNos);
|
if (CollectionUtil.isNotEmpty(materialNos)) {
|
||||||
Iterator<MaterialCostVO> iterator = vo.getCosts().iterator();
|
List<EBomDTO> materials = materialMainService.getInfos(materialNos);
|
||||||
while (iterator.hasNext()) {
|
Iterator<MaterialCostVO> iterator = vo.getCosts().iterator();
|
||||||
MaterialCostVO element = iterator.next();
|
while (iterator.hasNext()) {
|
||||||
EBomDTO cpm = materials.stream().filter(m -> StrUtil.equals(m.getMaterialNo(), element.getMaterialNo()))
|
MaterialCostVO element = iterator.next();
|
||||||
.findFirst()
|
EBomDTO cpm = materials.stream().filter(m -> StrUtil.equals(m.getMaterialNo(), element.getMaterialNo()))
|
||||||
.orElse(null);
|
.findFirst()
|
||||||
if (Objects.nonNull(cpm) && BigDecimalUtil.compareTo(cpm.getMaterialPrice(), price) > 0) {
|
.orElse(null);
|
||||||
element.setMaterialDesc(cpm.getMaterialDesc());
|
if (Objects.nonNull(cpm) && BigDecimalUtil.compareTo(cpm.getMaterialPrice(), price) > 0) {
|
||||||
element.setMaterialCategoryName(cpm.getCategoryName());
|
element.setMaterialDesc(cpm.getMaterialDesc());
|
||||||
element.setMaterialUnit(cpm.getMaterialUnit());
|
element.setMaterialCategoryName(cpm.getCategoryName());
|
||||||
element.setMaterialRowId(cpm.getMaterialRowId());
|
element.setMaterialUnit(cpm.getMaterialUnit());
|
||||||
element.setRelCategoryCode(cpm.getRelCategoryCode());
|
element.setMaterialRowId(cpm.getMaterialRowId());
|
||||||
element.setInventory(cpm.getInventory());
|
element.setRelCategoryCode(cpm.getRelCategoryCode());
|
||||||
element.setLeadTime(cpm.getLeadTime());
|
element.setInventory(cpm.getInventory());
|
||||||
element.setPrice(cpm.getMaterialPrice());
|
element.setLeadTime(cpm.getLeadTime());
|
||||||
element.setTotalPrice(element.getPrice().multiply(element.getNum()));
|
element.setPrice(cpm.getMaterialPrice());
|
||||||
} else {
|
element.setTotalPrice(element.getPrice().multiply(element.getNum()));
|
||||||
iterator.remove();
|
} 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;
|
return vo;
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue