wuzeyu
2024-08-28 d65cc4cd967d9c8cbdc8a4dd7c803e952f01098f
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -494,7 +494,7 @@
               CASE
                   WHEN oh.op_type = 1 THEN '刷卡开阀'
                   WHEN oh.op_type = 3 THEN '中心站开阀'
                   WHEN oh.op_type = 5 THEN '欠费关阀'
                   WHEN oh.op_type = 5 THEN '余额不足关阀'
                   WHEN oh.op_type = 8 THEN '用户远程开阀'
                   WHEN oh.op_type = 11 THEN '开关阀卡开阀'
                   ELSE '未知'
@@ -510,7 +510,7 @@
               CASE
                   WHEN oh.cl_type = 2 THEN '刷卡关阀'
                   WHEN oh.cl_type = 4 THEN '中心站关阀'
                   WHEN oh.cl_type = 5 THEN '欠费关阀'
                   WHEN oh.cl_type = 5 THEN '余额不足关阀'
                   WHEN oh.cl_type = 6 THEN '流量计故障关阀'
                   WHEN oh.cl_type = 7 THEN '紧急关阀'
                   WHEN oh.cl_type = 9 THEN '用户远程关阀'
@@ -563,7 +563,7 @@
               CASE
                   WHEN oh.op_type = 1 THEN '刷卡开阀'
                   WHEN oh.op_type = 3 THEN '中心站开阀'
                   WHEN oh.op_type = 5 THEN '欠费关阀'
                   WHEN oh.op_type = 5 THEN '余额不足关阀'
                   WHEN oh.op_type = 8 THEN '用户远程开阀'
                   WHEN oh.op_type = 11 THEN '开关阀卡开阀'
                   ELSE '未知'
@@ -579,7 +579,7 @@
               CASE
                   WHEN oh.cl_type = 2 THEN '刷卡关阀'
                   WHEN oh.cl_type = 4 THEN '中心站关阀'
                   WHEN oh.cl_type = 5 THEN '欠费关阀'
                   WHEN oh.cl_type = 5 THEN '余额不足关阀'
                   WHEN oh.cl_type = 6 THEN '流量计故障关阀'
                   WHEN oh.cl_type = 7 THEN '紧急关闭'
                   WHEN oh.cl_type = 9 THEN '用户远程关阀'
@@ -791,9 +791,10 @@
    <select id="getLargeWaterConsumptionClientsCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client cli
                 INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id
        WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop}
          AND his.cl_this_amount > #{waterConsumption}
        WHERE (SELECT SUM(his.cl_this_amount)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterConsumption}
    </select>
    <!--获取指定时间段内用水量超过指定值的农户-->
@@ -805,9 +806,10 @@
               cli.phone,
               cli.idCard
        FROM se_client cli
                 INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id
        WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop}
          AND his.cl_this_amount > #{waterConsumption}
        WHERE (SELECT SUM(his.cl_this_amount)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterConsumption}
        ORDER BY cli.id
        <trim prefix="limit ">
            <if test="start != null and count != null">
@@ -820,9 +822,10 @@
    <select id="getLargeAmountSpentClientsCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client cli
                 INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id
        WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop}
          AND his.cl_this_money > #{amountSpent}
        WHERE (SELECT SUM(his.cl_this_money)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{amountSpent}
    </select>
    <!--获取指定时间段内消费金额超过指定值的农户-->
    <select id="getLargeAmountSpentClients" resultType="com.dy.pipIrrGlobal.voSt.VoClient">
@@ -833,9 +836,10 @@
               cli.phone,
               cli.idCard
        FROM se_client cli
                 INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id
        WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop}
          AND his.cl_this_money > #{amountSpent}
        WHERE (SELECT SUM(his.cl_this_money)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{amountSpent}
        ORDER BY cli.id
        <trim prefix="limit ">
            <if test="start != null and count != null">
@@ -848,9 +852,10 @@
    <select id="getLargeWaterDurationClientsCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        FROM se_client cli
                 INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id
        WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop}
          AND his.cl_this_time > #{waterDuration}
        WHERE (SELECT SUM(his.cl_this_time)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterDuration}
    </select>
    <!--获取指定时间段内用水时长超过指定值的农户-->
@@ -862,9 +867,10 @@
               cli.phone,
               cli.idCard
        FROM se_client cli
                 INNER JOIN rm_open_close_valve_history his ON his.client_id = cli.id
        WHERE his.op_dt BETWEEN #{timeStart} AND #{timeStop}
          AND his.cl_this_time > #{waterDuration}
        WHERE (SELECT SUM(his.cl_this_time)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{waterDuration}
        ORDER BY cli.id
        <trim prefix="limit ">
            <if test="start != null and count != null">
@@ -872,4 +878,189 @@
            </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 &gt;= #{timeStart} AND rocvh.cl_dt &lt;= #{timeStop} AND inta.deleted = 0
        GROUP BY inta.id
        HAVING IFNULL(SUM(rocvh.cl_this_amount),0) &gt; #{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 &gt;= #{timeStart} AND rocvh.cl_dt &lt;= #{timeStop} AND inta.deleted = 0
        GROUP BY inta.id
        HAVING IFNULL(SUM(rocvh.cl_this_amount),0) &gt; #{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 &gt;= #{timeStart} AND rocvh.cl_dt &lt;= #{timeStop} AND inta.deleted = 0
        GROUP BY inta.id
        HAVING IFNULL(SUM(rocvh.cl_this_money),0) &gt; #{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 &gt;= #{timeStart} AND rocvh.cl_dt &lt;= #{timeStop} AND inta.deleted = 0
        GROUP BY inta.id
        HAVING IFNULL(SUM(rocvh.cl_this_money),0) &gt; #{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
        count(*)
        from
        (        SELECT
        inta.id AS intakeId,
        inta.NAME AS intakeNum,
        blo.NAME AS blockName ,
        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
        WHERE rocvh.op_dt &gt;= #{timeStart} AND rocvh.cl_dt &lt;= #{timeStop} AND inta.deleted = 0
        GROUP BY inta.id
        HAVING IFNULL(SUM(rocvh.cl_this_time),0) &gt; #{value}) c
    </select>
    <!--指定时间段内用水时长超过指定值的取水口-->
    <select id="getUseWaterDurationGtValueIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeOpenCount">
        SELECT
        inta.id AS intakeId,
        inta.NAME AS intakeNum,
        blo.NAME AS blockName ,
        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
        WHERE rocvh.op_dt &gt;= #{timeStart} AND rocvh.cl_dt &lt;= #{timeStop} AND inta.deleted = 0
        GROUP BY inta.id
        HAVING IFNULL(SUM(rocvh.cl_this_time),0) &gt; #{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="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>
    <!--指定时间段 有开阀 无关阀的取水口-->
    <select id="getHaveOpenNoCloseIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake">
        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
        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="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>
    <!--指定时间段 无开阀 有关阀的取水口-->
    <select id="getNoOpenHaveCloseIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake">
        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
        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>
</mapper>