燕山石化溯源三维电子沙盘-【后端】-服务
13693261870
2024-03-13 f6e0b62b719eeb948125c98cf6ceb249f70645f6
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
<?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.SuYuanMapper">
    <resultMap id="SuYuan2dResult" type="com.yssh.entity.SuYuan2d">
        <result property="id"    column="id"    />
        <result property="x"    column="x"    />
        <result property="y"    column="y"    />
        <result property="value"    column="c"    />
    </resultMap>
    
    <resultMap id="SuYuan3dResult" type="com.yssh.entity.SuYuan3d">
        <result property="id"    column="id"    />
        <result property="x"    column="x"    />
        <result property="y"    column="y"    />
        <result property="height0"    column="height0"    />
        <result property="height10"    column="height10"    />
        <result property="height20"    column="height20"    />
        <result property="height30"    column="height30"    />
        <result property="height40"    column="height40"    />
        <result property="height50"    column="height50"    />
        <result property="height60"    column="height60"    />
        <result property="height70"    column="height70"    />
        <result property="height80"    column="height80"    />
        <result property="height90"    column="height90"    />
    </resultMap>
    
    <resultMap id="DistanceSuYuanResult" type="com.yssh.entity.DistanceSuYuan">
        <result property="id"    column="id"    />
        <result property="x"    column="x"    />
        <result property="y"    column="y"    />
        <result property="u"    column="u"    />
        <result property="v"    column="v"    />
        <result property="vocsValue"    column="c"    />
    </resultMap>
    
    <resultMap id="TemporaryResult" type="com.yssh.entity.Temporary">
        <result property="id"    column="id"    />
        <result property="x"    column="x"    />
        <result property="y"    column="y"    />
        <result property="z"    column="z"    />
        <result property="u"    column="u"    />
        <result property="v"    column="v"    />
        <result property="w"    column="w"    />
        <result property="c"    column="c"    />
    </resultMap>
    
    <resultMap id="SuYuanMonitorDataResult" type="com.yssh.entity.SuYuanMonitorData">
        <result property="id"    column="id"    />
        <result property="value"    column="c"    />
        <result property="time"    column="time"    />
    </resultMap>
 
    <select id="get2d" resultMap="SuYuan2dResult">
        SELECT id, x, y, format(c, 2) "c"
        FROM ${tableName} 
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        ORDER BY z ASC, x ASC, y DESC
    </select>
    
    <select id="get3d" resultMap="SuYuan3dResult">
        SELECT sy.id, sy.x, sy.y,  sy.id, sy.x, sy.y, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  0)
        ) AS height0, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  1)
        ) AS height10, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  2)
        ) AS height20, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  3)
        ) AS height30, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  4)
        ) AS height40, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  5)
        ) AS height50, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  6)
        ) AS height60, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  7)
        ) AS height70, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  8)
        ) AS height80, (
            SELECT format(c, 2) "c" FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  9)
        ) AS height90
        FROM ${tableName} AS sy
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        ORDER BY sy.z ASC, sy.x ASC, sy.y DESC
    </select>
    
    <select id="getDistanceSuYuan" resultMap="DistanceSuYuanResult">
        SELECT id, x, y, format(c, 2) "c", u, v
        FROM ${tableName} 
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        ORDER BY z ASC, x ASC, y DESC
    </select>
 
    <select id="getSuYuan500Max" resultMap="DistanceSuYuanResult">
        select id, x, y, format(c, 2) "c", u, v
        from ${tableName}
        where id in
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        order by c desc
        limit 1;
    </select>
 
    <select id="getSuYuan500MaxByFilter" resultMap="DistanceSuYuanResult">
        select id, x, y, format(c, 2) "c", u, v
        from ${tableName}
        where ${filter}
        order by c desc
        limit 1;
    </select>
 
    <select id="getSuYuanById" resultMap="DistanceSuYuanResult">
        select id, x, y, format(c, 2) "c", u, v
        from ${tableName}
        where id = #{id}
    </select>
    
    <select id="getAlarmsAnalyse" resultMap="SuYuan2dResult">
        SELECT id, x, y, format(c, 2) "c"
        FROM ${tableName} 
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        AND c >= (SELECT jcbj FROM alert_config LIMIT 1)
    </select>
 
    <select id="getWarningAnalyse" resultMap="SuYuan2dResult">
        SELECT id, x, y, format(c, 2) "c"
        FROM ${tableName}
        WHERE id IN
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        and c >= (select jcyj from alert_config limit 1) and c &lt; (select jcbj from alert_config limit 1)
    </select>
    
    <select id="getMonitorData" resultMap="SuYuanMonitorDataResult">
        <foreach collection="tableNames" item="tableName" separator=" UNION ">
            SELECT id, format(c, 2) "c", SUBSTRING_INDEX(#{tableName}, '_', -1) AS time
            FROM ${tableName} 
            WHERE id = #{id}
        </foreach>
    </select>
    
    <select id="getMonthValueDataMax" resultType="java.util.Map">
        <foreach collection="tableNames" item="tableName" separator=" UNION ">
            SELECT format(c, 2) AS value, SUBSTRING_INDEX(#{tableName}, '_', -1) AS time
            FROM ${tableName}
            WHERE id = #{id}
        </foreach>
        ORDER BY value DESC
        LIMIT 1
    </select>
 
    <select id="selectSuYuan700ById" resultType="com.yssh.entity.SuYuan700">
        select * from suyuan_70_70
        where su_yuan_id = #{id} and create_time = #{time}
        limit 1;
    </select>
 
    <select id="selectSuYuan46ById" resultType="com.yssh.entity.SuYuan700">
        select * from suyuan_46
        where su_yuan_id = #{id} and create_time = #{time}
        limit 1;
    </select>
    
    <select id="getTemporary" resultMap="TemporaryResult">
        SELECT  x, y, z, u, v, w, format(c, 2) "c"
        FROM ${tableName}
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        ORDER BY z ASC, x ASC, y DESC
    </select>
    
    <insert id="batchInsert">
        INSERT INTO ${tableName} (
            id,x,y,z,u,v,w,c
        )VALUES
        <foreach collection="datas" item="item" separator=",">
            (
                #{item.id}, 
                #{item.x}, 
                #{item.y}, 
                #{item.z}, 
                #{item.u},
                #{item.v}, 
                #{item.w},
                #{item.c}
            )
        </foreach>
    </insert>
 
    <select id="isTableExists" resultType="java.lang.Integer">
        select count(*) from information_schema.tables where table_name = #{tableName};
    </select>
 
    <select id="selectFastById" resultType="com.yssh.entity.SuYuanFast">
        select * from yssh.suyuan_fast
        where su_yuan_id = #{id} and create_time = #{time}
        order by id;
    </select>
 
    <update id="createTable" parameterType="java.lang.String">
        create table ${tableName}  (
                 `id` varchar(10) not null comment '主键',
              `x` int(3) null default null,
              `y` int(3) null default null,
              `z` int(2) null default null,
              `u` double null default null,
              `v` double null default null,
              `w` double null default null,
              `c` double null default null,
              primary key (`id`) using btree
        ) engine = innodb character set = utf8 collate = utf8_general_ci row_format = dynamic;
    </update>
    
    <update id="update" >
        UPDATE ${tableName} SET c = #{value} WHERE id = #{id}
    </update>
 
    <update id="updateVocsName">
        update ${table} set vocsName = #{vocsName} where id = #{id};
    </update>
</mapper>