liurunyu
2024-12-24 1e60f7968ac5aebbc8129d902166c5f061605a0c
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
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
<?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>
 
 
    <!-- ======================================= -->
    <!--                                         -->
    <!-- 漏损                                     -->
    <!--                                         -->
    <!--  ====================================== -->
    <!-- 取水口漏损日统计相关, 此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>