zmc
2023-07-11 863e6585bbbeac284a1bdfb5193846565cb80c05
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
<?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.AnalysisDataMapper">
 
 
    <select id="findByDevId" resultType="com.job.zsc.pojo.AnalysisData">
    select * from analysis_data
    <where>
        <if test="devId != null and devId != '' ">
            fume_dev_id=#{devId}
        </if>
 
        <if test="begin != null and end != null">
            and fume_date between #{begin} and #{end}
        </if>
    </where>
    </select>
 
    <select id="find" resultType="com.job.zsc.pojo.AnalysisData">
        SELECT
        equipment_number as fume_dev_id,
        DATE(reporting_time) as fume_date,
        MIN(smoke_pop_density) as fume_day_min,
 
        MAX(smoke_pop_density) as fume_day_max,
 
        AVG(smoke_pop_density) as fume_day_average,
 
        CONCAT(ROUND(SUM(CASE WHEN smoke_pop_density > 0 and purifier > 0 THEN 1 ELSE 0 END)/144 * 100, 2), '%') as purifier_open_rate,
        SUM(CASE WHEN smoke_push_density >= 1 OR smoke_pop_density >= 1 THEN 1 ELSE 0 END) AS fume_minute_exceeding_num,
        CONCAT(ROUND(SUM(CASE WHEN smoke_push_density >= 1 OR smoke_pop_density >= 1 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_over_standard_rate,
        CONCAT(ROUND(SUM(CASE WHEN smoke_push_density > 0 OR smoke_pop_density > 0 THEN 1 ELSE 0 END)/COUNT(*) * 100, 2), '%') as fume_data_efficiency,
 
        CONCAT(ROUND(COUNT(*)/144 * 100, 2), '%') as daily_online_rate,
        CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_online_rate,
        CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END)/24 * 100, 2), '%') as night_online_rate,
        CONCAT(ROUND(SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_online_rate,
 
        CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/24 * 100, 2), '%') as noon_valid_rate,
        CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/24* 100, 2), '%') as night_valid_rate,
        CONCAT(ROUND(SUM(CASE WHEN ((TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59')) AND (smoke_push_density > 0 OR smoke_pop_density > 0) THEN 1 ELSE 0 END)/48* 100, 2), '%') as key_valid_rate,
 
        CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as noon_opening_count,
        CONCAT(ROUND(SUM(CASE WHEN TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59' THEN 1 ELSE 0 END) /24 * 100, 2), '%') as night_opening_count,
        CONCAT(ROUND(SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59') THEN 1 ELSE 0 END)/48 * 100, 2), '%') as 'key_opening_rate',
 
        SUM(CASE WHEN (TIME(attribution_time) BETWEEN '10:00:00' and '14:00:00') and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END) as noon_exceeding_num,
        SUM(CASE WHEN (TIME(attribution_time) BETWEEN '17:00:00' and '21:00:00') and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END) as night_exceeding_num,
        CONCAT(ROUND(SUM(CASE WHEN ((TIME(attribution_time) BETWEEN '10:00:00' and '13:59:59') or (TIME(attribution_time) BETWEEN '17:00:00' and '20:59:59'))and (smoke_push_density >= 1 OR smoke_pop_density >= 1) THEN 1 ELSE 0 END)/48 * 100, 2), '%') as key_exceeding_rate
        FROM
        ed_data
        <where>
            <if test="shopname != null and shopname != '' ">
                shop_name like concat('%',#{shopname},'%')
            </if>
            <if test="value != null and value != '' ">
                or shop_name like concat('%',#{value},'%')
            </if>
            <if test="begin != null and end != null">
               and reporting_time between #{begin} and #{end}
            </if>
        </where>
        GROUP BY equipment_number, DATE(reporting_time)
        limit 0,500
    </select>
 
 
    <!-- 去重-->
    <select id="search" resultType="Integer">
        select count(*) from fm_web_analysis_data
        <where>
            <if test="shopname != null and shopname != '' ">
                fume_dev_id=(select fume_dev_id
                from shopname_data
                where shop_name like concat('%',#{shopname},'%'))
            </if>
            <if test="value != null and value != null">
                or shop_name like concat('%',#{value},'%')
            </if>
 
            <if test="begin != null and end != null">
                and (fume_date between #{begin} and #{end})
            </if>
        </where>
        group by fume_dev_id
    </select>
</mapper>