Explorar el Código

报价评估价格回填

yzc hace 1 año
padre
commit
6819a55072

+ 9 - 5
hx-sale/src/main/java/com/fjhx/sale/service/quotation/impl/QuotationEstimateServiceImpl.java

@@ -28,6 +28,8 @@ import java.math.RoundingMode;
 import java.util.ArrayList;
 import java.util.Date;
 import java.util.List;
+import java.util.Map;
+import java.util.stream.Collectors;
 
 
 /**
@@ -70,6 +72,9 @@ public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateM
             quotationEstimateVos = new ArrayList<>();
             List<QuotationProductBom> list1 = quotationProductBomService.list(q -> q.eq(QuotationProductBom::getQuotationProductId, quotationProductId));
 
+            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));
+
             //获取产品BOM
             for (QuotationProductBom quotationProductBom : list1) {
                 QuotationEstimateVo quotationEstimate = new QuotationEstimateVo();
@@ -78,11 +83,10 @@ public class QuotationEstimateServiceImpl extends ServiceImpl<QuotationEstimateM
                 quotationEstimate.setMaterialId(quotationProductBom.getMaterialId());
                 quotationEstimate.setType(quotationProductBom.getType());
 
-                //原材料获取物料库单价
-                if (ObjectUtil.equals(quotationProductBom.getType(), 1)) {
-                    ProductInfo productInfo = productInfoService.getById(quotationProductBom.getMaterialId());
-                    Assert.notEmpty(productInfo, "查询不到原材料信息");
-                    quotationProductBom.setPrice(productInfo.getPrice());
+                //赋值单价信息
+                ProductInfo materialId = materialInfoMap.get(quotationProductBom.getMaterialId());
+                if (ObjectUtil.isNotEmpty(materialId)) {
+                    quotationEstimate.setPrice(materialId.getPrice());
                 }
 
                 //原材料不赋值数量