智慧保安后台管理-外网项目备份
zhongrj
2022-08-18 f288ed575764a898bb8df1eb06c9b3cba55f3e17
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
<?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.springblade.modules.dispatcher.mapper.DispatcherMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="dispatcherResultMap" type="org.springblade.modules.dispatcher.entity.Dispatcher">
        <id column="id" property="id"/>
        <result column="cardid" property="cardid"/>
        <result column="name" property="name"/>
        <result column="dispatcher" property="dispatcher"/>
        <result column="dispatcherTime" property="dispatchertime"/>
        <result column="dispatcherAddress" property="dispatcheraddress"/>
    </resultMap>
 
    <!--派遣记录分页数据-->
    <select id="selectDispatcherPage" resultType="org.springblade.modules.dispatcher.vo.DispatcherVO">
        select
            sd.*,bu.real_name securityName,sdu.name dispatcherCompany,bu.cardid idCardNo,bd.dept_name deptName
        from
            sys_dispatcher sd
        left join
            sys_dispatcher_unit sdu
        on
            sdu.id = sd.dispatcher_unit_id
        left join
            blade_user bu
        on
            bu.id = sd.user_ids
        left join
            blade_dept bd
        on
            bd.id = bu.dept_id
        left join
            sys_jurisdiction sj
        on
            sj.id = sdu.jurisdiction
        where 1=1
        and bu.status =1
        and bu.is_deleted = 0
        <if test="dispatcher.jurisdiction!=null  and dispatcher.jurisdiction!='' and dispatcher.jurisdiction!='1372091709474910209'">
            and (sj.id = #{dispatcher.jurisdiction} or sj.parent_id = #{dispatcher.jurisdiction})
        </if>
        <if test="dispatcher.dispatcherUnitId!=null">
            and sd.dispatcher_unit_id = #{dispatcher.dispatcherUnitId}
        </if>
        <if test="dispatcher.deptId!=null">
            and sd.dept_id in
            (
                select id from blade_dept where id = #{dispatcher.deptId}
                union
                SELECT
                id
                FROM
                (
                SELECT
                t1.id,t1.parent_id,t1.dept_name,
                IF
                ( find_in_set( parent_id, @pids ) > 0, @pids := concat( @pids, ',', id ), 0 ) AS ischild
                FROM
                ( SELECT id, parent_id,dept_name FROM blade_dept t ORDER BY parent_id, id ) t1,
                ( SELECT @pids := #{dispatcher.deptId} ) t2
                ) t3
                WHERE
                ischild != 0
            )
        </if>
        <if test="dispatcher.dispatch!=null and dispatcher.dispatch!=''">
            and bu.dispatch = #{dispatcher.dispatch}
            and sd.status = #{dispatcher.dispatch}
        </if>
        <if test="dispatcher.userIds!=null and  dispatcher.userIds!=''">
            and sd.user_ids like concat('%', #{dispatcher.userIds},'%')
        </if>
        <if test="dispatcher.name!=null and  dispatcher.name!=''">
            and sd.name like concat('%', #{dispatcher.name},'%')
        </if>
        <if test="dispatcher.securityName!=null and  dispatcher.securityName!=''">
            and bu.real_name like concat('%', #{dispatcher.securityName},'%')
        </if>
        <if test="dispatcher.deptName!=null and  dispatcher.deptName!=''">
            and bd.dept_name like concat('%', #{dispatcher.deptName},'%')
        </if>
        <if test="dispatcher.cardid!=null and  dispatcher.cardid!=''">
            and sd.cardid like concat('%', #{dispatcher.cardid},'%')
        </if>
        <if test="dispatcher.dispatcherCompany!=null and  dispatcher.dispatcherCompany!=''">
            and sdu.name like concat('%', #{dispatcher.dispatcherCompany},'%')
        </if>
        <if test="dispatcher.beginTime!=null or dispatcher.overTime!=null">
            <if test="dispatcher.beginTime!='' or dispatcher.overTime!=''">
                and sd.end_time &lt;= #{dispatcher.overTime} and sd.end_time &gt;= #{dispatcher.beginTime}
                or ( sd.dispatcherTime &lt;= #{dispatcher.overTime} and sd.dispatcherTime &gt;= #{dispatcher.beginTime})
            </if>
        </if>
    </select>
 
    <!--派遣记录详情-->
    <select id="getDispatcherInfo" resultType="org.springblade.modules.dispatcher.vo.DispatcherVO">
        select
            sd.*,sdu.name dispatcherCompany
        from
            sys_dispatcher sd
        left join
            sys_dispatcher_unit sdu
        on
            sdu.id = sd.dispatcher_unit_id
        where 1=1
        <if test="dispatcher.id!=null">
            and sd.id = #{dispatcher.id}
        </if>
    </select>
 
    <!--派遣记录条数-->
    <select id="getDispatcherCount" resultType="java.lang.Integer">
        select ifnull(count(*),0) count from sys_dispatcher
        where
        1=1
        and dispatcher_unit_id = #{dispatcherUnitVO1.id}
        and status = 0
    </select>
 
    <!--查询用的派遣信息-->
    <select id="getDispatcherInfoByUserId" resultType="org.springblade.modules.dispatcher.vo.DispatcherVO">
        select
            sd.*
        from
            sys_dispatcher sd
        left join
            sys_dispatcher_unit sdu
        on
            sdu.id = sd.dispatcher_unit_id
        where sd.user_ids = #{userId}
        and sd.status = 0
    </select>
 
    <update id="updateEndtime">
        update sys_dispatcher set end_time =#{endTime} where dispatcher_unit_id =#{disId}
    </update>
 
</mapper>