lin
2024-04-13 c565ed505c1762e0eaf3d5eaeb618b90478920b5
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
<?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="org.springblade.modules.district.mapper.DistrictMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="districtResultMap" type="org.springblade.modules.district.entity.DistrictEntity">
        <result column="id" property="id"/>
        <result column="aoi_code" property="aoiCode"/>
        <result column="community_code" property="communityCode"/>
        <result column="name" property="name"/>
        <result column="address" property="address"/>
        <result column="lng" property="lng"/>
        <result column="lat" property="lat"/>
        <result column="remark" property="remark"/>
        <result column="create_user" property="createUser"/>
        <result column="create_time" property="createTime"/>
        <result column="update_user" property="updateUser"/>
        <result column="update_time" property="updateTime"/>
        <result column="is_deleted" property="isDeleted"/>
    </resultMap>
 
    <!--自定义分页-->
    <select id="selectDistrictPage" resultType="org.springblade.modules.district.vo.DistrictVO">
        select
        jd.*,
        br.village_name as communityName,br.town_name as townStreetName
        from jczz_district jd
        left join blade_region br on br.code = jd.community_code
        where jd.is_deleted = 0
        <if test="district.name !=null and district.name !=''">
            and jd.name like concat('%',#{district.name},'%')
        </if>
        <if test="district.communityName !=null and district.communityName !=''">
            and br.village_name like concat('%', #{district.communityName},'%')
        </if>
        <if test="district.communityCode !=null and district.communityCode !=''">
            and jd.community_code = #{district.communityCode}
        </if>
        <if test="district.townStreetName !=null and district.townStreetName !=''">
            and br.town_name like concat('%',#{district.townStreetName},'%')
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                    and jd.community_code in
                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                        #{code}
                    </foreach>
                </when>
                <otherwise>
                    and jd.community_code in ('')
                </otherwise>
            </choose>
        </if>
    </select>
 
    <!--小区树查询-->
    <select id="getDistrictTree" resultType="org.springblade.common.node.TreeStringNode">
        SELECT
        code as id,
        parent_code as parentId,
        name,
        remark aoiCode
        FROM blade_region where district_code like concat('361102','%')
        <if test="isAdministrator==2">
            <choose>
                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                    and code in
                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                        #{code}
                    </foreach>
                </when>
                <otherwise>
                    and code in ('')
                </otherwise>
            </choose>
        </if>
        union all
        (
        select
        id,
        community_code as parentId,
        name,
        aoi_code aoiCode
        from jczz_district
        where is_deleted = 0 and community_code like concat('361102','%')
        <if test="district.districtIdList!=null and district.districtIdList.size() > 0">
            and id in
            <foreach collection="district.districtIdList" item="item" separator="," open="(" close=")">
                #{item}
            </foreach>
        </if>
        <if test="isAdministrator==2">
            <choose>
                <when test="regionChildCodesList !=null and regionChildCodesList.size()>0">
                    and community_code in
                    <foreach collection="regionChildCodesList" item="code" open="(" close=")" separator=",">
                        #{code}
                    </foreach>
                </when>
                <otherwise>
                    and community_code in ('')
                </otherwise>
            </choose>
        </if>
        )
    </select>
 
    <!--小区自定义获取详情查询-->
    <select id="getDetail" resultType="org.springblade.modules.district.vo.DistrictVO">
        SELECT jd.*,
               jda.nei_code as communityCode,
               jda.nei_name as communityName,
               jpo.organization_name,
               jpo.organization_type,
               jpo.branch_type,
               jpo.charge_person,
               jpo.phone
        FROM jczz_district jd
                 left join jczz_doorplate_address jda on jda.aoi_code = jd.aoi_code
                 LEFT JOIN jczz_party_organization jpo on jpo.area_id = jda.nei_code and jpo.is_deleted=0
        where jd.is_deleted = 0
          and jda.address_code = #{district.houseCode}
    </select>
 
 
</mapper>