智慧保安后台管理项目备份
zhongrj
2024-05-24 b5960d1968e007b91d4d33dd7cbb74f1b566f2c1
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
<?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.loginrecord.mapper.LoginRecordMapper">
 
    <!--登录记录自定义分页信息-->
    <select id="selectSecurityPaperPage" resultType="org.springblade.modules.loginrecord.vo.LoginRecordVo">
        select
            slr.*,
            bd.dept_name deptName
        from
            sys_login_record slr
        left join blade_dept bd on bd.id = slr.dept_id
        <if test="loginRecord.deptName!=null and loginRecord.deptName!=''">
            bd.dept_name like concat('%',#{loginRecord.deptName},'%')
        </if>
        <if test="loginRecord.createBy!=null and loginRecord.createBy!=''">
            slr.create_by like concat('%',#{loginRecord.createBy},'%')
        </if>
        order by slr.id desc
    </select>
 
    <!--自定义分页(企业登录分页记录)-->
    <select id="getInformationLoginPage" resultType="org.springblade.modules.loginrecord.vo.LoginRecordVo">
        select * from (
        SELECT
        a.enterpriseName deptName,
        a.stats,
        sj.dept_name jurisdictionName,
        ifnull( b.c, 0 ) num,
        c.create_time createTime
        FROM
        (
        SELECT
        si.*
        FROM
        sys_information si
        LEFT JOIN blade_dept bd ON si.departmentid = bd.id
        WHERE
        bd.is_deleted = 0
        AND bd.dept_category = 1
        ) a
        left join
        (
        SELECT count( * ) c, dept_id FROM `sys_login_record`
        where 1=1
        and type = 1
        <if test="loginRecord.startTime!=null and loginRecord.startTime!=''">
            and date(create_time) &gt;= #{loginRecord.startTime}
        </if>
        <if test="loginRecord.endTime!=null and loginRecord.endTime!=''">
            and date(create_time) &lt;= #{loginRecord.endTime}
        </if>
        GROUP BY dept_id
        ) b ON a.departmentid = b.dept_id
        left join
        (
        select dept_id,max(create_time) create_time from sys_login_record GROUP BY dept_id
        ) c on a.departmentid = c.dept_id
        left join sys_jurisdiction sj on a.jurisdiction = sj.id
        where 1=1
        <if test="loginRecord.jurisdiction!=null and loginRecord.jurisdiction!='' and loginRecord.jurisdiction!='1372091709474910209'">
            and (sj.id = #{loginRecord.jurisdiction} or sj.parent_id = #{loginRecord.jurisdiction})
        </if>
        <if test="loginRecord.deptName!=null and loginRecord.deptName!=''">
            and a.enterpriseName like concat('%',#{loginRecord.deptName},'%')
        </if>
        <if test="loginRecord.stats!=null and loginRecord.stats!=''">
            and a.stats = #{loginRecord.stats}
        </if>
        ) r where 1=1
        <if test="loginRecord.types ==1">
            and r.num = 0
        </if>
        <if test="loginRecord.types ==2">
            and r.num > 0
        </if>
    </select>
 
 
    <!--企业登录记录导出-->
    <select id="exportLoginRecord" resultType="org.springblade.modules.loginrecord.excel.LoginRecordExcel">
        select * from (
        SELECT
        a.enterpriseName deptName,
        case when a.stats=0 then '自招保安单位'
        when a.stats=2 then '本市保安公司'
        when a.stats=4 then '分公司'
        when a.stats=1 then '保安培训学校'
        else "其他" end as stats,
        sj.dept_name jurisdictionName,
        ifnull( b.c, 0 ) num,
        c.create_time createTime
        FROM
        (
        SELECT
        si.*
        FROM
        sys_information si
        LEFT JOIN blade_dept bd ON si.departmentid = bd.id
        WHERE
        bd.is_deleted = 0
        AND bd.dept_category = 1
        ) a
        left join
        (
        SELECT count( * ) c, dept_id FROM `sys_login_record`
        where 1=1
        and type = 1
        <if test="loginRecord.startTime!=null and loginRecord.startTime!='' and loginRecord.startTime!='undefined'">
            and date(create_time) &gt;= #{loginRecord.startTime}
        </if>
        <if test="loginRecord.endTime!=null and loginRecord.endTime!='' and loginRecord.endTime!='undefined'">
            and date(create_time) &lt;= #{loginRecord.endTime}
        </if>
        GROUP BY dept_id
        ) b ON a.departmentid = b.dept_id
        left join
        (
        select dept_id,max(create_time) create_time from sys_login_record GROUP BY dept_id
        ) c on a.departmentid = c.dept_id
        left join sys_jurisdiction sj on a.jurisdiction = sj.id
        where 1=1
        <if test="loginRecord.jurisdiction!=null and loginRecord.jurisdiction!='' and loginRecord.jurisdiction!='1372091709474910209'">
            and (sj.id = #{loginRecord.jurisdiction} or sj.parent_id = #{loginRecord.jurisdiction})
        </if>
        <if test="loginRecord.deptName!=null and loginRecord.deptName!=''">
            and a.enterpriseName like concat('%',#{loginRecord.deptName},'%')
        </if>
        <if test="loginRecord.stats!=null and loginRecord.stats!=''">
            and a.stats = #{loginRecord.stats}
        </if>
        ) r where 1=1
        <if test="loginRecord.types ==1">
            and r.num = 0
        </if>
        <if test="loginRecord.types ==2">
            and r.num > 0
        </if>
    </select>
 
</mapper>