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
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
<?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_community.dao.ComActSocialOrgDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActSocialOrg" id="ComActSocialOrgBaseResultMap">
        <result property="id" column="id"/>
        <result property="name" column="name"/>
        <result property="businessNumber" column="business_number"/>
        <result property="buildDate" column="build_date"/>
        <result property="agencyCode" column="agency_code"/>
        <result property="weixinOfficialAccounts" column="weixin_official_accounts"/>
        <result property="companyType" column="company_type"/>
        <result property="registFee" column="regist_fee"/>
        <result property="assetsTotal" column="assets_total"/>
        <result property="assetsNet" column="assets_net"/>
        <result property="salesFee" column="sales_fee"/>
        <result property="taxesLastYear" column="taxes_last_year"/>
        <result property="staffCount" column="staff_count"/>
        <result property="maillingAddr" column="mailling_addr"/>
        <result property="postCode" column="post_code"/>
        <result property="officialUrl" column="official_url"/>
        <result property="corporationName" column="corporation_name"/>
        <result property="corporationGen" column="corporation_gen"/>
        <result property="corporationOfficePhone" column="corporation_office_phone"/>
        <result property="corporationPosition" column="corporation_position"/>
        <result property="corporationPhone" column="corporation_phone"/>
        <result property="corporationEmail" column="corporation_email"/>
        <result property="contactName" column="contact_name"/>
        <result property="contactGen" column="contact_gen"/>
        <result property="contactOfficePhone" column="contact_office_phone"/>
        <result property="contactPosition" column="contact_position"/>
        <result property="contactPhone" column="contact_phone"/>
        <result property="contactEmail" column="contact_email"/>
        <result property="businessScope" column="business_scope"/>
        <result property="businessImpact" column="business_impact"/>
        <result property="attachUrl" column="attach_url"/>
        <result property="createBy" column="create_by"/>
        <result property="createAt" column="create_at"/>
        <result property="updateBy" column="update_by"/>
        <result property="updateAt" column="update_at"/>
        <result property="communityId" column="community_id"/>
        <result property="userId" column="user_id"/>
    </resultMap>
 
    <select id="pageList" resultType="com.panzhihua.common.model.vos.community.ComActSocialOrgVO">
        select t.*,t1.account,t1.password,t2.role_id as roleId,t4.name as streetName,t6.name as communityName from com_act_social_org t
        left join sys_user t1 on t.user_id = t1.user_id
        left join sys_user_role t2 on t.user_id = t2.user_id
        left join com_street t4 on t.street_id = t4.street_id
        left join com_act t6 on t.community_id = t6.community_id
        <where>
            1=1
            <if test="commonPage.type!=null">
                and t.company_type =#{commonPage.type}
            </if>
            <if test="commonPage.type2!=null">
                and t.service_type =#{commonPage.type2}
            </if>
            <if test="commonPage.name!=null and commonPage.name!=''">
                and t.name like concat(#{commonPage.name},'%')
            </if>
            <if test="commonPage.keyword!=null and commonPage.keyword!=''">
                and (t.name like concat('%',#{commonPage.keyword},'%') or t.contact_phone like concat('%',#{commonPage.keyword},'%') or  t.corporation_name like concat(#{commonPage.keyword},'%') )
            </if>
            <if test="commonPage.serialNo!=null and commonPage.serialNo!=''">
                and t.agency_code like concat(#{commonPage.serialNo},'%')
            </if>
            <if test="commonPage.username!=null and commonPage.username!=''">
                and t.corporation_name like concat(#{commonPage.username},'%')
            </if>
            <if test="commonPage.systemName!=null and commonPage.systemName!=''">
                and t.contact_name like concat(#{commonPage.systemName},'%')
            </if>
            <if test="commonPage.streetId!=null">
                and t.street_id =#{commonPage.streetId}
            </if>
            <if test="commonPage.phone!=null and commonPage.phone!=''">
                and t.contact_phone like concat(#{commonPage.phone},'%')
            </if>
            <if test="commonPage.status!=null">
                and t.status = #{commonPage.status}
            </if>
            <if test="commonPage.paramId2 == 1">
                and t.is_society = #{commonPage.paramId2}
                <if test="commonPage.communityId!=null">
                    and t.affiliated_unit_type = 2 AND t.affiliated_unit = #{commonPage.communityId}
                </if>
                <if test="commonPage.paramId!=null and commonPage.paramId!=0">
                    and t.affiliated_unit_type = 2 AND t.affiliated_unit = ${commonPage.paramId}
                </if>
            </if>
            <if test="commonPage.paramId2==null">
                and t.is_society is null
                <if test="commonPage.communityId!=null">
                    and t.community_id =#{commonPage.communityId}
                </if>
                <if test="commonPage.paramId!=null">
                    and t.community_id = ${commonPage.paramId}
                </if>
            </if>
        </where>
        order by t.create_at desc
    </select>
 
    <select id="detail" resultType="com.panzhihua.common.model.vos.community.ComActSocialOrgVO">
        select t.*,t1.account,t1.password,t2.role_id as roleId,t4.name as streetName from com_act_social_org t
                                                                                              left join sys_user t1 on t.user_id = t1.user_id
                                                                                              left join sys_user_role t2 on t.user_id = t2.user_id
                                                                                              left join com_street t4 on t.street_id = t4.street_id
        where t.id=#{id}
    </select>
 
    <select id="selectInfo" resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkSocialOrgInfo">
        select (select count(*)  from com_act_social_org where street_id = 15 <if test="communityId!=null"> and community_id = #{communityId}</if>) count
    </select>
    <select id="selectType" resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkProjectTypeInfo">
        select count(*) count,t1.name from com_act_social_org t INNER JOIN com_act_column t1 on t.service_type = t1.id  where t.street_id = 15 <if test="communityId!=null"> and t.community_id = #{communityId}</if> GROUP BY t1.id
    </select>
    <select id="selectOrgByUserId" resultType="com.panzhihua.service_community.entity.ComActSocialOrg">
        SELECT t1.*
        FROM com_act_social_org t1
                 LEFT JOIN sys_user t2 ON t1.contact_phone = t2.phone AND t2.`type` = 1
        WHERE t2.user_id = #{userId} AND t1.is_society = 1
    </select>
    <select id="pageHatchResult" resultType="com.panzhihua.common.model.vos.community.ComActSocialOrgVO">
        SELECT t.id, t.`name`, t.company_type, t.attach_url, t.streetName, t.create_at, t.service_type,
               (SELECT COUNT(id) FROM com_act_social_member WHERE org_id = t.id) AS staffCount,
               (SELECT COUNT(id) FROM com_act_social_project WHERE responsibility_type = 3 AND responsibility_id = t.id) AS undertakeProjectNum,
               (SELECT COUNT(id) FROM com_act_activity WHERE `type` = 4 AND project_id IN (
                   SELECT id FROM com_act_social_project WHERE responsibility_type = 3 AND responsibility_id = t.id)
               ) AS startActNum
        FROM (
                 SELECT t.*, t2.`name` AS streetName
                 FROM com_act_social_org t
                          LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
                          LEFT JOIN com_street t2 ON t1.street_id = t2.street_id
                 WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
                 UNION ALL
                 SELECT t.*, t1.`name` AS streetName
                 FROM com_act_social_org t
                          LEFT JOIN com_street t1 ON t.affiliated_unit = t1.street_id
                 WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 1 AND t.`status` = 1 AND t.affiliated_unit = #{streetId}) t
    </select>
    <select id="pageHatchSchedule" resultType="com.panzhihua.common.model.vos.community.ComActSocialOrgVO">
        SELECT t.id, t.`name`, 1 AS hatchSchedule, null AS affiliated_unit_name
        FROM com_act_social_org_hatch_audit t
                 LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
        WHERE t.hatch_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
        UNION ALl
        SELECT id, `name`, 1 AS hatchSchedule, null AS affiliated_unit_name
        FROM com_act_social_org_hatch_audit
        WHERE hatch_unit_type = 1 AND `status` = 1 AND hatch_unit = #{streetId}
        UNION ALl
        SELECT t.id, t.`name`, 2 AS hatchSchedule, null AS affiliated_unit_name
        FROM com_act_social_org_hatch t
                 LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
        WHERE t.hatch_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
        UNION ALL
        SELECT id, `name`, 2 AS hatchSchedule, null AS affiliated_unit_name
        FROM com_act_social_org_hatch
        WHERE hatch_unit_type = 1 AND `status` = 1 AND hatch_unit = #{streetId}
        UNION ALl
        SELECT t.id, t.`name`, 3 AS hatchSchedule, null AS affiliated_unit_name
        FROM com_act_social_org_hatch t
                 LEFT JOIN com_act t1 ON t.hatch_unit = t1.community_id
        WHERE t.hatch_unit_type = 2 AND t.`status` = 2 AND t1.street_id = #{streetId}
        UNION ALL
        SELECT id, `name`, 3 AS hatchSchedule, null AS affiliated_unit_name
        FROM com_act_social_org_hatch
        WHERE hatch_unit_type = 1 AND `status` = 2 AND hatch_unit = #{streetId}
        UNION ALL
        SELECT t.id, t.`name`, 4 AS hatchSchedule, affiliated_unit_name
        FROM com_act_social_org t
                 LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
        WHERE t.build_type = 1 AND t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
        UNION ALL
        SELECT id, `name`, 4 AS hatchSchedule, affiliated_unit_name
        FROM com_act_social_org
        WHERE build_type = 1 AND is_society = 1 AND affiliated_unit_type = 1 AND `status` = 1 AND affiliated_unit = #{streetId}
    </select>
 
    <select id="pageSocialOrgList" resultType="com.panzhihua.common.model.vos.community.ComActSocialOrgVO">
        SELECT t.id, t.`name`, t.company_type, t.attach_url, t.streetName, t.create_at, t.service_type,
               (SELECT COUNT(id) FROM com_act_social_member WHERE org_id = t.id) AS staffCount,
               (SELECT COUNT(id) FROM com_act_social_project WHERE responsibility_type = 3 AND responsibility_id = t.id) AS undertakeProjectNum,
               (SELECT COUNT(id) FROM com_act_activity WHERE `type` = 4 AND project_id IN (
                   SELECT id FROM com_act_social_project WHERE responsibility_type = 3 AND responsibility_id = t.id)
               ) AS startActNum
        FROM (
                 SELECT t.*, t2.`name` AS streetName
                 FROM com_act_social_org t
                          LEFT JOIN com_act t1 ON t.affiliated_unit = t1.community_id
                          LEFT JOIN com_street t2 ON t1.street_id = t2.street_id
                 WHERE t.is_society = 1 AND t.affiliated_unit_type = 2 AND t.`status` = 1 AND t1.street_id = #{streetId}
                 UNION ALL
                 SELECT t.*, t1.`name` AS streetName
                 FROM com_act_social_org t
                          LEFT JOIN com_street t1 ON t.affiliated_unit = t1.street_id
                 WHERE t.is_society = 1 AND t.affiliated_unit_type = 1 AND t.`status` = 1 AND t.affiliated_unit = #{streetId}) t
    </select>
 
</mapper>