Changed hours an dminutes logic in laser idle hour report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 5m47s
Laravel Larastan / larastan (pull_request) Failing after 8m21s
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 14s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 16s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 13s
Laravel Pint / pint (pull_request) Successful in 5m47s
Laravel Larastan / larastan (pull_request) Failing after 8m21s
This commit is contained in:
@@ -112,18 +112,6 @@ class SendLaserIdleHourReport extends Command
|
|||||||
// return (float) ($record->pump_marked_physical_count ?? 0);
|
// return (float) ($record->pump_marked_physical_count ?? 0);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
\Log::info('Laser Idle Pump Debug', [
|
|
||||||
'plant_id' => $plant->id,
|
|
||||||
'plant' => $plant->name,
|
|
||||||
'machine' => $machineName,
|
|
||||||
'pump_rows' => $pumpRecords->count(),
|
|
||||||
'pump_sum' => $pumpCount,
|
|
||||||
'pump_values' => $pumpRecords
|
|
||||||
->pluck('pump_marked_physical_count')
|
|
||||||
->countBy()
|
|
||||||
->toArray(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
$namePlateCount = $machineRecords
|
$namePlateCount = $machineRecords
|
||||||
->where('name_plate_machine_name', $machineName)
|
->where('name_plate_machine_name', $machineName)
|
||||||
->where('name_plate_marked_status', 'Marked')
|
->where('name_plate_marked_status', 'Marked')
|
||||||
@@ -140,33 +128,45 @@ class SendLaserIdleHourReport extends Command
|
|||||||
});
|
});
|
||||||
|
|
||||||
$totalExpectedMinutes =
|
$totalExpectedMinutes =
|
||||||
$machineRecords
|
$machineRecords
|
||||||
->where('motor_machine_name', $machineName)
|
->where('motor_machine_name', $machineName)
|
||||||
->sum(fn ($record) => (float) ($record->motor_expected_time ?? 0))
|
->sum(fn ($record) => (float) ($record->motor_expected_time ?? 0))
|
||||||
|
|
||||||
+ $machineRecords
|
+ $machineRecords
|
||||||
->where('pump_machine_name', $machineName)
|
->where('pump_machine_name', $machineName)
|
||||||
->sum(fn ($record) => (float) ($record->pump_expected_time ?? 0))
|
->sum(fn ($record) => (float) ($record->pump_expected_time ?? 0))
|
||||||
|
|
||||||
+ $machineRecords
|
+ $machineRecords
|
||||||
->where('name_plate_machine_name', $machineName)
|
->where('name_plate_machine_name', $machineName)
|
||||||
->sum(fn ($record) => (float) ($record->name_plate_expected_time ?? 0))
|
->sum(fn ($record) => (float) ($record->name_plate_expected_time ?? 0))
|
||||||
|
|
||||||
+ $machineRecords
|
+ $machineRecords
|
||||||
->where('motor_machine_name', $machineName)
|
->where('motor_machine_name', $machineName)
|
||||||
->sum(fn ($record) => (float) ($record->man_mark_expected_time ?? 0));
|
->sum(fn ($record) => (float) ($record->man_mark_expected_time ?? 0));
|
||||||
|
|
||||||
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
|
||||||
|
|
||||||
$totalHours = intdiv((int) $totalExpectedMinutes, 60);
|
// Keep only 3 decimal places
|
||||||
$totalMinutes = (int) $totalExpectedMinutes % 60;
|
$totalExpectedMinutes = round($totalExpectedMinutes, 3);
|
||||||
|
|
||||||
|
|
||||||
|
// Convert total minutes into hours + minutes
|
||||||
|
$totalHours = floor($totalExpectedMinutes / 60);
|
||||||
|
|
||||||
|
$totalMinutes = floor($totalExpectedMinutes % 60);
|
||||||
|
|
||||||
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
|
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
|
||||||
|
|
||||||
|
|
||||||
|
// Laser OFF
|
||||||
|
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
||||||
|
|
||||||
$totalLaserOffHoursValue = 22.5 - $totalLaserOnHoursValue;
|
$totalLaserOffHoursValue = 22.5 - $totalLaserOnHoursValue;
|
||||||
|
|
||||||
|
$totalLaserOffHoursValue = max(0, $totalLaserOffHoursValue);
|
||||||
|
|
||||||
$offHours = floor($totalLaserOffHoursValue);
|
$offHours = floor($totalLaserOffHoursValue);
|
||||||
$offMinutes = round(($totalLaserOffHoursValue - $offHours) * 60);
|
|
||||||
|
$offMinutes = floor(($totalLaserOffHoursValue - $offHours) * 60);
|
||||||
|
|
||||||
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user