yxm
2024-07-17 a1e7b27114eaf0bfd4d9768b76ba0db10e4d87bf
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
<?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.sjztmd.mapper.TbProjectMapper">
    <!--namespace根据自己需要创建的的mapper的路径和名称填写-->
    <sql id="selectResByRegion">
        SELECT arb."code",
               arb."name",
               arb."eng_scal",
               case when town."ad_grad" = 4 THEN town."ad_code" ELSE NULL END AS townCode,
               case when town."ad_grad" = 4 THEN town."ad_name" ELSE NULL END AS townName,
               case
                   when town."ad_grad" = 3 THEN town."ad_code"
                   when county."ad_grad" = 3 THEN county."ad_code" END        AS countyCode,
               case
                   when town."ad_grad" = 3 THEN town."ad_name"
                   when county."ad_grad" = 3 THEN county."ad_name" END        AS countyName,
               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 cityCode,
               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 cityName,
               case
                   when town."ad_grad" = 1 THEN town."ad_code"
                   when county."ad_grad" = 1 THEN county."ad_code"
                   when city."ad_grad" = 1 THEN city."ad_code"
                   ELSE province."ad_code" END                                AS provinceCode,
               case
                   when town."ad_grad" = 1 THEN town."ad_name"
                   when county."ad_grad" = 1 THEN county."ad_name"
                   when city."ad_grad" = 1 THEN city."ad_name"
                   ELSE province."ad_name" END                                AS provinceName
        FROM sjzt_MD."att_res_base" ARB
                 LEFT JOIN YWXT."att_ad_base" town ON town."ad_code" = arb."interior_ad_guid"
                 LEFT JOIN YWXT."att_ad_base" county ON county."ad_code" = town."p_ad_code"
                 LEFT JOIN YWXT."att_ad_base" city ON city."ad_code" = county."p_ad_code"
                 LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = city."p_ad_code"
    </sql>
    <update id="updateallcheck">
        update SJZT_MD."tb_project" set set "is_fill" ='', "check_state" ='';
    </update>
    <update id="updateFill">
        update SJZT_MD."tb_project_fill" set "isFil" = #{params.isFil}, "start_time" = #{params.stratTime},"end_time"= #{params.endTime}
    </update>
 
    <select id="getList" resultType="cn.gistack.sm.sjztmd.vo.TbProjectVO">
 
        SELECT
            *
        FROM SJZT_MD."tb_project" tb
        where
            tb."is_deleted" = 0
        <if test="vo.cityCode != null and vo.cityCode != ''">
            and tb."city_code" = #{vo.cityCode}
        </if>
        <if test="vo.countyCode != null and vo.countyCode != ''">
            and tb."county_code" = #{vo.countyCode}
        </if>
        <if test="vo.isEstablishPlan != null and vo.isEstablishPlan !=''">
            and tb."is_establish_plan" = #{vo.isEstablishPlan}
        </if>
        <if test="vo.isGovPurchase != null and vo.isGovPurchase != ''">
            and tb."is_gov_purchase" = #{vo.isGovPurchase}
        </if>
        <if test="vo.contractDateQuery != null and vo.contractDateQuery != ''">
            and tb."contract_date" = #{vo.contractDateQuery}
        </if>
        <if test="vo.startTime!=null and vo.startTime!=''">
            and tb."check_date">= #{vo.startTime}
        </if>
        <if test="vo.endTime!=null and vo.endTime!=''">
            and tb."check_date" &lt;= #{vo.endTime}
        </if>
        order by CAST(city_code AS number) asc,CAST(county_code AS number) asc,CAST(guid AS number) desc
    </select>
 
    <resultMap id="dto" type="cn.gistack.sm.sjztmd.dto.TbProjectDTO">
        <id property="guid" column="guid"/>
        <result property="tbYear" column="tb_year"/>
        <result property="cityCode" column="city_code"/>
        <result property="cityName" column="city_name"/>
        <result property="countyCode" column="county_code"/>
        <result property="countyName" column="county_name"/>
        <result property="other"      column="other"/>
        <result property="centerFund" column="center_fund"/>
        <result property="localFund" column="local_fund"/>
        <result property="isEstablishPlan" column="is_establish_plan"/>
        <result property="planUrl" column="plan_url"/>
        <result property="planFeedBackUrl" column="plan_feed_back_url"/>
        <result property="isGovPurchase" column="is_gov_purchase"/>
        <result property="purchaseWay" column="purchase_way"/>
        <result property="govUrl" column="gov_url"/>
        <result property="contractDate" column="contract_date"/>
        <result property="contractUrl" column="contract_url"/>
        <result property="checkDate" column="check_date"/>
        <result property="planCheckDate" column="plan_check_date"/>
 
        <result property="isCheck" column="is_check"/>
        <result property="checkUrl" column="check_url"/>
 
 
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_time" property="updateTime"/>
        <result column="update_user" property="updateUser"/>
 
        <collection property="tbProjectScheduleList" ofType="cn.gistack.sm.sjztmd.entity.TbProjectSchedule">
            <id property="guid" column="scheduleId"/>
            <result property="year" column="year"/>
            <result property="month" column="month"/>
            <result property="actualFund" column="actual_fund"/>
        </collection>
    </resultMap>
 
 
 
 
    <select id="getDetail" resultMap="dto">
        SELECT
            tb.*,
            TPS."guid" as scheduleId,
            TPS."year",
            TPS."month",
            TPS."actual_fund"
        from sjzt_md."tb_project" tb
        LEFT JOIN SJZT_MD."tb_project_schedule" TPS ON TPS."tb_project_id" = tb."guid"
        where
            tb."is_deleted" = 0
            AND tb."guid" = #{id}
    </select>
 
 
 
    <select id="getStatisticsTable" resultType="cn.gistack.sm.sjztmd.statisticsVO.StatisticsTableProject">
        SELECT
            aab."guid" adCode,
            aab."ad_name" adName,
            aab."ad_grad" AS adGrad,
            paab."guid" padCode,
            paab."ad_name" padName,
            tps.curMonthActualFund,
            project.totalActualFund,
            ifNull(resNum,0) resNum,
            ifNull(bigNum,0) bigNum,
            ifNull(midNum,0) midNum,
            ifNull(smallOneNum,0) smallOneNum,
            ifNull(smallTwoNum,0) smallTwoNum,
            dykeLength,
            levelOneLength,
            levelTwoLength,
            levelThreeLength,
            levelFourLength,
            levelFiveLength
        FROM YWXT."att_ad_base" aab
        left join (
            SELECT
                aab."guid",
                aab."ad_name",
                SUM(CASE WHEN arb."code" is not null then 1 else 0 end) as resNum ,
                SUM(CASE WHEN (arb."eng_scal" = '大(1)型' or arb."eng_scal" = '大(2)型') then 1 else 0 end) as bigNum ,
                SUM(CASE WHEN (arb."eng_scal" = '中型') then 1 else 0 end) as midNum ,
                SUM(CASE WHEN (arb."eng_scal" = '小(1)型') then 1 else 0 end) as smallOneNum ,
                SUM(CASE WHEN (arb."eng_scal" = '小(2)型') then 1 else 0 end) as smallTwoNum
            FROM YWXT."att_ad_base" aab
             LEFT JOIN
             (
                 <include refid="selectResByRegion"/>
             ) arb ON ((arb.townCode = aab."guid")or(arb.countyCode = aab."guid") or (arb.cityCode = aab."guid") or (arb.provinceCode = aab."guid") )
            right join sjzt_md."tb_res_general_investigation_state" trgis on trgis."res_guid" = arb."code"
                    <!--统计待审核和已审核的-->
                and (trgis."check_state" = 1 or trgis."check_state" = 2)
                <if test="params.tbYear != null and params.tbYear != ''">
                    and trgis."tb_year" = #{params.tbYear}
                </if>
            group by aab."guid",aab."ad_name"
        )res on res."guid" = aab."guid"
        left join (
            SELECT
                aab."guid",
                aab."ad_name",
                SUM(CASE WHEN trd."dyke_guid" is not null then trd.dangerLength else 0 END) as dykeLength,
                SUM(CASE WHEN trd."dyke_level" = '1级' THEN trd.dangerLength ELSE 0 END) AS levelOneLength,
                SUM(CASE WHEN trd."dyke_level" = '2级' THEN trd.dangerLength ELSE 0 END) AS levelTwoLength,
                SUM(CASE WHEN trd."dyke_level" = '3级' THEN trd.dangerLength ELSE 0 END)AS levelThreeLength,
                SUM(CASE WHEN trd."dyke_level" = '4级' THEN trd.dangerLength ELSE 0 END) AS levelFourLength,
                SUM(CASE WHEN trd."dyke_level" = '5级' THEN trd.dangerLength ELSE 0 END) AS levelFiveLength
            FROM YWXT."att_ad_base" aab
            LEFT JOIN (
                SELECT
                    trd."guid",
                    trd."dyke_length",
                    trd."dyke_level",
                    trd."dyke_guid",
                    trd.dangerLength,
                    county."guid" as countyCode,
                    city."guid" as cityCode,
                    province."guid" as provinceCode
                FROM (
                    SELECT
                        tdis."guid",
                        tdis."dyke_guid",
                        trd."ad_code",
                        trd."dyke_level",
                        trd."dyke_length",
                        tdi.dangerLength
                    FROM SJZT_MD."tb_dyke_investigation_state" tdis
                    LEFT JOIN SJZT_MD."tb_res_dyke" trd on trd."guid" = tdis."dyke_guid"
                    LEFT JOIN (
                        SELECT
                            TEMP1."tb_state_id",
                            TEMP1."unit",
                            TEMP1.dangerLength/temp1.num as dangerLength
                        FROM (
                            SELECT
                                tdi."tb_state_id",
                                tdi."dyke_guid",
                                tdi."unit",
                                count(*) as num,
                                SUM(CASE WHEN (tdi."danger_length") THEN tdi."danger_length" ELSE 0 END) AS dangerLength
                            from sjzt_md."tb_dyke_investigation" tdi
                            where 1=1
                             <if test="params.tbYear != null and params.tbYear != ''">
                                 AND  tdi."tb_year" = #{params.tbYear}
                            </if>
                            group by tdi."tb_state_id",tdi."dyke_guid",tdi."unit"
                        )TEMP1
                    ) tdi on tdi."tb_state_id" = tdis."guid"
                    <!--统计待审核和已审核的-->
                    where (tdis."check_state" = 1 or tdis."check_state" = 2)
                ) trd
                LEFT JOIN YWXT."att_ad_base" county ON county."ad_code" = trd."ad_code"
                LEFT JOIN YWXT."att_ad_base" city ON city."ad_code" = county."p_ad_code"
                LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = city."p_ad_code"
            )trd on ((trd.countyCode = aab."guid") or (trd.cityCode = aab."guid") or (trd.provinceCode = aab."guid"))
            group by aab."guid",aab."ad_name"
        )dyke on dyke."guid" = aab."guid"
        left join (
            SELECT
                aab."guid",
                aab."ad_name",
                SUM(CASE WHEN tb."actual_fund" then tb."actual_fund" else 0 end) as totalActualFund
            FROM YWXT."att_ad_base" aab
            LEFT JOIN (
                select
                tb."city_code" cityCode,
                tb."county_code" countyCode,
                province."guid" provinceCode,
                tps."actual_fund"
                from sjzt_md."tb_project" tb
                LEFT JOIN SJZT_MD."tb_project_schedule" tps on tps."tb_project_id" = tb."guid"
                LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = tb."city_code"
            )tb on ((tb.countyCode = aab."guid") or (tb.cityCode = aab."guid") or (tb.provinceCode = aab."guid"))
            group by aab."guid",aab."ad_name"
        ) project on project."guid" = aab."guid"
        left join (
            SELECT
            aab."guid",
            aab."ad_name",
            tb."actual_fund" curMonthActualFund
            FROM YWXT."att_ad_base" aab
            LEFT JOIN (
                select
                tb."city_code" cityCode,
                tb."county_code" countyCode,
                province."guid" provinceCode,
                tps."actual_fund"
                from sjzt_md."tb_project" tb
                LEFT JOIN SJZT_MD."tb_project_schedule" tps on tps."tb_project_id" = tb."guid"
                LEFT JOIN YWXT."att_ad_base" province ON province."ad_code" = tb."city_code"
                where
                    1=1
                    <if test="params.tbYear != null and params.tbYear !=''">
                    AND tps."year" = #{params.tbYear}
                    </if>
                  <if test="params.tbMonth != null and params.tbMonth != ''">
                      and tps."month" = #{params.tbMonth}
                  </if>
            )tb on ((tb.countyCode = aab."guid") or (tb.cityCode = aab."guid") or (tb.provinceCode = aab."guid"))
        ) tps on tps."guid" = aab."guid"
        left join ywxt."att_ad_base" paab on paab."guid" = aab."p_ad_code"
        where
            1=1
            <if test="params.adCode != null and params.adCode !=''">
            AND aab."p_ad_code" = #{params.adCode}
            </if>
    </select>
    <select id="getTbProjectInfo" resultType="cn.gistack.sm.sjztmd.entity.TbProject">
        SELECT
            *
        FROM SJZT_MD."tb_project"
        where 1=1
        <if test="params.cityCode != null and params.cityCode !=''">
            and "city_code"  = #{params.cityCode}
        </if>
        <if test="params.countyCode != null and params.countyCode !=''">
            and "county_code"  = #{params.countyCode}
        </if>
        <if test="params.tbYear != null and params.tbYear !=''">
            and "tb_year" = #{params.tbYear}
        </if>
    </select>
    <select id="getStatisticsPie" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPrice">
        SELECT
    sum(
    NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
    sum(
    NVL ( b."actual_fund", 0 )) sumPay,
    sum(
        NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
    NVL ( b."actual_fund", 0 )) noPay
FROM
    sjzt_md."tb_project" a
    LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
    WHERE 1=1
    <if test="params.tbYear != null and params.tbYear !=''">
      AND  "year" = #{params.tbYear}
    </if>
    <if test="params.tbMonth != null and params.tbMonth !=''">
        AND "month" = #{params.tbMonth}
    </if>
    ) b ON a."guid" = b."tb_project_id"
    </select>
    <select id="getStatisticsPies" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPrice">
        SELECT
    sum(
    NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
    sum(
    NVL ( b."actual_fund", 0 )) sumPay,
    sum(
        NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
    NVL ( b."actual_fund", 0 )) noPay
FROM
    sjzt_md."tb_project" a
    LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
        WHERE "check_state" = 3
        <if test="params.tbYear != null and params.tbYear !=''">
            AND  "year" = #{params.tbYear}
        </if>
        <if test="params.tbMonth != null and params.tbMonth !=''">
            AND "month" = #{params.tbMonth}
        </if>
        ) b ON a."guid" = b."tb_project_id"
    LEFT JOIN YWXT."att_ad_base" c ON ( a."city_code" = c."guid" )
    OR ( a."county_code" = c."guid" )
