mirror of
https://gitlab.com/Chill-Projet/chill-bundles.git
synced 2025-06-07 18:44:08 +00:00
DX: Improve Lux adress import command + register in config
This commit is contained in:
parent
c5a24e8ac5
commit
9c28df25a1
@ -33,16 +33,13 @@ class AddressReferenceLU
|
|||||||
throw new \Exception('Could not download CSV: '.$response->getStatusCode());
|
throw new \Exception('Could not download CSV: '.$response->getStatusCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
$tmpname = tempnam(sys_get_temp_dir(), 'php-add-');
|
$file = tmpfile();
|
||||||
$file = fopen($tmpname, 'r+b');
|
|
||||||
|
|
||||||
foreach ($this->client->stream($response) as $chunk) {
|
foreach ($this->client->stream($response) as $chunk) {
|
||||||
fwrite($file, $chunk->getContent());
|
fwrite($file, $chunk->getContent());
|
||||||
}
|
}
|
||||||
|
|
||||||
fclose($file);
|
fseek($file, 0);
|
||||||
|
|
||||||
//$uncompressedStream = gzopen($tmpname, 'r');
|
|
||||||
|
|
||||||
$csv = Reader::createFromStream($file);
|
$csv = Reader::createFromStream($file);
|
||||||
$csv->setDelimiter(';');
|
$csv->setDelimiter(';');
|
||||||
@ -54,7 +51,7 @@ class AddressReferenceLU
|
|||||||
|
|
||||||
$this->addressToReferenceMatcher->checkAddressesMatchingReferences();
|
$this->addressToReferenceMatcher->checkAddressesMatchingReferences();
|
||||||
|
|
||||||
//gzclose($uncompressedStream);
|
fclose($file);
|
||||||
}
|
}
|
||||||
|
|
||||||
private function process_address(Reader $csv): void
|
private function process_address(Reader $csv): void
|
||||||
@ -82,14 +79,13 @@ class AddressReferenceLU
|
|||||||
$stmt = Statement::create()->process($csv);
|
$stmt = Statement::create()->process($csv);
|
||||||
$arr_postal_codes = [];
|
$arr_postal_codes = [];
|
||||||
foreach ($stmt as $record) {
|
foreach ($stmt as $record) {
|
||||||
//if (false === \in_array($record['code_postal'], $arr_postal_codes, true)) {
|
if (false === \array_key_exists($record['code_postal'], $arr_postal_codes)) {
|
||||||
if (false === \array_key_exists($record['code_postal'], $arr_postal_codes, true)) {
|
|
||||||
$this->postalCodeBaseImporter->importCode(
|
$this->postalCodeBaseImporter->importCode(
|
||||||
'LU',
|
'LU',
|
||||||
trim((string) $record['localite']),
|
trim((string) $record['localite']),
|
||||||
trim((string) $record['code_postal']),
|
trim((string) $record['code_postal']),
|
||||||
trim((string) $record['code_postal']),
|
trim((string) $record['code_postal']),
|
||||||
'bd addresses',
|
'bd-addresses.lux',
|
||||||
(float) $record['lat_wgs84'],
|
(float) $record['lat_wgs84'],
|
||||||
(float) $record['lon_wgs84'],
|
(float) $record['lon_wgs84'],
|
||||||
4326
|
4326
|
||||||
|
@ -59,6 +59,12 @@ services:
|
|||||||
tags:
|
tags:
|
||||||
- { name: console.command }
|
- { name: console.command }
|
||||||
|
|
||||||
|
Chill\MainBundle\Command\LoadAddressesLUFromBDAddressCommand:
|
||||||
|
autoconfigure: true
|
||||||
|
autowire: true
|
||||||
|
tags:
|
||||||
|
- { name: console.command }
|
||||||
|
|
||||||
Chill\MainBundle\Command\ExecuteCronJobCommand:
|
Chill\MainBundle\Command\ExecuteCronJobCommand:
|
||||||
autoconfigure: true
|
autoconfigure: true
|
||||||
autowire: true
|
autowire: true
|
||||||
|
Loading…
x
Reference in New Issue
Block a user