xieb
2024-01-29 d5aef2e06c79541ed003af44e621df7c57fcf2e7
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
<?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.QualityManageMapper">
 
 
    <select id="selectCustomizePage" resultType="cn.gistack.sm.resDataCheck.vo.QualityManageVO">
        SELECT
               arb."guid" AS resGuid,
               arb."name" AS resName,
               arb."res_loc" AS resLoc,
                CASE aab."ad_name"
                when '' then
                CASE aa."ad_name" when '' then
                CASE ab."ad_name" when '' then ac."ad_name" else ab."ad_name" end
                else aa."ad_name"
                END
                else aab."ad_name"
                END  adName,
               arb."res_reg_code" AS resRegCode,
               arb."eng_scal" AS engScal,
               rule.name AS ruleName,
               rule.description AS ruleDesc,
               rule.pro_description AS proDesc,
               qm.*
        FROM (
            select * from  SM_RES_DATA_QUALITY_MANAGE qm
            WHERE qm.is_deleted = 0
            <if test="vo.startTime !=null and vo.startTime !=''">
                AND qm.create_time &gt;= #{vo.startTime}
            </if>
            <if test="vo.endTime !=null and vo.endTime !=''">
                AND qm.create_time &lt;= #{vo.endTime}
            </if>
        ) as qm
 
        LEFT JOIN SJZT_MD."att_res_base" arb ON arb."guid" = qm.res_id
        LEFT JOIN SM_RES_DATA_CHECK_RULES rule ON rule.id = qm.rule_id
 
        left join "SJZT_MD"."att_ad_base" aab on aab."guid" = arb."interior_ad_guid"
        left join "SJZT_MD"."att_ad_base" aa on aab."p_ad_code" = aa."ad_code"
        left join "SJZT_MD"."att_ad_base" ab on aa."p_ad_code" = ab."ad_code"
        left join "SJZT_MD"."att_ad_base" ac on ab."p_ad_code" = ac."ad_code"
        <where>
            <if test="vo.resName !=null and vo.resName !='' ">
                AND arb."name" LIKE CONCAT('%',#{vo.resName},'%')
            </if>
            <if test="vo.engScal !=null and vo.engScal !='' ">
                AND arb."eng_scal"  = #{vo.engScal}
            </if>
            <if test="vo.ruleName !=null and vo.ruleName !='' ">
                AND rule.name LIKE CONCAT('%',#{vo.ruleName},'%')
            </if>
 
            <if test="vo.adCode != null and vo.adCode != '' ">
                and (aab."ad_code" = #{vo.adCode} or aa."ad_code" = #{vo.adCode} or ab."ad_code" = #{vo.adCode} or ac."ad_code" = #{vo.adCode})
            </if>
        </where>
        order by qm.create_time desc
    </select>
    <select id="getDetail" resultType="cn.gistack.sm.resDataCheck.vo.QualityManageVO">
        SELECT
            arb."name" AS resName,
            arb."res_loc" AS resLoc,
            arb."res_reg_code" AS resRegCode,
            arb."eng_scal" AS engScal,
            rule.name AS ruleName,
            rule.description AS ruleDesc,
            rule.pro_description AS proDesc,
            qm.*
        FROM
            SM_RES_DATA_QUALITY_MANAGE qm
                LEFT JOIN SJZT_MD."att_res_base" arb ON arb."guid" = qm.res_id
                LEFT JOIN SM_RES_DATA_CHECK_RULES rule ON rule.id = qm.rule_id
        WHERE qm.is_deleted = 0 AND qm.id = #{id}
    </select>
 
    <insert id="addQualityManage">
        insert into SM_RES_DATA_QUALITY_MANAGE (res_id,rule_id,create_time,update_time,val)
        select distinct a."guid" as res_id,${ruleId} AS rule_id,NOW() AS create_time,NOW() AS update_time, ${varStr}
        from SJZT_MD."att_res_base" a
                 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>
 
</mapper>