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
<?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.ComActSocialWorkerDao">
 
    <resultMap type="com.panzhihua.service_community.entity.ComActSocialWorker" id="ComActSocialWorkerBaseResultMap">
        <result property="id" column="id"/>
        <result property="socialOrgId" column="social_org_id"/>
        <result property="name" column="name"/>
        <result property="telephone" column="telephone"/>
        <result property="gen" column="gen"/>
        <result property="streetId" column="street_id"/>
        <result property="communityId" column="community_id"/>
        <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="idCard" column="id_card"/>
        <result property="skillType" column="skill_type"/>
        <result property="joinTime" column="join_time"/>
        <result property="address" column="address"/>
        <result property="image" column="image"/>
    </resultMap>
 
    <!-- 分页查询 -->
    <select id="findByPage" resultType="com.panzhihua.common.model.vos.civil.ComActSocialWorkerVO"
            parameterType="com.panzhihua.common.model.dtos.civil.PageComActSocialWorkerDTO">
        SELECT a.*,b.name as socialOrgId,c.name as communityName,e.name as streetId
        FROM com_act_social_worker a
        left join com_act_social_org b on a.social_org_id = b.id
        left join com_act c on a.community_id = c.community_id
        left join com_street e on c.street_id = e.street_id
        <if test="pageComActSocialWorkerDTO.skillType != null">
            JOIN mysql.help_topic h ON h.help_topic_id &lt; ( length( a.skill_type ) - length( REPLACE ( a.skill_type, ',', '' ))+ 1 )
        </if>
        <where>
            <if test="pageComActSocialWorkerDTO.skillType != null">
                AND substring_index( substring_index( a.skill_type, ',', h.help_topic_id + 1 ), ',',- 1 ) = #{pageComActSocialWorkerDTO.skillType}
            </if>
            <if test="pageComActSocialWorkerDTO.id!=null">
                AND a.id = #{pageComActSocialWorkerDTO.id}
            </if>
            <if test="pageComActSocialWorkerDTO.socialOrgId!=null">
                AND a.social_org_id = #{pageComActSocialWorkerDTO.socialOrgId}
            </if>
            <if test="pageComActSocialWorkerDTO.name!=null and pageComActSocialWorkerDTO.name!=''">
                AND a.name like concat('%',#{pageComActSocialWorkerDTO.name},'%')
            </if>
            <if test="pageComActSocialWorkerDTO.keyword!=null and pageComActSocialWorkerDTO.keyword!=''">
                AND (a.name like concat('%',#{pageComActSocialWorkerDTO.keyword},'%') or a.telephone like
                concat('%',#{pageComActSocialWorkerDTO.keyword},'%') )
            </if>
            <if test="pageComActSocialWorkerDTO.ageBegin!=null">
                AND a.age>=#{pageComActSocialWorkerDTO.ageBegin}
            </if>
            <if test="pageComActSocialWorkerDTO.ageEnd!=null">
                AND #{pageComActSocialWorkerDTO.ageEnd} >= a.age
            </if>
            <if test="pageComActSocialWorkerDTO.telephone!=null">
                AND a.telephone = #{pageComActSocialWorkerDTO.telephone}
            </if>
            <if test="pageComActSocialWorkerDTO.gen!=null">
                AND a.gen = #{pageComActSocialWorkerDTO.gen}
            </if>
            <if test="pageComActSocialWorkerDTO.streetId!=null">
                AND e.street_id = #{pageComActSocialWorkerDTO.streetId}
            </if>
            <if test="pageComActSocialWorkerDTO.communityId!=null and pageComActSocialWorkerDTO.communityId!=0">
                AND a.community_id = #{pageComActSocialWorkerDTO.communityId}
            </if>
            <if test="pageComActSocialWorkerDTO.createBy!=null">
                AND a.create_by = #{pageComActSocialWorkerDTO.createBy}
            </if>
            <if test="pageComActSocialWorkerDTO.updateBy!=null">
                AND a.update_by = #{pageComActSocialWorkerDTO.updateBy}
            </if>
        </where>
        order by create_at desc
    </select>
 
    <select id="queryAll" resultType="com.panzhihua.common.model.dtos.civil.ComActSocialWorkerExcelVO">
        SELECT a.social_org_id,a.name as
        name,a.birthday,a.telephone,a.gen,a.social_worker_code,a.skill_field,a.business_scope,b.name as
        socialOrgId,c.name as communityId,e.name as streetId
        FROM com_act_social_worker a left join com_act_social_org b on a.social_org_id = b.id
        left join com_act c on a.community_id = c.community_id
        left join com_street e on a.street_id = e.street_id
        <where>
            <if test="socialOrgId!=null">
                AND a.social_org_id = #{socialOrgId}
            </if>
            <if test="name!=null and name !=''">
                AND a.name like concat('%',#{name},'%')
            </if>
            <if test="streetId!=null">
                AND a.street_id = #{streetId}
            </if>
            <if test="communityId!=null and communityId!=0">
                AND a.community_id = #{communityId}
            </if>
        </where>
    </select>
 
    <select id="selectType" resultType="Integer">
        select count(id) from com_act_social_worker where street_id = 15
        <if test="type ==1">
            and 30 >age
        </if>
        <if test="type ==2">
            and 59 >=age and age >=30
        </if>
        <if test="type ==3">
            and age >=60
        </if>
        <if test="communityId !=null">
            and community_id=#{communityId}
        </if>
    </select>
 
    <select id="selectSkillType"
            resultType="com.panzhihua.common.model.vos.community.bigscreen.BigScreenHmkProjectTypeInfo">
        select count(*) count,t1.name from com_act_social_worker t INNER JOIN com_act_column t1 on t.skill_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="selectActivity" resultType="com.panzhihua.common.model.vos.civil.ComActSocialWorkerVO">
        select t.*
        from com_act_social_worker t
                 LEFT JOIN sys_user t1 on t.telephone = t1.phone
        where t1.user_id in (select distinct user_id from com_act_act_regist where activity_id = #{id})
    </select>
 
    <select id="selectOneById" resultType="com.panzhihua.common.model.vos.civil.ComActSocialWorkerVO">
        SELECT a.*, b.name as socialOrgId, c.name as communityName, e.name as streetId
        FROM com_act_social_worker a
                 left join com_act_social_org b on a.social_org_id = b.id
                 left join com_act c on a.community_id = c.community_id
                 left join com_street e on c.street_id = e.street_id
        where a.id =#{id}
    </select>
    <select id="selectIncludeSkillWorkerList"
            resultType="com.panzhihua.service_community.entity.ComActSocialWorker">
        SELECT
            a.*
        FROM
            com_act_social_worker a
                JOIN mysql.help_topic b ON b.help_topic_id &lt; ( length( a.skill_type ) - length( REPLACE ( a.skill_type, ',', '' ))+ 1 )
        WHERE substring_index( substring_index( a.skill_type, ',', b.help_topic_id + 1 ), ',',- 1 ) = #{id}
    </select>
</mapper>