liurunyu
3 天以前 1cf88d43994ec7ec403319032a9d118b39fe3571
pipIrr-platform/pipIrr-global/src/main/resources/mapper/Temp4ChangeMapper.xml
New file
@@ -0,0 +1,220 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.dy.pipIrrGlobal.daoTmp.ChangeMapper">
    <!-- 查询出所有取水口 -->
    <select id="selectAllPrIntakes" resultType="com.dy.pipIrrGlobal.voSt.VoIntake">
        select id as intakeId,
               name as intakeNum
        from  pr_intake
        order by id ASC
    </select>
    <!-- ======================================= -->
    <!--                                         -->
    <!-- 取水量                                   -->
    <!--                                         -->
    <!--  ====================================== -->
    <!-- 取水口取水量日统计相关, 此SQL中的 ”order by id ASC “不可修改 -->
    <select id="selectOneIntakeAllAmountDay" resultType="com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay">
        select id as id,
               intake_id as intakeId ,
               dt as dt,
               amount as amount,
               total_amount_last as totalAmountLast
        from  rm_intake_amount_day
        where intake_id = #{intakeId}
        order by id ASC
    </select>
    <!-- 修改取水口取水量日统计 -->
    <update id="updateOneIntakeAmountDay" >
        update rm_intake_amount_day
        set amount = #{amount, jdbcType=FLOAT}
        where id = #{id, jdbcType=BIGINT}
    </update>
    <update id="updateOneIntakeAmountDay1" >
        update rm_intake_amount_day
        set amount = #{amount, jdbcType=FLOAT},
        money = #{money, jdbcType=FLOAT},
        times = #{times, jdbcType=INTEGER}
        where intake_id = #{intakeId, jdbcType=BIGINT}
        and dt = #{dt, jdbcType=DATE}
    </update>
    <delete id="deleteSomeIntakeAmountDay">
        delete from rm_intake_amount_day where times is null
    </delete>
    <!--  -->
    <select id="statisticAllIntakeAmountDayFromOpenCloseValveHistory" resultType="com.dy.pipIrrGlobal.voTmp.VoRmIntakeAmountDay">
        select intake_id as intakeId ,
        sum(cl_this_amount) as amount,
        sum(cl_this_money) as money,
        count(id) as times
        from  rm_open_close_valve_history
        where cl_dt <![CDATA[>=]]> #{startDt, jdbcType=TIMESTAMP}
        and cl_dt <![CDATA[<=]]> #{endDt, jdbcType=TIMESTAMP}
        group by intake_id
    </select>
    <select id="selectStIntakeDayStatisticsByDate" resultType="com.dy.pipIrrGlobal.pojoRm.RmIntakeAmountDay">
        select *
        from  rm_intake_amount_day
        where rm_intake_amount_day.intake_id = #{intakeId, jdbcType=BIGINT}
        and dt = #{date, jdbcType=DATE}
    </select>
    <delete id="deleteAllIntakeAmountMonth">
        delete from st_intake_amount_month
    </delete>
    <!--  -->
    <select id="statisticAllIntakeAmountMonthFromAmountDay" resultType="com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth">
        select intake_id as intakeId ,
        sum(amount) as amount
        from  rm_intake_amount_day
        where dt <![CDATA[>=]]> #{startDt, jdbcType=DATE}
        and dt <![CDATA[<=]]> #{endDt, jdbcType=DATE}
        group by intake_id
    </select>
    <insert id="saveOneIntakeAmountMonth" parameterType="com.dy.pipIrrGlobal.pojoSt.StIntakeAmountMonth">
        <!--@mbg.generated-->
        insert into st_intake_amount_month (
        id,
        intake_id,
        year,
        month,
        amount
        )
        values (#{id,jdbcType=BIGINT},
        #{intakeId,jdbcType=BIGINT},
        #{year,jdbcType=INTEGER},
        #{month,jdbcType=INTEGER},
        #{amount,jdbcType=FLOAT}
        )
    </insert>
    <delete id="deleteAllIntakeAmountYear">
        delete from st_intake_amount_year
    </delete>
    <!--  -->
    <select id="statisticAllIntakeAmountYearFromAmountDay" resultType="com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear">
        select intake_id as intakeId ,
        sum(amount) as amount
        from  rm_intake_amount_day
        where dt <![CDATA[>=]]> #{startDt, jdbcType=DATE}
        and dt <![CDATA[<=]]> #{endDt, jdbcType=DATE}
        group by intake_id
    </select>
    <insert id="saveOneIntakeAmountYear" parameterType="com.dy.pipIrrGlobal.pojoSt.StIntakeAmountYear">
        <!--@mbg.generated-->
        insert into st_intake_amount_year (
        id,
        intake_id,
        year,
        amount
        )
        values (#{id,jdbcType=BIGINT},
        #{intakeId,jdbcType=BIGINT},
        #{year,jdbcType=INTEGER},
        #{amount,jdbcType=FLOAT}
        )
    </insert>
    <!-- ======================================= -->
    <!--                                         -->
    <!-- 漏损                                     -->
    <!--                                         -->
    <!--  ====================================== -->
    <!-- 取水口漏损日统计相关, 此SQL中的 ”order by id ASC “不可修改 -->
    <select id="selectOneIntakeAllLossDay" resultType="com.dy.pipIrrGlobal.pojoRm.RmLossDay">
        select id as id,
        intake_id as intakeId ,
        dt as dt,
        loss_amount as lossAmount
        from  rm_loss_day
        where intake_id = #{intakeId}
        order by id ASC
    </select>
    <!-- 修改取水口漏损日统计 -->
    <update id="updateOneIntakeLossDay" >
        update rm_loss_day
        set loss_amount = #{loss, jdbcType=FLOAT}
        where id = #{id, jdbcType=BIGINT}
    </update>
    <delete id="deleteAllIntakeLossMonth">
        delete from st_loss_month
    </delete>
    <!--  -->
    <select id="statisticAllIntakeLossMonthFromLossDay" resultType="com.dy.pipIrrGlobal.pojoSt.StLossMonth">
        select intake_id as intakeId ,
        sum(loss_amount) as amount
        from  rm_loss_day
        where dt <![CDATA[>=]]> #{startDt, jdbcType=DATE}
        and dt <![CDATA[<=]]> #{endDt, jdbcType=DATE}
        group by intake_id
    </select>
    <insert id="saveOneIntakeLossMonth" parameterType="com.dy.pipIrrGlobal.pojoSt.StLossMonth">
        <!--@mbg.generated-->
        insert into st_loss_month (
        id,
        intake_id,
        year,
        month,
        amount
        )
        values (#{id,jdbcType=BIGINT},
        #{intakeId,jdbcType=BIGINT},
        #{year,jdbcType=INTEGER},
        #{month,jdbcType=INTEGER},
        #{amount,jdbcType=FLOAT}
        )
    </insert>
    <delete id="deleteAllIntakeLossYear">
        delete from st_loss_year
    </delete>
    <!--  -->
    <select id="statisticAllIntakeLossYearFromLossDay" resultType="com.dy.pipIrrGlobal.pojoSt.StLossYear">
        select intake_id as intakeId ,
        sum(loss_amount) as amount
        from  rm_loss_day
        where dt <![CDATA[>=]]> #{startDt, jdbcType=DATE}
        and dt <![CDATA[<=]]> #{endDt, jdbcType=DATE}
        group by intake_id
    </select>
    <insert id="saveOneIntakeLossYear" parameterType="com.dy.pipIrrGlobal.pojoSt.StLossYear">
        <!--@mbg.generated-->
        insert into st_loss_year (
        id,
        intake_id,
        year,
        amount
        )
        values (#{id,jdbcType=BIGINT},
        #{intakeId,jdbcType=BIGINT},
        #{year,jdbcType=INTEGER},
        #{amount,jdbcType=FLOAT}
        )
    </insert>
</mapper>