107 lines
3.1 KiB
PHP
107 lines
3.1 KiB
PHP
<?php
|
|
|
|
namespace App\Console\Commands;
|
|
|
|
use Illuminate\Console\Command;
|
|
|
|
class NotificationCheckAll extends Command
|
|
{
|
|
/**
|
|
* The name and signature of the console command.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $signature = 'notifications:check-all';
|
|
|
|
/**
|
|
* The console command description.
|
|
*
|
|
* @var string
|
|
*/
|
|
protected $description = 'Run all notification check commands at once (for initial trigger)';
|
|
|
|
/**
|
|
* List of all notification commands to run
|
|
*
|
|
* @var array
|
|
*/
|
|
protected $commands = [
|
|
'notifications:check-deleted-joints',
|
|
'notifications:check-repair-log-new-joint',
|
|
'notifications:check-daily-repair-rate',
|
|
'notifications:check-line-list-missing-data',
|
|
'notifications:check-pdf-documents',
|
|
'notifications:check-weldlog-certificate',
|
|
'notifications:check-incoming-control-certificate',
|
|
'notifications:check-nde-matrix-discrepancies',
|
|
'notifications:check-ndt-calculation',
|
|
'notifications:check-manage-ndt-unnecessary',
|
|
'notifications:check-support-log-weldlog',
|
|
'notifications:check-paint-system-values',
|
|
'notifications:check-weldlog-test-dates',
|
|
'notifications:check-ndt-request-overdue',
|
|
'notifications:check-test-log-pdf',
|
|
];
|
|
|
|
/**
|
|
* Execute the console command.
|
|
*
|
|
* @return int
|
|
*/
|
|
public function handle()
|
|
{
|
|
$this->info('Running all notification checks...');
|
|
$this->info('This will trigger initial scan for all notification types.');
|
|
$this->newLine();
|
|
|
|
$totalCommands = count($this->commands);
|
|
$successCount = 0;
|
|
$skipCount = 0;
|
|
$errorCount = 0;
|
|
|
|
$bar = $this->output->createProgressBar($totalCommands);
|
|
$bar->start();
|
|
|
|
foreach ($this->commands as $index => $command) {
|
|
$bar->advance();
|
|
|
|
try {
|
|
$exitCode = $this->call($command);
|
|
|
|
if ($exitCode === 0) {
|
|
$successCount++;
|
|
} else {
|
|
$errorCount++;
|
|
$this->newLine();
|
|
$this->warn("Command '{$command}' returned exit code: {$exitCode}");
|
|
}
|
|
} catch (\Exception $e) {
|
|
$errorCount++;
|
|
$this->newLine();
|
|
$this->error("Error running '{$command}': " . $e->getMessage());
|
|
}
|
|
}
|
|
|
|
$bar->finish();
|
|
$this->newLine(2);
|
|
|
|
// Summary
|
|
$this->info('=== Summary ===');
|
|
$this->line("Total commands: {$totalCommands}");
|
|
$this->line("Successful: {$successCount}");
|
|
$this->line("Skipped (5 min check): {$skipCount}");
|
|
$this->line("Errors: {$errorCount}");
|
|
$this->newLine();
|
|
|
|
if ($errorCount > 0) {
|
|
$this->warn('Some commands encountered errors. Check logs for details.');
|
|
return 1;
|
|
}
|
|
|
|
$this->info('All notification checks completed successfully!');
|
|
$this->info('Scheduler will continue running checks every 5 minutes automatically.');
|
|
|
|
return 0;
|
|
}
|
|
}
|