xuhy
2025-10-14 453ee097563df5788f96e102b38249f0ca70d82a
ruoyi-system/src/main/resources/mapper/system/TErpProcurementMapper.xml
@@ -144,5 +144,77 @@
            </if>
        group by date_format(t1.pay_time, '%m.%d')
    </select>
    <select id="supplierSalesStatisticsTypeCount" resultType="java.lang.Integer">
        select count(1)
        from t_erp_procurement tep
        left join t_erp_procurement_goods tepg on tep.id = tepg.procurement_id
        left join t_erp_goods teg on tepg.goods_id = teg.id
        where tep.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        and tep.status in (3,4,5)
        and tep.supplier_id = #{supplierId}
        group by teg.type_id
    </select>
    <select id="supplierSalesStatisticsCount" resultType="java.lang.Integer">
        select count(1)
        from t_erp_procurement tep
         left join t_erp_procurement_goods tepg on tep.id = tepg.procurement_id
        where tep.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
          and tep.status in (3,4,5)
          and tep.supplier_id = #{supplierId}
    </select>
    <select id="supplierSalesStatisticsMoney" resultType="java.math.BigDecimal">
        select sum(pay_money) from t_erp_procurement
        where disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
          and status in (3,4,5)
          and pay_time between #{startTime} and #{endTime}
          and supplier_id = #{supplierId}
    </select>
    <select id="supplierSalesStatisticsGoodsType"
            resultType="com.ruoyi.system.vo.SupplierSalesStatisticsGoodsTypeVO">
        select count(1), tegt.type_name
        from t_erp_procurement tep
                 left join t_erp_procurement_goods tepg on tep.id = tepg.procurement_id
                 left join t_erp_goods teg on tepg.goods_id = teg.id
                 left join t_erp_goods_type tegt on teg.type_id = tegt.id
        where tep.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
          and tep.status in (3,4,5)
          and tep.pay_time between #{startTime} and #{endTime}
          and tep.supplier_id = #{supplierId}
        group by teg.type_id
        order by count(1) desc
    </select>
    <select id="supplierSalesStatisticsGoodsCount"
            resultType="com.ruoyi.system.vo.SupplierSalesStatisticsGoodsCountVO">
        select
        date_format(t1.pay_time, '%m.%d') as `time`,
        date_format(t1.pay_time, '%Y-%m-%d') as payTime,
        sum(t2.purchase_count) as goodsCount
        from t_erp_procurement t1
        left join t_erp_procurement_goods t2 on t1.id = t2.procurement_id
        where t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        and t1.status in (3,4,5)
        and t1.pay_time between #{startTime} and #{endTime}
        and t1.supplier_id = #{supplierId}
        <if test="goodsName != null and goodsName != ''">
            and t2.goods_name like concat('%',#{goodsName},'%')
        </if>
        group by date_format(t1.pay_time, '%m.%d')
    </select>
    <select id="supplierSalesStatisticsGoodsCountMonth"
            resultType="com.ruoyi.system.vo.SupplierSalesStatisticsGoodsCountVO">
        select
        date_format(t1.pay_time, '%Y.%m') as `time`,
        sum(t2.purchase_count) as goodsCount
        from t_erp_procurement t1
        left join t_erp_procurement_goods t2 on t1.id = t2.procurement_id
        where t1.disabled = ${@com.ruoyi.common.enums.DisabledEnum@NO.getCode()}
        and t1.status in (3,4,5)
        and t1.pay_time between #{startTime} and #{endTime}
        and t1.supplier_id = #{supplierId}
        <if test="goodsName != null and goodsName != ''">
            and t2.goods_name like concat('%',#{goodsName},'%')
        </if>
        group by date_format(t1.pay_time, '%Y.%m')
    </select>
</mapper>