zhangherong
2025-06-12 6abc1a2fb78003bb1ea6283d813b8ccc0bcd9b2b
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
<?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="org.jeecg.modules.base.mapper.WorkCenterUserMapper">
    <select id="listByWorkCenterId" resultType="Map">
        select
        t1.id id,
        t2.id userId,
        t2.realname realName,
        t3.depart_name departName
        from mom_base_work_center_user t1
        left join (select * from sys_user where del_flag=0) t2
        on t1.user_id = t2.id
        left join (select * from sys_depart where del_flag=0) t3
        on t2.depart_id = t3.id
        where t1.work_center_id =#{workCenterId}
        and t1.del_flag=0
    </select>
    <select id="listByEnterpriseId" resultType="Map">
        select
        t1.id id,
        t1.username userName,
        t1.realname realName,
        t2.depart_name departName
        from sys_user t1
        left join (select * from sys_depart where del_flag=0) t2
        on t1.depart_id=t2.id
        where t1.del_flag=0
        and t1.enterprise_id=#{enterpriseId}
        <if test="userIdList != null and userIdList.size >  0">
            and t1.id not in (
            select id from sys_user where del_flag=0 and id in
            <foreach collection="userIdList" open="(" separator="," close=")" item="uid">
                #{uid}
            </foreach>
            )
        </if>
        <if test="departIds != null and departIds.size >  0">
            and t1.depart_id not in
            <foreach collection="departIds" open="(" separator="," close=")" item="did">
                #{did}
            </foreach>
        </if>
    </select>
    <select id="getAddUserList" resultType="Map">
        select
        t1.id id,
        t1.username userName,
        t1.realname realName,
        t2.depart_name departName
        from sys_user t1
        left join (select * from sys_depart where del_flag=0) t2
        on t1.depart_id=t2.id
        where t1.del_flag=0
        and t1.depart_id=#{departId}
        <if test="userIdList != null and userIdList.size >  0">
        and t1.id not in (
            select id from sys_user where del_flag=0 and id in
            <foreach collection="userIdList" open="(" separator="," close=")" item="uid">
                #{uid}
            </foreach>
            )
        </if>
    </select>
    <select id="getUserList" resultType="Map">
        select
        t1.id id,
        t1.username userName,
        t1.realname realName,
        t2.depart_name departName
        from sys_user t1
        left join (select * from sys_depart where del_flag=0) t2
        on t1.depart_id=t2.id
        where t1.del_flag=0
            and t1.depart_id in
        (
                SELECT
                id
                FROM
                (
                    SELECT
                    t4.id,
                    IF
                    ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), - 1 ) AS ischild
                    FROM
                    ( SELECT id, parent_id FROM sys_depart WHERE del_flag = 0 ) t4,
                    ( SELECT @pids := #{parentId} ) t5
                ) t6
                WHERE
                ischild != -1
        )
        and t1.id in (#{parentId})
        <if test="userIdList != null and userIdList.size >  0">
            and t1.id not in (
            select id from sys_user where del_flag=0 and id in
            <foreach collection="userIdList" open="(" separator="," close=")" item="uid">
                #{uid}
            </foreach>
            )
        </if>
    </select>
    <select id="getAddDepartTree" resultType="org.jeecg.common.system.vo.SelectTreeModel">
        select
            id as "key",
            depart_name as "title",
            parent_id as parentId
        from sys_depart
        where parent_id = #{parentId}
          and id != #{departId}
          and version = #{version}
          and del_flag='0'
    </select>
</mapper>