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);
|
// return (float) ($record->motor_marked_physical_count ?? 0);
|
||||||
// });
|
// });
|
||||||
|
|
||||||
$pumpRecords = $machineRecords
|
$pumpCount = $machineRecords
|
||||||
->where('pump_machine_name', $machineName);
|
->where('pump_machine_name', $machineName)
|
||||||
$pumpCount = $pumpRecords
|
->where('pump_marked_status', 'Marked')
|
||||||
// ->where('pump_machine_name', $machineName)
|
->filter(function ($record) {
|
||||||
// ->where('pump_marked_status', 'Marked')
|
return (float) ($record->pump_marked_physical_count ?? 0) > 0;
|
||||||
->sum(fn ($record) => (float) ($record->pump_marked_physical_count ?? 0));
|
})
|
||||||
// ->filter(function ($record) {
|
->count();
|
||||||
// return (float) ($record->pump_marked_physical_count ?? 0) > 0;
|
|
||||||
// })
|
|
||||||
// ->count();
|
|
||||||
// ->sum(function ($record) {
|
|
||||||
// return (float) ($record->pump_marked_physical_count ?? 0);
|
|
||||||
// });
|
|
||||||
|
|
||||||
$namePlateCount = $machineRecords
|
$namePlateCount = $machineRecords
|
||||||
->where('name_plate_machine_name', $machineName)
|
->where('name_plate_machine_name', $machineName)
|
||||||
@@ -128,104 +122,101 @@ class SendLaserIdleHourReport extends Command
|
|||||||
});
|
});
|
||||||
|
|
||||||
$totalExpectedMilliseconds =
|
$totalExpectedMilliseconds =
|
||||||
$machineRecords
|
$machineRecords
|
||||||
->where('motor_machine_name', $machineName)
|
->where('motor_machine_name', $machineName)
|
||||||
->sum(function ($record) {
|
->sum(function ($record) {
|
||||||
|
|
||||||
$value = (string) ($record->motor_expected_time ?? '0');
|
$value = (string) ($record->motor_expected_time ?? '0');
|
||||||
|
|
||||||
[$seconds, $milliseconds] = array_pad(
|
[$seconds, $milliseconds] = array_pad(
|
||||||
explode('.', $value, 2),
|
explode('.', $value, 2),
|
||||||
2,
|
2,
|
||||||
'0'
|
'0'
|
||||||
);
|
);
|
||||||
|
|
||||||
// Keep exactly 3 digits for milliseconds
|
// Keep exactly 3 digits for milliseconds
|
||||||
$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
|
+ $machineRecords
|
||||||
->where('pump_machine_name', $machineName)
|
->where('pump_machine_name', $machineName)
|
||||||
->sum(function ($record) {
|
->sum(function ($record) {
|
||||||
|
|
||||||
$value = (string) ($record->pump_expected_time ?? '0');
|
$value = (string) ($record->pump_expected_time ?? '0');
|
||||||
|
|
||||||
[$seconds, $milliseconds] = array_pad(
|
[$seconds, $milliseconds] = array_pad(
|
||||||
explode('.', $value, 2),
|
explode('.', $value, 2),
|
||||||
2,
|
2,
|
||||||
'0'
|
'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
|
+ $machineRecords
|
||||||
->where('name_plate_machine_name', $machineName)
|
->where('name_plate_machine_name', $machineName)
|
||||||
->sum(function ($record) {
|
->sum(function ($record) {
|
||||||
|
|
||||||
$value = (string) ($record->name_plate_expected_time ?? '0');
|
$value = (string) ($record->name_plate_expected_time ?? '0');
|
||||||
|
|
||||||
[$seconds, $milliseconds] = array_pad(
|
[$seconds, $milliseconds] = array_pad(
|
||||||
explode('.', $value, 2),
|
explode('.', $value, 2),
|
||||||
2,
|
2,
|
||||||
'0'
|
'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
|
+ $machineRecords
|
||||||
->where('motor_machine_name', $machineName)
|
->where('motor_machine_name', $machineName)
|
||||||
->sum(function ($record) {
|
->sum(function ($record) {
|
||||||
|
|
||||||
$value = (string) ($record->man_mark_expected_time ?? '0');
|
$value = (string) ($record->man_mark_expected_time ?? '0');
|
||||||
|
|
||||||
[$seconds, $milliseconds] = array_pad(
|
[$seconds, $milliseconds] = array_pad(
|
||||||
explode('.', $value, 2),
|
explode('.', $value, 2),
|
||||||
2,
|
2,
|
||||||
'0'
|
'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
|
// Laser OFF
|
||||||
$totalExpectedSeconds = $totalExpectedMilliseconds / 1000;
|
$totalLaserOnHoursValue = $totalExpectedMinutes / 60;
|
||||||
|
|
||||||
|
$totalLaserOffHoursValue = max(0, 22.5 - $totalLaserOnHoursValue);
|
||||||
|
|
||||||
// Convert seconds to minutes
|
$offHours = floor($totalLaserOffHoursValue);
|
||||||
$totalExpectedMinutes = $totalExpectedSeconds / 60;
|
|
||||||
|
|
||||||
|
$offMinutes = floor(
|
||||||
|
($totalLaserOffHoursValue - $offHours) * 60
|
||||||
|
);
|
||||||
|
|
||||||
// Convert minutes to hours + minutes
|
$totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
||||||
$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";
|
|
||||||
|
|
||||||
$tableData[] = [
|
$tableData[] = [
|
||||||
'no' => $no++,
|
'no' => $no++,
|
||||||
@@ -249,8 +240,6 @@ $totalLaserOffHours = "{$offHours} hr {$offMinutes} min";
|
|||||||
|
|
||||||
$mail = new LaserIdleMail($scheduleType, $tableData);
|
$mail = new LaserIdleMail($scheduleType, $tableData);
|
||||||
|
|
||||||
// $contentVars = $mail->content()->with;
|
|
||||||
|
|
||||||
foreach ($mailRules as $rule)
|
foreach ($mailRules as $rule)
|
||||||
{
|
{
|
||||||
$toEmails = collect(explode(',', $rule->email))
|
$toEmails = collect(explode(',', $rule->email))
|
||||||
|
|||||||
Reference in New Issue
Block a user