|  |  |  | 
|---|
|  |  |  | </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 * | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | WHERE inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY intakeId, intakeNum, blockName | 
|---|
|  |  |  | HAVING recordCount > #{value}) a | 
|---|
|  |  |  | 
|---|
|  |  |  | SELECT COUNT(*)  AS recordCount, | 
|---|
|  |  |  | inta.id   AS intakeId, | 
|---|
|  |  |  | inta.name AS intakeNum, | 
|---|
|  |  |  | inta.lng  AS lng, | 
|---|
|  |  |  | inta.lat  AS lat, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN (SELECT * | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | WHERE inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY intakeId, intakeNum, blockName | 
|---|
|  |  |  | HAVING recordCount > #{value} | 
|---|
|  |  |  | <!--        ORDER BY inta.id--> | 
|---|
|  |  |  | ORDER BY intakeId DESC | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--获取指定时间段内开阀次数低于指定值的取水口数量--> | 
|---|
|  |  |  | <select id="getOpenValveLtIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | select count(*) | 
|---|
|  |  |  | 
|---|
|  |  |  | inta.name AS intakeNum, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN (SELECT * | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | WHERE inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY intakeId, intakeNum, blockName | 
|---|
|  |  |  | HAVING recordCount < #{value}) a | 
|---|
|  |  |  | 
|---|
|  |  |  | SELECT COUNT(*)  AS recordCount, | 
|---|
|  |  |  | inta.id   AS intakeId, | 
|---|
|  |  |  | inta.name AS intakeNum, | 
|---|
|  |  |  | inta.lng  AS lng, | 
|---|
|  |  |  | inta.lat  AS lat, | 
|---|
|  |  |  | blo.name  AS blockName | 
|---|
|  |  |  | FROM pr_intake inta | 
|---|
|  |  |  | LEFT JOIN (SELECT * | 
|---|
|  |  |  | FROM rm_open_close_valve_history | 
|---|
|  |  |  | WHERE op_dt BETWEEN #{timeStart} AND #{timeStop}) his ON his.intake_id = inta.id | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | INNER JOIN ba_block blo ON blo.id = inta.blockId | 
|---|
|  |  |  | WHERE inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY intakeId, intakeNum, blockName | 
|---|
|  |  |  | HAVING recordCount < #{value} | 
|---|
|  |  |  | <!--        ORDER BY inta.id--> | 
|---|
|  |  |  | ORDER BY intakeId DESC | 
|---|
|  |  |  | <trim prefix="limit "> | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--指定时间段用水量超过指定值的取水口数量--> | 
|---|
|  |  |  | <select id="getUseWaterGtValueIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | count(*) | 
|---|
|  |  |  | from | 
|---|
|  |  |  | (        SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | blo.NAME AS blockName , | 
|---|
|  |  |  | IFNULL(SUM(rocvh.cl_this_amount),0) AS value | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | WHERE rocvh.op_dt >= #{timeStart} AND rocvh.cl_dt <= #{timeStop} AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | HAVING IFNULL(SUM(rocvh.cl_this_amount),0) > #{value}) c | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--指定时间段用水量超过指定值的取水口--> | 
|---|
|  |  |  | <select id="getUseWaterGtValueIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeAccumulateAmount"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | blo.NAME AS blockName , | 
|---|
|  |  |  | IFNULL(SUM(rocvh.cl_this_amount),0) AS value | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | WHERE rocvh.op_dt >= #{timeStart} AND rocvh.cl_dt <= #{timeStop} AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | HAVING IFNULL(SUM(rocvh.cl_this_amount),0) > #{value} | 
|---|
|  |  |  | ORDER BY inta.id | 
|---|
|  |  |  | <trim prefix="limit " > | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--指定时间段内消费金额超过指定值的取水口的数量--> | 
|---|
|  |  |  | <select id="getExpenseGtValueIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | count(*) | 
|---|
|  |  |  | from | 
|---|
|  |  |  | (        SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | blo.NAME AS blockName , | 
|---|
|  |  |  | IFNULL(SUM(rocvh.cl_this_money),0) AS value | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | WHERE rocvh.op_dt >= #{timeStart} AND rocvh.cl_dt <= #{timeStop} AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | HAVING IFNULL(SUM(rocvh.cl_this_money),0) > #{value}) c | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  | <!--指定时间段内消费金额超过指定值的取水口--> | 
|---|
|  |  |  | <select id="getExpenseGtValueIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeAccumulateAmount"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | blo.NAME AS blockName , | 
|---|
|  |  |  | IFNULL(SUM(rocvh.cl_this_money),0) AS value | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | WHERE rocvh.op_dt >= #{timeStart} AND rocvh.cl_dt <= #{timeStop} AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id | 
|---|
|  |  |  | HAVING IFNULL(SUM(rocvh.cl_this_money),0) > #{value} | 
|---|
|  |  |  | ORDER BY inta.id | 
|---|
|  |  |  | <trim prefix="limit " > | 
|---|
|  |  |  | <if test="start != null and count != null"> | 
|---|
|  |  |  | #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER} | 
|---|
|  |  |  | </if> | 
|---|
|  |  |  | </trim> | 
|---|
|  |  |  | </select> | 
|---|
|  |  |  |  | 
|---|
|  |  |  | <!--指定时间段内用水时长超过指定值的取水口数量--> | 
|---|
|  |  |  | <select id="getUseWaterDurationGtValueIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | select | 
|---|
|  |  |  | 
|---|
|  |  |  | 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} | 
|---|
|  |  |  | 
|---|
|  |  |  | <!--指定时间段 有开阀 无关阀的取水口数量--> | 
|---|
|  |  |  | <select id="getHaveOpenNoCloseIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | select count(*) from | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | 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 rocvh.op_dt BETWEEN #{timeStart} AND  #{timeStop} AND rocvh.cl_dt IS NULL AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id) c | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | <!--指定时间段 有开阀 无关阀的取水口--> | 
|---|
|  |  |  | <select id="getHaveOpenNoCloseIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | inta.lng AS lng, | 
|---|
|  |  |  | inta.lat AS lat, | 
|---|
|  |  |  | 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 rocvh.op_dt BETWEEN #{timeStart} AND  #{timeStop} AND rocvh.cl_dt IS NULL AND inta.deleted = 0 | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | 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} | 
|---|
|  |  |  | 
|---|
|  |  |  | <select id="getNoOpenHaveCloseIntakesCount" resultType="java.lang.Long"> | 
|---|
|  |  |  | select count(*) from | 
|---|
|  |  |  | ( | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | 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 rocvh.cl_dt BETWEEN #{timeStart} AND  #{timeStop} AND rocvh.op_dt IS NULL AND inta.deleted = 0 | 
|---|
|  |  |  | GROUP BY inta.id) c | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId | 
|---|
|  |  |  | FROM | 
|---|
|  |  |  | pr_intake inta | 
|---|
|  |  |  | 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> | 
|---|
|  |  |  | <!--指定时间段 无开阀 有关阀的取水口--> | 
|---|
|  |  |  | <select id="getNoOpenHaveCloseIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake"> | 
|---|
|  |  |  | SELECT | 
|---|
|  |  |  | inta.id AS intakeId, | 
|---|
|  |  |  | inta.NAME AS intakeNum, | 
|---|
|  |  |  | inta.lng AS lng, | 
|---|
|  |  |  | inta.lat AS lat, | 
|---|
|  |  |  | 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 rocvh.cl_dt BETWEEN #{timeStart} AND  #{timeStop} AND rocvh.op_dt IS NULL AND inta.deleted = 0 | 
|---|
|  |  |  | 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 | 
|---|
|  |  |  | 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} | 
|---|
|  |  |  | 
|---|
|  |  |  | 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> | 
|---|