Browse Source

胡庆余堂

cqp 6 tháng trước cách đây
mục cha
commit
e7749ef47b
1 tập tin đã thay đổi với 7 bổ sung5 xóa
  1. 7 5
      app/Service/StatisticsService.php

+ 7 - 5
app/Service/StatisticsService.php

@@ -306,7 +306,7 @@ class StatisticsService extends Service
 
             $rate_one = "100";
             $device[$key]['rate_one'] = $rate_one . "%";
-            $rate_two = floatval($rd_total_hours) > 0.0 ? bcdiv($rd_total_hours, $rd_total_hours,2) : 0;
+            $rate_two = floatval($rd_total_hours) > 0.0 ? bcdiv($rd_total_hours, $set_total_hours,2) : 0;
             $rate_two = bcmul($rate_two, 100,2);
             $device[$key]['rate_two'] = $rate_two . "%";
             $device[$key]['rate_three'] = $rate_two . "%";
@@ -539,7 +539,8 @@ class StatisticsService extends Service
 
             $rd_total_hours = bcdiv($device_map[$value['id']] ?? 0, 60, 2);
             $device[$key]['rd_total_hours'] = $rd_total_hours;
-            $device[$key]['set_total_hours'] = $set_map[$value['id']] ?? 0;
+            $set_total_hours = $set_map[$value['id']] ?? 0;
+            $device[$key]['set_total_hours'] = $set_total_hours;
 
             $every_item_hours = $device_map_2[$value['id']] ?? [];
             $details = $tmp;
@@ -562,9 +563,10 @@ class StatisticsService extends Service
 
             // 百分比计算
             $device[$key]['rate_one'] = "100%";
-            $rate_val = floatval($rd_total_hours) > 0.0 ? "100.00%" : "0.00%";
-            $device[$key]['rate_two'] = $rate_val;
-            $device[$key]['rate_three'] = $rate_val;
+            $rate_two = floatval($rd_total_hours) > 0.0 ? bcdiv($rd_total_hours, $set_total_hours,2) : 0;
+            $rate_two = bcmul($rate_two, 100,2);
+            $device[$key]['rate_two'] = $rate_two;
+            $device[$key]['rate_three'] = $rate_two;
         }
 
         // --- 合计逻辑 ---