shenyijian
2024-06-21 f20611265f7d34fd4fbcdfdaff6cb9cccd0b25fc
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
<?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.AttAdBaseMapper">
 
    <resultMap id="treeNodeResultMap" type="org.springblade.core.tool.node.TreeNode">
<!--    <resultMap id="treeNodeResultMap" type="cn.gistack.sm.sjztmd.vo.AttAdBaseVO">-->
        <id column="id" property="id"/>
        <result column="parent_id" property="parentId"/>
        <result column="title" property="title"/>
        <result column="value" property="value"/>
        <result column="key" property="key"/>
        <result column="has_children" property="hasChildren"/>
    </resultMap>
    <insert id="customizeSave">
        INSERT INTO "att_ad_base"
        ("guid","ad_code","ad_name","p_ad_code","p_ad_name","ad_grad")
        VALUES
        (#{attAdBase.adCode},#{attAdBase.adCode},#{attAdBase.adName},#{attAdBase.pAdCode},#{attAdBase.pAdName},#{attAdBase.adGrad})
    </insert>
 
    <select id="lazyTree" resultMap="treeNodeResultMap">
        SELECT
        region."ad_code" AS "id",
        region."p_ad_code" AS "parent_id",
        region."ad_name" AS "title",
        region."ad_code" AS "value",
        region."ad_grad" AS "adGrad",
        region."ad_code" AS "key",
        ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM "SJZT_MD"."att_ad_base" WHERE "p_ad_code" = region."ad_code" ) AS "has_children"
        FROM
        "SJZT_MD"."att_ad_base" region
        <where>
            <if test="param1!=null">
                and region."p_ad_code" = #{param1}
            </if>
            <if test="param2.code!=null and param2.code!=''">
                and region."ad_code" like concat(#{param2.code},'%')
            </if>
            <if test="param2.name!=null and param2.name!=''">
                and region."ad_name" like concat('%',#{param2.name},'%')
            </if>
            <if test="param2.showFour !=null and param2.showFour !=''">
                and  IF(#{param2.showFour} = 'true',region."ad_grad" != 5,region."ad_grad" != 4)
            </if>
        </where>
        ORDER BY region."order_id"
    </select>
 
    <select id="lazyTreeYwxt" resultMap="treeNodeResultMap">
        SELECT
        region."ad_code" AS "id",
        region."p_ad_code" AS "parent_id",
        region."ad_name" AS "title",
        region."ad_code" AS "value",
        region."ad_grad" AS "adGrad",
        region."ad_code" AS "key",
        ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM YWXT."att_ad_base" WHERE "p_ad_code" = region."ad_code" ) AS "has_children"
        FROM
        YWXT."att_ad_base" region
        <where>
            <if test="param1!=null">
                and region."p_ad_code" = #{param1}
            </if>
            <if test="param2.code!=null and param2.code!=''">
                and region."ad_code" like concat(#{param2.code},'%')
            </if>
            <if test="param2.name!=null and param2.name!=''">
                and region."ad_name" like concat('%',#{param2.name},'%')
            </if>
            <if test="param2.showFour !=null and param2.showFour !=''">
                and  IF(#{param2.showFour} = 'true',region."ad_grad" != 5,region."ad_grad" != 4)
            </if>
        </where>
        ORDER BY region."order_id"
    </select>
 
 
 
    <select id="selectAttAdBaseTree" resultType="cn.gistack.common.node.TreeNode">
        SELECT
        region."ad_code" AS "id",
        region."p_ad_code" AS "parent_id",
        region."ad_name" AS "name",
        region."ad_grad" AS "level",
        ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM "SJZT_MD"."att_ad_base" WHERE "p_ad_code" = region."ad_code" ) AS "has_children"
        FROM
        "SJZT_MD"."att_ad_base" region
        left join sjzt_md."att_ad_base" a2 on (region."p_ad_code" = a2."ad_code")
        left join sjzt_md."att_ad_base" a3 on (a2."p_ad_code" = a3."ad_code")
        left join sjzt_md."att_ad_base" a4 on (a3."p_ad_code" = a4."ad_code")
        <where>
            <if test="param1!=null">
                and region."p_ad_code" = #{param1}
            </if>
            <if test="param2.code!=null and param2.code!=''">
                and concat(region."ad_code",a2."ad_code",a3."ad_code",a4."ad_code") like concat(concat('%', #{param2.code}),'%')
            </if>
            <if test="param2.name!=null and param2.name!=''">
                and region."ad_name" like concat(concat('%', #{param2.name}),'%')
            </if>
            <if test="param2.level!=null and param2.level!=''">
                and region."ad_grad" &lt; #{param2.level}
            </if>
            <if test="param2.isTowns==null or param2.isTowns==''">
                and region."ad_grad" != 4
            </if>
        </where>
        ORDER BY region."order_id"
    </select>
 
    <select id="lazyTreeAll" resultMap="treeNodeResultMap">
        SELECT
        region."ad_code" AS "id",
        region."p_ad_code" AS "parent_id",
        region."ad_name" AS "title",
        region."ad_code" AS "value",
        region."ad_grad" AS "adGrad",
        region."ad_code" AS "key",
        ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM "SJZT_MD"."att_ad_base" WHERE "p_ad_code" = region."ad_code" ) AS "has_children"
        FROM
        "SJZT_MD"."att_ad_base" region
        <where>
            <if test="param1!=null">
                and region."p_ad_code" = #{param1}
            </if>
            <if test="param2.code!=null and param2.code!=''">
                and region."ad_code" like concat(concat('%', #{param2.code}),'%')
            </if>
            <if test="param2.name!=null and param2.name!=''">
                and region."ad_name" like concat(concat('%', #{param2.name}),'%')
            </if>
        </where>
        ORDER BY region."order_id"
    </select>
 
    <!--根据水库编号查询除责任人之外的人员信息-->
    <select id="getPersonListByResGuid" resultType="cn.gistack.sm.sjztmd.vo.PersonVO">
        select bu.real_name as name,bu.phone,bd.ad_code from YWXT.blade_user bu
        left join YWXT.blade_dept bd on locate(bd.id,bu.dept_id)>0 and bd.is_deleted = 0
        left join YWXT.blade_role br on locate(br.id,bu.role_id)>0 and br.is_deleted = 0
        where bu.is_deleted = 0
        and bd.ad_code in (
            select "ad_code" from SJZT_MD."att_ad_base"
            start with "ad_code" = (select "interior_ad_guid" from SJZT_MD."att_res_base" where "guid" = #{res_cd} )
            CONNECT BY PRIOR "p_ad_code"  =  "ad_code"
        )
        and locate(br.role_name,concat('%',#{roleName},'%'))>0
        and bu.phone is not null and bu.phone!=''
    </select>
 
    <select id="getDetail" resultType="cn.gistack.sm.sjztmd.vo.AttAdBaseVO">
        SELECT
            region."guid",
            region."ad_code",
            region."p_ad_code",
            region."ad_name",
            region."ad_grad",
            region."p_ad_name" AS pAdName,
            region."order_id" AS orderId,
            ( SELECT CASE WHEN count( 1 ) > 0 THEN 1 ELSE 0 END FROM "SJZT_MD"."att_ad_base" WHERE "p_ad_code" = region."ad_code" ) AS "has_children"
             FROM "SJZT_MD"."att_ad_base" region
             WHERE
                 1=1
            <if test="attAdBase.guid != null and attAdBase.guid !='' ">
               AND region."guid" = #{attAdBase.guid}
            </if>
            <if test="attAdBase.adName != null and attAdBase.adName !='' ">
               AND region."ad_name" = #{attAdBase.adName}
            </if>
    </select>
 
    <select id="getAdGradByAdCode" resultType="java.lang.String">
        select "ad_grad" from SJZT_MD."att_ad_base" where "guid" = #{adCode}
    </select>
    <select id="getYwxtAdDetail" resultType="cn.gistack.sm.sjztmd.entity.AttAdBase">
        select * from ywxt."att_ad_base" where "guid" = #{adCode}
    </select>
    <select id="getYwxtAdList" resultType="cn.gistack.sm.sjztmd.entity.AttAdBase">
        SELECT * FROM YWXT."att_ad_base" WHERE "ad_code" = #{adCode}
    </select>
    <select id="getZtAttAdBaseList" resultType="cn.gistack.sm.sjztmd.entity.AttAdBase">
        SELECT * FROM SJZT_MD."att_ad_base" where "p_ad_code" = #{parentId}
    </select>
    <select id="getYwxtAttAdBaseList" resultType="cn.gistack.sm.sjztmd.entity.AttAdBase">
        SELECT * FROM YWXT."att_ad_base" where "p_ad_code" = #{parentId}
    </select>
 
</mapper>