zhubaomin
2025-02-21 1f19230e00b543b58f03853df1a38ebd8b508e55
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
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
<?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.daoRm.RmTimingReportHistoryMapper">
  <resultMap id="BaseResultMap" type="com.dy.pipIrrGlobal.pojoRm.RmTimingReportHistory">
    <!--@mbg.generated-->
    <!--@Table rm_timing_report_history-->
    <id column="id" jdbcType="BIGINT" property="id" />
    <result column="controller_id" jdbcType="BIGINT" property="controllerId" />
    <result column="intake_id" jdbcType="BIGINT" property="intakeId" />
    <result column="rtu_addr" jdbcType="VARCHAR" property="rtuAddr" />
    <result column="dt" jdbcType="TIMESTAMP" property="dt" />
    <result column="rtu_dt" jdbcType="TIMESTAMP" property="rtuDt" />
    <result column="data_dt" jdbcType="DATE" property="dataDt" />
    <result column="water_total_amount_year" jdbcType="FLOAT" property="waterTotalAmountYear" />
    <result column="water_total_amount_meter" jdbcType="FLOAT" property="waterTotalAmountMeter" />
    <result column="ele_total_amount_year" jdbcType="FLOAT" property="eleTotalAmountYear" />
    <result column="ele_total_amount_meter" jdbcType="FLOAT" property="eleTotalAmountMeter" />
    <result column="water_total_amount_day" jdbcType="FLOAT" property="waterTotalAmountDay" />
    <result column="water_user_total_amount_day" jdbcType="FLOAT" property="waterUserTotalAmountDay" />
    <result column="loss_total_amount_day" jdbcType="FLOAT" property="lossTotalAmountDay" />
    <result column="battery_volt" jdbcType="FLOAT" property="batteryVolt" />
  </resultMap>
  <sql id="Base_Column_List">
    <!--@mbg.generated-->
    id, controller_id, intake_id, rtu_addr, dt, rtu_dt, data_dt, water_total_amount_year, 
    water_total_amount_meter, ele_total_amount_year, ele_total_amount_meter, water_total_amount_day, 
    water_user_total_amount_day, loss_total_amount_day, battery_volt
  </sql>
  <select id="selectByPrimaryKey" parameterType="java.lang.Long" resultMap="BaseResultMap">
    <!--@mbg.generated-->
    select 
    <include refid="Base_Column_List" />
    from rm_timing_report_history
    where id = #{id,jdbcType=BIGINT}
  </select>
  <delete id="deleteByPrimaryKey" parameterType="java.lang.Long">
    <!--@mbg.generated-->
    delete from rm_timing_report_history
    where id = #{id,jdbcType=BIGINT}
  </delete>
  <insert id="insert" parameterType="com.dy.pipIrrGlobal.pojoRm.RmTimingReportHistory">
    <!--@mbg.generated-->
    insert into rm_timing_report_history (id, controller_id, intake_id, 
      rtu_addr, dt, rtu_dt, 
      data_dt, water_total_amount_year, water_total_amount_meter, 
      ele_total_amount_year, ele_total_amount_meter, water_total_amount_day, 
      water_user_total_amount_day, loss_total_amount_day, 
      battery_volt)
    values (#{id,jdbcType=BIGINT}, #{controllerId,jdbcType=BIGINT}, #{intakeId,jdbcType=BIGINT}, 
      #{rtuAddr,jdbcType=VARCHAR}, #{dt,jdbcType=TIMESTAMP}, #{rtuDt,jdbcType=TIMESTAMP}, 
      #{dataDt,jdbcType=DATE}, #{waterTotalAmountYear,jdbcType=FLOAT}, #{waterTotalAmountMeter,jdbcType=FLOAT}, 
      #{eleTotalAmountYear,jdbcType=FLOAT}, #{eleTotalAmountMeter,jdbcType=FLOAT}, #{waterTotalAmountDay,jdbcType=FLOAT}, 
      #{waterUserTotalAmountDay,jdbcType=FLOAT}, #{lossTotalAmountDay,jdbcType=FLOAT}, 
      #{batteryVolt,jdbcType=FLOAT})
  </insert>
  <insert id="insertSelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmTimingReportHistory">
    <!--@mbg.generated-->
    insert into rm_timing_report_history
    <trim prefix="(" suffix=")" suffixOverrides=",">
      <if test="id != null">
        id,
      </if>
      <if test="controllerId != null">
        controller_id,
      </if>
      <if test="intakeId != null">
        intake_id,
      </if>
      <if test="rtuAddr != null">
        rtu_addr,
      </if>
      <if test="dt != null">
        dt,
      </if>
      <if test="rtuDt != null">
        rtu_dt,
      </if>
      <if test="dataDt != null">
        data_dt,
      </if>
      <if test="waterTotalAmountYear != null">
        water_total_amount_year,
      </if>
      <if test="waterTotalAmountMeter != null">
        water_total_amount_meter,
      </if>
      <if test="eleTotalAmountYear != null">
        ele_total_amount_year,
      </if>
      <if test="eleTotalAmountMeter != null">
        ele_total_amount_meter,
      </if>
      <if test="waterTotalAmountDay != null">
        water_total_amount_day,
      </if>
      <if test="waterUserTotalAmountDay != null">
        water_user_total_amount_day,
      </if>
      <if test="lossTotalAmountDay != null">
        loss_total_amount_day,
      </if>
      <if test="batteryVolt != null">
        battery_volt,
      </if>
    </trim>
    <trim prefix="values (" suffix=")" suffixOverrides=",">
      <if test="id != null">
        #{id,jdbcType=BIGINT},
      </if>
      <if test="controllerId != null">
        #{controllerId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="rtuAddr != null">
        #{rtuAddr,jdbcType=VARCHAR},
      </if>
      <if test="dt != null">
        #{dt,jdbcType=TIMESTAMP},
      </if>
      <if test="rtuDt != null">
        #{rtuDt,jdbcType=TIMESTAMP},
      </if>
      <if test="dataDt != null">
        #{dataDt,jdbcType=DATE},
      </if>
      <if test="waterTotalAmountYear != null">
        #{waterTotalAmountYear,jdbcType=FLOAT},
      </if>
      <if test="waterTotalAmountMeter != null">
        #{waterTotalAmountMeter,jdbcType=FLOAT},
      </if>
      <if test="eleTotalAmountYear != null">
        #{eleTotalAmountYear,jdbcType=FLOAT},
      </if>
      <if test="eleTotalAmountMeter != null">
        #{eleTotalAmountMeter,jdbcType=FLOAT},
      </if>
      <if test="waterTotalAmountDay != null">
        #{waterTotalAmountDay,jdbcType=FLOAT},
      </if>
      <if test="waterUserTotalAmountDay != null">
        #{waterUserTotalAmountDay,jdbcType=FLOAT},
      </if>
      <if test="lossTotalAmountDay != null">
        #{lossTotalAmountDay,jdbcType=FLOAT},
      </if>
      <if test="batteryVolt != null">
        #{batteryVolt,jdbcType=FLOAT},
      </if>
    </trim>
  </insert>
  <update id="updateByPrimaryKeySelective" parameterType="com.dy.pipIrrGlobal.pojoRm.RmTimingReportHistory">
    <!--@mbg.generated-->
    update rm_timing_report_history
    <set>
      <if test="controllerId != null">
        controller_id = #{controllerId,jdbcType=BIGINT},
      </if>
      <if test="intakeId != null">
        intake_id = #{intakeId,jdbcType=BIGINT},
      </if>
      <if test="rtuAddr != null">
        rtu_addr = #{rtuAddr,jdbcType=VARCHAR},
      </if>
      <if test="dt != null">
        dt = #{dt,jdbcType=TIMESTAMP},
      </if>
      <if test="rtuDt != null">
        rtu_dt = #{rtuDt,jdbcType=TIMESTAMP},
      </if>
      <if test="dataDt != null">
        data_dt = #{dataDt,jdbcType=DATE},
      </if>
      <if test="waterTotalAmountYear != null">
        water_total_amount_year = #{waterTotalAmountYear,jdbcType=FLOAT},
      </if>
      <if test="waterTotalAmountMeter != null">
        water_total_amount_meter = #{waterTotalAmountMeter,jdbcType=FLOAT},
      </if>
      <if test="eleTotalAmountYear != null">
        ele_total_amount_year = #{eleTotalAmountYear,jdbcType=FLOAT},
      </if>
      <if test="eleTotalAmountMeter != null">
        ele_total_amount_meter = #{eleTotalAmountMeter,jdbcType=FLOAT},
      </if>
      <if test="waterTotalAmountDay != null">
        water_total_amount_day = #{waterTotalAmountDay,jdbcType=FLOAT},
      </if>
      <if test="waterUserTotalAmountDay != null">
        water_user_total_amount_day = #{waterUserTotalAmountDay,jdbcType=FLOAT},
      </if>
      <if test="lossTotalAmountDay != null">
        loss_total_amount_day = #{lossTotalAmountDay,jdbcType=FLOAT},
      </if>
      <if test="batteryVolt != null">
        battery_volt = #{batteryVolt,jdbcType=FLOAT},
      </if>
    </set>
    where id = #{id,jdbcType=BIGINT}
  </update>
  <update id="updateByPrimaryKey" parameterType="com.dy.pipIrrGlobal.pojoRm.RmTimingReportHistory">
    <!--@mbg.generated-->
    update rm_timing_report_history
    set controller_id = #{controllerId,jdbcType=BIGINT},
      intake_id = #{intakeId,jdbcType=BIGINT},
      rtu_addr = #{rtuAddr,jdbcType=VARCHAR},
      dt = #{dt,jdbcType=TIMESTAMP},
      rtu_dt = #{rtuDt,jdbcType=TIMESTAMP},
      data_dt = #{dataDt,jdbcType=DATE},
      water_total_amount_year = #{waterTotalAmountYear,jdbcType=FLOAT},
      water_total_amount_meter = #{waterTotalAmountMeter,jdbcType=FLOAT},
      ele_total_amount_year = #{eleTotalAmountYear,jdbcType=FLOAT},
      ele_total_amount_meter = #{eleTotalAmountMeter,jdbcType=FLOAT},
      water_total_amount_day = #{waterTotalAmountDay,jdbcType=FLOAT},
      water_user_total_amount_day = #{waterUserTotalAmountDay,jdbcType=FLOAT},
      loss_total_amount_day = #{lossTotalAmountDay,jdbcType=FLOAT},
      battery_volt = #{batteryVolt,jdbcType=FLOAT}
    where id = #{id,jdbcType=BIGINT}
  </update>
 
  <!--根据指定条件获取定时报历史记录数量-->
  <select id="getTimingReportsCount_history" resultType="java.lang.Long">
    SELECT
        COUNT(*) AS recordCount
    FROM rm_timing_report_history tim
        INNER JOIN pr_intake inta ON inta.id = tim.intake_id
    <where>
      <if test="intakeId != null and intakeId >0">
        AND tim.intake_id = #{intakeId}
      </if>
      <if test = "intakeNum != null and intakeNum !=''">
        AND inta.name LIKE CONCAT('%',#{intakeNum},'%')
      </if>
      <if test = "rtuAddr != null and rtuAddr !=''">
        AND tim.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%')
      </if>
      <if test = "timeStart != null and timeStop != null">
        AND tim.dt BETWEEN #{timeStart} AND #{timeStop}
      </if>
    </where>
  </select>
 
  <!--根据指定条件获取定时报历史记录-->
  <select id="getTimingReports_history" resultType="com.dy.pipIrrGlobal.voRm.VoTiming">
    SELECT
      tim.intake_id AS intakeId,
      inta.name AS intakenum,
      tim.rtu_addr AS rtuAddr,
      tim.dt AS receiveTime,
      tim.water_total_amount_year AS waterTotalAmountYear,
      tim.water_total_amount_meter AS waterTotalAmountMeter,
      tim.ele_total_amount_year AS eleTotalAmountYear,
      tim.ele_total_amount_meter AS eleTotalAmountMeter,
      tim.water_total_amount_day AS waterTotalAmountDay,
      tim.water_user_total_amount_day AS waterUserTotalAmountDay,
      tim.loss_total_amount_day AS lossTotalAmountDay,
      tim.battery_volt AS batteryVolt
    FROM rm_timing_report_history tim
    INNER JOIN pr_intake inta ON inta.id = tim.intake_id
    <where>
      <if test="intakeId != null and intakeId >0">
        AND tim.intake_id = #{intakeId}
      </if>
      <if test = "intakeNum != null and intakeNum !=''">
        AND inta.name LIKE CONCAT('%',#{intakeNum},'%')
      </if>
      <if test = "rtuAddr != null and rtuAddr !=''">
        AND tim.rtu_addr LIKE CONCAT('%',#{rtuAddr},'%')
      </if>
      <if test = "timeStart != null and timeStop != null">
        AND tim.dt BETWEEN #{timeStart} AND #{timeStop}
      </if>
    </where>
    ORDER BY tim.dt DESC, tim.loss_total_amount_day DESC
    <trim prefix="limit " >
      <if test="start != null and count != null">
        #{start,javaType=Integer,jdbcType=INTEGER}, #{count,javaType=Integer,jdbcType=INTEGER}
      </if>
    </trim>
  </select>
</mapper>