Merge pull request 'Changed logic in laser idle hour report' (#1238) from ranjith-dev into master
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
All checks were successful
Scan for leaked secrets using Kingfisher / kingfisher-secrets-scan (push) Successful in 15s
Reviewed-on: #1238
This commit was merged in pull request #1238.
This commit is contained in:
@@ -98,19 +98,13 @@ class SendLaserIdleHourReport extends Command
|
||||
// return (float) ($record->motor_marked_physical_count ?? 0);
|
||||
// });
|
||||
|
||||
$pumpRecords = $machineRecords
|
||||
->where('pump_machine_name', $machineName);
|
||||
$pumpCount = $pumpRecords
|
||||
// ->where('pump_machine_name', $machineName)
|
||||
// ->where('pump_marked_status', 'Marked')
|
||||
->sum(fn ($record) => (float) ($record->pump_marked_physical_count ?? 0));
|
||||
// ->filter(function ($record) {
|
||||
// return (float) ($record->pump_marked_physical_count ?? 0) > 0;
|
||||
// })
|
||||
// ->count();
|
||||
// ->sum(function ($record) {
|
||||
// return (float) ($record->pump_marked_physical_count ?? 0);
|
||||
// });
|
||||
$pumpCount = $machineRecords
|
||||
->where('pump_machine_name', $machineName)
|
||||
->where('pump_marked_status', 'Marked')
|
||||
->filter(function ($record) {
|
||||
return (float) ($record->pump_marked_physical_count ?? 0) > 0;
|
||||
})
|
||||
->count();
|
||||
|
||||
$namePlateCount = $machineRecords
|
||||
->where('name_plate_machine_name', $machineName)
|
||||
@@ -128,104 +122,101 @@ class SendLaserIdleHourReport extends Command
|
||||
});
|
||||
|
||||
$totalExpectedMilliseconds =
|
||||
$machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
$machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->motor_expected_time ?? '0');
|
||||
$value = (string) ($record->motor_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
// Keep exactly 3 digits for milliseconds
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
// Keep exactly 3 digits for milliseconds
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
|
||||
+ $machineRecords
|
||||
->where('pump_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
+ $machineRecords
|
||||
->where('pump_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->pump_expected_time ?? '0');
|
||||
$value = (string) ($record->pump_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
|
||||
+ $machineRecords
|
||||
->where('name_plate_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
+ $machineRecords
|
||||
->where('name_plate_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->name_plate_expected_time ?? '0');
|
||||
$value = (string) ($record->name_plate_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
})
|
||||
|
||||
+ $machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
+ $machineRecords
|
||||
->where('motor_machine_name', $machineName)
|
||||
->sum(function ($record) {
|
||||
|
||||
$value = (string) ($record->man_mark_expected_time ?? '0');
|
||||
$value = (string) ($record->man_mark_expected_time ?? '0');
|
||||
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
[$seconds, $milliseconds] = array_pad(
|
||||
explode('.', $value, 2),
|
||||
2,
|
||||
'0'
|
||||
);
|
||||
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
$milliseconds = substr(str_pad($milliseconds, 3, '0'), 0, 3);
|
||||
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
});
|
||||
return ((int) $seconds * 1000) + (int) $milliseconds;
|
||||
});
|
||||
|
||||
// Convert total milliseconds to total seconds
|
||||
$totalExpectedSeconds = $totalExpectedMilliseconds / 1000;
|
||||
|
||||
// Convert seconds to minutes
|
||||
$totalExpectedMinutes = $totalExpectedSeconds / 60;
|
||||
|
||||
// Convert minutes to hours + minutes
|
||||
$totalHours = floor($totalExpectedMinutes / 60);
|
||||
|
||||
$totalMinutes = floor($totalExpectedMinutes % 60);
|
||||
|
||||
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
|
||||
|
||||
|
||||
// Convert total milliseconds to total seconds
|
||||
$totalExpectedSeconds = $totalExpectedMilliseconds / 1000;
|
||||
// Laser OFF
|
||||
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
||||
|
||||
$totalLaserOffHoursValue = max(0, 22.5 - $totalLaserOnHoursValue);
|
||||
|
||||
// Convert seconds to minutes
|
||||
$totalExpectedMinutes = $totalExpectedSeconds / 60;
|
||||
$offHours = floor($totalLaserOffHoursValue);
|
||||
|
||||
$offMinutes = floor(
|
||||
($totalLaserOffHoursValue - $offHours) * 60
|
||||
);
|
||||
|
||||
// Convert minutes to hours + minutes
|
||||
$totalHours = floor($totalExpectedMinutes / 60);
|
||||
|
||||
$totalMinutes = floor($totalExpectedMinutes % 60);
|
||||
|
||||
$totalLaserOnHours = "{$totalHours} hr {$totalMinutes} min";
|
||||
|
||||
|
||||
// Laser OFF
|
||||
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
||||
|
||||
$totalLaserOffHoursValue = max(0, 22.5 - $totalLaserOnHoursValue);
|
||||
|
||||
$offHours = floor($totalLaserOffHoursValue);
|
||||
|
||||
$offMinutes = floor(
|
||||
($totalLaserOffHoursValue - $offHours) * 60
|
||||
);
|
||||
|
||||
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
||||
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
||||
|
||||
$tableData[] = [
|
||||
'no' => $no++,
|
||||
@@ -249,8 +240,6 @@ $totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
||||
|
||||
$mail = new LaserIdleMail($scheduleType, $tableData);
|
||||
|
||||
// $contentVars = $mail->content()->with;
|
||||
|
||||
foreach ($mailRules as $rule)
|
||||
{
|
||||
$toEmails = collect(explode(',', $rule->email))
|
||||
|
||||
Reference in New Issue
Block a user