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
<?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.ComActFourMemberDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActFourMember" id="ComActFourMemberBaseResultMap">
        <result property="id" column="id"/>
        <result property="userId" column="user_id"/>
        <result property="position" column="position"/>
        <result property="jurisdiction" column="jurisdiction"/>
        <result property="communityId" column="community_id"/>
        <result property="createTime" column="create_time"/>
        <result property="jurisdictionContent" column="jurisdiction_content"/>
        <result property="idCard" column="id_card"/>
    </resultMap>
 
    <resultMap id="baseResultMap" type="com.panzhihua.common.model.vos.community.ComActFourMemberVO">
        <collection property="buildings"
                    ofType="String"
                    column="{id = jurisdiction}"
                    select="selectBuilding"
                    javaType="java.util.ArrayList" />
    </resultMap>
 
    <select id="pageList" resultMap="baseResultMap">
        select t.*,t1.*,t2.role_id from com_act_four_member 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
        <where>
            1=1
            <if test="commonPage.paramId !=null">
                and t.community_id = ${commonPage.paramId}
            </if>
            <if test="commonPage.position !=null and commonPage.position !=''">
                and t.position like concat('%',#{commonPage.position},'%')
            </if>
            <if test="commonPage.keyword !=null and commonPage.keyword !=''">
                and (t1.name like concat(#{commonPage.keyword},'%') or t1.phone like concat(#{commonPage.keyword},'%') or t.jurisdiction_content like concat('%',#{commonPage.keyword},'%'))
            </if>
            <if test="commonPage.status !=null">
                and t1.status =#{commonPage.status}
            </if>
        </where>
        order by t.create_time desc
    </select>
 
    <select id="selectBuilding" resultType="String">
        select distinct concat(alley,house_num,'号',IFNULL(floor,0),'栋') from com_mng_population_house   where id in (${id})
    </select>
 
    <select id="getById" resultMap="baseResultMap">
        select t.*,t1.*,t2.role_id from com_act_four_member 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 where t.id =#{id}
    </select>
    <select id="getFourMemberBaseData"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenFourMemberStatisticsInfo">
        SELECT
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId}) AS szsyTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','居民小组长','%') OR position = '全部')) AS jmxzzTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','妇女小组长','%') OR position = '全部')) AS fnxzzTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','党小组长','%') OR position = '全部')) AS dxzzTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','楼栋长','%') OR position = '全部')) AS ldzTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','调解员','%') OR position = '全部')) AS tjyTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','安全员','%') OR position = '全部')) AS aqyTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','宣传员','%') OR position = '全部')) AS xcyTotal,
        (SELECT COUNT(id) FROM com_act_four_member WHERE community_id = #{communityId} AND (position LIKE CONCAT('%','监督员','%') OR position = '全部')) AS jdyTotal,
        (SELECT
            (SELECT COUNT(t1.id)
            FROM com_act_easy_photo_handler t1
            INNER JOIN com_act_easy_photo t2 ON t1.service_id = t2.id
            WHERE t1.community_id = #{communityId} AND t1.`type` = 5 AND t1.service_type = 1 AND t2.`status` = 5
            ) +
            (SELECT COUNT(t1.id)
            FROM com_act_easy_photo_handler t1
            INNER JOIN com_act_micro_wish t2 ON t1.service_id = t2.id
            WHERE t1.community_id = #{communityId} AND t1.`type` = 5 AND t1.service_type = 2 AND t2.`status` = 6
            )
        ) AS jjwtTotal,
        (SELECT COUNT(id) FROM com_act_discuss WHERE community_id = #{communityId} AND content_type = 2 AND is_del = 2) AS ylysTotal
    </select>
    <select id="getFourMembers" resultType="com.panzhihua.common.model.vos.community.ComActFourMemberVO">
        SELECT
        a.id,
        su.`name`,
        su.phone,
        a.position,
        a.url,
        substring_index( substring_index( a.jurisdiction_content, ',', b.help_topic_id + 1 ), ',',- 1 ) AS jurisdiction_content
        FROM
        com_act_four_member a
        LEFT JOIN sys_user su ON a.user_id = su.user_id
        JOIN mysql.help_topic b ON b.help_topic_id &lt; ( length( a.jurisdiction_content ) - length( REPLACE ( a.jurisdiction_content, ',', '' ))+ 1 )
        WHERE
        a.community_id = #{communityId}
    </select>
    <select id="retrieveJJWTAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
            SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(1) AS num
            FROM com_act_easy_photo_handler t1
            INNER JOIN com_act_easy_photo t2 ON t1.service_id = t2.id
            WHERE t1.community_id = #{communityId} AND t1.`type` = 5 AND t1.service_type = 1 AND t2.`status` = 5 AND DATE_FORMAT( create_at, '%Y-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
            ) GROUP BY filed
            UNION ALL
            SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(1) AS num
            FROM com_act_easy_photo_handler t1
            INNER JOIN com_act_micro_wish t2 ON t1.service_id = t2.id
            WHERE t1.community_id = #{communityId} AND t1.`type` = 5 AND t1.service_type = 2 AND t2.`status` = 6 AND DATE_FORMAT( create_at, '%Y-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
            ) GROUP BY filed
            UNION ALL SELECT * FROM
            (
                    SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
            ) temT
        ) temp GROUP BY filed ORDER BY filed ASC
    </select>
    <select id="retrieveJJWTTotalPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT
        (SELECT COUNT(1) AS num
        FROM com_act_easy_photo_handler t1
        INNER JOIN com_act_easy_photo t2 ON t1.service_id = t2.id
        WHERE t1.community_id = #{communityId} AND t1.`type` = 5
        AND t1.service_type = 1 AND t2.`status` = 5 AND DATE_FORMAT( t2.create_at, '%Y-%m' ) &lt;= #{date}
        )
        +
        (SELECT COUNT(1) AS num
        FROM com_act_easy_photo_handler t1
        INNER JOIN com_act_micro_wish t2 ON t1.service_id = t2.id
        WHERE t1.community_id = #{communityId} AND t1.`type` = 5
        AND t1.service_type = 2 AND t2.`status` = 6 AND DATE_FORMAT( t2.create_at, '%Y-%m' ) &lt;= #{date}
        ) AS num
    </select>
    <select id="retrieveYLYSAddPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT filed, SUM(num) AS num FROM (
            SELECT DATE_FORMAT( create_at, '%Y-%m' ) AS filed, COUNT(1) AS num
            FROM com_act_discuss
            WHERE community_id = #{communityId} AND content_type = 2 AND is_del = 2 AND DATE_FORMAT( create_at, '%Y-%m' ) &gt; DATE_FORMAT(date_sub(curdate(), interval 12 month),'%Y-%m'
            ) GROUP BY filed
            UNION ALL SELECT * FROM
            (
                    SELECT DATE_FORMAT(curdate(),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 1 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 2 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 3 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 4 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 5 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 6 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 7 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 8 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 9 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 10 month),'%Y-%m') AS filed, 0 AS num union
                    SELECT DATE_FORMAT(date_sub(curdate(), interval 11 month),'%Y-%m') AS filed, 0 AS num
            ) temT
        ) temp GROUP BY filed ORDER BY filed ASC
    </select>
    <select id="retrieveYLYSTotalPolylineData"
            resultType="com.panzhihua.common.model.vos.community.StatisticsCommVO">
        SELECT COUNT(1) AS num
        FROM com_act_discuss
        WHERE community_id = #{communityId} AND content_type = 2 AND is_del = 2 AND DATE_FORMAT( create_at, '%Y-%m' ) &lt;= #{date}
    </select>
 
</mapper>