shenyijian
2024-08-30 44d30cbd79df473dbdf6d28decde2bbc931c0821
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
452
453
454
455
456
457
458
459
460
461
462
463
464
<?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.sg.mapper.SgProjectInfoMapper">
 
    <select id="queryPageList" resultType="cn.gistack.sm.sg.DO.SgProjectInfoDO">
        SELECT
        info.*,
        dria."city_nm",
        dria."county_nm",
        dria."town_nm",
        dria."eng_scal",
        dria."bas_guid"
        FROM
        YWXT.SG_PROJECT_INFO info
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        WHERE
        1 =1
        <if test="dto.projectName != null and dto.projectName != ''">
            and info.project_name like concat( concat ('%',#{dto.projectName}),'%')
        </if>
        <if test="dto.skName != null and dto.skName != ''">
            and info.sk_name like concat(concat('%',#{dto.skName}),'%')
        </if>
        <if test="dto.lot != null and dto.lot != ''">
            and info.lot = #{dto.lot}
        </if>
        <if test="dto.resCd != null and dto.resCd != '' ">
            and info.sk_id like CONCAT(CONCAT('%', #{dto.resCd}), '%')
        </if>
        <if test="dto.engScal != null and dto.engScal != '' ">
            and dria."eng_scal" like CONCAT(CONCAT('%', #{dto.engScal}), '%')
        </if>
        <if test="dto.status != null">
            and info.status = #{dto.status}
        </if>
        <if test="dto.isBegin != null and dto.isBegin == 1">
            and info.status in(1,2)
        </if>
        <if test="dto.isBegin != null and dto.isBegin == 2">
            and info.status = 0
        </if>
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and info.build_stage = #{dto.buildStage}
        </if>
        <if test="dto.projectIds != null and dto.projectIds.size > 0">
            and info.id in
         <foreach collection="dto.projectIds" item="id" separator="," open="(" close=")">
             #{id}
         </foreach>
        </if>
        <if test="dto.sgCodeS != null and dto.sgCodeS.size > 0">
            and (dria."province_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
                or dria."city_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
                or dria."county_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
                or dria."town_cd" in
            <foreach collection="dto.sgCodeS" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>)
        </if>
        <if test="dto.projectSort == null or dto.projectSort ==0">
            ORDER BY info.status desc ,info.project_progress desc
        </if>
        <if test="dto.projectSort ==1">
            ORDER BY info.project_progress desc
        </if>
        <if test="dto.projectSort != null and dto.projectSort ==2">
            ORDER BY info.sk_id asc
        </if>
    </select>
 
    <sql id="sgCodeCondition">
        <if test="dto.sgCodeS != null and dto.sgCodeS.size() > 0">
            AND (
            <foreach collection="dto.sgCodeS" item="id" separator="OR" open="(" close=")">
                dria.province_cd = #{id}
                OR dria.city_cd = #{id}
                OR dria.county_cd = #{id}
                or dria.town_cd = #{id}
            </foreach>
            )
        </if>
    </sql>
 
    <select id="queryStepByProject" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
 
        SELECT
        pro.id,
        pro.project_name,
        gx.id AS gxId,
        gx.gx_name,
        d.device_name,
        Pdict.dict_key as Ptype,
        Pdict.dict_value as PtypeName,
        d.device_type,
        dict."DICT_VALUE" AS typeName,
        d.id AS dId,
        step.gx_step_name,
        step.gx_step_num,
        step.id AS stepId,
        re.STATUS AS reportStatus,
        d.STATUS AS deviceStatus,
        pro.STATUS AS projectStatus,
        re.id AS reportId,
        pro.lon_lat,
        re.resubmit
        FROM
        ywxt.sg_project_info pro
        LEFT JOIN ywxt.sg_device d ON pro.id = d.program_id
        LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON d.device_type = dict.DICT_KEY AND dict.CODE = 'SG_DEVICE_TYPE'
        LEFT JOIN YWXT."BLADE_DICT_BIZ" Pdict on dict.parent_id = Pdict.id
        LEFT JOIN ywxt.sg_gx gx ON d.device_type = gx.gx_type
        LEFT JOIN ywxt.sg_gx_step step ON gx.id = step.gx_info_id
        LEFT JOIN ywxt.sg_progress_report re ON re.gx_step_id = step.id
        AND re.gx_device_id = d.id
        where 1=1
        <if test="dto.projectId != null and dto.projectId != ''">
            and pro.id = #{dto.projectId}
        </if>
        <if test="dto.projectName != null and dto.projectName != ''">
            and pro.project_name like CONCAT(CONCAT('%', #{dto.projectName}), '%')
        </if>
        <if test="dto.status != null">
            and pro.status = #{dto.status}
        </if>
        <if test="dto.projectIds != null and dto.projectIds.size > 0">
            and pro.id in
            <foreach collection="dto.projectIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
       ORDER BY pro.status desc ,pro.project_progress desc
 
    </select>
    <select id="progressList" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
       SELECT
        pro.id,
        pro.project_name,
        pro.lon_lat,
        pro.status
        FROM
        ywxt.sg_project_info pro
        WHERE 1=1
        <if test="dto.status != null">
        and pro.status = #{dto.status}
    </if>
     <if test="dto.projectName != null and dto.projectName != ''">
         and pro.project_name like CONCAT(CONCAT('%',#{dto.projectName}),'%')
     </if>
    </select>
    <select id="getSgstatiss" resultType="cn.gistack.sm.sg.VO.SgStatisticsVO">
        SELECT
            SUM( CASE WHEN info.STATUS = 0 THEN 1 ELSE 0 END ) AS noCommenceNum,
            SUM( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
            count( info.STATUS ) projectSum
        FROM
            YWXT.SG_PROJECT_INFO info
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        WHERE
            1 = 1
        <if test="grad == 0">
            AND
            info.lot = #{code}
        </if>
        <if test="grad == 2">
            AND
            dria."city_cd" = #{code}
        </if>
        <if test="grad == 3">
            AND
            dria."county_cd" = #{code}
        </if>
 
 
    </select>
 
    <select id="getsgStatisticsList" resultType="cn.gistack.sm.sg.VO.SgStatisProVO">
    SELECT
    a."ad_code" CODE,
    a."ad_name" NAME,
    SUM( CASE WHEN b.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
    count( b.STATUS ) projectSum,
    LISTAGG(b.id, ',') as proIds
FROM
    (
    SELECT
        dria."county_cd" AS countyCode,
        att."guid" AS cityCode,
        ad."ad_code" AS provinceCode,
        info.STATUS,
        info.id
    FROM
        YWXT.SG_PROJECT_INFO info
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        LEFT JOIN YWXT."att_ad_base" att ON att."ad_code" = dria."city_cd"
        LEFT JOIN YWXT."att_ad_base" ad ON att."p_ad_code" = ad."ad_code"
        LEFT JOIN YWXT."att_ad_base" aad ON aad."ad_code" = ad."p_ad_code"
    ) b
    LEFT JOIN YWXT."att_ad_base" a ON (
        ( b.countyCode = a."guid" )
        OR ( b.cityCode = a."guid" )
    OR ( b.provinceCode = a."guid" ))
WHERE
    a."p_ad_code" = #{code}
GROUP BY
    a."ad_code",
    a."ad_name"
    </select>
 
    <select id="getsgStatisticsZero" resultType="cn.gistack.sm.sg.VO.SgStatisProVO">
        SELECT
    dria."city_cd" code, dria."city_nm" name ,
    sum( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
    count( info.STATUS ) projectSum,
    LISTAGG(info.id, ',') as proIds
    FROM
    YWXT.SG_PROJECT_INFO info
    LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
    WHERE
    1 = 1
    <if test="code != null and code != ''">
        AND   info.lot =#{code}
    </if>
    Group By dria."city_cd",dria."city_nm"
    HAVING
    dria."city_cd" IS NOT NULL AND
    dria."city_nm" IS NOT NULL
    </select>
 
    <select id="getsgStatisticsOne" resultType="cn.gistack.sm.sg.VO.SgStatisProVO">
     SELECT
<!--    dria."bas_name" AS code,
    dria."bas_guid" AS name,-->
    info.lot as code,
    info.lot as name,
    sum( CASE WHEN info.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END ) AS commenceNum,
    count( info.STATUS ) AS projectSum,
    LISTAGG(info.id, ',') as proIds
FROM
    YWXT.SG_PROJECT_INFO info
    LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
WHERE
    1 = 1
GROUP BY
     info.lot
 <!--    dria."bas_guid", dria."bas_name" -->
    HAVING
 <!--   dria."bas_guid" IS NOT NULL AND
    dria."bas_name" IS NOT NULL -->
        info.lot is not null
    </select>
 
    <select id="getProjectId" resultType="java.lang.String">
        select id from YWXT.SG_PROJECT_INFO info
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        where info.STATUS<![CDATA[<>]]>'0' and 1=1
        <if test="grad == 0">
            AND
            dria."bas_name" = #{code}
        </if>
        <if test="grad == 2">
            AND
            dria."city_cd" = #{code}
        </if>
        <if test="grad == 3">
            AND
            dria."county_cd" = #{code}
        </if>
    </select>
    <select id="getSgdevices" resultType="cn.gistack.sm.sg.VO.SgStatistccVO">
            SELECT
    dict."DICT_VALUE" AS typeName,
    dict.CODE code,
    count(ds.ID) as deviceNum
FROM
    YWXT."SG_DEVICE" AS ds
    LEFT JOIN YWXT."SG_PROJECT_INFO" AS project ON ds.program_id = project.id
    LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON ds.device_type = dict.DICT_KEY
    AND dict.CODE = 'SG_DEVICE_TYPE'
    LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = project.sk_id
WHERE
    1 =1
        <if test="grad == 0">
            AND
            dria."bas_name" = #{code}
        </if>
        <if test="grad == 2">
            AND
            dria."city_cd" = #{code}
        </if>
        <if test="grad == 3">
            AND
            dria."county_cd" = #{code}
        </if>
    Group By dict.CODE,dict."DICT_VALUE"
    </select>
    <select id="getname" resultType="java.lang.String">
        select DISTINCT  "bas_guid"  from SJZT_DW."dim_res_info_a" where "bas_name" = #{code}
    </select>
    <select id="progressList1" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
        select pro.id,
        pro.project_name,
        pro.lon_lat,
        pro.status
        from
        (SELECT
        pro.id,
        pro.project_name,
        pro.lon_lat,
        pro.status,
        dria."county_cd" AS countyCode,
        att."guid" AS cityCode,
        ad."ad_code" AS provinceCode
        FROM
        ywxt.sg_project_info pro
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = pro.sk_id
        LEFT JOIN YWXT."att_ad_base" att ON att."ad_code" = dria."city_cd"
        LEFT JOIN YWXT."att_ad_base" ad ON att."p_ad_code" = ad."ad_code"
        LEFT JOIN YWXT."att_ad_base" aad ON aad."ad_code" = ad."p_ad_code") pro
         LEFT JOIN YWXT."att_ad_base" a ON (
        ( pro.countyCode = a."guid" )
        OR ( pro.cityCode = a."guid" )
        OR ( pro.provinceCode = a."guid" ))
        WHERE 1=1 and (a."p_ad_code" = #{dto.adCode} or a."ad_code" = #{dto.adCode})
        <if test="dto.status != null">
            and pro.status = #{dto.status}
        </if>
        <if test="dto.projectName != null and dto.projectName != ''">
            and pro.project_name like CONCAT(CONCAT('%',#{dto.projectName}),'%')
        </if>
    </select>
    <select id="queryStepByProject1" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
    select
        pro.id,
        pro.project_name,
        pro.gxId,
        pro.gx_name,
        pro.device_name,
        pro.device_type,
        pro.typeName,
        pro.dId,
        pro.gx_step_name,
        pro.gx_step_num,
        pro.stepId,
        pro.reportStatus,
        pro.deviceStatus,
        pro.projectStatus,
        pro.reportId,
        pro.lon_lat,
        pro.project_progress
        from
        (SELECT
        pro.id,
        pro.project_name,
        gx.id AS gxId,
        gx.gx_name,
        d.device_name,
        d.device_type,
        dict."DICT_VALUE" AS typeName,
        d.id AS dId,
        step.gx_step_name,
        step.gx_step_num,
        step.id AS stepId,
        re.STATUS AS reportStatus,
        d.STATUS AS deviceStatus,
        pro.STATUS AS projectStatus,
        re.id AS reportId,
        pro.lon_lat,
        dria."county_cd" AS countyCode,
        att."guid" AS cityCode,
        ad."ad_code" AS provinceCode,
        pro.project_progress
        FROM
        ywxt.sg_project_info pro
        LEFT JOIN ywxt.sg_device d ON pro.id = d.program_id
        LEFT JOIN YWXT."BLADE_DICT_BIZ" AS dict ON d.device_type = dict.DICT_KEY
        AND dict.CODE = 'SG_DEVICE_TYPE'
        LEFT JOIN ywxt.sg_gx gx ON d.device_type = gx.gx_type
        LEFT JOIN ywxt.sg_gx_step step ON gx.id = step.gx_info_id
        LEFT JOIN ywxt.sg_progress_report re ON re.gx_step_id = step.id
        AND re.gx_device_id = d.id
        LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = pro.sk_id
        LEFT JOIN YWXT."att_ad_base" att ON att."ad_code" = dria."city_cd"
        LEFT JOIN YWXT."att_ad_base" ad ON att."p_ad_code" = ad."ad_code"
        LEFT JOIN YWXT."att_ad_base" aad ON aad."ad_code" = ad."p_ad_code") pro
        LEFT JOIN YWXT."att_ad_base" a ON (
        ( pro.countyCode = a."guid" )
        OR ( pro.cityCode = a."guid" )
        OR ( pro.provinceCode = a."guid" ))
        WHERE 1=1 and (a."p_ad_code" = #{dto.adCode} or a."ad_code" = #{dto.adCode})
        <if test="dto.projectId != null and dto.projectId != ''">
            and pro.id = #{dto.projectId}
        </if>
        <if test="dto.projectName != null and dto.projectName != ''">
            and pro.project_name like CONCAT(CONCAT('%', #{dto.projectName}), '%')
        </if>
        <if test="dto.status != null">
            and pro.status = #{dto.status}
        </if>
        <if test="dto.projectIds != null and dto.projectIds.size > 0">
            and pro.id in
            <foreach collection="dto.projectIds" item="id" separator="," open="(" close=")">
                #{id}
            </foreach>
        </if>
        ORDER BY pro.projectStatus desc ,pro.project_progress desc
    </select>
    <select id="selectVOById" resultType="cn.gistack.sm.sg.VO.SgProjectInfoVO">
        select * from  ywxt.sg_project_info pro where pro.id = #{proframId}
    </select>
 
    <select id="getDeviceTypes" resultType="cn.gistack.sm.sg.VO.SgStatisDeviceVO">
        SELECT
            count( d.id) AS deviceCount,
            sum( CASE WHEN d.STATUS IN ( 1, 2 ) THEN 1 ELSE 0 END) deviceStart,
            Pdict.DICT_KEY as pType
        FROM
            ywxt.sg_device d
                LEFT JOIN ywxt.blade_dict_biz dict ON d.device_type = dict.DICT_KEY
                LEFT JOIN YWXT."BLADE_DICT_BIZ" Pdict ON dict.parent_id = Pdict.id
        WHERE program_id IN ${s}
        GROUP BY
            Pdict.DICT_KEY
    </select>
    <select id="getSgCodeByUser" resultType="java.lang.String">
        SELECT
            dp."SG_CODE"
        FROM
            ywxt.BLADE_USER u
                LEFT JOIN ywxt.blade_dept dp ON u.dept_id = cast( dp.id AS VARCHAR )
        WHERE u.id = #{userId}
 
    </select>
    <select id="queryDept" resultType="cn.gistack.sm.sg.VO.SgAllDeptOrUser">
        select id,full_name as name from "YWXT"."BLADE_DEPT"
    </select>
    <select id="queryUser" resultType="cn.gistack.sm.sg.VO.SgAllDeptOrUser">
        select id,real_name as name from "YWXT"."BLADE_USER";
    </select>
    <select id="projectTree" resultType="cn.gistack.sm.sg.VO.SgProjectTreeVO">
        SELECT
            info.id,
            dria."city_nm",
            dria."province_nm",
            dria."county_nm",
            dria."res_nm"
        FROM
            YWXT.SG_PROJECT_INFO info
                LEFT JOIN SJZT_DW."dim_res_info_a" dria ON dria."res_cd" = info.sk_id
        WHERE
            1 =1
        <if test="dto.buildStage != null and dto.buildStage != ''">
            and info.build_stage = #{dto.buildStage}
        </if>
    </select>
</mapper>