📊 詳細工時分配報告

{{ $data['date'] }} ({{ $data['day_of_week'] }}) - 差額分配法分析

@if(count($data['users']) > 0)

🎯 整體統計摘要

@php $totalUsers = count($data['users']); $totalHours = array_sum(array_column($data['users'], 'total_hours')); $totalManDays = array_sum(array_column($data['users'], 'total_man_days')); $totalAdjustments = array_sum(array_column($data['users'], 'adjusted_count')); $accuracyIssues = array_filter($data['users'], function($user) { return !$user['is_accurate']; }); $accuracyRate = $totalUsers > 0 ? (($totalUsers - count($accuracyIssues)) / $totalUsers) * 100 : 100; @endphp
參與人數 總工時 總人天 調整項目 計算精確率
{{ $totalUsers }} 人 {{ number_format($totalHours, 2) }} 小時 {{ number_format($totalManDays, 2) }} 人天 {{ $totalAdjustments }} 個 {{ number_format($accuracyRate, 1) }}%
@if(count($accuracyIssues) > 0)
⚠️ 需要關注: @foreach($accuracyIssues as $issue) {{ $issue['user_name'] }}{{ !$loop->last ? ', ' : '' }} @endforeach 的計算結果異常,建議檢查。
@endif

👥 用戶詳細工時分配

@foreach($data['users'] as $user)
👤 {{ $user['user_name'] }} {{ $user['is_accurate'] ? '✅ 計算精確' : '⚠️ 計算異常' }}
總計: {{ number_format($user['total_hours'], 2) }}小時 = {{ number_format($user['total_man_days'], 2) }}人天 (標準: {{ number_format($user['standard_hours'], 1) }}小時) @if($user['overtime_hours'] > 0) | 加班: {{ number_format($user['overtime_hours'], 2) }}小時 @endif @if($user['adjusted_count'] > 0) | 調整項目: {{ $user['adjusted_count'] }}個 @endif
@if(count($user['projects']) > 0) @foreach($user['projects'] as $project) @endforeach
專案名稱 工時 原始人天 調整後人天 差異 是否調整 加班時數 備註
{{ $project['project_name'] }} {{ number_format($project['hours'], 2) }}h {{ number_format($project['original_man_days'], 4) }} {{ number_format($project['final_man_days'], 2) }} {{ number_format($project['difference'], 4) }} @if($project['adjusted']) ✅ 已調整 @else ❌ 未調整 @endif @if($project['overtime_hours'] > 0) {{ number_format($project['overtime_hours'], 2) }}h @else - @endif {{ $project['remark'] ?: '-' }}
@else

該用戶當日無工時記錄

@endif
@endforeach

📋 差額分配法說明

🎯 什麼是差額分配法?

差額分配法是一種確保工時人天計算總和精確性的演算法,解決傳統四捨五入造成的累積誤差問題。

📊 運作流程:

  1. 向下取整:所有專案先向下取到小數2位
  2. 計算差額:目標總和 - 當前總和 = 需分配差額
  3. 智慧分配:將差額分配給餘數最大的專案

✅ 核心優勢:

🔍 表格說明:

@else

📭 {{ $data['date'] }} 當日無工時記錄

@endif