new importfiles
This commit is contained in:
parent
9bf0994b25
commit
48230c73a6
@ -8,13 +8,13 @@
|
|||||||
<jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url>
|
<jdbc-url>jdbc:mysql://127.0.0.1:3306</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
<data-source source="LOCAL" name="DDEV" uuid="b6d8fd7a-dc7c-4d77-a130-438821ee9c9c">
|
<data-source source="LOCAL" name="DDEV" uuid="096edb5d-73f9-4ef4-b462-f3f8e939a139">
|
||||||
<driver-ref>mariadb</driver-ref>
|
<driver-ref>mariadb</driver-ref>
|
||||||
<synchronize>true</synchronize>
|
<synchronize>true</synchronize>
|
||||||
<configured-by-url>true</configured-by-url>
|
<configured-by-url>true</configured-by-url>
|
||||||
<remarks>DDEV generated data source</remarks>
|
<remarks>DDEV generated data source</remarks>
|
||||||
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
|
<jdbc-driver>org.mariadb.jdbc.Driver</jdbc-driver>
|
||||||
<jdbc-url>jdbc:mariadb://127.0.0.1:64102/db?user=db&password=db</jdbc-url>
|
<jdbc-url>jdbc:mariadb://127.0.0.1:32836/db?user=db&password=db</jdbc-url>
|
||||||
<working-dir>$ProjectFileDir$</working-dir>
|
<working-dir>$ProjectFileDir$</working-dir>
|
||||||
</data-source>
|
</data-source>
|
||||||
</component>
|
</component>
|
||||||
|
@ -20,14 +20,10 @@ Starte MySQL-Server:
|
|||||||
|
|
||||||
Erstelle Datenbank (nicht die Tabellen)
|
Erstelle Datenbank (nicht die Tabellen)
|
||||||
> bin/console doctrine:database:create
|
> bin/console doctrine:database:create
|
||||||
>
|
|
||||||
|
|
||||||
Erstelle Tabellen
|
Erstelle Tabellen
|
||||||
> bin/console doctrine:migrations:migrate
|
> bin/console doctrine:migrations:migrate
|
||||||
|
|
||||||
Erstellen der Tabellen
|
|
||||||
> bin/console doctrine:migrations:migrate
|
|
||||||
|
|
||||||
Update der Datenbank
|
Update der Datenbank
|
||||||
> bin/console doctrine:migrations:execute
|
> bin/console doctrine:migrations:execute
|
||||||
|
|
||||||
|
@ -62,7 +62,7 @@ class HiltesImportCommand extends Command
|
|||||||
|
|
||||||
$r = $hiltesImport->startImport();
|
$r = $hiltesImport->startImport();
|
||||||
|
|
||||||
if($r['error']){
|
if(isset($r['error'])){
|
||||||
$io->error($r['text']);
|
$io->error($r['text']);
|
||||||
$this->logger->error($r['text']);
|
$this->logger->error($r['text']);
|
||||||
return Command::FAILURE;
|
return Command::FAILURE;
|
||||||
|
@ -113,10 +113,10 @@ class HiltesImport
|
|||||||
// Header überspringen
|
// Header überspringen
|
||||||
$c++;
|
$c++;
|
||||||
#*** Convertiert die Zeile in UTF8
|
#*** Convertiert die Zeile in UTF8
|
||||||
//$str = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
$data = iconv('ISO-8859-1','UTF-8',$file->fgets());
|
||||||
|
|
||||||
#*** Zerlegt die Zeile **********
|
#*** Zerlegt die Zeile **********
|
||||||
$data = $file->fgets();
|
//$data = $file->fgets();
|
||||||
if($c <= 1){ continue; }
|
if($c <= 1){ continue; }
|
||||||
|
|
||||||
$this->switchSaveData($this->splitLine($data));
|
$this->switchSaveData($this->splitLine($data));
|
||||||
@ -212,29 +212,44 @@ class HiltesImport
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $wareHouseName
|
||||||
|
* @return Warehouse|false|int|mixed|null
|
||||||
|
*/
|
||||||
private function checkWareHouseName(string $wareHouseName){
|
private function checkWareHouseName(string $wareHouseName){
|
||||||
#*** WEnn keine geCached Id Vorhanden
|
#*** WEnn keine geCached Id Vorhanden
|
||||||
$warehouse2 = false;
|
|
||||||
if(empty($this->cachedWarehouseIds[$wareHouseName])){
|
if(empty($this->cachedWarehouseIds[$wareHouseName])){
|
||||||
#*** Check
|
#*** Check
|
||||||
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||||
#dump($warehouse2);
|
//dump($warehouse2);
|
||||||
if(empty($warehouse2)){
|
if(empty($warehouse2)){
|
||||||
$warehouse = new Warehouse();
|
$warehouse = new Warehouse();
|
||||||
$warehouse->setId((int)$wareHouseName);
|
$warehouse->setId((int)$wareHouseName);
|
||||||
$warehouse->setName($wareHouseName);
|
$warehouse->setName($wareHouseName);
|
||||||
#
|
#
|
||||||
|
|
||||||
$this->warehouseRepository->save($warehouse,true);
|
$this->warehouseRepository->save($warehouse,true);
|
||||||
|
|
||||||
|
$this->cachedWarehouseIds[$wareHouseName] = $warehouse;
|
||||||
#*****************
|
#*****************
|
||||||
$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
#$warehouse2 = $this->warehouseRepository->findOneBy(['id'=> (int)$wareHouseName]);
|
||||||
#dump($warehouse2);
|
#dump($warehouse2);
|
||||||
}
|
}else{
|
||||||
$this->cachedWarehouseIds[$wareHouseName] = $warehouse2;
|
$this->cachedWarehouseIds[$wareHouseName] = $warehouse2;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!empty($this->cachedWarehouseIds[$wareHouseName]))
|
if(!empty($this->cachedWarehouseIds[$wareHouseName]))
|
||||||
return $this->cachedWarehouseIds[$wareHouseName];
|
return $this->cachedWarehouseIds[$wareHouseName];
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param string $gtin
|
||||||
|
* @param string $modellNr
|
||||||
|
* @param string $modellBez
|
||||||
|
* @return false|int|mixed|null
|
||||||
|
*/
|
||||||
private function checkProduct(string $gtin,string $modellNr,string $modellBez){
|
private function checkProduct(string $gtin,string $modellNr,string $modellBez){
|
||||||
#*** WEnn keine geCached Id Vorhanden
|
#*** WEnn keine geCached Id Vorhanden
|
||||||
if(empty($this->cachedProdIds[$gtin])){
|
if(empty($this->cachedProdIds[$gtin])){
|
||||||
@ -244,16 +259,18 @@ class HiltesImport
|
|||||||
if(empty($prod2)){
|
if(empty($prod2)){
|
||||||
$prod = new Product();
|
$prod = new Product();
|
||||||
$prod->setGtin($gtin);
|
$prod->setGtin($gtin);
|
||||||
$prod->setModellNr($modellNr);
|
$prod->setModellNr(trim($modellNr));
|
||||||
$prod->setModellBez($modellBez);
|
$prod->setModellBez(trim($modellBez));
|
||||||
$prod->setShopwareId("");
|
$prod->setShopwareId("");
|
||||||
#
|
#
|
||||||
$this->productRepository->save($prod,true);
|
$this->cachedProdIds[$gtin] = $this->productRepository->save($prod,true);
|
||||||
#*****************
|
#*****************
|
||||||
$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
//$prod2 = $this->productRepository->findOneBy(['gtin'=> $gtin]);
|
||||||
#dump($warehouse2);
|
#dump($warehouse2);
|
||||||
}
|
}else{
|
||||||
$this->cachedProdIds[$gtin] = $prod2->getId();
|
$this->cachedProdIds[$gtin] = $prod2->getId();
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
if(!empty($this->cachedProdIds[$gtin]))
|
if(!empty($this->cachedProdIds[$gtin]))
|
||||||
return $this->cachedProdIds[$gtin];
|
return $this->cachedProdIds[$gtin];
|
||||||
|
@ -21,7 +21,7 @@ class ProductRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Product::class);
|
parent::__construct($registry, Product::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(Product $entity, bool $flush = false): void
|
public function save(Product $entity, bool $flush = false): ?int
|
||||||
{
|
{
|
||||||
|
|
||||||
$entity->setUpdateTime(new \DateTime());
|
$entity->setUpdateTime(new \DateTime());
|
||||||
@ -31,6 +31,8 @@ class ProductRepository extends ServiceEntityRepository
|
|||||||
if ($flush) {
|
if ($flush) {
|
||||||
$this->getEntityManager()->flush();
|
$this->getEntityManager()->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $entity->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove(Product $entity, bool $flush = false): void
|
public function remove(Product $entity, bool $flush = false): void
|
||||||
|
@ -21,7 +21,7 @@ class WarehouseRepository extends ServiceEntityRepository
|
|||||||
parent::__construct($registry, Warehouse::class);
|
parent::__construct($registry, Warehouse::class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public function save(Warehouse $entity, bool $flush = false): void
|
public function save(Warehouse $entity, bool $flush = false): ?int
|
||||||
{
|
{
|
||||||
$entity->setPrio(0);
|
$entity->setPrio(0);
|
||||||
$this->getEntityManager()->persist($entity);
|
$this->getEntityManager()->persist($entity);
|
||||||
@ -29,6 +29,8 @@ class WarehouseRepository extends ServiceEntityRepository
|
|||||||
if ($flush) {
|
if ($flush) {
|
||||||
$this->getEntityManager()->flush();
|
$this->getEntityManager()->flush();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return $entity->getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
public function remove(Warehouse $entity, bool $flush = false): void
|
public function remove(Warehouse $entity, bool $flush = false): void
|
||||||
|
Loading…
Reference in New Issue
Block a user