zhubaomin
2025-04-14 4a2deb11b819dd78a8c75e244ef67ec2e48cf5f5
pipIrr-platform/pipIrr-global/src/main/resources/mapper/RmIntakeAmountDayMapper.xml
@@ -8,6 +8,8 @@
        <result column="intake_id" jdbcType="BIGINT" property="intakeId"/>
        <result column="dt" jdbcType="DATE" property="dt"/>
        <result column="amount" jdbcType="DOUBLE" property="amount"/>
        <result column="money" jdbcType="DOUBLE" property="money" />
        <result column="times" jdbcType="INTEGER" property="times" />
        <result column="dt_last" jdbcType="TIMESTAMP" property="dtLast"/>
        <result column="rtu_addr_last" jdbcType="VARCHAR" property="rtuAddrLast"/>
        <result column="controller_id_last" jdbcType="BIGINT" property="controllerIdLast"/>
@@ -19,7 +21,7 @@
        id,
        intake_id,
        dt,
        amount,
        amount, money, times,
        dt_last,
        rtu_addr_last,
        controller_id_last,
@@ -49,11 +51,11 @@
    <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay">
        <!--@mbg.generated-->
        insert into rm_intake_amount_day (id, intake_id, dt,
                                          amount, dt_last,
                                          amount, money, times, dt_last,
                                          rtu_addr_last, controller_id_last, total_amount_last,
                                          rtu_dt_last)
        values (#{id,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT}, #{dt,jdbcType=DATE},
                #{amount,jdbcType=DOUBLE}, #{dtLast,jdbcType=TIMESTAMP},
                #{amount,jdbcType=DOUBLE}, #{money,jdbcType=DOUBLE}, #{times,jdbcType=INTEGER}, #{dtLast,jdbcType=TIMESTAMP},
                #{rtuAddrLast,jdbcType=VARCHAR}, #{controllerIdLast,jdbcType=BIGINT}, #{totalAmountLast,jdbcType=FLOAT},
                #{rtuDtLast,jdbcType=TIMESTAMP})
    </insert>
@@ -72,6 +74,12 @@
            </if>
            <if test="amount != null">
                amount,
            </if>
           <if test="money != null">
               money,
            </if>
           <if test="times != null">
               times,
            </if>
            <if test="dtLast != null">
                dt_last,
@@ -101,6 +109,12 @@
            </if>
            <if test="amount != null">
                #{amount,jdbcType=DOUBLE},
            </if>
            <if test="money != null">
                #{money,jdbcType=DOUBLE},
            </if>
            <if test="times != null">
                #{times,jdbcType=INTEGER},
            </if>
            <if test="dtLast != null">
                #{dtLast,jdbcType=TIMESTAMP},
@@ -132,6 +146,12 @@
            <if test="amount != null">
                amount = #{amount,jdbcType=DOUBLE},
            </if>
            <if test="money != null">
                money = #{money,jdbcType=DOUBLE},
            </if>
            <if test="times != null">
                times = #{times,jdbcType=INTEGER},
            </if>
            <if test="dtLast != null">
                dt_last = #{dtLast,jdbcType=TIMESTAMP},
            </if>
@@ -156,6 +176,8 @@
        set intake_id          = #{intakeId,jdbcType=BIGINT},
            dt                 = #{dt,jdbcType=DATE},
            amount             = #{amount,jdbcType=DOUBLE},
            money              = #{money,jdbcType=DOUBLE},
            times              = #{times,jdbcType=INTEGER},
            dt_last            = #{dtLast,jdbcType=TIMESTAMP},
            rtu_addr_last      = #{rtuAddrLast,jdbcType=VARCHAR},
            controller_id_last = #{controllerIdLast,jdbcType=BIGINT},
@@ -189,6 +211,8 @@
               pint.name                             as intakeName,
               riad.dt                               as dt,
               riad.amount                           as amount,
               riad.money                            as money,
               riad.times                            as times,
               riad.dt_last                          as dtLast,
               riad.rtu_addr_last                    as rtuAddrLast,
               CAST(riad.controller_id_last AS char) AS controllerIdLast,
@@ -995,5 +1019,121 @@
    ) as tb31 on tb31.intakeId = inta.intakeId
  </select>
    <!--指定时间段用水量超过指定值的取水口数量-->
    <select id="getUseWaterGtValueIntakesCount" resultType="java.lang.Long">
        select
        count(*)
        from (
        SELECT
        SUM(riad.amount) AS value
        FROM
        pr_intake inta
        INNER JOIN ba_block blo ON blo.id = inta.blockId
        INNER JOIN rm_intake_amount_day riad ON riad.intake_id = inta.id
        WHERE inta.deleted = 0 and riad.dt &gt;= #{timeStart} AND riad.dt &lt;= #{timeStop}
        GROUP BY inta.id
        HAVING value &gt; #{value}
        ) c
    </select>
    <!--指定时间段用水量超过指定值的取水口-->
    <select id="getUseWaterGtValueIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeAccumulateAmount">
        SELECT
        inta.id AS intakeId,
        inta.NAME AS intakeNum,
        inta.lng  AS lng,
        inta.lat  AS lat,
        blo.NAME AS blockName ,
        SUM(riad.amount) AS value
        FROM
        pr_intake inta
        INNER JOIN ba_block blo ON blo.id = inta.blockId
        INNER JOIN rm_intake_amount_day riad ON riad.intake_id = inta.id
        WHERE inta.deleted = 0 and riad.dt &gt;= #{timeStart} AND riad.dt &lt;= #{timeStop}
        GROUP BY inta.id
        HAVING value &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
        SUM(riad.money) AS value
        FROM
        pr_intake inta
        INNER JOIN ba_block blo ON blo.id = inta.blockId
        INNER JOIN rm_intake_amount_day riad ON riad.intake_id = inta.id
        WHERE inta.deleted = 0 and riad.dt &gt;= #{timeStart} AND riad.dt &lt;= #{timeStop}
        GROUP BY inta.id
        HAVING value &gt; #{value}
        ) c
    </select>
    <!--指定时间段内消费金额超过指定值的取水口-->
    <select id="getExpenseGtValueIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeAccumulateAmount">
        SELECT
        inta.id AS intakeId,
        inta.NAME AS intakeNum,
        inta.lng  AS lng,
        inta.lat  AS lat,
        blo.NAME AS blockName ,
        SUM(riad.money) AS value
        FROM
        pr_intake inta
        INNER JOIN ba_block blo ON blo.id = inta.blockId
        INNER JOIN rm_intake_amount_day riad ON riad.intake_id = inta.id
        WHERE inta.deleted = 0 and riad.dt &gt;= #{timeStart} AND riad.dt &lt;= #{timeStop}
        GROUP BY inta.id
        HAVING value &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="getUseWaterTimesGtValueIntakesCount" resultType="java.lang.Long">
        select
        count(*)
        from (
        SELECT
        SUM(riad.times) AS valueInt
        FROM
        pr_intake inta
        INNER JOIN ba_block blo ON blo.id = inta.blockId
        INNER JOIN rm_intake_amount_day riad ON riad.intake_id = inta.id
        WHERE inta.deleted = 0 and riad.dt &gt;= #{timeStart} AND riad.dt &lt;= #{timeStop}
        GROUP BY inta.id
        HAVING valueInt &gt; #{value}
        ) c
    </select>
    <!--指定时间段内取水次数超过指定值的取水口-->
    <select id="getUseWaterTimesGtValueIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntakeAccumulateAmount">
        SELECT
        inta.id AS intakeId,
        inta.NAME AS intakeNum,
        inta.lng  AS lng,
        inta.lat  AS lat,
        blo.NAME AS blockName ,
        SUM(riad.times) AS valueInt
        FROM
        pr_intake inta
        INNER JOIN ba_block blo ON blo.id = inta.blockId
        INNER JOIN rm_intake_amount_day riad ON riad.intake_id = inta.id
        WHERE inta.deleted = 0 and riad.dt &gt;= #{timeStart} AND riad.dt &lt;= #{timeStop}
        GROUP BY inta.id
        HAVING valueInt &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>