WHERE
    c."guid" = #{params.adCode}
    </select>
    <select id="getStatisticsPieBar" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPriceVO">
            SELECT
        c."ad_code" adCode,
        c."ad_name" adName,
 
        sum(
        NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
        sum(
        NVL ( b."actual_fund", 0 )) sumPay,
        sum(
            NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
        NVL ( b."actual_fund", 0 )) noPay
    FROM
        sjzt_md."tb_project" a
        LEFT JOIN  ( SELECT * FROM sjzt_md."tb_project_schedule"
        WHERE "check_state" = 3
        <if test="params.tbYear != null and params.tbYear !=''">
            AND  "year" = #{params.tbYear}
        </if>
        <if test="params.tbMonth != null and params.tbMonth !=''">
            AND "month" = #{params.tbMonth}
        </if>
        ) b ON a."guid" = b."tb_project_id"
        RIGHT JOIN YWXT."att_ad_base" c on c."ad_code" = a."city_code"
        where c."p_ad_code" = #{params.adCode}
    GROUP BY
        c."ad_code" ,
        c."ad_name"
    </select>
    <select id="getStatisticsPieBars" resultType="cn.gistack.sm.sjztmd.vo.StatisticsPriceVO">
        SELECT
    b."ad_name" adName,
    b."ad_code" adCode,
    a.sumPrice  sumPrice,
    a.noPay     noPay,
    a.sumPay    sumPay
FROM
    (
    SELECT
        a."county_code",
        a."county_name",
        a."city_code",
        sum(
        NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 )) AS sumPrice,
        sum(
        NVL ( b."actual_fund", 0 )) sumPay,
        sum(
            NVL ( a."center_fund", 0 )+ NVL ( a."local_fund", 0 ))- sum(
        NVL ( b."actual_fund", 0 )) noPay
    FROM
        sjzt_md."tb_project" a
        LEFT JOIN ( SELECT * FROM sjzt_md."tb_project_schedule"
        WHERE 1=1
        <if test="params.tbYear != null and params.tbYear !=''">
            AND  "year" = #{params.tbYear}
        </if>
        <if test="params.tbMonth != null and params.tbMonth !=''">
            AND "month" = #{params.tbMonth}
        </if>
        ) b ON a."guid" = b."tb_project_id"
    GROUP BY
        a."county_code",
        a."county_name",
        a."city_code"
    ) a
    RIGHT JOIN YWXT."att_ad_base" b ON ( b."guid" = a."city_code" )
    OR ( b."guid" = a."county_code" )
WHERE
    b."p_ad_code" = #{params.adCode}
    </select>
    <select id="getfill" resultType="cn.gistack.sm.sjztmd.vo.TbProjectIsfillVO">
        select "isFil","end_time" endTime, "start_time" stratTime from SJZT_MD."tb_project_fill"
    </select>
</mapper>