1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
<?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>
 
 
    <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>
 
</mapper>