liurunyu
2025-07-29 86eba8eaec4494bf29657333ea7b0385cb818578
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -559,7 +559,7 @@
        SELECT COUNT(*) AS recordCount
        FROM pr_intake inta
        LEFT JOIN
        (SELECT intake_id FROM rm_on_hour_report_history
        (SELECT intake_id FROM rm_open_close_valve_history
        <where>
            <if test = "idStart != null">
                id <![CDATA[>=]]> #{idStart}
@@ -583,7 +583,7 @@
               pct.rtuAddr  AS rtuAddr
        FROM pr_intake inta
        LEFT JOIN
        (SELECT intake_id FROM rm_on_hour_report_history
        (SELECT intake_id FROM rm_open_close_valve_history
        <where>
            <if test = "idStart != null">
                id <![CDATA[>=]]> #{idStart}
@@ -611,7 +611,7 @@
                     inta.name AS intakeNum,
                     blo.name  AS blockName
              FROM pr_intake inta
              LEFT JOIN (SELECT intake_id
              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
@@ -629,7 +629,7 @@
               inta.lat  AS lat,
               blo.name  AS blockName
        FROM pr_intake inta
        LEFT JOIN(SELECT intake_id
        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
@@ -653,7 +653,7 @@
                     inta.name AS intakeNum,
                     blo.name  AS blockName
              FROM pr_intake inta
              LEFT JOIN (SELECT intake_id
              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
@@ -671,7 +671,7 @@
               inta.lat  AS lat,
               blo.name  AS blockName
        FROM pr_intake inta
        LEFT JOIN(SELECT intake_id
        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
@@ -692,12 +692,13 @@
        SELECT COUNT(*) AS recordCount
        FROM se_client cli
        <where>
            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
                (SELECT COUNT(*)
                FROM rm_open_close_valve_history his
                WHERE his.client_id = cli.id
                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
            (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}
            </if>
            ) > #{openCount}
        </where>
    </select>
@@ -714,17 +715,18 @@
                <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}
                        AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}
                    </if>
                </where>) AS openCount
        FROM se_client cli
        <where>
            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
               (SELECT COUNT(*)
               FROM rm_open_close_valve_history his
               WHERE his.client_id = cli.id
                 AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) > #{openCount}
            (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 his.op_dt BETWEEN #{timeStart} AND #{timeStop}
            </if>
            ) > #{openCount}
        </where>
        ORDER BY cli.id
        <trim prefix="limit ">
@@ -739,11 +741,14 @@
        SELECT COUNT(*) AS recordCount
        FROM se_client cli
        <where>
            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
                (SELECT COUNT(*)
                FROM rm_open_close_valve_history his
                WHERE his.client_id = cli.id
                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) &lt; #{openCount}
            (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}
            </if>
            <if test="openCount != null">
                ) &lt; #{openCount}
            </if>
        </where>
    </select>
@@ -766,11 +771,14 @@
                </where>) AS openCount
        FROM se_client cli
        <where>
            <if test="timeStart != null and timeStart != '' and timeStop != null and timeStop != '' and openCount != null">
                (SELECT COUNT(*)
                FROM rm_open_close_valve_history his
                WHERE his.client_id = cli.id
                AND his.op_dt BETWEEN #{timeStart} AND #{timeStop}) &lt; #{openCount}
            (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}
            </if>
            <if test="openCount != null">
                &lt; #{openCount}
            </if>
        </where>
        ORDER BY cli.id
@@ -1336,8 +1344,8 @@
        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">
@@ -1347,8 +1355,8 @@
        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>