勤务榜只统计已关闭记录(whereNotNull logout_at);清理今日重复坏数据
This commit is contained in:
@@ -50,17 +50,9 @@ class DutyHallController extends Controller
|
||||
|
||||
// ① 在线时长(position_duty_logs)
|
||||
$dutyQuery = PositionDutyLog::query()
|
||||
->selectRaw('
|
||||
user_id,
|
||||
SUM(
|
||||
CASE
|
||||
WHEN logout_at IS NULL
|
||||
THEN GREATEST(0, TIMESTAMPDIFF(SECOND, login_at, NOW()))
|
||||
ELSE duration_seconds
|
||||
END
|
||||
) as total_seconds,
|
||||
COUNT(*) as checkin_count
|
||||
');
|
||||
->selectRaw('user_id, SUM(duration_seconds) as total_seconds, COUNT(*) as checkin_count')
|
||||
// 只统计有离开时间的已完结记录,open session 不计入(防止实时计算偏差)
|
||||
->whereNotNull('logout_at');
|
||||
|
||||
// ② 管理操作(position_authority_logs,排除任命/撤销等人事操作)
|
||||
$authQuery = PositionAuthorityLog::query()
|
||||
|
||||
Reference in New Issue
Block a user