Przeglądaj źródła

封装的报表类方法

gogs 1 miesiąc temu
rodzic
commit
c53acbf3f3

+ 8 - 5
app/Service/Statistic/StatisticCommonService.php

@@ -359,14 +359,14 @@ class StatisticCommonService extends Service
                     "total_depreciation" => $total_depreciation,
                 ];
                 $device_total_depreciation['total_hours'][$key] =  round($total_min/60,2)*100;
-                $device_total_depreciation['total_depreciation'][$key] =  $total_depreciation*100;
+                $device_total_depreciation['total_depreciation'][$key] =  $total_depreciation;
             }
 
 
             // B. 计算工资分摊:(项目工时 / 月总工时) * 月工资
             if ($total_min > 0) {
-                $ratio = round($item['total_work'] / $total_min, 3);
-                $allocated_salary = round($ratio * $total_depreciation, 2);
+                $ratio = round((round($item['total_work']/60,2) / round($total_min/60,2)), 4);
+                $allocated_salary = round($ratio * $total_depreciation);
             } else {
                 $ratio = 0;
                 $allocated_salary = 0;
@@ -404,14 +404,17 @@ class StatisticCommonService extends Service
             if( !isset($sum[$k][$key]))  $sum[$k][$key] = 0;
             if (--$count[$k][$key] > 0) {
                 if($v['type'] == "hour") $current_hours = round($item[$v['key']] / 60, 2);
-                elseif($v['type'] == "money") $current_hours = round($item[$v['key']] / 100, 2);
+                elseif($v['type'] == "money") {
+                    $current_hours = round($item[$v['key']] / 100, 2);
+                }
                 else $current_hours = $item[$v['key']];
+
                 if($v['type'] == "100b") {
                     $sum[$k][$key] -= $current_hours ;
                     $item[$v['value']] = $current_hours/100;
                 }
                 else{
-                    $sum[$k][$key] -= $current_hours * 100;
+                    $sum[$k][$key] -= ($current_hours * 100);
                     $item[$v['value']] = $current_hours;
                 }
             } else {

+ 7 - 8
app/Service/StatisticService.php

@@ -240,12 +240,12 @@ class StatisticService extends StatisticCommonService
         $collect = collect($item_month_list);
 
         $word_keys = [
-//            "total_depreciation" =>
-//                [
-//                    "key" => "allocated_depreciation",
-//                    "value" => "allocated_depreciation",
-//                    "type" => "money",
-//                ],
+            "total_depreciation" =>
+                [
+                    "key" => "allocated_depreciatio",
+                    "value" => "allocated_depreciatio",
+                    "type" => "money",
+                ],
             "total_hours" =>
                 [
                     "key" => "hours",
@@ -270,12 +270,11 @@ class StatisticService extends StatisticCommonService
             $device_counts[$k] = $device_count;
         }
         $device_total_depreciation['ratio'] = [];
-
         $item_month_list = collect($item_month_list)->transform(function ($item) use ($item_title_key_list, $item_code_key_list, $device_key_list, $device_original_value_key_list, &$device_total_depreciation, &$device_counts,&$rate_list,$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['device_title'] = $device_key_list[$item['device_id']] ?? "未知人员({$item['device_id']})";
-            $item['allocated_depreciatio'] = round($item['allocated_depreciation']/100,2);
+            $item['allocated_depreciatio'] = $item['allocated_depreciation'];
             $item['total_depreciatio'] =  round($item['total_depreciation']/100,2);
             $item['device_original'] = $device_original_value_key_list[$item['device_id']] ?? "未知人员({$item['device_id']})";
             $item['hours'] = round($item['work_minutes'] / 60, 1);