Ver código fonte

Merge remote-tracking branch 'origin/master'

cqp 1 mês atrás
pai
commit
f195b0e2dc

+ 9 - 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,18 +404,22 @@ 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 {
                 if($v['type'] == "day")   $item[$v['value']] = $sum[$k][$key];
+                if($v['type'] == "ratio")   $item[$v['value']] =round($sum[$k][$key] / 100, 4);
                 else $item[$v['value']] = round($sum[$k][$key] / 100, 2);
             }
 

+ 3 - 4
app/Service/StatisticService.php

@@ -242,8 +242,8 @@ class StatisticService extends StatisticCommonService
         $word_keys = [
             "total_depreciation" =>
                 [
-                    "key" => "allocated_depreciation",
-                    "value" => "allocated_depreciation",
+                    "key" => "allocated_depreciatio",
+                    "value" => "allocated_depreciatio",
                     "type" => "money",
                 ],
             "total_hours" =>
@@ -270,13 +270,12 @@ class StatisticService extends StatisticCommonService
             $device_counts[$k] = $device_count;
         }
         $device_total_depreciation['ratio'] = [];
-
-//        dd($item_month_list);
         $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'] = $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);
             $item['total_hours'] = round($item['total_min'] / 60, 1);