mitao
2025-02-21 31573d6180d15ef65ed0df9c2732495f40b12663
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
<?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="com.panzhihua.service_dangjian.dao.ComPbOrgDAO">
 
    <resultMap type="com.panzhihua.service_dangjian.model.dos.ComPbOrgDO" id="ComPbOrgMap">
        <result property="id" column="id" jdbcType="INTEGER"/>
        <result property="level" column="level" jdbcType="INTEGER"/>
        <result property="parentId" column="parent_id" jdbcType="INTEGER"/>
        <result property="name" column="name" jdbcType="VARCHAR"/>
        <result property="communityId" column="community_id" jdbcType="INTEGER"/>
        <result property="status" column="status" jdbcType="INTEGER"/>
        <result property="type" column="type" jdbcType="INTEGER"/>
        <result property="subjection" column="subjection" jdbcType="INTEGER"/>
        <result property="areaId" column="area_id" jdbcType="INTEGER"/>
        <result property="address" column="address" jdbcType="VARCHAR"/>
        <result property="longitude" column="longitude" jdbcType="VARCHAR"/>
        <result property="latitude" column="latitude" jdbcType="VARCHAR"/>
        <result property="oneId" column="one_id" jdbcType="INTEGER"/>
        <result property="twoId" column="two_id" jdbcType="INTEGER"/>
        <result property="thirdId" column="third_id" jdbcType="INTEGER"/>
        <result property="fourId" column="four_id" jdbcType="INTEGER"/>
        <result property="fiveId" column="five_id" jdbcType="INTEGER"/>
        <result property="buildId" column="build_id" jdbcType="INTEGER"/>
    </resultMap>
 
    <select id="listPartyOrganizationAll" resultType="com.panzhihua.common.model.vos.partybuilding.west.PartyOrganizationVO">
        SELECT
            cpo.id,
            cpo.`name`,
            cpo.`status`,
            cpo.parent_id,
            cpo.subjection,
            cpo.area_id,
            cpo.build_id,
            cpo.address,
            cpo.longitude,
            cpo.latitude,
            cpo.type,
            cmv.`name` AS areaName,
            cmb.`name` AS buildName,
            cpmr.`name` AS userName,
            cpmr.phone,
            (select count(id) from com_pb_member where org_id = cpo.id and audit_result = 1) as countPerson
        FROM
            com_pb_org AS cpo
            LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cpo.area_id
            left join com_mng_building as cmb on cmb.id = cpo.build_id
            LEFT JOIN com_pb_member_role cpmr ON cpmr.org_id = cpo.id
        <where>
            <if test="partyOrganizationVO.communityId != null">
                and cpo.community_id = ${partyOrganizationVO.communityId}
            </if>
            <if test="partyOrganizationVO.keyWord == null or partyOrganizationVO.keyWord == ''">
                AND cpo.parent_id = 0
            </if>
            <if test="partyOrganizationVO.keyWord != null and partyOrganizationVO.keyWord != ''">
                and cpo.`name` like CONCAT(#{partyOrganizationVO.keyWord}, '%')
            </if>
            <if test="partyOrganizationVO.subjection != null">
                and cpo.subjection = #{partyOrganizationVO.subjection}
            </if>
            <if test="partyOrganizationVO.areaId != null">
                and cpo.area_id = #{partyOrganizationVO.areaId}
            </if>
            <if test="partyOrganizationVO.buildId != null">
                and cpo.build_id = #{partyOrganizationVO.buildId}
            </if>
        </where>
        GROUP BY cpo.id
        ORDER BY cpo.id desc
    </select>
 
    <select id="getChildOrgList" resultType="com.panzhihua.common.model.vos.partybuilding.west.PartyOrganizationVO">
        SELECT
            cpo.id,
            cpo.`name`,
            cpo.`status`,
            cpo.parent_id,
            cpo.subjection,
            cpo.area_id,
            cpo.build_id,
            cpo.address,
            cpo.longitude,
            cpo.latitude,
            cpo.type,
            cmv.`name` AS areaName,
            cmb.`name` AS buildName,
            cpmr.`name` AS userName,
            cpmr.phone AS phone,
            (select count(id) from com_pb_member where org_id = cpo.id and audit_result = 1) as countPerson
        FROM
            com_pb_org AS cpo
            LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cpo.area_id
            LEFT JOIN com_pb_member_role AS cpmr ON cpmr.org_id = cpo.id
            left join com_mng_building as cmb on cmb.id = cpo.build_id
        <where>
            <if test="partyOrganizationVO.parentId != null">
                AND cpo.parent_id = ${partyOrganizationVO.parentId}
            </if>
            <if test="partyOrganizationVO.communityId != null">
                and cpo.community_id = ${partyOrganizationVO.communityId}
            </if>
            <if test="partyOrganizationVO.subjection != null">
                and cpo.subjection = #{partyOrganizationVO.subjection}
            </if>
            <if test="partyOrganizationVO.areaId != null">
                and cpo.area_id = #{partyOrganizationVO.areaId}
            </if>
            <if test="partyOrganizationVO.buildId != null">
                and cpo.build_id = #{partyOrganizationVO.buildId}
            </if>
        </where>
        GROUP BY cpo.id
        ORDER BY cpo.id desc
    </select>
 
    <select id="getPbOrgAllList" resultType="com.panzhihua.common.model.vos.partybuilding.west.PartyOrganizationVO">
        SELECT
        cpo.id,
        cpo.`name`,
        cpo.`status`,
        cpo.parent_id,
        cpo.subjection,
        cpo.area_id,
        cpo.build_id,
        cpo.address,
        cpo.longitude,
        cpo.latitude,
        cpo.type,
        cmv.`name` AS areaName,
        cmb.`name` AS buildName,
        cpmr.`name` AS userName,
        cpmr.phone AS phone,
        (select count(id) from com_pb_member where org_id = cpo.id and audit_result = 1) as countPerson
        FROM
        com_pb_org AS cpo
        LEFT JOIN com_mng_village AS cmv ON cmv.village_id = cpo.area_id
        LEFT JOIN com_pb_member_role AS cpmr ON cpmr.org_id = cpo.id
        left join com_mng_building as cmb on cmb.id = cpo.build_id
        <where>
            <if test="partyOrganizationVO.communityId != null">
                and cpo.community_id = ${partyOrganizationVO.communityId}
            </if>
            <if test="partyOrganizationVO.keyWord == null or partyOrganizationVO.keyWord == ''">
                AND cpo.parent_id = 0
            </if>
            <if test="partyOrganizationVO.keyWord != null and partyOrganizationVO.keyWord != ''">
                and cpo.`name` like CONCAT(#{partyOrganizationVO.keyword}, '%')
            </if>
            <if test="partyOrganizationVO.subjection != null">
                and cpo.subjection = #{partyOrganizationVO.subjection}
            </if>
            <if test="partyOrganizationVO.areaId != null">
                and cpo.area_id = #{partyOrganizationVO.areaId}
            </if>
            <if test="partyOrganizationVO.buildId != null">
                and cpo.build_id = #{partyOrganizationVO.buildId}
            </if>
        </where>
        GROUP BY cpo.id
        ORDER BY cpo.id desc
    </select>
 
</mapper>