<?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')>=#{attendance.beginTime}
|
</if>
|
<if test="attendance.endTime!=null and attendance.endTime!=''">
|
and date_format(sa.clock_time,'%Y-%m-%d')<=#{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>=#{attendance.beginTime}
|
</if>
|
<if test="attendance.endTime!=null and attendance.endTime!=''">
|
and sa.clock_time<=#{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>
|