Parcourir la source

封装的报表类方法

gogs il y a 1 mois
Parent
commit
444eb5d459

+ 2 - 2
app/Service/Statistic/StatisticCommonService.php

@@ -405,8 +405,8 @@ class StatisticCommonService extends Service
                 $item[$v['value']] = $current_hours;
                 $item[$v['value']] = $current_hours;
                 $sum[$k][$key] -= $current_hours * 100;
                 $sum[$k][$key] -= $current_hours * 100;
             } else {
             } else {
-
-                $item[$v['value']] = round($sum[$k][$key] / 100, 2);
+                if($v['type'] == "day")   $item[$v['value']] = $sum[$k][$key];
+                else $item[$v['value']] = round($sum[$k][$key] / 100, 2);
             }
             }
 
 
         }
         }

+ 5 - 6
app/Service/StatisticService.php

@@ -97,9 +97,8 @@ class StatisticService extends StatisticCommonService
             return $group->count();
             return $group->count();
         })->toArray();
         })->toArray();
         $item_day_count = $collect->groupBy(fn($item) => $item['month'])
         $item_day_count = $collect->groupBy(fn($item) => $item['month'])
-            ->map(fn($group) => round($group->sum('work_minutes') / 8 / 60))
+            ->map(fn($group) => round($group->sum('work_minutes') / 8 / 60)*100)
             ->toArray();
             ->toArray();
-
 //        $all_salary = collect($salary_map)
 //        $all_salary = collect($salary_map)
 //            ->groupBy(function ($value, $key) {
 //            ->groupBy(function ($value, $key) {
 //                // 1. 提取下划线后面的内容 (例如: 2024-02)
 //                // 1. 提取下划线后面的内容 (例如: 2024-02)
@@ -110,7 +109,7 @@ class StatisticService extends StatisticCommonService
 //                return $group->sum();
 //                return $group->sum();
 //            })
 //            })
 //            ->toArray();
 //            ->toArray();
-        $item_count = [
+        $item_counts = [
             "all_salary" => $item_count,
             "all_salary" => $item_count,
             "item_day_sum" => $item_count,
             "item_day_sum" => $item_count,
         ];
         ];
@@ -129,12 +128,12 @@ class StatisticService extends StatisticCommonService
                     "type" => "",
                     "type" => "",
                 ],
                 ],
         ];
         ];
-        $item_month_list = collect($item_month_list)->transform(function ($item) use ($item_title_key_list, $item_code_key_list, &$item_count,&$sums,&$word_keys) {
+
+        $item_month_list = collect($item_month_list)->transform(function ($item) use ($item_title_key_list, $item_code_key_list, &$item_counts,&$sums,&$word_keys) {
             $item['item_title'] = $item_title_key_list[$item['item_id']] ?? "未知项目({$item['item_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']})";
             $item['item_code'] = $item_code_key_list[$item['item_id']] ?? "未知项目({$item['item_id']})";
-//            $item['allocated_salary'] = round($item['allocated_salary']/100, 2);
             $key = $item['month'];
             $key = $item['month'];
-            $this->calculateClosure($key,$item,$item_count,$sums,$word_keys);
+            $this->calculateClosure($key,$item,$item_counts,$sums,$word_keys);
             return $item;
             return $item;
         })->all();
         })->all();
         return [true, $item_month_list];
         return [true, $item_month_list];