Add update consolidado command and queuing
This commit is contained in:
@ -27,12 +27,12 @@ class Queue extends Command {
|
||||
if ($response->getStatusCode() !== 200) {
|
||||
return Command::FAILURE;
|
||||
}
|
||||
$input = json_decode($response->getBody()->getContents());
|
||||
$data = json_decode($response->getBody()->getContents());
|
||||
$output = [
|
||||
'input' => $input,
|
||||
'input' => $data,
|
||||
'processed' => []
|
||||
];
|
||||
foreach ($input->pending as $queue) {
|
||||
foreach ($data->pending as $queue) {
|
||||
$log = "Running {$queue->command} from queue. Created in {$queue->created}.";
|
||||
error_log($log);
|
||||
$cmd = '/usr/local/bin/php /app/bin/console ' . $queue->cmd;
|
||||
|
38
console/common/Command/UpdateConsolidar.php
Normal file
38
console/common/Command/UpdateConsolidar.php
Normal file
@ -0,0 +1,38 @@
|
||||
<?php
|
||||
namespace Contabilidad\Common\Command;
|
||||
|
||||
use Psr\Http\Client\ClientInterface;
|
||||
use Symfony\Component\Console\Command\Command;
|
||||
use Symfony\Component\Console\Input\InputInterface;
|
||||
use Symfony\Component\Console\Output\OutputInterface;
|
||||
|
||||
class UpdateConsolidar extends Command {
|
||||
protected $client;
|
||||
public function __construct(ClientInterface $client = null, string $name = null) {
|
||||
parent::__construct($name);
|
||||
$this->setClient($client);
|
||||
}
|
||||
|
||||
public function setClient(ClientInterface $client) {
|
||||
$this->client = $client;
|
||||
return $this;
|
||||
}
|
||||
public function getClient(): ClientInterface {
|
||||
return $this->client;
|
||||
}
|
||||
public function execute(InputInterface $input, OutputInterface $output) {
|
||||
try {
|
||||
$mes = $input->getArgument('mes');
|
||||
$cuenta = $input->getArgument('cuenta');
|
||||
$response = $this->getClient()->get("/consolidar/update/{$mes}/{$cuenta}/");
|
||||
if ($response->getStatusCode() === 200) {
|
||||
return Command::SUCCESS;
|
||||
}
|
||||
error_log($response->getReasonPhrase());
|
||||
return Command::FAILURE;
|
||||
} catch (\Exception $e) {
|
||||
error_log($e);
|
||||
return Command::FAILURE;
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user