|
|
@@ -153,8 +153,7 @@ class StatisticService extends StatisticCommonService
|
|
|
$employee_monthly_total_min = $this->calculateSum($month_employee_list,$keys,"total_work");
|
|
|
//查询所有项目人员的工时比例
|
|
|
// 3. 计算分摊比例
|
|
|
- list($item_month_list,$salary_all) = $this->calculateRatioForMonth($month_employee_list,$employee_monthly_total_min,$salary_map,["employee_id","order_month"],["order_month","item_id","employee_id"]);
|
|
|
-
|
|
|
+ list($item_month_list,) = $this->calculateRatioForMonth($month_employee_list,$employee_monthly_total_min,$salary_map,["employee_id","order_month"],["order_month","item_id","employee_id"]);
|
|
|
$collect = collect($item_month_list);
|
|
|
$employee_count = $collect->groupBy(function ($item) {
|
|
|
// 这里的 $item 是集合中的每一行数据
|
|
|
@@ -179,13 +178,13 @@ class StatisticService extends StatisticCommonService
|
|
|
// 注意:round 会根据你的精度要求处理小数
|
|
|
return round($value / 60) * 100;
|
|
|
})->toArray();
|
|
|
- $sums = ["work_hours"=>$month_total_hour,"allocated_salary"=>$salary_all];
|
|
|
+ $sums = ["work_hours"=>$month_total_hour,"allocated_salary"=>$salary_map];
|
|
|
$word_keys = [
|
|
|
"allocated_salary" =>
|
|
|
[
|
|
|
"key" => "allocated_salary",
|
|
|
"value" => "allocated_salary",
|
|
|
- "type" => "money",
|
|
|
+ "type" => "100b",
|
|
|
],
|
|
|
"work_hours" =>
|
|
|
[
|
|
|
@@ -198,11 +197,15 @@ class StatisticService extends StatisticCommonService
|
|
|
foreach ($word_keys as $k=>$v){
|
|
|
$counts[$k] = $employee_count;
|
|
|
}
|
|
|
+// var_dump($sums['allocated_salary']);
|
|
|
+// var_dump($item_month_list);
|
|
|
+// $sums($item_month_list);
|
|
|
$item_month_list = collect($item_month_list)->transform(function ($item) use ($item_title_key_list, $item_code_key_list, $employee_key_list, &$sums, &$counts,$word_keys) {
|
|
|
$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['employee_title'] = $employee_key_list[$item['employee_id']] ?? "未知人员({$item['employee_id']})";
|
|
|
- $item['total_hours'] = round($item['total_min'] / 60);
|
|
|
+ $item['total_hours'] = round($item['total_work'] / 60);
|
|
|
+ $item['total_salary'] = round($item['total_salary'] / 100,2);
|
|
|
$key = $item['employee_id'] . '_' . $item['month'];
|
|
|
// // 如果不是最后一条
|
|
|
|