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
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:
@@ -127,48 +127,105 @@ class SendLaserIdleHourReport extends Command
|
||||
return (float) ($record->man_marked_status ?? 0);
|
||||
});
|
||||
|
||||
$totalExpectedMinutes =
|
||||
$machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(fn ($record) => (float) ($record->motor_expected_time ?? 0))
|
||||
$totalExpectedMilliseconds =
|
||||
$machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
+ $machineRecords
|
||||
->where('pump_machine_name', $machineName)
|
||||
->sum(fn ($record) => (float) ($record->pump_expected_time ?? 0))
|
||||
$value = (string) ($record->motor_expected_time ?? '0');
|
||||
|
||||
+ $machineRecords
|
||||
->where('name_plate_machine_name', $machineName)
|
||||
->sum(fn ($record) => (float) ($record->name_plate_expected_time ?? 0))
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
+ $machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(fn ($record) => (float) ($record->man_mark_expected_time ?? 0));
|
||||
// Keep exactly 3 digits for milliseconds
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
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
|
||||
$totalExpectedMinutes = round($totalExpectedMinutes, 3);
|
||||
// Convert total milliseconds to total seconds
|
||||
$totalExpectedSeconds = $totalExpectedMilliseconds / 1000;
|
||||
|
||||
|
||||
// Convert total minutes into hours + minutes
|
||||
$totalHours = floor($totalExpectedMinutes / 60);
|
||||
|
||||
$totalMinutes = floor($totalExpectedMinutes % 60);
|
||||
|
||||
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
|
||||
// Convert seconds to minutes
|
||||
$totalExpectedMinutes = $totalExpectedSeconds / 60;
|
||||
|
||||
|
||||
// Laser OFF
|
||||
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
||||
// Convert minutes to hours + minutes
|
||||
$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[] = [
|
||||
'no' => $no++,
|
||||
|
||||
Reference in New Issue
Block a user