浏览代码

采购价格指导 添加前10 供应商价格

yzc 1 年之前
父节点
当前提交
32d4d00a06

+ 5 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/contract/vo/ContractProductVo.java

@@ -207,4 +207,9 @@ public class ContractProductVo extends ContractProduct {
      */
     private String currency;
 
+    /**
+     * 是否结清 1是0否
+     */
+    private Integer isSettled;
+
 }

+ 5 - 0
hx-sale/src/main/java/com/fjhx/sale/entity/purchase/vo/EhsdPurchaseProductVo.java

@@ -61,4 +61,9 @@ public class EhsdPurchaseProductVo extends EhsdPurchaseProduct {
      * 产品规格
      */
     private String productSpec;
+
+    /**
+     * 采购单号
+     */
+    private String purchaseCode;
 }

+ 11 - 0
hx-sale/src/main/java/com/fjhx/sale/service/purchase/impl/EhsdPurchaseServiceImpl.java

@@ -54,7 +54,10 @@ import com.fjhx.sale.service.pack.PackDetailService;
 import com.fjhx.sale.service.purchase.*;
 import com.fjhx.sale.service.sample.SampleProductService;
 import com.fjhx.supply.entity.supplier.po.SupplierInfo;
+import com.fjhx.supply.entity.supplier.po.SupplierPrice;
+import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
 import com.fjhx.supply.service.supplier.SupplierInfoService;
+import com.fjhx.supply.service.supplier.SupplierPriceService;
 import com.ruoyi.common.core.domain.BasePo;
 import com.ruoyi.common.core.domain.BaseSelectDto;
 import com.ruoyi.common.exception.ServiceException;
@@ -121,6 +124,8 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
     private SubscribeDetailService subscribeDetailService;
     @Autowired
     private AccountManagementService accountManagementService;
+    @Autowired
+    private SupplierPriceService supplierPriceService;
 
     /**
      * 分页
@@ -539,6 +544,10 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
         Map<Long, List<EhsdPurchaseProductVo>> purchaseProductMap =
                 purchaseProductList.stream().collect(Collectors.groupingBy(EhsdPurchaseProductVo::getProductId));
 
+        //按价格升序 获取前10供应商
+        List<SupplierPriceVo> topPriceList = supplierPriceService.getTopPriceList(productIds, 10);
+        Map<Long, List<SupplierPriceVo>> topPriceMap = topPriceList.stream().collect(Collectors.groupingBy(SupplierPrice::getProductInfoId));
+
         //处理输出数据
         Map<Long, Map<String, Object>> reData = new HashMap<>();
         for (Long productId : productIds) {
@@ -547,6 +556,8 @@ public class EhsdPurchaseServiceImpl extends ServiceImpl<EhsdPurchaseMapper, Ehs
             data.put("supplyPurchaseProductList", supplyPurchaseProductMap.getOrDefault(productId, new ArrayList<>()));
             //该产品近20条销售价格
             data.put("purchaseProductList", purchaseProductMap.getOrDefault(productId, new ArrayList<>()));
+            //前10供应商价格
+            data.put("topPriceList", topPriceMap.getOrDefault(productId, new ArrayList<>()));
 
             reData.put(productId, data);
         }

+ 3 - 1
hx-sale/src/main/resources/mapper/contract/ContractMapper.xml

@@ -519,7 +519,9 @@
     </select>
     <select id="getProductPriceInfo" resultType="com.fjhx.sale.entity.contract.vo.ContractProductVo">
         SELECT cp.*,
-               c.currency
+               c.currency,
+               c.code contractCode,
+               c.is_settled
         FROM contract_product cp
                  LEFT JOIN contract c ON cp.contract_id = c.id
             ${ew.customSqlSegment}

+ 2 - 1
hx-sale/src/main/resources/mapper/purchase/EhsdPurchaseMapper.xml

@@ -23,7 +23,8 @@
     </update>
 
     <select id="getProductPriceInfo" resultType="com.fjhx.sale.entity.purchase.vo.EhsdPurchaseProductVo">
-        SELECT epp.*
+        SELECT epp.*,
+               ep.code as purchaseCode
         FROM ehsd_purchase_product epp
                  LEFT JOIN ehsd_purchase ep ON epp.purchase_id = ep.id
             ${ew.customSqlSegment}

+ 7 - 0
hx-supply/src/main/java/com/fjhx/supply/mapper/supplier/SupplierPriceMapper.java

@@ -7,6 +7,8 @@ import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
 import com.ruoyi.common.utils.wrapper.IWrapper;
 import org.apache.ibatis.annotations.Param;
 
+import java.util.List;
+
 
 /**
  * <p>
@@ -23,4 +25,9 @@ public interface SupplierPriceMapper extends BaseMapper<SupplierPrice> {
      */
     Page<SupplierPriceVo> getPage(@Param("page") Page<Object> page, @Param("ew") IWrapper<SupplierPrice> wrapper);
 
