Uploaded From CV. Swandhana Server
This commit is contained in:
34
app/Console/Commands/ProcessAstmMessages.php
Normal file
34
app/Console/Commands/ProcessAstmMessages.php
Normal file
@@ -0,0 +1,34 @@
|
||||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use App\Services\AstmMessageService;
|
||||
use App\DataListiner;
|
||||
|
||||
class ProcessAstmMessages extends Command
|
||||
{
|
||||
protected $signature = 'astm:process-messages';
|
||||
protected $description = 'Process pending ASTM messages';
|
||||
|
||||
private $astmMessageService;
|
||||
|
||||
public function __construct(AstmMessageService $astmMessageService)
|
||||
{
|
||||
parent::__construct();
|
||||
$this->astmMessageService = $astmMessageService;
|
||||
}
|
||||
|
||||
public function handle()
|
||||
{
|
||||
// Ambil data dari DataListener
|
||||
$dataListener = DataListiner::whereNull('processed')->get();
|
||||
if ($dataListener) {
|
||||
$jumlah = count($dataListener);
|
||||
$pesan = $this->astmMessageService->processAstmMessages($dataListener);
|
||||
$this->info($jumlah.' Message processed '.$pesan.' at '.date('Y-m-d H:i:s'));
|
||||
} else {
|
||||
$this->info('Skipped Proses at '.date('Y-m-d H:i:s'));
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user