|
|
@@ -38,22 +38,24 @@ class StatisticService extends StatisticCommonService
|
|
|
$employee_count = $this->calculateCount($day_employee_list,$keys);
|
|
|
$employee_work_count = $this->calculateSumForHour($day_employee_list,$keys,"total_work");
|
|
|
$collection = collect($day_employee_list);
|
|
|
- $month_employee_list = $collection->transform(function ($item) use ($employee_key_list, $item_title_key_list, $item_code_key_list, &$employee_work_count, &$employee_count,$keys) {
|
|
|
+ $sums = ["employee_work_count"=>$employee_work_count];
|
|
|
+ $word_keys = [
|
|
|
+ "employee_work_count" =>
|
|
|
+ [
|
|
|
+ "key" => "total_work",
|
|
|
+ "value" => "total_work_hours",
|
|
|
+ "type" => "hour",
|
|
|
+ ]
|
|
|
+ ];
|
|
|
+ $employee_counts = ['employee_work_count' => $employee_count];
|
|
|
+ $month_employee_list = $collection->transform(function ($item) use ($employee_key_list, $item_title_key_list, $item_code_key_list, &$employee_work_count, &$employee_counts,$keys,$word_keys,&$sums) {
|
|
|
$item['employee_name'] = $employee_key_list[$item['employee_id']] ?? "未知员工({$item['employee_id']})";
|
|
|
$item['item_title'] = $item_title_key_list[$item['item_id']] ?? "未知项目({$item['item_id']})";
|
|
|
$item['item_code'] = $item_code_key_list[$item['item_id']] ?? "未知项目({$item['item_id']})";
|
|
|
// 如果不是最后一条
|
|
|
$key = collect($keys)->map(fn($k) => $item[$k] ?? '')->implode('_');
|
|
|
- $sums = ["employee_work_count"=>$employee_work_count];
|
|
|
- $word_keys = [
|
|
|
- "employee_work_count" =>
|
|
|
- [
|
|
|
- "key" => "total_work",
|
|
|
- "value" => "total_work_hours",
|
|
|
- "type" => "hour",
|
|
|
- ]
|
|
|
- ];
|
|
|
- $this->calculateClosure($key,$item,$employee_count,$sums,$word_keys);
|
|
|
+
|
|
|
+ $this->calculateClosure($key,$item,$employee_counts,$sums,$word_keys);
|
|
|
return $item;
|
|
|
})->all();
|
|
|
return [true, $month_employee_list];
|