燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-08-12 ab94a1bded125837276d70cc14a3d8c7282294f4
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
<?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.yssh.mapper.QxshMapper">
    <select id="selectByTime" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time = #{time}
        order by name;
    </select>
 
    <select id="selectMonthTop10" resultType="com.yssh.entity.Qxsh">
        with rs as (
            select id, name, lon, lat, format(value, 2) "value", time
            from yssh_qxsh
            where time like #{time} and name like 'AI-%'
        )
        select id, name, lon, lat, value, time from rs
        order by value desc
        limit 10;
    </select>
 
    <select id="selectWeekTop10" resultType="com.yssh.entity.Qxsh">
        with rs as (
            select id, name, lon, lat, format(value, 2) "value", time
            from yssh_qxsh
            where time between #{start} and #{end} and name like 'AI-%'
        )
        select id, name, lon, lat, value, time from rs
        order by value desc
        limit 10;
    </select>
 
    <select id="selectDayTop10" resultType="com.yssh.entity.Qxsh">
        with rs as (
            select id, name, lon, lat, format(value, 2) "value", time
            from yssh_qxsh
            where time like #{time} and name like 'AI-%'
        )
        select id, name, lon, lat, value, time from rs
        order by value desc
        limit 10;
    </select>
 
    <select id="selectWarnByBeginAndEnd" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcyj from alert_config limit 1) and value &lt;= (select jcbj from alert_config limit 1)
        order by time desc, name;
    </select>
 
    <select id="selectAlarmByBeginAndEnd" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcbj from alert_config limit 1)
        order by time desc, name;
    </select>
 
    <select id="countMonthForWarn" resultType="java.lang.Integer">
        select count(*)
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcyj from alert_config limit 1) and value &lt;= (select jcbj from alert_config limit 1);
    </select>
 
    <select id="countMonthForAlarm" resultType="java.lang.Integer">
        select count(*)
        from yssh_qxsh
        where time between #{start} and #{end} and name like 'AI-%'
            and value > (select jcbj from alert_config limit 1);
    </select>
 
    <select id="count7DayForWarn" resultType="java.util.Map">
        with rs as (
            select left(time, 8) "createTime"
            from yssh_qxsh
            where time between #{start} and #{end} and name like 'AI-%'
                and value > (select jcyj from alert_config limit 1) and value &lt;= (select jcbj from alert_config limit 1)
        )
        select createTime, count(*) "num" from rs group by createTime order by createTime;
    </select>
 
    <select id="count7DayForAlarm" resultType="java.util.Map">
        with rs as (
            select left(time, 8) "createTime"
            from yssh_qxsh
            where time between #{start} and #{end} and name like 'AI-%'
                and value > (select jcbj from alert_config limit 1)
        )
        select createTime, count(*) "num" from rs group by createTime order by createTime;
    </select>
 
    <select id="select3Hours" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end}
            and value > (select jcyj from alert_config limit 1) and name like 'AI-%'
        order by time, name;
    </select>
 
    <select id="selectForReport" resultType="com.yssh.entity.Qxsh">
        select id, name, format(value, 2) "value", time
        from yssh_qxsh
        where time between #{start} and #{end}
            and value > (select jcbj from alert_config limit 1) and name like 'AI-%'
        order by time, name;
    </select>
 
    <select id="selectLastYearVal" resultType="java.lang.Double">
         select format(value, 2) "value"
         from yssh_qxsh
         where time = #{time} and name = #{name}
         limit 1;
    </select>
 
    <select id="selectByTimeAndName" resultType="com.yssh.entity.Qxsh">
        select id, name, lon, lat, format(value, 2) "value", time
        from yssh_qxsh
        where time = #{time} and name = #{name}
        limit 1;
    </select>
</mapper>