yangys
2025-11-18 8e944cfabb253fc2556588e308e282586043f7b0
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
<?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.qianwen.smartman.modules.smis.mapper.EmployeeMapper">
 
    <select id="selectEmployeePage" resultType="com.qianwen.smartman.modules.smis.dto.EmployeeDTO">
        select a.id,a.code,a.name,
        a.email,a.tel,a.hire_date,
        a.job_number,a.pin_code,a.dept_id,
        a.post_id,a.user_id,a.role_id,a.organization_id,a.avatar,
        <if test="_databaseId == 'mysql' ">
            group_concat(c.name) organizationName,
        </if>
        <if test="_databaseId == 'dm' ">
            wm_concat(c.name) organizationName,
        </if>
        a.status
        from blade_employee a
        join blade_common_group_of_item b on b.item_id = a.id
        left join blade_common_group c on c.id = b.group_id
        <where>
            and a.is_deleted=0
            <if test="query.postId != null and query.postId != ''">
                and a.post_id like concat(concat('%', #{query.postId}),'%')
            </if>
            <if test="query.keywords != null and query.keywords != ''">
                and a.job_number LIKE concat(#{query.keywords},'%')
                or a.name LIKE concat(#{query.keywords},'%')
            </if>
            <if test="query.status != null">
                and a.status = #{query.status}
            </if>
            <if test="organizationIdList != null and organizationIdList.size() > 0">
                AND b.group_id IN
                <foreach collection="organizationIdList" item="organizationId" open="(" separator="," close=")">
                    #{organizationId}
                </foreach>
            </if>
        </where>
        group by a.id,a.code,a.name,
        a.email,a.tel,a.hire_date,
        a.job_number,a.pin_code,a.dept_id,
        a.post_id,a.user_id,a.role_id,a.organization_id,a.status,a.create_time,a.avatar
        order by a.create_time desc,a.id desc;
    </select>
    <select id="getUnbindEmployeeList" resultType="com.qianwen.smartman.modules.smis.vo.GroupTreeVO">
        SELECT b.id,b.code,b.name,b.organization_id parentId,0 isGroup
        FROM blade_employee b
        LEFT JOIN blade_user a ON a.id = b.user_id and a.is_deleted = 0
        WHERE b.is_deleted = 0 and b.status = 1
        <choose>
            <when test="employeeId != null and employeeId != ''">
                and (b.user_id is null OR b.user_id = '' or b.id = #{employeeId})
            </when>
            <otherwise>
                and (b.user_id is null OR b.user_id = '' or b.user_id = '')
            </otherwise>
        </choose>
        order by b.create_time desc,b.job_number
    </select>
    <select id="selectEmployeeList" resultType="com.qianwen.smartman.modules.smis.dto.EmployeeDTO">
        select a.id,a.code,a.name,
        a.email,a.tel,a.hire_date,
        a.job_number,a.pin_code,a.dept_id,
        a.post_id,a.user_id,a.role_id,a.organization_id,a.avatar,
        <if test="_databaseId == 'mysql' ">
            group_concat(c.name) organizationName,
        </if>
        <if test="_databaseId == 'dm' ">
            wm_concat(c.name) organizationName,
        </if>
        a.status
        from blade_employee a
        join blade_common_group_of_item b on b.item_id = a.id
        left join blade_common_group c on c.id = b.group_id
        <where>
            and a.is_deleted=0
            <if test="query.postId != null and query.postId != ''">
                and a.post_id like concat(concat('%', #{query.postId}),'%')
            </if>
            <if test="query.keywords != null and query.keywords != ''">
                and a.job_number LIKE concat(#{query.keywords},'%')
                or a.name LIKE concat(#{query.keywords},'%')
            </if>
            <if test="query.status != null">
                and a.status = #{query.status}
            </if>
            <if test="organizationIdList != null and organizationIdList.size() > 0">
                AND b.group_id IN
                <foreach collection="organizationIdList" item="organizationId" open="(" separator="," close=")">
                    #{organizationId}
                </foreach>
            </if>
        </where>
        group by a.id,a.code,a.name,
        a.email,a.tel,a.hire_date,
        a.job_number,a.pin_code,a.dept_id,
        a.post_id,a.user_id,a.role_id,a.organization_id,a.status,a.create_time,a.avatar
        order by a.create_time desc,a.job_number
    </select>
 
 
</mapper>