| | |
| | | Map<Long, MdmItemRespDTO> itemMap = mdmItemApi.getItemList(productIds).getCheckedData() |
| | | .stream().collect(Collectors.toMap(MdmItemRespDTO::getId, Function.identity())); |
| | | |
| | | // 6. 构建订单项(报价为总价,需除以数量得到单价) |
| | | BigDecimal totalQuoteAmount = quotes.stream() |
| | | .map(SrmSupplierQuoteDO::getQuotePrice) |
| | | .reduce(BigDecimal.ZERO, BigDecimal::add); |
| | | // 6. 构建订单项(报价为“单价”口径:行金额 = 报价单价 × 数量; |
| | | // 定标金额与报价合计不一致时按行金额比例分摊,订单行单价仍取报价单价) |
| | | BigDecimal totalQuoteAmount = BigDecimal.ZERO; |
| | | for (SrmTenderMaterialDO material : materials) { |
| | | SrmSupplierQuoteDO quote = quoteMap.get(material.getId()); |
| | | BigDecimal quantity = material.getQuantity(); |
| | | if (quote == null || quote.getQuotePrice() == null |
| | | || quantity == null || quantity.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | totalQuoteAmount = totalQuoteAmount.add(quote.getQuotePrice().multiply(quantity)); |
| | | } |
| | | BigDecimal awardAmount = award.getAwardAmount() != null ? award.getAwardAmount() : totalQuoteAmount; |
| | | BigDecimal ratio = totalQuoteAmount.compareTo(BigDecimal.ZERO) > 0 |
| | | ? awardAmount.divide(totalQuoteAmount, 8, RoundingMode.HALF_UP) |
| | |
| | | List<ErpPurchaseOrderCreateReqDTO.Item> orderItems = new ArrayList<>(); |
| | | for (SrmTenderMaterialDO material : materials) { |
| | | SrmSupplierQuoteDO quote = quoteMap.get(material.getId()); |
| | | if (quote == null) { |
| | | if (quote == null || quote.getQuotePrice() == null) { |
| | | continue; |
| | | } |
| | | BigDecimal quantity = material.getQuantity(); |
| | | if (quantity == null || quantity.compareTo(BigDecimal.ZERO) <= 0) { |
| | | continue; |
| | | } |
| | | MdmItemRespDTO mdmItem = itemMap.get(material.getProductId()); |
| | | if (mdmItem == null) { |
| | | continue; |
| | | } |
| | | BigDecimal materialTotal = quote.getQuotePrice().multiply(ratio); |
| | | BigDecimal unitPrice = materialTotal.divide(material.getQuantity(), 4, RoundingMode.HALF_UP); |
| | | BigDecimal unitPrice = quote.getQuotePrice().multiply(ratio).setScale(4, RoundingMode.HALF_UP); |
| | | ErpPurchaseOrderCreateReqDTO.Item item = new ErpPurchaseOrderCreateReqDTO.Item(); |
| | | item.setProductId(material.getProductId()); |
| | | item.setProductUnitId(mdmItem.getUnitMeasureId()); |
| | | item.setProductPrice(unitPrice); |
| | | item.setCount(material.getQuantity()); |
| | | item.setCount(quantity); |
| | | item.setTaxPercent(quote.getTaxRate()); |
| | | item.setRemark("招标编号: " + award.getAwardNo()); |
| | | orderItems.add(item); |