智慧农业后台管理
guoshilong
2022-07-22 fdff4ca4813fc77a9006309ed4e5c232b4f3c85e
src/main/java/org/springblade/modules/farmplant/mapper/FarmProductStockMapper.xml
@@ -4,9 +4,10 @@
    <!--自定义查询农产品库存分页数据-->
    <select id="selectFarmProductStockPage" resultType="org.springblade.modules.farmplant.vo.FarmProductStockVO">
        select sfps.strain_id strainId,sfps.land_id,sum(sfps.weight) weight,ss.url,ss.strain_name strainName from
        select sfps.id,sfps.strain_id strainId,sfps.land_id,sum(sfps.weight) weight,ss.url,ss.strain_name strainName from
        sys_farm_product_stock sfps
        left join sys_strain ss on ss.id = sfps.strain_id
        left join sys_land sl on sl.id = sfps.land_id
        where 1=1
        <if test="farmProductStock.strainId!=null and farmProductStock.strainId!=''">
            and sfps.strain_id = #{farmProductStock.strainId}
@@ -26,13 +27,17 @@
        <if test="farmProductStock.tenantId!=null and farmProductStock.tenantId!=''">
            and sfps.tenant_id = #{farmProductStock.tenantId}
        </if>
        group by sfps.strain_id,ss.url,ss.strain_name,sfps.land_id
        <if test="farmProductStock.farmId!=null and farmProductStock.farmId!=''">
            and sl.farm_id = #{farmProductStock.farmId}
        </if>
        group by sfps.id,sfps.strain_id,ss.url,ss.strain_name,sfps.land_id
    </select>
    <select id="selectFarmProductStockPages" resultType="org.springblade.modules.farmplant.vo.FarmProductStockVO">
        select sfps.strain_id strainId,sfps.land_id,sum(sfps.weight) weight,ss.url,ss.strain_name strainName from
        sys_farm_product_stock sfps
        left join sys_strain ss on ss.id = sfps.strain_id
        left join sys_land sl on sl.id = sfps.land_id
        where 1=1
        <if test="farmProductStock.strainId!=null and farmProductStock.strainId!=''">
            and sfps.strain_id = #{farmProductStock.strainId}
@@ -51,6 +56,9 @@
        </if>
        <if test="farmProductStock.tenantId!=null and farmProductStock.tenantId!=''">
            and sfps.tenant_id = #{farmProductStock.tenantId}
        </if>
        <if test="farmProductStock.farmId!=null and farmProductStock.farmId!=''">
            and sl.farm_id = #{farmProductStock.farmId}
        </if>
        group by sfps.strain_id,ss.url,ss.strain_name,sfps.land_id
    </select>
@@ -58,9 +66,10 @@
    <!--查询农产品库存数据-->
    <select id="statisticsProduct" resultType="org.springblade.modules.farmplant.vo.FarmProductStockVO">
        select sfps.strain_id strainId,sum(sfps.weight) weight,ss.url,ss.strain_name strainName from
        select sfps.id,sfps.strain_id strainId,sum(sfps.weight) weight,ss.url,ss.strain_name strainName from
        sys_farm_product_stock sfps
        left join sys_strain ss on ss.id = sfps.strain_id
        LEFT JOIN sys_land sl ON sl.id = sfps.land_id
        where 1=1
        <if test="farmProductStock.strainId!=null and farmProductStock.strainId!=''">
            and sfps.strain_id = #{farmProductStock.strainId}
@@ -80,7 +89,10 @@
        <if test="farmProductStock.tenantId!=null and farmProductStock.tenantId!=''">
            and sfps.tenant_id = #{farmProductStock.tenantId}
        </if>
        group by sfps.strain_id,ss.url,ss.strain_name
        <if test="farmProductStock.farmId!=null and farmProductStock.farmId!=''">
            and sl.farm_id = #{farmProductStock.farmId}
        </if>
        group by sfps.id,sfps.strain_id,ss.url,ss.strain_name
    </select>
    <!--大屏产量每个月统计-->
@@ -358,12 +370,12 @@
        FROM
            sys_farm_product_stock
        WHERE
            strain_id = #{id}
            id = #{id}
    </select>
    <!--减去对应库存-->
    <update id="stockReduce">
        UPDATE sys_farm_product_stock SET weight = weight - #{sale}
        WHERE
            strain_id = #{id}
            id = #{id}
    </update>
</mapper>