tangzy
2021-09-25 0cfec24a4eb3807acc3014b92b7e2ebc7b804f1c
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
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
<?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="org.springblade.modules.mountainrain.mapper.MountainrainMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="mountainrainResultMap" type="org.springblade.modules.mountainrain.entity.Mountainrain">
        <result column="id" property="id"/>
        <result column="crainfall" property="crainfall"/>
        <result column="cenconding" property="cenconding"/>
        <result column="gohour" property="gohour"/>
        <result column="gthour" property="gthour"/>
        <result column="gshour" property="gshour"/>
        <result column="imohour" property="imohour"/>
        <result column="imthour" property="imthour"/>
        <result column="imshour" property="imshour"/>
    </resultMap>
 
    <!--山洪预警全查-->
    <resultMap id="ResultMap" type="org.springblade.modules.mountainrain.vo.MountainrainSSVO">
        <result column="id" property="id"/>
        <result column="cenconding" property="cenconding"/>
        <result column="aconding" property="aconding"/>
        <result column="township" property="township"/>
        <result column="village" property="village"/>
        <result column="village_group" property="village_group"/>
        <result column="dj" property="dj"/>
        <result column="bw" property="bw"/>
        <result column="fyear" property="fyear"/>
        <result column="tyear" property="tyear"/>
        <result column="oyear" property="oyear"/>
        <result column="county" property="county"/>
        <result column="crainfall" property="crainfall"/>
        <result column="arainfall" property="arainfall"/>
        <result column="gohour" property="gohour"/>
        <result column="gthour" property="gthour"/>
        <result column="gshour" property="gshour"/>
        <result column="imohour" property="imohour"/>
        <result column="imthour" property="imthour"/>
        <result column="imshour" property="imshour"/>
    </resultMap>
 
 
    <!-- 通用查询映射结果 -->
    <resultMap id="mountainrainResultMaps" type="org.springblade.modules.mountainrain.vo.MountainrainsVO">
        <result column="c" property="c"/>
        <result column="cenconding" property="cenconding"/>
        <result column="b" property="b"/>
        <result column="aconding" property="aconding"/>
    </resultMap>
 
 
    <resultMap id="mountainrainResultMapcInfo" type="org.springblade.modules.mountainrain.vo.MountainrainsCVO">
        <result column="c" property="c"/>
        <result column="cenconding" property="cenconding"/>
        <result column="crainfall" property="crainfall"/>
        <result column="gohour" property="gohour"/>
        <result column="gthour" property="gthour"/>
        <result column="gshour" property="gshour"/>
        <result column="imohour" property="imohour"/>
        <result column="imthour" property="imthour"/>
        <result column="imshour" property="imshour"/>
        <result column="drp1" property="drp1"/>
        <result column="drp3" property="drp3"/>
        <result column="drp6" property="drp6"/>
        <result column="township" property="township"/>
        <result column="village" property="village"/>
        <result column="village_group" property="village_group"/>
        <result column="dj" property="dj"/>
        <result column="bw" property="bw"/>
        <result column="county" property="county"/>
        <result column="fyear" property="fyear"/>
        <result column="tyear" property="tyear"/>
        <result column="oyear" property="oyear"/>
        <result column="dyp" property="dyp"/>
    </resultMap>
 
    <resultMap id="mountainrainResultMapaInfo" type="org.springblade.modules.mountainrain.vo.MountainrainsAVO">
        <result column="c" property="c"/>
        <result column="aconding" property="aconding"/>
        <result column="arainfall" property="arainfall"/>
        <result column="gohour" property="gohour"/>
        <result column="gthour" property="gthour"/>
        <result column="gshour" property="gshour"/>
        <result column="imohour" property="imohour"/>
        <result column="imthour" property="imthour"/>
        <result column="imshour" property="imshour"/>
        <result column="drp1" property="drp1"/>
        <result column="drp3" property="drp3"/>
        <result column="drp6" property="drp6"/>
        <result column="township" property="township"/>
        <result column="village" property="village"/>
        <result column="village_group" property="village_group"/>
        <result column="dj" property="dj"/>
        <result column="bw" property="bw"/>
        <result column="county" property="county"/>
        <result column="fyear" property="fyear"/>
        <result column="tyear" property="tyear"/>
        <result column="oyear" property="oyear"/>
        <result column="dyp" property="dyp"/>
    </resultMap>
 
    <resultMap id="DPFX" type="org.springblade.modules.mountainrain.vo.MountainrainsDPVO">
        <result column="sttp" property="sttp"/>
        <result column="count" property="count"/>
    </resultMap>
 
 
    <select id="selectMountainrainPage" resultMap="mountainrainResultMap">
        select *
        from blade_mountainrain
    </select>
    <select id="selectNoticePage" resultMap="ResultMap">
        SELECT
        mr.id,
        mr.cenconding,
        mr.township,
        mr.village,
        mr.village_group as village_group,
        Convert(decimal(18,4),mr.dj) as dj,
        Convert(decimal(18,4),mr.bw) as bw,
        mr.fyear,
        mr.tyear,
        mr.oyear,
        mr.county,
        mr.crainfall,
        isnull(mr.gohour,0) gohour,
        isnull(mr.gthour,0) gthour,
        isnull(mr.gshour,0) gshour,
        isnull(mr.imohour,0) imohour,
        isnull(mr.imthour,0) imthour,
        isnull(mr.imshour,0) imshour
        FROM
        dbo.blade_mountain mr
        where 1=1
        <if test="mountainrainSSVO.crainfall!=null">
            and mr.crainfall like '%' + #{mountainrainSSVO.crainfall} + '%'
        </if>
        <if test="mountainrainSSVO.arainfall!=null">
            and mr.arainfall like '%' + #{mountainrainSSVO.arainfall} + '%'
        </if>
        <if test="mountainrainSSVO.township!=null">
            and mr.township like '%' + #{mountainrainSSVO.township} + '%'
        </if>
        <if test="mountainrainSSVO.village_group!=null">
            and mr.village_group like '%' + #{mountainrainSSVO.village_group} + '%'
        </if>
        <if test="mountainrainSSVO.county!=null">
            and mr.county like '%' + #{mountainrainSSVO.county} + '%'
        </if>
        <if test="mountainrainSSVO.village!=null">
            and mr.village like '%' + #{mountainrainSSVO.village} + '%'
        </if>
        ORDER BY mr.cenconding
    </select>
    <select id="selectInfo" resultMap="ResultMap">
        SELECT mr.id,
               mr.cenconding,
               mr.aconding,
               mr.township,
               mr.village,
               mr.village_group as   village_group,
               mr.dj,
               mr.bw,
               mr.fyear,
               mr.tyear,
               mr.oyear,
               mr.county,
               mr.crainfall,
               mr.arainfall,
               isnull(mr.gohour, 0)  gohour,
               isnull(mr.gthour, 0)  gthour,
               isnull(mr.gshour, 0)  gshour,
               isnull(mr.imohour, 0) imohour,
               isnull(mr.imthour, 0) imthour,
               isnull(mr.imshour, 0) imshour
        FROM dbo.blade_mountain mr
        where mr.id = #{id}
    </select>
 
 
    <select id="selectcInfos" resultMap="mountainrainResultMapcInfo">
        SELECT cs.id,
               cs.cenconding,
               cs.crainfall,
               isnull(cs.gohour, 0)   gohour,
               isnull(cs.gthour, 0)   gthour,
               isnull(cs.gshour, 0)   gshour,
               isnull(cs.imohour, 0)  imohour,
               isnull(cs.imthour, 0)  imthour,
               isnull(cs.imshour, 0)  imshour,
               css.drp1,
               cs2.drp3,
               cs6.drp6,
               isnull(csd.dyp, 0)     dyp,
               cs.township,
               cs.village,
               cs.village_group,
               cs.dj,
               cs.bw,
               cs.county,
               isnull(cs.fyear, 0) as fyear,
               isnull(cs.tyear, 0) as tyear,
               isnull(cs.oyear, 0) as oyear
        FROM (SELECT id,
                     cenconding,
                     crainfall,
                     township,
                     village,
                     village_group,
                     dj,
                     bw,
                     county,
                     fyear,
                     tyear,
                     oyear,
                     gohour,
                     gthour,
                     gshour,
                     imohour,
                     imthour,
                     imshour
              FROM blade_mountain) cs
                 INNER JOIN (
            SELECT ISNULL(SUM(str.DRP), 0) AS drp1,
                   STCD
            FROM dbo.ST_PPTN_R str
            WHERE str.TM &gt; #{dateEnd1}
              AND str.TM &lt;= #{times}
            GROUP BY STCD
        ) css ON css.STCD = cs.cenconding
                 FULL JOIN (
            SELECT ISNULL(SUM(s.DRP), 0) AS drp3,
                   STCD
            FROM dbo.ST_PPTN_R s
            WHERE s.TM &gt; #{dateEnd3}
              AND s.TM &lt;= #{times}
            GROUP BY STCD
        ) cs2 ON cs2.STCD = cs.cenconding
                 FULL JOIN (
            SELECT ISNULL(SUM(strs.DRP), 0) AS drp6,
                   STCD
            FROM dbo.ST_PPTN_R strs
            WHERE strs.TM &gt; #{dateEnd6}
              AND strs.TM &lt;= #{times}
            GROUP BY STCD
        ) cs6 ON cs6.STCD = cs.cenconding
                 FULL JOIN (
            SELECT SUM(strd.DRP) AS dyp,
                   STCD
            FROM dbo.ST_PPTN_R strd
            WHERE strd.TM &gt; #{timess}
              AND strd.TM &lt;= #{times}
            GROUP BY STCD
        ) csd on csd.STCD = cs.cenconding
    </select>
 
 
    <select id="selectCode" resultType="java.lang.String">
        SELECT stuff((
            SELECT ',' + CONVERT(VARCHAR (25), m.cenconding)
            FROM dbo.blade_mountain m
                     INNER JOIN ST_STBPRP_B s ON s.STCD = m.cenconding
            GROUP BY m.cenconding FOR XML PATH ('')),
        1,
        1,
    ''
    ) AS siteids
    </select>
 
    <select id="Mountains" resultMap="mountainrainResultMapcInfo">
        SELECT cs.id,
               cs.cenconding,
               cs.crainfall,
               isnull(cs.gohour, 0)     gohour,
               isnull(cs.gthour, 0)     gthour,
               isnull(cs.gshour, 0)     gshour,
               isnull(cs.imohour, 0)    imohour,
               isnull(cs.imthour, 0)    imthour,
               isnull(cs.imshour, 0)    imshour,
               isnull(cs.gohours, 0)    gohours,
               isnull(cs.gthours, 0)    gthours,
               a.drp1,
               b.drp2,
               c.drp3,
               cs.township,
               cs.village,
               cs.village_group,
               cs.dj,
               cs.bw,
               cs.county,
               isnull(cs.fyear, 0)   as fyear,
               isnull(cs.tyear, 0)   as tyear,
               isnull(cs.oyear, 0)   as oyear,
               isnull(so.soilval, 0) as soilval
        FROM (
                 SELECT ISNULL(SUM(str.DRP), 0) AS drp1,
                        STCD
                 FROM dbo.ST_PPTN_R str
                 WHERE str.TM &gt; #{dateEnd1}
                   AND str.TM &lt;= #{times}
                   AND str.STCD IN (${code})
                 GROUP BY str.STCD
             ) a
                 FULL JOIN (
            SELECT ISNULL(SUM(s.DRP), 0) AS drp2,
                   STCD
            FROM dbo.ST_PPTN_R s
            WHERE s.TM &gt; #{dateEnd2}
              AND s.TM &lt;= #{times}
              AND s.STCD IN (${code})
            GROUP BY s.STCD
        ) b ON a.STCD = b.STCD
                 FULL JOIN (
            SELECT ISNULL(SUM(strs.DRP), 0) AS drp3,
                   STCD
            FROM dbo.ST_PPTN_R strs
            WHERE strs.TM &gt; #{dateEnd3}
              AND strs.TM &lt;= #{times}
              AND strs.STCD IN (${code})
            GROUP BY STCD
        ) c ON a.STCD = c.STCD
                 LEFT JOIN (
            SELECT id,
                   cenconding,
                   crainfall,
                   township,
                   village,
                   village_group,
                   dj,
                   bw,
                   county,
                   fyear,
                   tyear,
                   oyear,
                   gohour,
                   gthour,
                   gshour,
                   imohour,
                   imthour,
                   imshour,
                   gohours,
                   gthours
            FROM blade_mountain
        ) cs ON cs.cenconding = a.STCD
                 LEFT JOIN (
            SELECT stcd, soilval
            FROM sys_soleval
        ) so ON so.stcd = a.STCD
    </select>
 
    <!--第一种预警-->
    <select id="selecMone" resultType="java.util.Map">
        SELECT cs.STCD,
               cs.STNM,
               cs.STLC,
               cs.ADDVNM,
               cs.RVNM,
               cs.HNNM,
               cs.LTTD,
               cs.LGTD,
               isnull(a.drp1, 0) as drp1,
               isnull(b.drp2, 0) as drp2,
               isnull(c.drp3, 0) as drp3
        FROM (
                 SELECT SUM(str.DRP) AS drp1,
                        STCD
                 FROM dbo.ST_PPTN_R str
                 WHERE str.TM &gt; #{dateEnd1}
                   AND str.TM &lt;= #{times}
                   AND str.STCD IN (${code})
                 GROUP BY str.STCD
             ) a
                 FULL JOIN (
            SELECT SUM(s.DRP) AS drp2,
                   STCD
            FROM dbo.ST_PPTN_R s
            WHERE s.TM &gt; #{dateEnd2}
              AND s.TM &lt;= #{times}
              AND s.STCD IN (${code})
            GROUP BY s.STCD
        ) b ON a.STCD = b.STCD
                 FULL JOIN (
            SELECT SUM(strs.DRP) AS drp3,
                   STCD
            FROM dbo.ST_PPTN_R strs
            WHERE strs.TM &gt; #{dateEnd3}
              AND strs.TM &lt;= #{times}
              AND strs.STCD IN (${code})
            GROUP BY STCD
        ) c ON a.STCD = c.STCD
                 LEFT JOIN (
            SELECT STCD,
                   st.STNM,
                   st.ADDVCD,
                   st.STLC,
                   st.LTTD,
                   st.LGTD,
                   st.RVNM,
                   st.HNNM,
                   ad.ADDVNM
            FROM dbo.ST_STBPRP_B st
                     INNER JOIN dbo.ST_ADDVCD_D ad ON ad.ADDVCD = st.ADDVCD
        ) cs ON cs.STCD = a.STCD
    </select>
 
    <!--土壤湿度计算-->
    <select id="selectMtwo" resultType="java.util.Map">
        SELECT ISNULL(SUM(DRP), 0) AS drp,
               STCD
        FROM dbo.ST_PPTN_R
        WHERE TM &gt; #{time3}
          AND TM &lt;= #{time}
          AND STCD IN (${code})
        GROUP BY STCD
    </select>
 
    <insert id="soleInster">
        insert
        sys_soleval(stcd,soilval) value (
        #{stcd},
        #{soilval}
        )
    </insert>
 
    <delete id="soildel">
        DELETE
        FROM sys_soleval
    </delete>
 
 
    <!--通过行政区编码查询站点-->
    <select id="selectAddvcd" resultType="java.util.Map" >
        SELECT STCD
        FROM dbo.ST_STBPRP_B
        WHERE STTP='RR' AND ADDVCD=#{addvcd}
    </select>
 
    <!-- 批量插入预报信息-->
    <insert id ="insertYuc" parameterType="java.util.List" >
        insert into sys_yucpptn
        (STCD, TM, DRP, INTV)
        values
        <foreach collection ="list" item="reddemCode" index= "index" separator =",">
            (
            #{reddemCode.STCD}, #{reddemCode.TM},
            #{reddemCode.DRP},
            #{reddemCode.INTV}
            )
        </foreach >
    </insert >
</mapper>