Save
This commit is contained in:
parent
62e28d1f3e
commit
1769837a14
3 changed files with 147 additions and 0 deletions
36
app/Console/Commands/ProcessCodesUniques.php
Normal file
36
app/Console/Commands/ProcessCodesUniques.php
Normal file
|
|
@ -0,0 +1,36 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\ProcessUniqueCode as JobProcessUniqueCode;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ProcessCodesUniques extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:process-codes-uniques';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info('Running the Job, this could take some time.');
|
||||
$job = new JobProcessUniqueCode(66545617, 9);
|
||||
$job->handle();
|
||||
$this->info('Job completed');
|
||||
}
|
||||
}
|
||||
61
app/Console/Commands/ProcessExportCodesUniques.php
Normal file
61
app/Console/Commands/ProcessExportCodesUniques.php
Normal file
|
|
@ -0,0 +1,61 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use App\Jobs\ProcessExportCodesUniques as ProcessExportCodesUniquesJob;
|
||||
use Illuminate\Console\Command;
|
||||
|
||||
class ProcessExportCodesUniques extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:process-export-codes-uniques';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*/
|
||||
public function handle()
|
||||
{
|
||||
// Nombre total de code à exporter.
|
||||
$nbCodeTot = $this->ask("Combien de code doivent être exporté ?");
|
||||
while (empty(intval($nbCodeTot)) || !is_int(intval($nbCodeTot))) {
|
||||
$this->info("Valeur incorrect, veuillez entrer un nombre entier.");
|
||||
$nbCodeTot = $this->ask("Veuillez entrer une nouvelle valeur");
|
||||
}
|
||||
$nbCodeTot = intval($nbCodeTot);
|
||||
|
||||
// Nombre de code par fichier.
|
||||
$nbCodeFic = $this->ask("Combien de code par fichier ?");
|
||||
while (empty(intval($nbCodeFic)) || !is_int(intval($nbCodeFic))) {
|
||||
$this->info("Valeur incorrect, veuillez entrer un nombre entier.");
|
||||
$nbCodeFic = $this->ask("Veuillez entrer une nouvelle valeur");
|
||||
}
|
||||
$nbCodeFic = intval($nbCodeFic);
|
||||
|
||||
// Nombre de code par ligne.
|
||||
$nbCodeLigne = $this->ask("Combien de code par ligne dans un fichier ?");
|
||||
while (empty(intval($nbCodeLigne)) || !is_int(intval($nbCodeLigne))) {
|
||||
$this->info("Valeur incorrect, veuillez entrer un nombre entier.");
|
||||
$nbCodeLigne = $this->ask("Veuillez entrer une nouvelle valeur");
|
||||
}
|
||||
$nbCodeLigne = intval($nbCodeLigne);
|
||||
|
||||
$this->info("Traitement en cours, veuillez patienter...");
|
||||
|
||||
$job = new ProcessExportCodesUniquesJob($nbCodeFic, $nbCodeTot, $nbCodeLigne);
|
||||
$job->handle();
|
||||
|
||||
$this->info("Fin du traitement, creation de l'archive...");
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
50
app/Console/Commands/RemettreLesPtnDeCodesDansLordre.php
Normal file
50
app/Console/Commands/RemettreLesPtnDeCodesDansLordre.php
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
<?php
|
||||
|
||||
namespace App\Console\Commands;
|
||||
|
||||
use Illuminate\Console\Command;
|
||||
use Illuminate\Support\Facades\File;
|
||||
|
||||
class RemettreLesPtnDeCodesDansLordre extends Command
|
||||
{
|
||||
/**
|
||||
* The name and signature of the console command.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $signature = 'app:remettre-les-ptn-de-codes-dans-lordre';
|
||||
|
||||
/**
|
||||
* The console command description.
|
||||
*
|
||||
* @var string
|
||||
*/
|
||||
protected $description = 'Command description';
|
||||
|
||||
/**
|
||||
* Execute the console command.
|
||||
*
|
||||
* @return void
|
||||
*/
|
||||
public function handle(): void
|
||||
{
|
||||
$this->info("Début de traitement");
|
||||
|
||||
$tempFilePath = \storage_path('export_codes_uniques/tmp/Demande1.csv');
|
||||
$NewTempFilePath = \storage_path('export_codes_uniques/tmp/Demande1OK.csv');
|
||||
$i = 1;
|
||||
if (($handle = fopen($tempFilePath, "r")) !== false) {
|
||||
while (($data = fgetcsv($handle, null, ";")) !== false) {
|
||||
if ($i === 8) {
|
||||
File::append($NewTempFilePath, $data[0] . "\n");
|
||||
$i = 1;
|
||||
} else {
|
||||
File::append($NewTempFilePath, $data[0] . ';');
|
||||
$i++;
|
||||
}
|
||||
}
|
||||
fclose($handle);
|
||||
}
|
||||
$this->info("Fin de traitement");
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue