|
|
@ -20,6 +20,8 @@ import org.springframework.stereotype.Service; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.transaction.annotation.Transactional; |
|
|
import org.springframework.util.StringUtils; |
|
|
import org.springframework.util.StringUtils; |
|
|
|
|
|
|
|
|
|
|
|
import java.math.BigDecimal; |
|
|
|
|
|
import java.math.RoundingMode; |
|
|
import java.util.*; |
|
|
import java.util.*; |
|
|
import java.util.stream.Collectors; |
|
|
import java.util.stream.Collectors; |
|
|
|
|
|
|
|
|
@ -142,19 +144,21 @@ public class QuoteRoutingHeaderServiceImpl extends ServiceImpl<QuoteRoutingHeade |
|
|
.eq(QuoteRoutingDetail::getHeaderId,quoteRoutingHeader.getId()).remove(); |
|
|
.eq(QuoteRoutingDetail::getHeaderId,quoteRoutingHeader.getId()).remove(); |
|
|
// 查询 routing信息 |
|
|
// 查询 routing信息 |
|
|
List<QuoteRoutingDetail> quoteRoutingDetails = baseMapper.getRoutingComponentEntityList(quoteRoutingHeader); |
|
|
List<QuoteRoutingDetail> quoteRoutingDetails = baseMapper.getRoutingComponentEntityList(quoteRoutingHeader); |
|
|
// todo 删除 routing |
|
|
|
|
|
// 判断是 header 存在parentId 不存在不是最上层 工艺 不需要修改工具信息 否则需要删除工具信息并新增最新版 |
|
|
// 判断是 header 存在parentId 不存在不是最上层 工艺 不需要修改工具信息 否则需要删除工具信息并新增最新版 |
|
|
QuoteRoutingHeader routingHeader = lambdaQuery().eq(QuoteRoutingHeader::getId, quoteRoutingHeader.getId()).one(); |
|
|
QuoteRoutingHeader routingHeader = lambdaQuery().eq(QuoteRoutingHeader::getId, quoteRoutingHeader.getId()).one(); |
|
|
if (Objects.nonNull(routingHeader) && routingHeader.getParentId() == 0){ |
|
|
|
|
|
// 处理工具 |
|
|
|
|
|
// 删除工具 并 新增 调用删除工具新增工具方法,该方法需要计算 单位报价成本 预计使用寿命 为 1 其他值复制过来 参数为 |
|
|
|
|
|
generateQuotationTools(quoteRoutingHeader); |
|
|
|
|
|
} |
|
|
|
|
|
// 新增 Detail |
|
|
// 新增 Detail |
|
|
|
|
|
// 删除工具信息 todo 待优化不明确是否删除哪些工具信息 |
|
|
|
|
|
quotationToolService.lambdaUpdate() |
|
|
|
|
|
.eq(QuotationTool::getQuotationDetailId,routingHeader.getQuoteDetailId()) |
|
|
|
|
|
.remove(); |
|
|
for (QuoteRoutingDetail quoteRoutingDetail : quoteRoutingDetails) { |
|
|
for (QuoteRoutingDetail quoteRoutingDetail : quoteRoutingDetails) { |
|
|
quoteRoutingDetail.setQuoteDetailId(quoteRoutingHeader.getQuoteDetailId()); |
|
|
quoteRoutingDetail.setQuoteDetailId(quoteRoutingHeader.getQuoteDetailId()); |
|
|
quoteRoutingDetail.setHeaderId(quoteRoutingHeader.getId()); |
|
|
quoteRoutingDetail.setHeaderId(quoteRoutingHeader.getId()); |
|
|
quoteRoutingDetailService.save(quoteRoutingDetail); |
|
|
quoteRoutingDetailService.save(quoteRoutingDetail); |
|
|
|
|
|
if (Long.valueOf(0).equals(routingHeader.getParentId())){ |
|
|
|
|
|
// 处理工具 |
|
|
|
|
|
generateQuotationTools(0L,quoteRoutingDetail); |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
@ -243,19 +247,42 @@ public class QuoteRoutingHeaderServiceImpl extends ServiceImpl<QuoteRoutingHeade |
|
|
save(routingHeader); |
|
|
save(routingHeader); |
|
|
// 新增 Details |
|
|
// 新增 Details |
|
|
List<QuoteRoutingDetail> availableList = baseMapper.getRoutingComponentEntityAvailableList(routingHeader); |
|
|
List<QuoteRoutingDetail> availableList = baseMapper.getRoutingComponentEntityAvailableList(routingHeader); |
|
|
|
|
|
// 删除工具信息 todo 待优化不明确是否删除哪些工具信息 |
|
|
|
|
|
quotationToolService.lambdaUpdate() |
|
|
|
|
|
.eq(QuotationTool::getQuotationDetailId,routingHeader.getQuoteDetailId()) |
|
|
|
|
|
.remove(); |
|
|
for (QuoteRoutingDetail routingDetail : availableList) { |
|
|
for (QuoteRoutingDetail routingDetail : availableList) { |
|
|
routingDetail.setQuoteDetailId(routingHeader.getQuoteDetailId()); |
|
|
routingDetail.setQuoteDetailId(routingHeader.getQuoteDetailId()); |
|
|
routingDetail.setHeaderId(routingHeader.getId()); |
|
|
routingDetail.setHeaderId(routingHeader.getId()); |
|
|
quoteRoutingDetailService.save(routingDetail); |
|
|
quoteRoutingDetailService.save(routingDetail); |
|
|
|
|
|
generateQuotationTools(parentId, routingDetail); |
|
|
} |
|
|
} |
|
|
saveAllQuoteBomHeader(bomHeaderVo.getList(),routingHeader.getId()); |
|
|
saveAllQuoteBomHeader(bomHeaderVo.getList(),routingHeader.getId()); |
|
|
} |
|
|
} |
|
|
return routingHeader; |
|
|
return routingHeader; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private List<QuotationTool> generateQuotationTools(QuoteRoutingHeader routingHeader) { |
|
|
|
|
|
|
|
|
|
|
|
return null; |
|
|
|
|
|
|
|
|
private void generateQuotationTools(Long parentId, QuoteRoutingDetail routingDetail) { |
|
|
|
|
|
if (Objects.isNull(parentId) || Long.valueOf(0).equals(parentId)){ |
|
|
|
|
|
// 如果为零说明是最上层 处理工具信息 |
|
|
|
|
|
// 1、查询工具信息 |
|
|
|
|
|
List<QuotationTool> toolList = baseMapper.queryRoutingTool(routingDetail); |
|
|
|
|
|
for (QuotationTool tool : toolList) { |
|
|
|
|
|
if (Objects.isNull(tool.getToolQuantity()) || tool.getToolQuantity().compareTo(BigDecimal.ZERO) == 0){ |
|
|
|
|
|
tool.setQuotationUnitCost(BigDecimal.ZERO); |
|
|
|
|
|
}else if (Objects.isNull(tool.getUnitCost()) || tool.getUnitCost().compareTo(BigDecimal.ZERO) == 0){ |
|
|
|
|
|
tool.setQuotationUnitCost(BigDecimal.ZERO); |
|
|
|
|
|
}else if (Objects.isNull(tool.getExpectedServiceLife()) || tool.getExpectedServiceLife().compareTo(BigDecimal.ZERO) == 0){ |
|
|
|
|
|
tool.setExpectedServiceLife(BigDecimal.ONE); |
|
|
|
|
|
}else { |
|
|
|
|
|
BigDecimal quoteUnitQuote; |
|
|
|
|
|
quoteUnitQuote = tool.getUnitCost().multiply(tool.getToolQuantity()); |
|
|
|
|
|
quoteUnitQuote = quoteUnitQuote.divide(tool.getExpectedServiceLife(),4 , RoundingMode.HALF_UP); |
|
|
|
|
|
tool.setQuotationUnitCost(quoteUnitQuote); |
|
|
|
|
|
} |
|
|
|
|
|
// 2、新增工具信息 |
|
|
|
|
|
quotationToolService.save(tool); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
} |