liurunyu
2024-08-07 2edf7dc27783594eb86b727a926f1d280ec561a7
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -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">
@@ -911,4 +917,82 @@
            </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>
</mapper>