+    /**
+     * 查某产品前n条低价供应商
+     */
+    List<SupplierPriceVo> getTopPriceList(List<Long> productIds, Integer count);
+
 }

+ 6 - 0
hx-supply/src/main/java/com/fjhx/supply/service/supplier/SupplierPriceService.java

@@ -9,6 +9,7 @@ import com.fjhx.supply.entity.supplier.vo.SupplierPriceVo;
 import com.ruoyi.common.core.service.BaseService;
 
 import java.math.BigDecimal;
+import java.util.List;
 import java.util.Map;
 
 
@@ -48,4 +49,9 @@ public interface SupplierPriceService extends BaseService<SupplierPrice> {
      * 根据供应商id和产品列表获取价格
      */
     Map<Long, BigDecimal> getSupplierPriceByProductIds(SupplierPriceDto dto);
+
+    /**
+     * 查某产品前n条低价供应商
+     */
+    List<SupplierPriceVo> getTopPriceList(List<Long> productIds, Integer count);
 }

+ 5 - 0
hx-supply/src/main/java/com/fjhx/supply/service/supplier/impl/SupplierPriceServiceImpl.java

@@ -172,5 +172,10 @@ public class SupplierPriceServiceImpl extends ServiceImpl<SupplierPriceMapper, S
         return list.stream().collect(Collectors.toMap(SupplierPrice::getProductInfoId, SupplierPrice::getPrice));
     }
 
+    @Override
+    public List<SupplierPriceVo> getTopPriceList(List<Long> productIds, Integer count) {
+        return baseMapper.getTopPriceList(productIds, count);
+    }
+
 
 }

+ 25 - 2
hx-supply/src/main/resources/mapper/supplier/SupplierPriceMapper.xml

@@ -6,11 +6,34 @@
                sp.supplier_info_id,
                sp.product_info_id,
                sp.price,
-               si.name       supplierName,
-               si.type       supplierType
+               si.name supplierName,
+               si.type supplierType
         from supplier_price sp
                  inner join supplier_info si on sp.supplier_info_id = si.id
             ${ew.customSqlSegment}
     </select>
+    <select id="getTopPriceList" resultType="com.fjhx.supply.entity.supplier.vo.SupplierPriceVo">
+        SELECT
+        t1.*,
+        si.`name` AS supplierName
+        FROM
+        (
+        SELECT
+        sp.supplier_info_id,
+        sp.product_info_id,
+        sp.price,
+        @row_number :=IF( @product_info_id = sp.product_info_id, @row_number + 1, 1 ) AS row_number
+        FROM
+        supplier_price sp,(SELECT @row_number := 0) b
+        ORDER BY
+        sp.price ASC
+        ) t1
+        left join supplier_info si on t1.supplier_info_id = si.id
+        where
+        t1.row_number &lt;= #{count}
+        <foreach collection="productIds" item="productId" open="AND t1.product_info_id IN (" separator="," close=")">
+            #{productId}
+        </foreach>
+    </select>
 
 </mapper>