liurunyu
2025-01-08 1e268bf14a18a4abb0480355300fb03c311f9a71
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmOpenCloseValveHistoryMapper.xml
@@ -507,7 +507,7 @@
               oh.op_ic_card_no        AS openIcNum,
               oh.op_ic_card_addr      AS openIcAddr,
               oh.open_dt              AS openTime,
               oh.op_type              AS openType_,
               oh.op_type              AS opType,
               oh.op_order_no          AS openOrderNo,
               oh.op_total_amount      AS openTotalAmount,
               oh.op_remain_money      AS openRemainMoney,
@@ -516,7 +516,7 @@
               oh.cl_ic_card_no        AS closeIcNum,
               oh.cl_ic_card_addr      AS closeIcAddr,
               oh.close_dt             AS closeTime,
               oh.cl_type              AS closeType_,
               oh.cl_type              AS clType,
               oh.cl_this_amount       AS closeThisAmount,
               oh.cl_this_time         AS thisTime,
               oh.cl_price             AS closePrice,
@@ -525,7 +525,7 @@
               oh.cl_total_amount      AS closeTotalAmount
        FROM rm_open_close_valve_history oh
        LEFT JOIN pr_intake inta ON inta.id = oh.intake_id
        LEFT JOIN ba_client cl ON cl.id = oh.client_id
        LEFT JOIN se_client cl ON cl.id = oh.client_id
        <where>
            <if test="intakeId != null and intakeId > 0">
                AND oh.intake_id = #{intakeId}
@@ -546,7 +546,7 @@
                AND oh.cl_dt BETWEEN #{timeStart_close} AND #{timeStop_close}
            </if>
        </where>
        ORDER BY oh.op_dt DESC
        ORDER BY oh.id DESC
        <trim prefix="limit ">
            <if test="start != null and count != null">
                #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
@@ -1037,84 +1037,7 @@
            </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
@@ -1367,4 +1290,34 @@
            </if>
        </trim>
    </select>
    <!-- /////////////////////////////////// -->
    <!-- 统计相关                              -->
    <!-- /////////////////////////////////// -->
    <select id="statisticsByIc" resultType="com.dy.pipIrrGlobal.voSt.VoIcConsumeStatistics">
        select ocvh.client_id as clientId,
        cc.id as cardId,
        sum(ocvh.cl_this_amount) as water,
        sum(ocvh.cl_this_money) as amount,
        sum(ocvh.cl_this_time) as duration,
        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}
        group by ocvh.client_id, cc.id
    </select>
    <select id="statisticsByClient" resultType="com.dy.pipIrrGlobal.voSt.VoClientConsumeStatistics">
        select client_id as clientId,
        sum(cl_this_amount) as water,
        sum(cl_this_money) as amount,
        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}
        group by client_id
    </select>
</mapper>