liurunyu
2025-07-29 2132a4073fdd350ddce3fc5f999b305fffae1b01
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
        inner join (
        SELECT client_id, COUNT(*) AS openCount
        FROM rm_open_close_valve_history
        <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}
                op_dt BETWEEN #{timeStart} AND #{timeStop}
            </if>
            ) &lt; #{openCount}
        </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
    </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 ">