From 1cd80b0193db031638fcda535573e2d8bc40e499 Mon Sep 17 00:00:00 2001
From: Administrator <admin>
Date: Wed, 02 Mar 2022 17:46:24 +0800
Subject: [PATCH] 考勤打卡查询修改,导出修改

---
 src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.xml |   72 ++++++++++++++++++++++++++----------
 1 files changed, 52 insertions(+), 20 deletions(-)

diff --git a/src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.xml b/src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.xml
index f3cf109..7b08a66 100644
--- a/src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.xml
+++ b/src/main/java/org/springblade/modules/attendance/mapper/AttendanceMapper.xml
@@ -19,40 +19,72 @@
         <result column="address" property="address"/>
     </resultMap>
 
-
-    <select id="selectAttendancePage" resultMap="attendanceResultMap">
-        select * from sys_attendance where is_deleted = 0
-        <if test="attendance.name!=null and attendance.name != ''">
-            and name = #{attendance.name}
+    <!--自定义查询考试分页数据-->
+    <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.department!=null and attendance.department != ''">
-            and department = #{department}
+        <if test="attendance.deptId!=null">
+            and sa.dept_id = #{attendance.deptId}
         </if>
-        <if test="attendance.attendancetype!=null and attendance.attendancetype != ''">
-            and attendancetype = #{attendance.attendancetype}
+        <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.beginTime!=null and attendance.beginTime!=''">
-            and clockTime&gt;=#{attendance.beginTime}
+            and date_format(sa.clock_time,'%Y-%m-%d')&gt;=#{attendance.beginTime}
         </if>
         <if test="attendance.endTime!=null and attendance.endTime!=''">
-            and clockTime&lt;=#{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 id, name, number, department, weather, clockTime, clockType, attendanceType,week,address FROM sys_attendance where is_deleted = 0
-        <if test="name!=null and name != ''">
-            and name = #{name}
+        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 '早退'
+        when sa.attendance_type=4 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="beginTimes!=null and beginTimes!=''">
-            and clockTime&gt;=#{beginTimes}
+        <if test="attendance.deptId!=null">
+            and sa.dept_id = #{attendance.deptId}
         </if>
-        <if test="endTimes!=null and endTimes!=''">
-            and clockTime&lt;=#{endTimes}
+        <if test="attendance.userId!=null">
+            and sa.user_id = #{attendance.userId}
         </if>
-        <if test="attendancetypes!=null and attendancetypes!=''">
-            and attendancetype=#{attendancetypes}
+        <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>
 
     <!--查询当前考勤人员当天的考勤信息-->

--
Gitblit v1.9.3