燕山石化溯源三维电子沙盘-【后端】-服务
1
13693261870
2023-04-26 d254c34b538e190fd5a9355d757f64bd495bdda9
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
<?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.dao.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, 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 c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  0)
        ) AS height0, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  1)
        ) AS height10, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  2)
        ) AS height20, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  3)
        ) AS height30, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  4)
        ) AS height40, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  5)
        ) AS height50, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  6)
        ) AS height60, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  7)
        ) AS height70, (
            SELECT c FROM ${tableName} WHERE id = concat_ws('_', SUBSTRING_INDEX(sy.id,'_',2),  8)
        ) AS height80, (
            SELECT 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, 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="getAlarmsAnalyse" resultMap="SuYuan2dResult">
        SELECT id, x, y, c 
        FROM ${tableName} 
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        AND c > (SELECT jcbj FROM alert_config LIMIT 0, 1)
    </select>
    
    <select id="getWarningAnalyse" resultMap="SuYuan2dResult">
        SELECT id, x, y, c 
        FROM ${tableName} 
        WHERE id IN 
        <foreach collection="ids" item="item" open="(" separator="," close=")">
            #{item}
        </foreach>
        AND c > (SELECT jcyj FROM alert_config LIMIT 0, 1)
    </select>
    
    <select id="getMonitorData" resultMap="SuYuanMonitorDataResult">
        <foreach collection="tableNames" item="tableName" separator=" UNION ">
            SELECT id, 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 id, TRUNCATE(c, 2) AS value, SUBSTRING_INDEX(#{tableName},'_',-1) AS time  
            FROM ${tableName} 
            WHERE id = #{id}
        </foreach>
        ORDER BY value DESC
        LIMIT 0, 1
    </select>
    
    <select id="getTemporary" resultMap="TemporaryResult">
        SELECT  x, y, z, c, u, v, w, 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>
    
    <update id="createTable" parameterType="java.lang.String">
       CREATE TABLE ${tableName}  (
             `id` varchar(255) NOT NULL COMMENT '主键',
          `x` int(7) NULL DEFAULT NULL,
          `y` int(7) NULL DEFAULT NULL,
          `z` int(7) 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>