xieb
2024-05-07 5e972eb9928c39b5abbdfd35e2a0aeff40876e7d
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
<?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="cn.gistack.sm.resDataCheck.mapper.QualityManageDetailMapper">
 
 
    <insert id="saveQualityManageDetail">
 
        insert into
            SM_RES_DATA_QUALITY_MANAGE_DETAIL
            (
                res_id,rule_id,rule_name,rule_description,create_time,update_time,val,
                is_gate,eng_scal,is_danger,town_code,town_name,county_code,county_name,city_code,city_name,
                res_reg_code,res_name,rz,tb_weir_top_elevation,tb_flse_lim_stag,tb_norm_pool_stag,tb_control_z,tb_des_fl_stag,tb_dam_top_elevation,tb_dead_stag,flag,remark
            )
        select
            distinct
            a."guid" as res_id,
            ${rule.id} AS rule_id,
            ${rule.name}AS rule_name,
            ${rule.description}AS rule_description,
            NOW() AS create_time,
            NOW() AS update_time,
            ${varStr},
            a."is_gate" AS is_gate,
            a."eng_scal" AS eng_scal,
            dria."is_danger_res" AS is_danger,
 
            case when town."ad_grad" = 4 THEN town."ad_code" ELSE NULL END AS town_code,
            case when town."ad_grad" = 4 THEN town."ad_name" ELSE NULL END AS town_name,
 
            case when town."ad_grad" = 3 THEN town."ad_code"
                 when county."ad_grad" = 3 THEN county."ad_code" END AS county_code,
 
            case when town."ad_grad" = 3 THEN town."ad_name"
                 when county."ad_grad" = 3 THEN county."ad_name" END AS county_name,
 
            case when town."ad_grad" = 2 THEN town."ad_code"
                 when county."ad_grad" = 2 THEN county."ad_code"
                 ELSE city."ad_code" END AS city_code,
 
            case when town."ad_grad" = 2 THEN town."ad_name"
                 when county."ad_grad" = 2 THEN county."ad_name"
                 ELSE city."ad_name" END AS city_name,
 
            a."res_reg_code" as res_reg_code,
            a."name" as res_name,
            f."rz" as rz,
            g."tb_weir_top_elevation",
            d2."tb_flse_lim_stag",
            c."tb_norm_pool_stag",
            b."tb_control_z",
            c."tb_des_fl_stag",
            h."tb_dam_top_elevation",
            c."tb_dead_stag",
            case when f."flag" = '老库' THEN '地方平台'
                 when f."flag" = '物联网' THEN '省级平台'
                 when f."flag" = '水文' THEN '水文系统'
                 else ''
                end as flag,
            ${rule.description} as remark
 
 
            from SJZT_MD."att_res_base" a
 
                 LEFT JOIN SJZT_MD."att_ad_base" town ON town."guid" = a."interior_ad_guid"
                 LEFT JOIN SJZT_MD."att_ad_base" county ON county."guid" = town."p_ad_code"
                 LEFT JOIN SJZT_MD."att_ad_base" city ON city."guid" = county."p_ad_code"
 
                 left join SJZT_DW."dim_res_info_a" dria ON (dria."guid" = a."guid")
                 left join SJZT_MD."att_res_danger_manage_special" b on (a."guid" = b."res_guid")
                 left join SJZT_MD."att_res_stag_char" c on (a."guid" = c."res_guid")
                 left join SJZT_MD."att_res_flse_lim" d1 on (a."guid" = d1."res_guid" and d1."flood_season_name" = '前汛期')
                 left join SJZT_MD."att_res_flse_lim" d2 on (a."guid" = d2."res_guid" and d2."flood_season_name" = '中汛期')
                 left join SJZT_MD."att_res_flse_lim" d3 on (a."guid" = d3."res_guid" and d3."flood_season_name" = '后汛期')
                 left join SJZT_MD."att_st_base" e on (a."guid" = e."res_guid" and e."is_main_rsvr" = '1')
                 left join SJZT_MD."st_rsvr_r_last" f on (e."code" = f."stcd")
                 left join (select tmp."res_guid",max(tmp."tb_weir_top_elevation") "tb_weir_top_elevation" from SJZT_MD."att_res_rsb_norspi" tmp group by tmp."res_guid") g on (a."guid" = g."res_guid")
                 left join (select tmp2."res_guid",max(tmp2."tb_dam_top_elevation") "tb_dam_top_elevation" from SJZT_MD."att_res_water_block" tmp2 group by tmp2."res_guid") h on (a."guid" = h."res_guid")
            ${whereStr}
    </insert>
 
 
 
 
    <select id="selectCustomizePage" resultType="cn.gistack.sm.resDataCheck.vo.QualityManageDetailVO">
        SELECT
            MAX(id) id,
            RES_ID,
            MAX(is_gate) is_gate,
            MAX(eng_scal) eng_scal,
            MAX(is_danger) is_danger,
            MAX(town_code) town_code,
            MAX(town_name) town_name,
            MAX(county_code)county_code,
            MAX(county_name)county_name,
            MAX(city_code) city_code,
            MAX(city_name) city_name,
            MAX(res_reg_code) res_reg_code,
            MAX(res_name) res_name,
            MAX(rz) rz,
            MAX(tb_flse_lim_stag) tb_flse_lim_stag,
            MAX(tb_weir_top_elevation) tb_weir_top_elevation,
            MAX(tb_norm_pool_stag) tb_norm_pool_stag,
            MAX(tb_control_z) tb_control_z,
            MAX(tb_des_fl_stag) tb_des_fl_stag,
            MAX(tb_dam_top_elevation) tb_dam_top_elevation,
            MAX(tb_dead_stag) tb_dead_stag,
            replace(wm_concat(remark),',',';') as remark,
            MAX(create_time) create_time,
            MAX(flag) flag
        from YWXT.SM_RES_DATA_QUALITY_MANAGE_DETAIL
        where
            1=1
        <if test="vo.resId != null and vo.resId != ''">
            AND res_id = #{vo.resId}
        </if>
        <if test="vo.resName != null and vo.resName != ''">
            AND res_name LIKE CONCAT('%', #{vo.resName},'%')
        </if>
        <if test="vo.startTime != null and vo.startTime != ''">
            AND create_time  &gt;= #{vo.startTime}
        </if>
        <if test="vo.endTime != null and vo.endTime !='' ">
            AND create_time &lt;= #{vo.endTime}
        </if>
        <if test="vo.engScal != null and vo.engScal != ''">
            and eng_scal = #{vo.engScal}
        </if>
        <if test="vo.isDanger != null and vo.isDanger != ''">
            and is_danger = #{vo.isDanger}
        </if>
        <if test="vo.cityCode != null and vo.cityCode != ''">
            and city_code = #{vo.cityCode}
        </if>
        <if test="vo.countyCode != null and vo.countyCode != ''">
           and county_code = #{vo.countyCode}
        </if>
        <if test="vo.townCode != null and vo.townCode != ''">
            and town_code= #{vo.townCode}
        </if>
        <if test="vo.flag != null and vo.flag != ''">
            and flag= #{vo.flag}
        </if>
        GROUP BY
            RES_ID
    </select>
    <select id="getAll" resultType="cn.gistack.sm.resDataCheck.vo.QualityManageDetailVO">
        SELECT
        MAX(id) id,
        RES_ID,
        MAX(is_gate) is_gate,
        MAX(eng_scal) eng_scal,
        MAX(is_danger) is_danger,
        MAX(town_code) town_code,
        MAX(town_name) town_name,
        MAX(county_code)county_code,
        MAX(county_name)county_name,
        MAX(city_code) city_code,
        MAX(city_name) city_name,
        MAX(res_reg_code) res_reg_code,
        MAX(res_name) res_name,
        MAX(rz) rz,
        MAX(tb_flse_lim_stag) tb_flse_lim_stag,
        MAX(tb_weir_top_elevation) tb_weir_top_elevation,
        MAX(tb_norm_pool_stag) tb_norm_pool_stag,
        MAX(tb_control_z) tb_control_z,
        MAX(tb_des_fl_stag) tb_des_fl_stag,
        MAX(tb_dam_top_elevation) tb_dam_top_elevation,
        MAX(tb_dead_stag) tb_dead_stag,
        replace(wm_concat(remark),',',';') as remark,
        MAX(create_time) create_time,
        MAX(flag) flag
        from YWXT.SM_RES_DATA_QUALITY_MANAGE_DETAIL
        where
        1=1
        <if test="vo.resId != null and vo.resId != ''">
            AND res_id = #{vo.resId}
        </if>
        <if test="vo.resName != null and vo.resName != ''">
            AND res_name LIKE CONCAT('%', #{vo.resName},'%')
        </if>
        <if test="vo.startTime != null and vo.startTime != ''">
            AND create_time  &gt;= #{vo.startTime}
        </if>
        <if test="vo.endTime != null and vo.endTime !='' ">
            AND create_time &lt;= #{vo.endTime}
        </if>
        <if test="vo.engScal != null and vo.engScal != ''">
            and eng_scal = #{vo.engScal}
        </if>
        <if test="vo.isDanger != null and vo.isDanger != ''">
            and is_danger = #{vo.isDanger}
        </if>
        <if test="vo.cityCode != null and vo.cityCode != ''">
            and city_code = #{vo.cityCode}
        </if>
        <if test="vo.countyCode != null and vo.countyCode != ''">
            and county_code = #{vo.countyCode}
        </if>
        <if test="vo.townCode != null and vo.townCode != ''">
            and town_code= #{vo.townCode}
        </if>
        <if test="vo.flag != null and vo.flag != ''">
            and flag= #{vo.flag}
        </if>
        GROUP BY
        RES_ID
    </select>
 
 
    <select id="exportData" resultType="cn.gistack.sm.resDataCheck.excel.QualityManageDetailExcel">
    SELECT ROWNUM AS no ,t.* from (
        SELECT
        MAX(id) id,
        RES_ID,
        MAX(is_gate) is_gate,
        MAX(eng_scal) eng_scal,
 
        case when max(is_danger)= 'false' THEN '否'
        when max(is_danger)= 'true' THEN '是'
        else ''
        end as is_danger,
 
        MAX(town_code) town_code,
        MAX(town_name) town_name,
        MAX(county_code)county_code,
        MAX(county_name)county_name,
        MAX(city_code) city_code,
        MAX(city_name) city_name,
        MAX(res_reg_code) res_reg_code,
        MAX(res_name) res_name,
        MAX(rz) rz,
        MAX(tb_flse_lim_stag) tb_flse_lim_stag,
        MAX(tb_weir_top_elevation) tb_weir_top_elevation,
        MAX(tb_norm_pool_stag) tb_norm_pool_stag,
        MAX(tb_control_z) tb_control_z,
        MAX(tb_des_fl_stag) tb_des_fl_stag,
        MAX(tb_dam_top_elevation) tb_dam_top_elevation,
        MAX(tb_dead_stag) tb_dead_stag,
        replace(wm_concat(remark),',',';') as remark,
        MAX(create_time) create_time,
        MAX(flag) flag
        from YWXT.SM_RES_DATA_QUALITY_MANAGE_DETAIL
        where
        1=1
        <if test="vo.resId != null and vo.resId != ''">
            AND res_id = #{vo.resId}
        </if>
        <if test="vo.resName != null and vo.resName != ''">
            AND res_name LIKE CONCAT('%', #{vo.resName},'%')
        </if>
        <if test="vo.startTime != null and vo.startTime != ''">
            AND create_time  &gt;= #{vo.startTime}
        </if>
        <if test="vo.endTime != null and vo.endTime !='' ">
            AND create_time &lt;= #{vo.endTime}
        </if>
        <if test="vo.engScal != null and vo.engScal != ''">
            and eng_scal = #{vo.engScal}
        </if>
        <if test="vo.isDanger != null and vo.isDanger != ''">
            and is_danger = #{vo.isDanger}
        </if>
        <if test="vo.cityCode != null and vo.cityCode != ''">
            and city_code = #{vo.cityCode}
        </if>
        <if test="vo.countyCode != null and vo.countyCode != ''">
            and county_code = #{vo.countyCode}
        </if>
        <if test="vo.townCode != null and vo.townCode != ''">
            and town_code= #{vo.townCode}
        </if>
        <if test="vo.flag != null and vo.flag != ''">
            and flag= #{vo.flag}
        </if>
        GROUP BY
        RES_ID
 
        ) t
 
 
    </select>
</mapper>