changed logic in laser idle report
Some checks failed
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 20s
Gemini PR Review / Gemini PR Review (pull_request) Failing after 21s
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (pull_request) Successful in 20s
Laravel Pint / pint (pull_request) Successful in 4m2s
Laravel Larastan / larastan (pull_request) Failing after 7m27s

This commit is contained in:
dhanabalan
2026-10-06 11:31:17 +05:30
parent a217bccc1c
commit 1cc78f8e68

View File

@@ -127,48 +127,105 @@ class SendLaserIdleHourReport extends Command
return (float) ($record->man_marked_status ?? 0); return (float) ($record->man_marked_status ?? 0);
}); });
$totalExpectedMinutes = $totalExpectedMilliseconds =
$machineRecords $machineRecords
->where('motor_machine_name', $machineName) ->where('motor_machine_name', $machineName)
->sum(fn ($record) => (float) ($record->motor_expected_time ?? 0)) ->sum(function ($record) {
+ $machineRecords $value = (string) ($record->motor_expected_time ?? '0');
->where('pump_machine_name', $machineName)
->sum(fn ($record) => (float) ($record->pump_expected_time ?? 0))
+ $machineRecords [$seconds, $milliseconds] = array_pad(
->where('name_plate_machine_name', $machineName) explode('.', $value, 2),
->sum(fn ($record) => (float) ($record->name_plate_expected_time ?? 0)) 2,
'0'
);
+ $machineRecords // Keep exactly 3 digits for milliseconds
->where('motor_machine_name', $machineName) $milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
->sum(fn ($record) => (float) ($record->man_mark_expected_time ?? 0));
return ((int) $seconds * 1000) + (int) $milliseconds;
})
+ $machineRecords
->where('pump_machine_name', $machineName)
->sum(function ($record) {
$value = (string) ($record->pump_expected_time ?? '0');
[$seconds, $milliseconds] = array_pad(
explode('.', $value, 2),
2,
'0'
);
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
return ((int) $seconds * 1000) + (int) $milliseconds;
})
+ $machineRecords
->where('name_plate_machine_name', $machineName)
->sum(function ($record) {
$value = (string) ($record->name_plate_expected_time ?? '0');
[$seconds, $milliseconds] = array_pad(
explode('.', $value, 2),
2,
'0'
);
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
return ((int) $seconds * 1000) + (int) $milliseconds;
})
+ $machineRecords
->where('motor_machine_name', $machineName)
->sum(function ($record) {
$value = (string) ($record->man_mark_expected_time ?? '0');
[$seconds, $milliseconds] = array_pad(
explode('.', $value, 2),
2,
'0'
);
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
return ((int) $seconds * 1000) + (int) $milliseconds;
});
// Keep only 3 decimal places // Convert total milliseconds to total seconds
$totalExpectedMinutes = round($totalExpectedMinutes, 3); $totalExpectedSeconds = $totalExpectedMilliseconds / 1000;
// Convert total minutes into hours + minutes // Convert seconds to minutes
$totalHours = floor($totalExpectedMinutes / 60); $totalExpectedMinutes = $totalExpectedSeconds / 60;
$totalMinutes = floor($totalExpectedMinutes % 60);
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
// Laser OFF // Convert minutes to hours + minutes
$totalLaserOnHoursValue = $totalExpectedMinutes / 60; $totalHours = floor($totalExpectedMinutes / 60);
$totalLaserOffHoursValue = 22.5 - $totalLaserOnHoursValue; $totalMinutes = floor($totalExpectedMinutes % 60);
$totalLaserOffHoursValue = max(0, $totalLaserOffHoursValue); $totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
$offHours = floor($totalLaserOffHoursValue);
$offMinutes = floor(($totalLaserOffHoursValue - $offHours) * 60); // Laser OFF
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min"; $totalLaserOffHoursValue = max(0, 22.5 - $totalLaserOnHoursValue);
$offHours = floor($totalLaserOffHoursValue);
$offMinutes = floor(
($totalLaserOffHoursValue - $offHours) * 60
);
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
$tableData[] = [ $tableData[] = [
'no' => $no++, 'no' => $no++,