<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.ruoyi.web.v2.v1.mapper.JsDistributionMapper">

    <select id="getAllList" resultType="com.ruoyi.web.v2.v1.entity.vo.ProductionVo">
select b.productName produceName,a.afterWeight weight,a.amount amount,b.unit unit FROM
(select produce_name produceName,convert(SUM(after_weight),decimal(10,2)) afterWeight,SUM(amount) amount FROM js_distribution where purchaser_name=#{purchaserName}
        <if test="startTime != null">
            AND distribution_time between #{startTime} and #{endTime}
        </if>
GROUP BY produce_name)
 as a right JOIN
(select product_name productName,unit unit FROM product_category WHERE del_flag='0') AS b
on a.produceName=b.productName

    </select>

    <select id="getAllList1" resultType="com.ruoyi.web.v2.v1.entity.vo.ProductionVo">
        select b.productName produceName,a.afterWeight weight,a.amount amount,b.unit unit FROM
        (select produce_name produceName,convert(SUM(after_weight),decimal(10,2)) afterWeight,SUM(amount) amount FROM js_distribution where purchaser_name=#{purchaserName}
        and supplier_name=#{supplierName}
        <if test="startTime != null">
            AND distribution_time between #{startTime} and #{endTime}
        </if>
        GROUP BY produce_name)
        as a right JOIN
        (select product_name productName,unit unit FROM product_category WHERE del_flag='0') AS b
        on a.produceName=b.productName

    </select>
</mapper>
