|  |  |  | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内从未开过阀的取水口数量--> | 
|---|
|  |  |  | <select id="getNeverOpenValveIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | WHERE inta.deleted = 0 | 
|---|
|  |  |  | AND NOT EXISTS(SELECT * | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | AND intake_id = inta.id) | 
|---|
|  |  |  | LEFT JOIN | 
|---|
|  |  |  | (SELECT intake_id FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test = "idStart != null"> | 
|---|
|  |  |  | id <![CDATA[>=]]> #{idStart} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test = "idEnd != null"> | 
|---|
|  |  |  | AND id <![CDATA[<=]]> #{idEnd} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where>) his | 
|---|
|  |  |  | ON his.intake_id = inta.id | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | LEFT JOIN pr_controller pct ON inta.id = pct.intakeId | 
|---|
|  |  |  | WHERE his.intake_id IS NULL AND inta.deleted = 0 | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--获取指定时间段内从未开过阀的取水口--> | 
|---|
|  |  |  | <select id="getNeverOpenValveIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> | 
|---|
|  |  |  | SELECT inta.id   AS intakeId, | 
|---|
|  |  |  | inta.name AS intakeNum, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | <select id="getNeverOpenValveIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeUnOpenValve"> | 
|---|
|  |  |  | SELECT inta.id      AS intakeId, | 
|---|
|  |  |  | inta.name    AS intakeNum, | 
|---|
|  |  |  | inta.lng     AS lng, | 
|---|
|  |  |  | inta.lat     AS lat, | 
|---|
|  |  |  | blo.name     AS blockName, | 
|---|
|  |  |  | pct.rtuAddr  AS rtuAddr | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | WHERE inta.deleted = 0 | 
|---|
|  |  |  | AND NOT EXISTS(SELECT * | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | AND intake_id = inta.id) | 
|---|
|  |  |  | ORDER BY inta.id | 
|---|
|  |  |  | LEFT JOIN | 
|---|
|  |  |  | (SELECT intake_id FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test = "idStart != null"> | 
|---|
|  |  |  | id <![CDATA[>=]]> #{idStart} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test = "idEnd != null"> | 
|---|
|  |  |  | AND id <![CDATA[<=]]> #{idEnd} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where>) his | 
|---|
|  |  |  | ON his.intake_id = inta.id | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | LEFT JOIN pr_controller pct ON inta.id = pct.intakeId | 
|---|
|  |  |  | WHERE his.intake_id IS NULL AND inta.deleted = 0 | 
|---|
|  |  |  | ORDER BY inta.id DESC | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.name AS intakeNum, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN (SELECT intake_id | 
|---|
|  |  |  | INNER JOIN (SELECT intake_id | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE id <![CDATA[>=]]> #{idStart} AND id <![CDATA[<=]]> #{idEnd} | 
|---|
|  |  |  | ) his ON his.intake_id = inta.id | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.lat  AS lat, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN(SELECT intake_id | 
|---|
|  |  |  | INNER JOIN(SELECT intake_id | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE id <![CDATA[>=]]> #{idStart} AND id <![CDATA[<=]]> #{idEnd} | 
|---|
|  |  |  | ) his ON his.intake_id = inta.id | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.name AS intakeNum, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN (SELECT intake_id | 
|---|
|  |  |  | INNER JOIN (SELECT intake_id | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE id <![CDATA[>=]]> #{idStart} AND id <![CDATA[<=]]> #{idEnd} | 
|---|
|  |  |  | ) his ON his.intake_id = inta.id | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.lat  AS lat, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN(SELECT intake_id | 
|---|
|  |  |  | INNER JOIN(SELECT intake_id | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE id <![CDATA[>=]]> #{idStart} AND id <![CDATA[<=]]> #{idEnd} | 
|---|
|  |  |  | ) his ON his.intake_id = inta.id | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内开阀次数超过指定值的农户数量--> | 
|---|
|  |  |  | <select id="getLargeOpenCountClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, COUNT(*) AS openCount | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="openCount != null and openCount > 0"> | 
|---|
|  |  |  | having openCount > #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeOpenCountClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null"> | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount} | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) > #{openCount} | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内开阀次数超过指定值的农户--> | 
|---|
|  |  |  | <select id="getLargeOpenCountClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.openCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, COUNT(*) AS openCount | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="openCount != null and openCount > 0"> | 
|---|
|  |  |  | having openCount > #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeOpenCountClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | his.client_id = cli.id | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where>) AS openCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null"> | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount} | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null"> | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) > #{openCount} | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内开阀次数低于指定值的农户数量--> | 
|---|
|  |  |  | <select id="getSmallOpenCountClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, COUNT(*) AS openCount | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="openCount != null and openCount > 0"> | 
|---|
|  |  |  | having openCount < #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallOpenCountClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null"> | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{openCount} | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="openCount != null"> | 
|---|
|  |  |  | ) < #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内开阀次数低于指定值的农户--> | 
|---|
|  |  |  | <select id="getSmallOpenCountClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.openCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, COUNT(*) AS openCount | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="openCount != null and openCount > 0"> | 
|---|
|  |  |  | having openCount < #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallOpenCountClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  | </where>) AS openCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null"> | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) < #{openCount} | 
|---|
|  |  |  | (SELECT COUNT(*) | 
|---|
|  |  |  | FROM rm_open_close_valve_history his | 
|---|
|  |  |  | WHERE his.client_id = cli.id | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | AND his.op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | <if test="openCount != null"> | 
|---|
|  |  |  | < #{openCount} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水量超过指定值的农户数量--> | 
|---|
|  |  |  | <select id="getLargeWaterConsumptionClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_amount) AS waterConsumption | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterConsumption != null and waterConsumption > 0"> | 
|---|
|  |  |  | having waterConsumption > #{waterConsumption} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeWaterConsumptionClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水量超过指定值的农户--> | 
|---|
|  |  |  | <select id="getLargeWaterConsumptionClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.waterConsumption | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_amount) AS waterConsumption | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterConsumption != null and waterConsumption > 0"> | 
|---|
|  |  |  | having waterConsumption > #{waterConsumption} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeWaterConsumptionClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水量低于指定值的农户数量--> | 
|---|
|  |  |  | <select id="getSmallWaterConsumptionClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_amount) AS waterConsumption | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterConsumption != null and waterConsumption > 0"> | 
|---|
|  |  |  | having waterConsumption < #{waterConsumption} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallWaterConsumptionClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水量低于指定值的农户--> | 
|---|
|  |  |  | <select id="getSmallWaterConsumptionClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.waterConsumption | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_amount) AS waterConsumption | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterConsumption != null and waterConsumption > 0"> | 
|---|
|  |  |  | having waterConsumption < #{waterConsumption} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallWaterConsumptionClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内消费金额超过指定值的农户数量--> | 
|---|
|  |  |  | <select id="getLargeAmountSpentClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_money) AS amountSpent | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="amountSpent != null and amountSpent > 0"> | 
|---|
|  |  |  | having amountSpent > #{amountSpent} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeAmountSpentClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--获取指定时间段内消费金额超过指定值的农户--> | 
|---|
|  |  |  | <select id="getLargeAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.amountSpent | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_money) AS amountSpent | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="amountSpent != null and amountSpent > 0"> | 
|---|
|  |  |  | having amountSpent > #{amountSpent} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内消费金额低于指定值的农户数量--> | 
|---|
|  |  |  | <select id="getSmallAmountSpentClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_money) AS amountSpent | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="amountSpent != null and amountSpent > 0"> | 
|---|
|  |  |  | having amountSpent < #{amountSpent} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallAmountSpentClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--获取指定时间段内消费金额低于指定值的农户--> | 
|---|
|  |  |  | <select id="getSmallAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.amountSpent | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_money) AS amountSpent | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="amountSpent != null and amountSpent > 0"> | 
|---|
|  |  |  | having amountSpent < #{amountSpent} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水时长超过指定值的农户数量--> | 
|---|
|  |  |  | <select id="getLargeWaterDurationClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_time) AS waterDuration | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterDuration != null and waterDuration > 0"> | 
|---|
|  |  |  | having waterDuration > #{waterDuration} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeWaterDurationClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水时长超过指定值的农户--> | 
|---|
|  |  |  | <select id="getLargeWaterDurationClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.waterDuration | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_time) AS waterDuration | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterDuration != null and waterDuration > 0"> | 
|---|
|  |  |  | having waterDuration > #{waterDuration} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getLargeWaterDurationClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水时长低于指定值的农户数量--> | 
|---|
|  |  |  | <select id="getSmallWaterDurationClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_time) AS waterDuration | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterDuration != null and waterDuration > 0"> | 
|---|
|  |  |  | having waterDuration < #{waterDuration} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallWaterDurationClientsCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | SELECT COUNT(*) AS recordCount | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内用水时长低于指定值的农户--> | 
|---|
|  |  |  | <select id="getSmallWaterDurationClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id  AS clientId, | 
|---|
|  |  |  | cli.name       AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | cli.address, | 
|---|
|  |  |  | cli.phone, | 
|---|
|  |  |  | cli.idCard, | 
|---|
|  |  |  | his.waterDuration | 
|---|
|  |  |  | FROM se_client cli | 
|---|
|  |  |  | inner join ( | 
|---|
|  |  |  | SELECT client_id, SUM(cl_this_time) AS waterDuration | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | <where> | 
|---|
|  |  |  | <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != ''"> | 
|---|
|  |  |  | op_dt BETWEEN #{timeStart} AND #{timeStop} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </where> | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | <if test="waterDuration != null and waterDuration > 0"> | 
|---|
|  |  |  | having waterDuration < #{waterDuration} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | ) as his on his.client_id = cli.id | 
|---|
|  |  |  | ORDER BY cli.id | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!-- 2025-07-29 下面SQL查询太慢,废弃  --> | 
|---|
|  |  |  | <select id="_getSmallWaterDurationClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient"> | 
|---|
|  |  |  | SELECT cli.id                                 AS clientId, | 
|---|
|  |  |  | cli.name                               AS clientName, | 
|---|
|  |  |  | cli.clientNum, | 
|---|
|  |  |  | 
|---|
|  |  |  | IFNULL(SUM(rocvh.cl_this_time),0) AS recordCount | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | LEFT JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | INNER JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE rocvh.op_dt >= #{timeStart} AND rocvh.cl_dt <= #{timeStop} AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | HAVING IFNULL(SUM(rocvh.cl_this_time),0) > #{value} | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.id AS intakeId | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | inner JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id >= #{idStart} AND  rocvh.id >= #{idEnd} AND rocvh.cl_dt IS NULL | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | INNER JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id <![CDATA[>=]]> #{idStart} AND  rocvh.id <![CDATA[<=]]> #{idEnd} AND rocvh.cl_dt IS NULL | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | ) c | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | 
|---|
|  |  |  | blo.NAME AS blockName | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | inner JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id >= #{idStart} AND  rocvh.id >= #{idEnd} AND rocvh.cl_dt IS NULL | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | INNER JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id <![CDATA[>=]]> #{idStart} AND  rocvh.id <![CDATA[<=]]> #{idEnd} AND rocvh.cl_dt IS NULL | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | ORDER BY inta.id DESC | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.id AS intakeId | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | inner JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id >= #{idStart} AND  rocvh.id >= #{idEnd} AND rocvh.op_dt IS NULL | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | INNER JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id <![CDATA[>=]]> #{idStart} AND  rocvh.id <![CDATA[<=]]> #{idEnd} AND rocvh.op_dt IS NULL | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | ) c | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | 
|---|
|  |  |  | blo.NAME AS blockName | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | inner JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id >= #{idStart} AND  rocvh.id >= #{idEnd} AND rocvh.op_dt IS NULL | 
|---|
|  |  |  | LEFT JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | INNER JOIN rm_open_close_valve_history rocvh ON rocvh.intake_id = inta.id | 
|---|
|  |  |  | WHERE inta.deleted = 0 AND rocvh.id <![CDATA[>=]]> #{idStart} AND  rocvh.id <![CDATA[<=]]> #{idEnd} AND rocvh.op_dt IS NULL | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | ORDER BY inta.id DESC | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | 
|---|
|  |  |  | count(ocvh.id) as times | 
|---|
|  |  |  | from rm_open_close_valve_history ocvh | 
|---|
|  |  |  | inner join se_client_card cc on CAST(cc.cardNum AS CHAR) = ocvh.cl_ic_card_no | 
|---|
|  |  |  | where ocvh.cl_dt <![CDATA[>=]]> #{startDt, jdbcType=BIGINT} | 
|---|
|  |  |  | and ocvh.cl_dt <![CDATA[<=]]> #{endDt, jdbcType=BIGINT} | 
|---|
|  |  |  | where ocvh.cl_dt <![CDATA[>=]]> #{startDt, jdbcType=TIMESTAMP } | 
|---|
|  |  |  | and ocvh.cl_dt <![CDATA[<=]]> #{endDt, jdbcType=TIMESTAMP} | 
|---|
|  |  |  | group by ocvh.client_id, cc.id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <select id="statisticsByClient" resultType="com.dy.pipIrrGlobal.voSt.VoClientConsumeStatistics"> | 
|---|
|  |  |  | 
|---|
|  |  |  | sum(cl_this_time) as duration, | 
|---|
|  |  |  | count(id) as times | 
|---|
|  |  |  | from rm_open_close_valve_history | 
|---|
|  |  |  | where cl_dt <![CDATA[>=]]> #{startDt, jdbcType=BIGINT} | 
|---|
|  |  |  | and cl_dt <![CDATA[<=]]> #{endDt, jdbcType=BIGINT} | 
|---|
|  |  |  | where cl_dt <![CDATA[>=]]> #{startDt, jdbcType=TIMESTAMP} | 
|---|
|  |  |  | and cl_dt <![CDATA[<=]]> #{endDt, jdbcType=TIMESTAMP} | 
|---|
|  |  |  | group by client_id | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | </mapper> | 
|---|