fix(成本分析): 计算高价值外购件添加null判断,因为如果是T项的话是没有缓存数据的
This commit is contained in:
parent
83d886d1e1
commit
c47d47d62e
|
|
@ -192,25 +192,29 @@ public class ProductCostAnalysisService {
|
||||||
|
|
||||||
private void buildHighValuePurchasedParts(Long parentRowId, HighValuePurchasedPartsVO pvo, BigDecimal num, BigDecimal price, List<EBomCostCacheDTO> datas) {
|
private void buildHighValuePurchasedParts(Long parentRowId, HighValuePurchasedPartsVO pvo, BigDecimal num, BigDecimal price, List<EBomCostCacheDTO> datas) {
|
||||||
List<EBomChildEntity> children = ebomService.getChildren(parentRowId);
|
List<EBomChildEntity> children = ebomService.getChildren(parentRowId);
|
||||||
children.parallelStream().forEach(child -> {
|
children.forEach(child -> {
|
||||||
EBomCostCacheDTO ccost = datas.stream().filter(d -> StrUtil.equals(d.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
|
EBomCostCacheDTO ccost = datas.stream().filter(d -> StrUtil.equals(d.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
|
||||||
BigDecimal tnum = child.getNum().multiply(num);
|
BigDecimal tnum = child.getNum().multiply(num);
|
||||||
if (ccost.isPurchasedParts() && ccost.getTotalCost().compareTo(price) >= 0) {
|
if (Objects.isNull(ccost)) {
|
||||||
MaterialCostVO cvo;
|
log.error("没有找到{}的缓存数据", child.getMaterialNo());
|
||||||
cvo = pvo.getCosts().stream().filter(v -> StrUtil.equals(v.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
|
} else {
|
||||||
if (Objects.isNull(cvo)) {
|
if (ccost.isPurchasedParts() && ccost.getTotalCost().compareTo(price) >= 0) {
|
||||||
cvo = new MaterialCostVO();
|
MaterialCostVO cvo;
|
||||||
cvo.setMaterialNo(child.getMaterialNo());
|
cvo = pvo.getCosts().stream().filter(v -> StrUtil.equals(v.getMaterialNo(), child.getMaterialNo())).findFirst().orElse(null);
|
||||||
cvo.setPrice(ccost.getTotalCost());
|
if (Objects.isNull(cvo)) {
|
||||||
cvo.setNum(tnum);
|
cvo = new MaterialCostVO();
|
||||||
pvo.getCosts().add(cvo);
|
cvo.setMaterialNo(child.getMaterialNo());
|
||||||
} else {
|
cvo.setPrice(ccost.getTotalCost());
|
||||||
cvo.setNum(cvo.getNum().add(tnum));
|
cvo.setNum(tnum);
|
||||||
|
pvo.getCosts().add(cvo);
|
||||||
|
} else {
|
||||||
|
cvo.setNum(cvo.getNum().add(tnum));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo());
|
||||||
|
if (Objects.nonNull(cparent)) {
|
||||||
|
buildHighValuePurchasedParts(cparent.getRowId(), pvo, tnum, price, datas);
|
||||||
}
|
}
|
||||||
}
|
|
||||||
EBomParentEntity cparent = ebomService.getParent(child.getMaterialNo());
|
|
||||||
if (Objects.nonNull(cparent)) {
|
|
||||||
buildHighValuePurchasedParts(cparent.getRowId(), pvo, tnum, price, datas);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue