智慧农业后台管理
tangzy
2022-06-30 373513b5e5c32f935320625e35d18abace6c0720
src/main/java/org/springblade/modules/farm/mapper/FarmingRecordMapper.xml
@@ -65,15 +65,17 @@
    <!--查询统计本年农事记录操作总数-->
    <select id="getFarmingCount" resultType="java.lang.Integer">
        select ifnull(count(*),0) count from sys_farming_record
        select ifnull(count(*), 0) count
        from sys_farming_record
        where 1=1
        and YEAR(time)=YEAR(NOW())
          and dept_id=#{deptId}
    </select>
    <!--查询统计本年农事记录操作总数-->
    <select id="getFarmingStatis" resultType="org.springblade.modules.farm.vo.FarmingStatisVO">
        select
        case when type=0 then '施肥'
        select case
                   when type = 0 then '施肥'
         when type=1 then '翻耕'
         when type=2 then '灌溉'
         when type=3 then '起垄'
@@ -91,6 +93,34 @@
        from sys_farming_record
        where 1=1
        and YEAR(time)=YEAR(NOW())
          and dept_id=#{deptId}
        group by type
    </select>
    <!--今年农资使用量-->
    <select id="selectJyCount" resultType="java.lang.Double">
        SELECT IFNULL(SUM(census), 0) AS jynum
        FROM sys_farming_record
        WHERE
            YEAR ( time ) = YEAR ( NOW( ) )
          AND stock_id != NULL
          and dept_id=#{deptId}
    </select>
    <!--去年农资使用量-->
    <select id="selectQyCount" resultType="java.lang.Double">
        SELECT IFNULL(SUM(census), 0) AS qynum
        FROM sys_farming_record
        WHERE
            YEAR (time) = YEAR ( date_sub(now()
            , INTERVAL 1 YEAR))
          and dept_id=#{deptId}
    </select>
    <!--本月农资使用量-->
    <select id="selectByCount" resultType="java.lang.Double">
        SELECT IFNULL(SUM(census), 0) AS bynum
        FROM sys_farming_record
        WHERE DATE_FORMAT(time, '%Y%m') = DATE_FORMAT(CURDATE(), '%Y%m')
          and dept_id = #{deptId}
    </select>
</mapper>