liurunyu
2025-02-10 a2d5f396dcee51917d333e42a977a544091e5389
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
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
<?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.daoLargeScreen.Ls4StatisticsMapper">
 
    <select id="totalCountOfDistrict" resultType="java.lang.Integer">
        select
            count(*) as count
        from ba_district tb
        where tb.level = #{level, jdbcType=INTEGER}
            and tb.deleted != 1
    </select>
 
    <select id="totalCountOfBlock" resultType="java.lang.Integer">
        select
            count(*) as count
        from ba_block tb
        where tb.deleted != 1
    </select>
 
    <select id="totalCountOfDivide" resultType="java.lang.Integer">
        select
            count(*) as count
        from pr_divide tb
        where tb.deleted != 1
    </select>
 
    <select id="totalCountOfIntake" resultType="java.lang.Integer">
        select
        count(*) as count
        from pr_intake tb
        where tb.deleted != 1
    </select>
 
    <select id="totalCountOfIntakeWithController" resultType="java.lang.Integer">
        select count(*) as count
        from (
             select distinct tb.id
             from pr_intake tb
                inner join pr_intake_controller ctb on tb.id = ctb.intakeId
             where tb.deleted != 1
                and ctb.id is not null
        ) otb
    </select>
 
    <select id="totalCountOfIntakeWithoutController" resultType="java.lang.Integer">
        select
            count(*) as count
        from pr_intake tb
                 left join pr_intake_controller ctb on tb.id = ctb.intakeId
        where tb.deleted != 1
          and ctb.id is null
    </select>
 
    <select id="totalCountOfController" resultType="java.lang.Integer">
        select
            count(*) as count
        from pr_controller tb
        where tb.deleted != 1
    </select>
 
    <select id="totalCountOfControllerTramp" resultType="java.lang.Integer">
        select
            count(*) as count
        from pr_controller_tramp tb
    </select>
 
    <select id="totalCountOfOpenValve" resultType="java.lang.Integer">
        select
            count(*) as count
        from rm_alarm_state_last tb
        where valve_state = 0
        <if test="dt != null ">
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="totalCountOfCloseValve" resultType="java.lang.Integer">
        select
            count(*) as count
        from rm_alarm_state_last tb
        where valve_state = 1
        <if test="dt != null ">
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="totalCountOfAlarm" resultType="java.lang.Integer">
        select
            count(*) as count
        from rm_alarm_state_last tb
        where (alarm_remain_water = 1 or
            alarm_exceed_year = 1 or
            alarm_water_meter_fault = 1 or
            alarm_loss = 1 or
            alarm_water_meter_break = 1 or
            alarm_ele_meter_fault = 1 or
            alarm_inner_door = 1 or
            alarm_outer_door = 1 or
            alarm_ele_miss = 1 or
            alarm_ele_exceed = 1 or
            alarm_ele_low_volt = 1 or
            state_ic_enable = 1 or
            alarm_battery_volt = 1 or
            alarm_valve = 1)
        <if test="dt != null ">
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="totalCountOfNoAlarm" resultType="java.lang.Integer">
        select
        count(*) as count
        from rm_alarm_state_last tb
        where ((alarm_remain_water is null or alarm_remain_water = 0) and
        (alarm_remain_water is null or alarm_exceed_year = 0)  and
        (alarm_remain_water is null or alarm_water_meter_fault = 0)  and
        (alarm_remain_water is null or alarm_loss = 0)  and
        (alarm_remain_water is null or alarm_water_meter_break = 0)  and
        (alarm_remain_water is null or alarm_ele_meter_fault = 0)  and
        (alarm_remain_water is null or alarm_inner_door = 0)  and
        (alarm_remain_water is null or alarm_outer_door = 0)  and
        (alarm_remain_water is null or alarm_ele_miss = 0)  and
        (alarm_remain_water is null or alarm_ele_exceed = 0)  and
        (alarm_remain_water is null or alarm_ele_low_volt = 0)  and
        (alarm_remain_water is null or state_ic_enable = 0)  and
        (alarm_remain_water is null or alarm_battery_volt = 0)  and
        (alarm_remain_water is null or alarm_valve = 0) )
        <if test="dt != null ">
            AND tb.dt <![CDATA[>=]]> #{dt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="mTotalCountOfReport" resultType="java.lang.Integer">
        select
        count(*) as count
        from rm_on_hour_report_last tb
        where tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP}
    </select>
 
    <select id="mTotalCountOfNoReport" resultType="java.lang.Integer">
        select
        count(*) as count
        from pr_intake tb
            left join (
                select ltb.intake_id
                from rm_on_hour_report_last ltb
                where ltb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP}
            ) temTb on tb.id = temTb.intake_id
        where temTb.intake_id is null
    </select>
 
 
    <select id="mTotalCountOfNeverReport" resultType="java.lang.Integer">
        select
        count(*) as count
        from pr_intake tb
            left join (
                select ltb.intake_id
                from rm_on_hour_report_last ltb
            ) temTb on tb.id = temTb.intake_id
        where temTb.intake_id is null
    </select>
 
 
 
 
    <select id="mTotalCountOfOpenValve" resultType="java.lang.Integer">
        select
        count(*) as count
        from rm_alarm_state_last tb
        where valve_state = 0
        <if test="fromDt != null ">
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="mTotalCountOfCloseValve" resultType="java.lang.Integer">
        select
        count(*) as count
        from rm_alarm_state_last tb
        where valve_state = 1
        <if test="fromDt != null ">
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="mTotalCountOfNeverOpenValve" resultType="java.lang.Integer">
        select
            count(*) as count
        from pr_intake tb
            left join (
                /* 此处理解为有过记录,那么就开过阀 */
                select ltb.intake_id
                from rm_alarm_state_last ltb
            ) temTb on tb.id = temTb.intake_id
        where temTb.intake_id is null
    </select>
 
 
    <select id="mTotalCountOfAlarm" resultType="java.lang.Integer">
        select
        count(*) as count
        from rm_alarm_state_last tb
        where (alarm_remain_water = 1 or
        alarm_exceed_year = 1 or
        alarm_water_meter_fault = 1 or
        alarm_loss = 1 or
        alarm_water_meter_break = 1 or
        alarm_ele_meter_fault = 1 or
        alarm_inner_door = 1 or
        alarm_outer_door = 1 or
        alarm_ele_miss = 1 or
        alarm_ele_exceed = 1 or
        alarm_ele_low_volt = 1 or
        state_ic_enable = 1 or
        alarm_battery_volt = 1 or
        alarm_valve = 1)
        <if test="fromDt != null ">
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="mTotalCountOfNoAlarm" resultType="java.lang.Integer">
        select
        count(*) as count
        from rm_alarm_state_last tb
        where ((alarm_remain_water is null or alarm_remain_water = 0) and
        (alarm_remain_water is null or alarm_exceed_year = 0)  and
        (alarm_remain_water is null or alarm_water_meter_fault = 0)  and
        (alarm_remain_water is null or alarm_loss = 0)  and
        (alarm_remain_water is null or alarm_water_meter_break = 0)  and
        (alarm_remain_water is null or alarm_ele_meter_fault = 0)  and
        (alarm_remain_water is null or alarm_inner_door = 0)  and
        (alarm_remain_water is null or alarm_outer_door = 0)  and
        (alarm_remain_water is null or alarm_ele_miss = 0)  and
        (alarm_remain_water is null or alarm_ele_exceed = 0)  and
        (alarm_remain_water is null or alarm_ele_low_volt = 0)  and
        (alarm_remain_water is null or state_ic_enable = 0)  and
        (alarm_remain_water is null or alarm_battery_volt = 0)  and
        (alarm_remain_water is null or alarm_valve = 0) )
        <if test="fromDt != null ">
            AND tb.dt <![CDATA[>=]]> #{fromDt, javaType=DATE, jdbcType=TIMESTAMP}
        </if>
    </select>
 
    <select id="mTotalCountOfNeverAlarm" resultType="java.lang.Integer">
        select
            count(*) as count
        from pr_intake tb
                 left join (
            select ltb.intake_id
            from rm_alarm_state_last ltb
            where ((ltb.alarm_remain_water is null or ltb.alarm_remain_water = 0) and
                   (ltb.alarm_remain_water is null or ltb.alarm_exceed_year = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_water_meter_fault = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_loss = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_water_meter_break = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_meter_fault = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_inner_door = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_outer_door = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_miss = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_exceed = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_ele_low_volt = 0)  and
                   (ltb.alarm_remain_water is null or ltb.state_ic_enable = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_battery_volt = 0)  and
                   (ltb.alarm_remain_water is null or ltb.alarm_valve = 0) )
        ) temTb on tb.id = temTb.intake_id
        where temTb.intake_id is null
    </select>
 
 
 
 
    <select id="topXClientAtCertainDay" resultType="com.dy.pipIrrGlobal.voSpecial.VoTopXClient">
        select mTb.id as id, mTb.client_id as clientId,
        scTb.name as clientName, scTb.clientNum as clientNum, scTb.address as clientAddress,
        mTb.amount as amount
        from rm_client_amount_day mTb
        left join se_client scTb on scTb.id = mTb.client_id
        <where>
            <if test = "idStart != null">
                mTb.id <![CDATA[>=]]> #{idStart, javaType=LONG, jdbcType=BIGINT}
            </if>
            <if test = "idEnd != null">
                and mTb.id <![CDATA[<=]]> #{idEnd, javaType=LONG, jdbcType=BIGINT}
            </if>
        </where>
        order by mTb.amount DESC
        <trim prefix="limit " >
            <if test="count != null">
                0, #{count,javaType=Integer, jdbcType=INTEGER}
            </if>
        </trim>
    </select>
 
 
    <select id="topXIntakeAtCertainDay" resultType="com.dy.pipIrrGlobal.voSpecial.VoTopXIntake">
        select mTb.id as id, mTb.intake_id as intakeId,
        piTb.name as intakeNum, piTb.lng as intakeLng, piTb.lat as intakeLat,
        mTb.amount as amount
        from rm_intake_amount_day mTb
        left join pr_intake piTb on piTb.id = mTb.intake_id
        <where>
            <if test = "idStart != null">
                mTb.id <![CDATA[>=]]> #{idStart, javaType=LONG, jdbcType=BIGINT}
            </if>
            <if test = "idEnd != null">
                and mTb.id <![CDATA[<=]]> #{idEnd, javaType=LONG, jdbcType=BIGINT}
            </if>
        </where>
        order by mTb.amount DESC
        <trim prefix="limit " >
            <if test="count != null">
                0, #{count,javaType=Integer, jdbcType=INTEGER}
            </if>
        </trim>
    </select>
 
</mapper>