每月/日出勤/在职人数统计优化

This commit is contained in:
guoshengxiong 2025-10-29 16:42:42 +08:00
parent c5ca758835
commit e092cde020

View File

@ -136,7 +136,23 @@
</if> </if>
,count(*) as total_in_service_num ,count(*) as total_in_service_num
,ifnull(sum(t.is_attendance),0) as total_attendance_num ,ifnull(sum(t.is_attendance),0) as total_attendance_num
from worker_daily_attendance_statistics_v2 t from (
select * from
worker_daily_attendance_statistics_v2 t
where 1=1
<if test="startMonth != null and startMonth != ''">
and t.attendance_date <![CDATA[>=]]> concat(#{startMonth},'-01 00:00:00')
</if>
<if test="endMonth != null and endMonth != ''">
and t.attendance_date <![CDATA[<=]]> CONCAT(LAST_DAY(CONCAT(#{endMonth}, '-01')), ' 23:59:59')
</if>
<if test="startDate != null and startDate != ''">
and t.attendance_date >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and t.attendance_date <![CDATA[<=]]> concat(#{endDate},' 23:59:59')
</if>
) t
JOIN worker_info a on t.person_sn=a.person_sn JOIN worker_info a on t.person_sn=a.person_sn
LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1 LEFT JOIN team_info b ON a.team_id = b.id and a.person_type = 1
LEFT JOIN department_info c ON a.department_id = c.id and a.person_type = 2 LEFT JOIN department_info c ON a.department_id = c.id and a.person_type = 2
@ -156,18 +172,6 @@
<if test="departmentId != null and departmentId != ''"> <if test="departmentId != null and departmentId != ''">
and a.department_id=#{departmentId} and a.department_id=#{departmentId}
</if> </if>
<if test="startMonth != null and startMonth != ''">
and t.attendance_date <![CDATA[>=]]> concat(#{startMonth},'-01 00:00:00')
</if>
<if test="endMonth != null and endMonth != ''">
and t.attendance_date <![CDATA[<=]]> CONCAT(LAST_DAY(CONCAT(#{endMonth}, '-01')), ' 23:59:59')
</if>
<if test="startDate != null and startDate != ''">
and t.attendance_date >= #{startDate}
</if>
<if test="endDate != null and endDate != ''">
and t.attendance_date <![CDATA[<=]]> concat(#{endDate},' 23:59:59')
</if>
group by x_name group by x_name
)t )t
</select> </select>