智慧保安后台管理-外网项目备份
zhongrj
2023-09-17 8853292babb2ad94de4a3207966f1e83b767cd2d
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
<?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.attendance.mapper.AttendanceMapper">
 
    <!-- 通用查询映射结果 -->
    <resultMap id="attendanceResultMap" type="org.springblade.modules.attendance.entity.Attendance">
        <id column="id" property="id"/>
        <result column="name" property="name"/>
        <result column="number" property="number"/>
        <result column="department" property="department"/>
        <result column="weather" property="weather"/>
        <result column="clockTime" property="clockTime"/>
        <result column="jd" property="jd"/>
        <result column="wd" property="wd"/>
        <result column="clockType" property="clocktype"/>
        <result column="attendanceType" property="attendancetype"/>
        <result column="tenant_id" property="tenantId"/>
        <result column="week" property="week"/>
        <result column="address" property="address"/>
    </resultMap>
 
    <!--自定义查询考试分页数据-->
    <select id="selectAttendancePage" resultType="org.springblade.modules.attendance.vo.AttendanceVO">
        select sa.*,bu.real_name realName from sys_attendance sa
        left join blade_user bu on bu.id = sa.user_id
        where 1=1
        <if test="attendance.realName!=null and attendance.realName!=''">
            and bu.real_name like concat('%',#{attendance.realName},'%')
        </if>
        <if test="attendance.deptId!=null">
            and sa.dept_id = #{attendance.deptId}
        </if>
        <if test="attendance.userId!=null">
            and sa.user_id = #{attendance.userId}
        </if>
        <if test="attendance.attendanceType!=null">
            and sa.attendance_type = #{attendance.attendanceType}
        </if>
        <if test="attendance.clockType!=null">
            and sa.clock_type = #{attendance.clockType}
        </if>
        <if test="attendance.legwork!=null">
            and sa.legwork = #{attendance.legwork}
        </if>
        <if test="attendance.beginTime!=null and attendance.beginTime!=''">
            and date_format(sa.clock_time,'%Y-%m-%d')&gt;=#{attendance.beginTime}
        </if>
        <if test="attendance.endTime!=null and attendance.endTime!=''">
            and date_format(sa.clock_time,'%Y-%m-%d')&lt;=#{attendance.endTime}
        </if>
        order by sa.id desc
    </select>
 
    <select id="exportAttendane" resultType="org.springblade.modules.attendance.excel.AttendanceExcel">
        select
        sa.clock_time clockTime,
        bu.real_name realName,
        bd.dept_name deptName,
        if(sa.clock_type=1,'上班','下班') clockType,
        case when sa.attendance_type=1 then '正常'
        when sa.attendance_type=2 then '迟到'
        when sa.attendance_type=3 then '早退'
        else '无效打卡' end as attendanceType
         from sys_attendance sa
        left join blade_user bu on bu.id = sa.user_id
        left join blade_dept bd on bd.id = sa.dept_id
        where 1=1
        <if test="attendance.realName!=null and attendance.realName!=''">
            and bu.real_name like concat('%',#{attendance.realName},'%')
        </if>
        <if test="attendance.deptId!=null">
            and sa.dept_id = #{attendance.deptId}
        </if>
        <if test="attendance.userId!=null">
            and sa.user_id = #{attendance.userId}
        </if>
        <if test="attendance.clockType!=null">
            and sa.clock_type = #{attendance.clockType}
        </if>
        <if test="attendance.attendanceType!=null">
            and sa.attendance_type = #{attendance.attendanceType}
        </if>
        <if test="attendance.beginTime!=null and attendance.beginTime!=''">
            and sa.clock_time&gt;=#{attendance.beginTime}
        </if>
        <if test="attendance.endTime!=null and attendance.endTime!=''">
            and sa.clock_time&lt;=#{attendance.endTime}
        </if>
        order by sa.id desc
    </select>
 
    <!--查询当前考勤人员当天的考勤信息-->
    <select id="selAttendanceListNow" resultType="org.springblade.modules.attendance.entity.Attendance">
        select * from sys_attendance
            where
        number = #{number}
            and
        to_days(now())=to_days(clock_time)
    </select>
 
    <!--查询当前时间之前最新的一条数据-->
    <select id="selAttendanceNewNow" resultType="org.springblade.modules.attendance.entity.Attendance">
        select * from sys_attendance
        where
        user_id = #{userId}
        and
        to_days(now())=to_days(clock_time)
        order by clock_time desc
        limit 1
    </select>
 
 
</mapper>