add fixed export
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Marko 2023-12-13 14:23:45 +01:00
parent c6bc1776bd
commit 047db97928
No known key found for this signature in database
4 changed files with 26 additions and 26 deletions

View File

@ -60,7 +60,7 @@ class HiltesImportCommand extends Command
$hiltesImport = new HiltesImport($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $rootPath);
$hiltesImport->startImport($delta);
$prodIds = $hiltesImport->startImport($delta);
if (isset($r['error'])) {
$io->error($r['text']);
@ -72,10 +72,10 @@ class HiltesImportCommand extends Command
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $rootPath);
//Export für Standartlager
$jtl->createExportFile($jtl->getProducts(['1', '3', '5', '10']), 'standard' . ($delta ? '_delta' : ''));
$jtl->createExportFile($jtl->getProducts($prodIds, ['1', '3', '5', '10']), 'standard' . ($delta ? '_delta' : ''));
//Export für WMS Lager
$jtl->createExportFile($jtl->getProducts(['8']), 'wms' . ($delta ? '_delta' : ''));
$jtl->createExportFile($jtl->getProducts($prodIds, ['8']), 'wms' . ($delta ? '_delta' : ''));
$io->success('Done.');
return Command::SUCCESS;

View File

@ -44,9 +44,10 @@ class HiltesImport
/**
* @return void
* @param bool $delta
* @return array
*/
public function startImport($delta = false)
public function startImport(bool $delta = false): array
{
#*** Holt alle Dateien
if ($this->getFiles($delta)) {
@ -63,18 +64,20 @@ class HiltesImport
}
}
$this->logger->info("Imported $count stocks");
return $this->cachedProdIds;
} else {
$this->logger->info('No Files');
}
} else {
throw new RuntimeException('No Files to Import');
}
return [];
}
/**
* @return bool
*/
protected function getFiles($delta = false): bool
protected function getFiles(bool $delta = false): bool
{
$finder = Finder::create();
$finder
@ -230,9 +233,9 @@ class HiltesImport
if (empty($product)) {
$product = new Product();
$product->setGtin($gtin);
$this->cachedProdIds[$gtin] = $this->productRepository->save($product, true);
$this->cachedProdIds["$gtin"] = $this->productRepository->save($product, true);
} else {
$this->cachedProdIds[$gtin] = $product->getId();
$this->cachedProdIds["$gtin"] = $product->getId();
}
}

View File

@ -59,10 +59,10 @@ class Jtl
* @param array $warehousesName
* @return array
*/
public function getProducts(array $warehousesName): array
public function getProducts(array $prodIds, array $warehousesName): array
{
$data = array();
$products = $this->productRepository->findAll();
$products = $this->productRepository->findById($prodIds);
foreach ($warehousesName as $wn) {
$warehouse = $this->warehouseRepository->findByWarehouseByName($wn);
@ -82,7 +82,7 @@ class Jtl
$data[$s->getProductId() . $warehouseName] = [
'gtin' => $products[$s->getProductId()]->getGtin(),
'stock' => $s->getInstock(),
'warehouse' => $this->arrLager[$warehouseName] ?? 'Lager ' . $warehouseName,
'warehouse' => $this->arrLager[$warehouseName] ?? 'Lager_' . $warehouseName,
'lager' => '01'
];
@ -97,7 +97,7 @@ class Jtl
// 'stock' => 0,
// 'warehouse' => 0
// ];
// $this->logger->info('No stock for product ' . s->getProductId()->getId());
$this->logger->info('No stock for product ' . s->getProductId()->getId());
}
}
}

View File

@ -45,20 +45,17 @@ class ProductRepository extends ServiceEntityRepository
}
}
// /**
// * @return Product[] Returns an array of Product objects
// */
// public function findByExampleField($value): array
// {
// return $this->createQueryBuilder('p')
// ->andWhere('p.exampleField = :val')
// ->setParameter('val', $value)
// ->orderBy('p.id', 'ASC')
// ->setMaxResults(10)
// ->getQuery()
// ->getResult()
// ;
// }
/**
* @return Product[] Returns an array of Product objects
*/
public function findById($value): array
{
return $this->createQueryBuilder('p')
->andWhere('p.id IN (:val)')
->setParameter('val', $value)
->getQuery()
->getResult();
}
// public function findOneBySomeField($value): ?Product
// {