<?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.dy.pipIrrGlobal.daoLargeScreen.Ls4StatisticsMapper"> 
 | 
  
 | 
    <select id="totalCountOfDistrict" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from ba_district tb 
 | 
        where tb.level = #{level, jdbcType=INTEGER} 
 | 
            and tb.deleted != 1 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfBlock" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from ba_block tb 
 | 
        where tb.deleted != 1 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfDivide" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from pr_divide tb 
 | 
        where tb.deleted != 1 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfIntake" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from pr_intake tb 
 | 
        where tb.deleted != 1 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfIntakeWithController" resultType="java.lang.Integer"> 
 | 
        select count(*) as count 
 | 
        from ( 
 | 
             select distinct tb.id 
 | 
             from pr_intake tb 
 | 
                inner join pr_intake_controller ctb on tb.id = ctb.intakeId 
 | 
             where tb.deleted != 1 
 | 
                and ctb.id is not null 
 | 
        ) otb 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfIntakeWithoutController" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from pr_intake tb 
 | 
                 left join pr_intake_controller ctb on tb.id = ctb.intakeId 
 | 
        where tb.deleted != 1 
 | 
          and ctb.id is null 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfController" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from pr_controller tb 
 | 
        where tb.deleted != 1 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfControllerTramp" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from pr_controller_tramp tb 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfOpenValve" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        where valve_state = 0 
 | 
        <if test="dt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfCloseValve" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        where valve_state = 1 
 | 
        <if test="dt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfAlarm" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        where (alarm_remain_water = 1 or 
 | 
            alarm_exceed_year = 1 or 
 | 
            alarm_water_meter_fault = 1 or 
 | 
            alarm_loss = 1 or 
 | 
            alarm_water_meter_break = 1 or 
 | 
            alarm_ele_meter_fault = 1 or 
 | 
            alarm_inner_door = 1 or 
 | 
            alarm_outer_door = 1 or 
 | 
            alarm_ele_miss = 1 or 
 | 
            alarm_ele_exceed = 1 or 
 | 
            alarm_ele_low_volt = 1 or 
 | 
            state_ic_enable = 1 or 
 | 
            alarm_battery_volt = 1 or 
 | 
            alarm_valve = 1) 
 | 
        <if test="dt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="totalCountOfNoAlarm" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        where ((alarm_remain_water is null or alarm_remain_water = 0) and 
 | 
        (alarm_remain_water is null or alarm_exceed_year = 0)  and 
 | 
        (alarm_remain_water is null or alarm_water_meter_fault = 0)  and 
 | 
        (alarm_remain_water is null or alarm_loss = 0)  and 
 | 
        (alarm_remain_water is null or alarm_water_meter_break = 0)  and 
 | 
        (alarm_remain_water is null or alarm_ele_meter_fault = 0)  and 
 | 
        (alarm_remain_water is null or alarm_inner_door = 0)  and 
 | 
        (alarm_remain_water is null or alarm_outer_door = 0)  and 
 | 
        (alarm_remain_water is null or alarm_ele_miss = 0)  and 
 | 
        (alarm_remain_water is null or alarm_ele_exceed = 0)  and 
 | 
        (alarm_remain_water is null or alarm_ele_low_volt = 0)  and 
 | 
        (alarm_remain_water is null or state_ic_enable = 0)  and 
 | 
        (alarm_remain_water is null or alarm_battery_volt = 0)  and 
 | 
        (alarm_remain_water is null or alarm_valve = 0) ) 
 | 
        <if test="dt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="mTotalCountOfReport" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from rm_on_hour_report_last tb 
 | 
        inner join pr_intake tbIn on tb.intake_id = tbIn.id 
 | 
        where tbIn.deleted != 1 and tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
    </select> 
 | 
  
 | 
    <select id="mTotalCountOfNoReport" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from pr_intake tb 
 | 
            left join ( 
 | 
                select ltb.intake_id 
 | 
                from rm_on_hour_report_last ltb 
 | 
                where ltb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
            ) temTb on tb.id = temTb.intake_id 
 | 
        where tb.deleted != 1 and temTb.intake_id is null 
 | 
    </select> 
 | 
  
 | 
  
 | 
    <select id="mTotalCountOfNeverReport" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from pr_intake tb 
 | 
            left join ( 
 | 
                select ltb.intake_id 
 | 
                from rm_on_hour_report_last ltb 
 | 
            ) temTb on tb.id = temTb.intake_id 
 | 
        where tb.deleted != 1 and temTb.intake_id is null 
 | 
    </select> 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    <select id="mTotalCountOfOpenValve" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        inner join pr_intake tbIn on tb.intake_id = tbIn.id 
 | 
        where tbIn.deleted != 1 and valve_state = 0 
 | 
        <if test="fromDt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="mTotalCountOfCloseValve" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        inner join pr_intake tbIn on tb.intake_id = tbIn.id 
 | 
        where tbIn.deleted != 1 and valve_state = 1 
 | 
        <if test="fromDt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="mTotalCountOfNeverOpenValve" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from pr_intake tb 
 | 
            left join ( 
 | 
                /* 此处理解为有过记录,那么就开过阀 */ 
 | 
                select ltb.intake_id 
 | 
                from rm_alarm_state_last ltb 
 | 
            ) temTb on tb.id = temTb.intake_id 
 | 
        where tb.deleted != 1 and temTb.intake_id is null 
 | 
    </select> 
 | 
  
 | 
  
 | 
    <select id="mTotalCountOfAlarm" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        inner join pr_intake tbIn on tb.intake_id = tbIn.id 
 | 
        where tbIn.deleted != 1 and 
 | 
        (alarm_remain_water = 1 or 
 | 
        alarm_exceed_year = 1 or 
 | 
        alarm_water_meter_fault = 1 or 
 | 
        alarm_loss = 1 or 
 | 
        alarm_water_meter_break = 1 or 
 | 
        alarm_ele_meter_fault = 1 or 
 | 
        alarm_inner_door = 1 or 
 | 
        alarm_outer_door = 1 or 
 | 
        alarm_ele_miss = 1 or 
 | 
        alarm_ele_exceed = 1 or 
 | 
        alarm_ele_low_volt = 1 or 
 | 
        alarm_battery_volt = 1 or 
 | 
        alarm_valve = 1) 
 | 
        <if test="fromDt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="mTotalCountOfNoAlarm" resultType="java.lang.Integer"> 
 | 
        select 
 | 
        count(*) as count 
 | 
        from rm_alarm_state_last tb 
 | 
        inner join pr_intake tbIn on tb.intake_id = tbIn.id 
 | 
        where tbIn.deleted != 1 and 
 | 
        ((alarm_remain_water is null or alarm_remain_water = 0) and 
 | 
        (alarm_exceed_year is null or alarm_exceed_year = 0)  and 
 | 
        (alarm_water_meter_fault is null or alarm_water_meter_fault = 0)  and 
 | 
        (alarm_loss is null or alarm_loss = 0)  and 
 | 
        (alarm_water_meter_break is null or alarm_water_meter_break = 0)  and 
 | 
        (alarm_ele_meter_fault is null or alarm_ele_meter_fault = 0)  and 
 | 
        (alarm_inner_door is null or alarm_inner_door = 0)  and 
 | 
        (alarm_outer_door is null or alarm_outer_door = 0)  and 
 | 
        (alarm_ele_miss is null or alarm_ele_miss = 0)  and 
 | 
        (alarm_ele_exceed is null or alarm_ele_exceed = 0)  and 
 | 
        (alarm_ele_low_volt is null or alarm_ele_low_volt = 0)  and 
 | 
        (alarm_battery_volt is null or alarm_battery_volt = 0)  and 
 | 
        (alarm_valve is null or alarm_valve = 0) ) 
 | 
        <if test="fromDt != null "> 
 | 
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP} 
 | 
        </if> 
 | 
    </select> 
 | 
  
 | 
    <select id="mTotalCountOfNeverAlarm" resultType="java.lang.Integer"> 
 | 
        select 
 | 
            count(*) as count 
 | 
        from pr_intake tb 
 | 
                 left join ( 
 | 
            select ltb.intake_id 
 | 
            from rm_alarm_state_last ltb 
 | 
            where ((ltb.alarm_remain_water is null or ltb.alarm_remain_water = 0) and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_exceed_year = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_water_meter_fault = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_loss = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_water_meter_break = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_meter_fault = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_inner_door = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_outer_door = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_miss = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_exceed = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_low_volt = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.state_ic_enable = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_battery_volt = 0)  and 
 | 
                   (ltb.alarm_remain_water is null or ltb.alarm_valve = 0) ) 
 | 
        ) temTb on tb.id = temTb.intake_id 
 | 
        where tb.deleted != 1 and temTb.intake_id is null 
 | 
    </select> 
 | 
  
 | 
  
 | 
  
 | 
  
 | 
    <select id="topXClientAtCertainDay" resultType="com.dy.pipIrrGlobal.voSpecial.VoTopXClient"> 
 | 
        select mTb.id as id, mTb.client_id as clientId, 
 | 
        scTb.name as clientName, scTb.clientNum as clientNum, scTb.address as clientAddress, 
 | 
        mTb.amount as amount 
 | 
        from rm_client_amount_day mTb 
 | 
        left join se_client scTb on scTb.id = mTb.client_id 
 | 
        <where> 
 | 
            <if test = "idStart != null"> 
 | 
                mTb.id <![CDATA[>=]]> #{idStart, javaType=LONG, jdbcType=BIGINT} 
 | 
            </if> 
 | 
            <if test = "idEnd != null"> 
 | 
                and mTb.id <![CDATA[<=]]> #{idEnd, javaType=LONG, jdbcType=BIGINT} 
 | 
            </if> 
 | 
        </where> 
 | 
        order by mTb.amount DESC 
 | 
        <trim prefix="limit " > 
 | 
            <if test="count != null"> 
 | 
                0, #{count,javaType=Integer, jdbcType=INTEGER} 
 | 
            </if> 
 | 
        </trim> 
 | 
    </select> 
 | 
  
 | 
  
 | 
    <select id="topXIntakeAtCertainDay" resultType="com.dy.pipIrrGlobal.voSpecial.VoTopXIntake"> 
 | 
        select mTb.id as id, mTb.intake_id as intakeId, 
 | 
        piTb.name as intakeNum, piTb.lng as intakeLng, piTb.lat as intakeLat, 
 | 
        mTb.amount as amount 
 | 
        from rm_intake_amount_day mTb 
 | 
        left join pr_intake piTb on piTb.id = mTb.intake_id 
 | 
        <where> 
 | 
            <if test = "idStart != null"> 
 | 
                mTb.id <![CDATA[>=]]> #{idStart, javaType=LONG, jdbcType=BIGINT} 
 | 
            </if> 
 | 
            <if test = "idEnd != null"> 
 | 
                and mTb.id <![CDATA[<=]]> #{idEnd, javaType=LONG, jdbcType=BIGINT} 
 | 
            </if> 
 | 
        </where> 
 | 
        order by mTb.amount DESC 
 | 
        <trim prefix="limit " > 
 | 
            <if test="count != null"> 
 | 
                0, #{count,javaType=Integer, jdbcType=INTEGER} 
 | 
            </if> 
 | 
        </trim> 
 | 
    </select> 
 | 
  
 | 
    <select id="allCropts" resultType="com.dy.pipIrrGlobal.voMd.VoCropsSimple"> 
 | 
        select mTb.id as id, mTb.name as name 
 | 
        from md_crops mTb 
 | 
        where mTb.deleted != 1 
 | 
        order by mTb.id DESC 
 | 
    </select> 
 | 
  
 | 
    <select id="et0InWeek" resultType="com.dy.pipIrrGlobal.voMd.VoEt0Simple"> 
 | 
        select mTb.id as id, mTb.dt as dt, mTb.et0 as et0 
 | 
        from md_et0 mTb 
 | 
        <where> 
 | 
            <if test="cropId != null"> 
 | 
                AND mTb.crop_id = #{cropId} 
 | 
            </if> 
 | 
            <if test = "startDate != null and startDate !='' and endDate != null and endDate != ''"> 
 | 
                AND mTb.dt BETWEEN #{startDate} AND #{endDate} 
 | 
            </if> 
 | 
        </where> 
 | 
        order by mTb.id ASC 
 | 
    </select> 
 | 
</mapper> 
 |