feiyu02
2023-12-01 c6842e8498c2d9b469890b38cd9f0d714392c445
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
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE mapper
        PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN"
        "https://mybatis.org/dtd/mybatis-3-mapper.dtd">
<mapper namespace="com.flightfeather.monitor.mapper.FugitiveDustMapper">
    <update id="update">
        update audit_info
        <set>
            <if test="exceptionId != null and exceptionId!=''" >
                exception_id = #{exceptionId},
            </if>
            <if test="checker != null and checker!=''" >
                checker = #{checker},
            </if>
 
            <if test="checkerContent != null and checkerContent!=''" >
                checker_content = #{checkerContent} ,
            </if>
            <if test="enterpriseContent != null and enterpriseContent!=''" >
                enterprise_content = #{enterpriseContent},
            </if>
            <if test="auditStatus != null and auditStatus!=''" >
                audit_status = #{auditStatus},
            </if>
            <if test="updateTime != null" >
                update_time = #{updateTime}
        </if>
 
        </set>
        where exception_id = #{exceptionId}
    </update>
 
    <select id="conditonQueryDustHistoryData" resultType="com.flightfeather.monitor.pojo.DustSiteData">
        select a.*,b.*
        from ja_t_dust_site_data_info as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="siteName !=null and siteName != ''">
<!--                b.name like concat('%',#{siteName},'%')-->
                b.name = #{siteName}
            </if>
            <if test="mnCode !=null and mnCode != ''">
                and a.mn_code = #{mnCode}
            </if>
            <if test="beginTime != null and endTime != null">
                and a.lst between #{beginTime} and #{endTime}
            </if>
 
            <if test="scenarioType != null and scenarioType != '' ">
                and b.typename in
                <foreach item="item" collection="scenarioType" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
        </where>
<!--    limit 0,1000-->
    </select>
 
<!--分析数据-->
    <select id="analysisdata" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">
        select a.*,b.name,b.duty_company from dust_statistics_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name = #{siteName}
            </if>
 
            <if test="beginTime != null and endTime != null">
                and a.Lst between #{beginTime} and #{endTime} and a.type = #{type}
            </if>
        </where>
    </select>
 
 
<!--    &lt;!&ndash;    根据站点名字和时段进行统计分析&ndash;&gt;-->
<!--    <select id="analysisByTime" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">-->
<!--        select  c.name,d.*-->
<!--        from ja_t_dust_site_info as c  join-->
<!--        (-->
<!--        select-->
<!--        mn_code as mn_code,-->
<!--        DATE(lst) as lst,-->
<!--        ROUND(AVG(dust_value),3)  as day_avg,-->
<!--        min(dust_value) as min,-->
<!--        max(dust_value) as max,-->
<!--        CONCAT(ROUND(COUNT(*)/96*100, 2), '%')  as day_online,-->
<!--        CONCAT(ROUND(SUM(CASE WHEN dust_value >0 THEN 1 ELSE 0 END)/96 *100, 2), '%') as day_valid,-->
<!--        CONCAT(ROUND(SUM(CASE WHEN dust_value >= 1  THEN 1 ELSE 0 END)/96*100,2),'%') as  day_exceeding-->
<!--        from ja_t_dust_site_data_info-->
<!--        <where>-->
<!--&lt;!&ndash;            <if test="siteName !=null and siteName != ''">&ndash;&gt;-->
<!--&lt;!&ndash;                b.name = #{siteName}&ndash;&gt;-->
<!--&lt;!&ndash;            </if>&ndash;&gt;-->
 
<!--            <if test="beginTime != null and endTime != null">-->
<!--                lst between #{beginTime} and #{endTime}-->
<!--            </if>-->
 
<!--        </where>-->
<!--        GROUP BY mn_code,DATE(lst)-->
<!--        order by lst asc ) as d  on c.mn_code = d.mn_code-->
<!--    </select>-->
 
    <!--    根据站点名字和时段进行统计分析-->
    <select id="analysisByTime" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">
        select  c.name,d.*
        from ja_t_dust_site_info as c  join dust_statistics_value as d  on c.mn_code = d.mn_code
        <where>
            <if test="beginTime != null and endTime != null">
                d.lst between #{beginTime} and #{endTime} and d.type = 'day'
            </if>
        </where>
        order by d.day_avg desc
    </select>
 
 
    <!--条件查询异常数据  加上了审计信息-->
    <select id="getExceptionData" resultType="com.flightfeather.monitor.pojo.DustExceptionData">
        select *
        from (select a.* ,b.name,b.typename,b.address,b.duty_company
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name like concat('%',#{siteName},'%')
            </if>
 
            <if test="exceptionType != null and exceptionType != '' ">
                and a.exception_type in
                <foreach item="item" collection="exceptionType" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
 
 
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
        </where>
        )
        as c left join audit_info as d  on c.id = d.exception_id
    </select>
 
 
 
    <!--   根据某段时间内某个异常类型查询对应的店铺名称和设备编号-->
    <select id="getExceptionSitenameAndCode" resultType="com.flightfeather.monitor.pojo.DustExceptionData">
        select DISTINCT b.name,a.mn_code
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
 
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name = #{siteName}
            </if>
            <if test="exceptionType !=null and exceptionType != ''">
                and a.exception_type  = #{exceptionType}
            </if>
 
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
            <if test="street != null and street != '' ">
                and b.address in
                <foreach item="item" collection="street" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
            <if test="dutyCompany != null and dutyCompany != '' ">
                and b.duty_company in
                <foreach item="item" collection="dutyCompany" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
        </where>
    </select>
 
<!--    条件查询历史数据-->
    <select id="conditonQueryHistoryData" resultType="com.flightfeather.monitor.pojo.DustSiteData">
        select a.*,b.name,b.duty_Company
        from ja_t_dust_site_data_info as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name  = #{siteName}
            </if>
 
            <if test="beginTime != null and endTime != null">
                and a.lst between #{beginTime} and #{endTime}
            </if>
        </where>
        order by a.lst asc
    </select>
 
    <select id="getHasAuditedData" resultType="com.flightfeather.monitor.pojo.DustExceptionData">
        select *
        from dust_exception_data as a left join audit_info as b on a.id = b.exception_id
        <where>
            <if test="beginTime != null and endTime != null">
                (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime}) and b.audit_status != 0
 
            </if>
        </where>
 
    </select>
    <select id="getSiteNameByTimeAndExceptionType" resultType="com.flightfeather.monitor.pojo.DustExceptionData">
        select DISTINCT b.name
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="exceptionType != null and exceptionType != '' ">
                a.exception_type in
                <foreach item="item" collection="exceptionType" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
 
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
        </where>
 
    </select>
    <select id="analysisdataByType" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">
        select a.*,b.name,b.duty_company from dust_statistics_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        <where>
            <if test="month != null and month != null">
               a.lst  = #{month}
            </if>
 
            <if test="type != null and type != ''">
                and a.type  = #{type}
            </if>
        </where>
    </select>
 
 
    <select id="analysisdataByTimeAndType" resultType="com.flightfeather.monitor.pojo.AnalysisDustData">
        select a.*,b.name,b.duty_company from dust_statistics_value as a join ja_t_dust_site_info as b on a.mn_code = b. mn_code
        <where>
            <if test="beginTime != null and endTime != null">
                a.Lst between #{beginTime} and #{endTime}
            </if>
 
            <if test="type != null and type != ''">
                and a.type  = #{type}
            </if>
        </where>
    </select>
 
    <select id="getExceptionData2" resultType="com.flightfeather.monitor.pojo.DustExceptionData">
 
       select a.* ,b.*
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="street != null and street != '' ">
                 b.address in
                <foreach item="item" collection="street" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
 
            <if test="dutyCompany != null and dutyCompany != '' ">
                and b.duty_company in
                <foreach item="item" collection="dutyCompany" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
            <if test="siteName !=null and siteName != ''">
                and b.name like concat('%',#{siteName},'%')
            </if>
 
            <if test="exceptionType != null and exceptionType != '' ">
                and a.exception_type in
                <foreach item="item" collection="exceptionType" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
 
 
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
 
 
 
        </where>
 
    </select>
    <select id="exceptionNum" resultType="java.lang.Integer">
        select count(*)
        from dust_exception_data as a join ja_t_dust_site_info as b on a.mn_code = b.mn_code
        <where>
            <if test="siteName !=null and siteName != ''">
                b.name = #{siteName}
            </if>
            <if test="exceptionType != null and exceptionType != '' ">
                and a.exception_type = #{exceptionType}
            </if>
 
            <if test="street != null and street != '' ">
                and b.address in
                <foreach item="item" collection="street" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
 
            <if test="dutyCompany != null and dutyCompany != '' ">
                and b.duty_company in
                <foreach item="item" collection="dutyCompany" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
 
            <if test="beginTime != null and endTime != null">
                and (a.begin_time between #{beginTime} and #{endTime} or a.end_time between #{beginTime} and  #{endTime})
            </if>
 
        </where>
 
    </select>
 
</mapper>