This commit is contained in:
parent
c6bc1776bd
commit
047db97928
@ -60,7 +60,7 @@ class HiltesImportCommand extends Command
|
|||||||
$hiltesImport = new HiltesImport($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $rootPath);
|
$hiltesImport = new HiltesImport($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $rootPath);
|
||||||
|
|
||||||
|
|
||||||
$hiltesImport->startImport($delta);
|
$prodIds = $hiltesImport->startImport($delta);
|
||||||
|
|
||||||
if (isset($r['error'])) {
|
if (isset($r['error'])) {
|
||||||
$io->error($r['text']);
|
$io->error($r['text']);
|
||||||
@ -72,10 +72,10 @@ class HiltesImportCommand extends Command
|
|||||||
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $rootPath);
|
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger, $rootPath);
|
||||||
|
|
||||||
//Export für Standartlager
|
//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
|
//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.');
|
$io->success('Done.');
|
||||||
return Command::SUCCESS;
|
return Command::SUCCESS;
|
||||||
|
@ -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
|
#*** Holt alle Dateien
|
||||||
if ($this->getFiles($delta)) {
|
if ($this->getFiles($delta)) {
|
||||||
@ -63,18 +64,20 @@ class HiltesImport
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
$this->logger->info("Imported $count stocks");
|
$this->logger->info("Imported $count stocks");
|
||||||
|
return $this->cachedProdIds;
|
||||||
} else {
|
} else {
|
||||||
$this->logger->info('No Files');
|
$this->logger->info('No Files');
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
throw new RuntimeException('No Files to Import');
|
throw new RuntimeException('No Files to Import');
|
||||||
}
|
}
|
||||||
|
return [];
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @return bool
|
* @return bool
|
||||||
*/
|
*/
|
||||||
protected function getFiles($delta = false): bool
|
protected function getFiles(bool $delta = false): bool
|
||||||
{
|
{
|
||||||
$finder = Finder::create();
|
$finder = Finder::create();
|
||||||
$finder
|
$finder
|
||||||
@ -230,9 +233,9 @@ class HiltesImport
|
|||||||
if (empty($product)) {
|
if (empty($product)) {
|
||||||
$product = new Product();
|
$product = new Product();
|
||||||
$product->setGtin($gtin);
|
$product->setGtin($gtin);
|
||||||
$this->cachedProdIds[$gtin] = $this->productRepository->save($product, true);
|
$this->cachedProdIds["$gtin"] = $this->productRepository->save($product, true);
|
||||||
} else {
|
} else {
|
||||||
$this->cachedProdIds[$gtin] = $product->getId();
|
$this->cachedProdIds["$gtin"] = $product->getId();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -59,10 +59,10 @@ class Jtl
|
|||||||
* @param array $warehousesName
|
* @param array $warehousesName
|
||||||
* @return array
|
* @return array
|
||||||
*/
|
*/
|
||||||
public function getProducts(array $warehousesName): array
|
public function getProducts(array $prodIds, array $warehousesName): array
|
||||||
{
|
{
|
||||||
$data = array();
|
$data = array();
|
||||||
$products = $this->productRepository->findAll();
|
$products = $this->productRepository->findById($prodIds);
|
||||||
|
|
||||||
foreach ($warehousesName as $wn) {
|
foreach ($warehousesName as $wn) {
|
||||||
$warehouse = $this->warehouseRepository->findByWarehouseByName($wn);
|
$warehouse = $this->warehouseRepository->findByWarehouseByName($wn);
|
||||||
@ -82,7 +82,7 @@ class Jtl
|
|||||||
$data[$s->getProductId() . $warehouseName] = [
|
$data[$s->getProductId() . $warehouseName] = [
|
||||||
'gtin' => $products[$s->getProductId()]->getGtin(),
|
'gtin' => $products[$s->getProductId()]->getGtin(),
|
||||||
'stock' => $s->getInstock(),
|
'stock' => $s->getInstock(),
|
||||||
'warehouse' => $this->arrLager[$warehouseName] ?? 'Lager ' . $warehouseName,
|
'warehouse' => $this->arrLager[$warehouseName] ?? 'Lager_' . $warehouseName,
|
||||||
'lager' => '01'
|
'lager' => '01'
|
||||||
];
|
];
|
||||||
|
|
||||||
@ -97,7 +97,7 @@ class Jtl
|
|||||||
// 'stock' => 0,
|
// 'stock' => 0,
|
||||||
// 'warehouse' => 0
|
// 'warehouse' => 0
|
||||||
// ];
|
// ];
|
||||||
// $this->logger->info('No stock for product ' . s->getProductId()->getId());
|
$this->logger->info('No stock for product ' . s->getProductId()->getId());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -45,20 +45,17 @@ class ProductRepository extends ServiceEntityRepository
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// /**
|
/**
|
||||||
// * @return Product[] Returns an array of Product objects
|
* @return Product[] Returns an array of Product objects
|
||||||
// */
|
*/
|
||||||
// public function findByExampleField($value): array
|
public function findById($value): array
|
||||||
// {
|
{
|
||||||
// return $this->createQueryBuilder('p')
|
return $this->createQueryBuilder('p')
|
||||||
// ->andWhere('p.exampleField = :val')
|
->andWhere('p.id IN (:val)')
|
||||||
// ->setParameter('val', $value)
|
->setParameter('val', $value)
|
||||||
// ->orderBy('p.id', 'ASC')
|
->getQuery()
|
||||||
// ->setMaxResults(10)
|
->getResult();
|
||||||
// ->getQuery()
|
}
|
||||||
// ->getResult()
|
|
||||||
// ;
|
|
||||||
// }
|
|
||||||
|
|
||||||
// public function findOneBySomeField($value): ?Product
|
// public function findOneBySomeField($value): ?Product
|
||||||
// {
|
// {
|
||||||
|
Loading…
Reference in New Issue
Block a user