feat(产品成本分析): BOM组件成本分析
This commit is contained in:
parent
8665c1a793
commit
1d6e8b9296
|
|
@ -68,7 +68,10 @@ public class BomCostCalculateService {
|
||||||
VUtils.isTure(StrUtil.isBlank(materialNo)).throwMessage("物料编号不能为空");
|
VUtils.isTure(StrUtil.isBlank(materialNo)).throwMessage("物料编号不能为空");
|
||||||
List<EBomDTO> datas = new ArrayList<>();
|
List<EBomDTO> datas = new ArrayList<>();
|
||||||
EBomParentEntity parent = ebomService.getParent(materialNo);
|
EBomParentEntity parent = ebomService.getParent(materialNo);
|
||||||
VUtils.isTure(Objects.isNull(parent)).throwMessage("未找到BOM: " + materialNo);
|
// VUtils.isTure(Objects.isNull(parent)).throwMessage("未找到BOM: " + materialNo);
|
||||||
|
if (Objects.isNull(parent)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
log.debug(StrUtil.format("BOM成本计算 {} 起始节点", materialNo));
|
log.debug(StrUtil.format("BOM成本计算 {} 起始节点", materialNo));
|
||||||
EBomDTO pDto = convert(parent);
|
EBomDTO pDto = convert(parent);
|
||||||
datas.add(pDto);
|
datas.add(pDto);
|
||||||
|
|
|
||||||
|
|
@ -1,5 +1,6 @@
|
||||||
package com.nflg.product.technology.service;
|
package com.nflg.product.technology.service;
|
||||||
|
|
||||||
|
import cn.hutool.core.collection.CollectionUtil;
|
||||||
import cn.hutool.core.util.StrUtil;
|
import cn.hutool.core.util.StrUtil;
|
||||||
import com.nflg.product.technology.constant.BomConstant;
|
import com.nflg.product.technology.constant.BomConstant;
|
||||||
import com.nflg.product.technology.pojo.dto.EBomCostCacheDTO;
|
import com.nflg.product.technology.pojo.dto.EBomCostCacheDTO;
|
||||||
|
|
@ -19,10 +20,7 @@ import javax.validation.constraints.NotBlank;
|
||||||
import java.math.BigDecimal;
|
import java.math.BigDecimal;
|
||||||
import java.time.LocalDateTime;
|
import java.time.LocalDateTime;
|
||||||
import java.time.format.DateTimeFormatter;
|
import java.time.format.DateTimeFormatter;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Objects;
|
|
||||||
import java.util.Set;
|
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -53,6 +51,9 @@ public class ProductCostAnalysisService {
|
||||||
|
|
||||||
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)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
EBomParentEntity parent = ebomService.getParent(materialNo);
|
EBomParentEntity parent = ebomService.getParent(materialNo);
|
||||||
return buildSingleLayerChildren(parent.getRowId(), datas);
|
return buildSingleLayerChildren(parent.getRowId(), datas);
|
||||||
}
|
}
|
||||||
|
|
@ -95,6 +96,9 @@ public class ProductCostAnalysisService {
|
||||||
|
|
||||||
public BomCostMultilayerVO getBomCostMultilayer(String materialNo) {
|
public BomCostMultilayerVO getBomCostMultilayer(String materialNo) {
|
||||||
List<EBomCostCacheDTO> datas = bomCostCalculateService.calculate(materialNo);
|
List<EBomCostCacheDTO> datas = bomCostCalculateService.calculate(materialNo);
|
||||||
|
if (CollectionUtil.isEmpty(datas)) {
|
||||||
|
return new BomCostMultilayerVO();
|
||||||
|
}
|
||||||
List<EBomDTO> materials = materialMainService.getInfos(datas.stream().map(EBomCostCacheDTO::getMaterialNo).collect(Collectors.toSet()));
|
List<EBomDTO> materials = materialMainService.getInfos(datas.stream().map(EBomCostCacheDTO::getMaterialNo).collect(Collectors.toSet()));
|
||||||
EBomParentEntity parent = ebomService.getParent(materialNo);
|
EBomParentEntity parent = ebomService.getParent(materialNo);
|
||||||
BomCostMultilayerVO vo = new BomCostMultilayerVO();
|
BomCostMultilayerVO vo = new BomCostMultilayerVO();
|
||||||
|
|
@ -291,7 +295,9 @@ public class ProductCostAnalysisService {
|
||||||
|
|
||||||
public void saveCost(String materialNo) {
|
public void saveCost(String materialNo) {
|
||||||
List<EBomCostCacheDTO> datas = bomCostCalculateService.calculate(materialNo);
|
List<EBomCostCacheDTO> datas = bomCostCalculateService.calculate(materialNo);
|
||||||
bomCostService.save(datas);
|
if (CollectionUtil.isNotEmpty(datas)) {
|
||||||
|
bomCostService.save(datas);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<String> getCostVersion(@Valid @NotBlank String materialNo) {
|
public List<String> getCostVersion(@Valid @NotBlank String materialNo) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue