zmc
2023-08-14 9376436cdd6e3986cc4af4b4a6aa9e78e2b32de0
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
<?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.job.zsc.mapper.FugitiveDustMapper">
 
    <select id="conditonQueryDustHistoryData" resultType="com.job.zsc.pojo.DustSiteData">
        select *
        from monitor_site
        <where>
            <if test="siteName !=null and siteName != ''">
                Name like concat('%',#{siteName},'%')
            </if>
            <if test="mnCode !=null and mnCode != ''">
                and MN_Code = #{mnCode}
            </if>
            <if test="beginTime != null and endTime != null">
                and Lst between #{beginTime} and #{endTime}
            </if>
 
            <if test="scenarioType != null and scenarioType != '' ">
                and Type_Name in
                <foreach item="item" collection="scenarioType" separator="," open="("  close=")">
                    #{item}
                </foreach>
            </if>
        </where>
<!--    limit 0,1000-->
    </select>
 
<!--分析数据-->
    <select id="analysisdata" resultType="com.job.zsc.pojo.AnalysisDustData">
        select a.* 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}
            </if>
        </where>
    </select>
 
 
<!--    根据站点名字和时段进行统计分析-->
<!--    <select id="analysisByTime" resultType="com.job.zsc.pojo.AnalysisDustData">-->
<!--        select-->
<!--        a.mn_code as mn_code,-->
<!--        DATE(a.lst) as lst,-->
<!--        ROUND(AVG(a.dust_value),3)  as day_avg,-->
<!--        CONCAT(ROUND(COUNT(*)/96*100, 2), '%')  as day_online,-->
<!--        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >0 THEN 1 ELSE 0 END)/COUNT(*) *100, 2), '%') as day_valid,-->
<!--        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >= 1  THEN 1 ELSE 0 END)/96*100,2),'%') as  day_exceeding-->
<!--        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>-->
<!--        group by a.mn_code,DATE(a.lst)-->
<!--        order by lst asc-->
<!--    </select>-->
    <!--    根据站点名字和时段进行统计分析-->
    <select id="analysisByTime" resultType="com.job.zsc.pojo.AnalysisDustData">
        select  c.name,d.*
        from ja_t_dust_site_info as c  join
        (select
        a.mn_code as mn_code,
        DATE(a.lst) as lst,
        ROUND(AVG(a.dust_value),3)  as day_avg,
        CONCAT(ROUND(COUNT(*)/96*100, 2), '%')  as day_online,
        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >0 THEN 1 ELSE 0 END)/COUNT(*) *100, 2), '%') as day_valid,
        CONCAT(ROUND(SUM(CASE WHEN a.dust_value >= 1  THEN 1 ELSE 0 END)/96*100,2),'%') as  day_exceeding
        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>
        GROUP BY a.mn_code,DATE(a.lst)
        order by lst asc ) as d  on c.mn_code = d.mn_code
    </select>
</mapper>