|
@@ -5,7 +5,6 @@ import cn.hutool.core.util.ObjectUtil;
|
|
|
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
|
|
|
import com.fjhx.common.utils.Assert;
|
|
|
import com.fjhx.item.entity.product.ProcessesBo;
|
|
|
-import com.fjhx.item.entity.product.po.ProductInfo;
|
|
|
import com.fjhx.item.service.product.ProductInfoService;
|
|
|
import com.fjhx.sale.entity.quotation.dto.QuotationEstimateDto;
|
|
|
import com.fjhx.sale.entity.quotation.po.QuotationEstimate;
|
|
@@ -17,6 +16,7 @@ import com.fjhx.sale.entity.quotation.vo.QuotationProductVo;
|
|
|
import com.fjhx.sale.entity.sale.po.SaleQuotation;
|
|
|
import com.fjhx.sale.entity.sale.vo.SaleQuotationVo;
|
|
|
import com.fjhx.sale.mapper.quotation.QuotationEstimateMapper;
|
|
|
+import com.fjhx.sale.service.purchase.EhsdPurchaseProductService;
|
|
|
import com.fjhx.sale.service.quotation.QuotationEstimateService;
|
|
|
import com.fjhx.sale.service.quotation.QuotationProductBomService;
|
|
|
import com.fjhx.sale.service.quotation.QuotationProductService;
|
|
@@ -51,13 +51,15 @@ public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateM
|
|
|
private final QuotationProductService quotationProductService;
|
|
|
private final ProductInfoService productInfoService;
|
|
|
private final SaleQuotationService saleQuotationService;
|
|
|
+ private final EhsdPurchaseProductService purchaseProductService;
|
|
|
|
|
|
@Autowired
|
|
|
- public QuotationEstimateServiceImpl(QuotationProductBomService quotationProductBomService, QuotationProductService quotationProductService, ProductInfoService productInfoService, SaleQuotationService saleQuotationService) {
|
|
|
+ public QuotationEstimateServiceImpl(QuotationProductBomService quotationProductBomService, QuotationProductService quotationProductService, ProductInfoService productInfoService, SaleQuotationService saleQuotationService, EhsdPurchaseProductService purchaseProductService) {
|
|
|
this.quotationProductBomService = quotationProductBomService;
|
|
|
this.quotationProductService = quotationProductService;
|
|
|
this.productInfoService = productInfoService;
|
|
|
this.saleQuotationService = saleQuotationService;
|
|
|
+ this.purchaseProductService = purchaseProductService;
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -68,6 +70,9 @@ public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateM
|
|
|
QuotationProduct quotationProduct = quotationProductService.getById(quotationProductId);
|
|
|
Assert.notEmpty(quotationProduct, "查询不到报价明细信息!");
|
|
|
|
|
|
+ SaleQuotation saleQuotation = saleQuotationService.getById(quotationProduct.getSaleQuotationId());
|
|
|
+ Assert.notEmpty(saleQuotation, "查询不到报价单信息!");
|
|
|
+
|
|
|
// Long technologyId = quotationProduct.getTechnologyId();
|
|
|
|
|
|
//查询现有报价信息
|
|
@@ -84,12 +89,18 @@ public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateM
|
|
|
);
|
|
|
|
|
|
List<Long> mIds = list1.stream().map(QuotationProductBom::getMaterialId).collect(Collectors.toList());
|
|
|
- Map<Long, ProductInfo> materialInfoMap = productInfoService.mapKEntity(ProductInfo::getId, q -> q.in(ProductInfo::getId, mIds));
|
|
|
+// Map<Long, ProductInfo> materialInfoMap = productInfoService.mapKEntity(ProductInfo::getId, q -> q.in(ProductInfo::getId, mIds));
|
|
|
|
|
|
//获取工序信息
|
|
|
List<ProcessesBo> processesList = baseMapper.getProductionProcessesList();
|
|
|
Map<Long, ProcessesBo> collect = processesList.stream().collect(Collectors.toMap(ProcessesBo::getId, Function.identity()));
|
|
|
|
|
|
+ //获取最后一次采购价格
|
|
|
+ Map<Long, BigDecimal> lastPurchasePriceMap = purchaseProductService.getLastPurchasePrice(IWrapper.getWrapper()
|
|
|
+ .in("epp.product_id", mIds)
|
|
|
+ .eq("ep.company_id", saleQuotation.getOfCompanyId())
|
|
|
+ );
|
|
|
+
|
|
|
//获取产品BOM
|
|
|
for (QuotationProductBom quotationProductBom : list1) {
|
|
|
QuotationEstimateVo quotationEstimate = new QuotationEstimateVo();
|
|
@@ -99,10 +110,11 @@ public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateM
|
|
|
quotationEstimate.setType(quotationProductBom.getType());
|
|
|
|
|
|
//赋值单价信息
|
|
|
- ProductInfo materialId = materialInfoMap.get(quotationProductBom.getMaterialId());
|
|
|
- if (ObjectUtil.isNotEmpty(materialId)) {
|
|
|
- quotationEstimate.setPrice(materialId.getPrice());
|
|
|
- }
|
|
|
+ quotationEstimate.setPrice(lastPurchasePriceMap.get(quotationProductBom.getMaterialId()));
|
|
|
+// ProductInfo materialId = materialInfoMap.get(quotationProductBom.getMaterialId());
|
|
|
+// if (ObjectUtil.isNotEmpty(materialId)) {
|
|
|
+// quotationEstimate.setPrice(materialId.getPrice());
|
|
|
+// }
|
|
|
|
|
|
//原材料不赋值数量
|
|
|
if (ObjectUtil.notEqual(quotationProductBom.getType(), 1)) {
|