liurunyu
2025-08-20 d4c8e72800fcf6fbaa3804d383c7b6a23f826f3e
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -786,17 +786,21 @@
    <!--获取指定时间段内开阀次数低于指定值的农户数量-->
    <select id="getSmallOpenCountClientsCount" resultType="java.lang.Long">
        SELECT COUNT(*) AS recordCount
        SELECT COUNT(*)
        FROM se_client cli
        <where>
            (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}
        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 &lt; #{openCount}
            </if>
            ) &lt; #{openCount}
        </where>
        ) as his on his.client_id = cli.id
    </select>
    <!-- 2025-07-29 下面SQL查询太慢,废弃  -->
    <select id="_getSmallOpenCountClientsCount" resultType="java.lang.Long">
@@ -827,16 +831,16 @@
        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}
            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 &lt; #{openCount}
            </if>
        </where>
        group by client_id
        <if test="openCount != null and openCount > 0">
            having openCount &lt; #{openCount}
        </if>
        ) as his on his.client_id = cli.id
        ORDER BY cli.id
        <trim prefix="limit ">
@@ -883,6 +887,24 @@
    <!--获取指定时间段内用水量超过指定值的农户数量-->
    <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 &gt; #{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>
@@ -897,6 +919,36 @@
    <!--获取指定时间段内用水量超过指定值的农户-->
    <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 &gt; #{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,
@@ -931,6 +983,24 @@
    <!--获取指定时间段内用水量低于指定值的农户数量-->
    <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 &lt; #{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>
@@ -945,6 +1015,36 @@
    <!--获取指定时间段内用水量低于指定值的农户-->
    <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 &lt; #{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,
@@ -979,6 +1079,24 @@
    <!--获取指定时间段内消费金额超过指定值的农户数量-->
    <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 &gt; #{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>
@@ -992,6 +1110,36 @@
    </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 &gt; #{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,
@@ -1026,6 +1174,24 @@
    <!--获取指定时间段内消费金额低于指定值的农户数量-->
    <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 &lt; #{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>
@@ -1039,6 +1205,36 @@
    </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 &lt; #{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,
@@ -1073,6 +1269,24 @@
    <!--获取指定时间段内用水时长超过指定值的农户数量-->
    <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 &gt; #{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>
@@ -1087,6 +1301,36 @@
    <!--获取指定时间段内用水时长超过指定值的农户-->
    <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 &gt; #{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,
@@ -1121,6 +1365,24 @@
    <!--获取指定时间段内用水时长低于指定值的农户数量-->
    <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 &lt; #{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>
@@ -1135,6 +1397,36 @@
    <!--获取指定时间段内用水时长低于指定值的农户-->
    <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 &lt; #{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,