diff --git a/.idea/dataSources.xml b/.idea/dataSources.xml
index 8b1bb13..a64f19a 100644
--- a/.idea/dataSources.xml
+++ b/.idea/dataSources.xml
@@ -8,13 +8,13 @@
jdbc:mysql://127.0.0.1:3306
$ProjectFileDir$
-
+
mariadb
true
true
DDEV generated data source
org.mariadb.jdbc.Driver
- jdbc:mariadb://127.0.0.1:60219/db?user=db&password=db
+ jdbc:mariadb://127.0.0.1:55567/db?user=db&password=db
$ProjectFileDir$
diff --git a/src/Command/HiltesImportCommand.php b/src/Command/HiltesImportCommand.php
index d53170c..e3bdef5 100644
--- a/src/Command/HiltesImportCommand.php
+++ b/src/Command/HiltesImportCommand.php
@@ -3,6 +3,7 @@
namespace App\Command;
use App\Helper\HiltesImport;
+use App\Helper\Jtl;
use App\Repository\ProductRepository;
use App\Repository\StockRepository;
use App\Repository\WarehouseRepository;
@@ -57,7 +58,7 @@ class HiltesImportCommand extends Command
$hiltesImport = new HiltesImport($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
- $r = $hiltesImport->startImport();
+ $r = $hiltesImport->startImport($input->getOption('delta'));
if(isset($r['error'])){
$io->error($r['text']);
@@ -66,8 +67,8 @@ class HiltesImportCommand extends Command
}else{
$io->info('Start Hiltes Push JTL');
- $jtl = new JtlExportCommand($this->productRepository,$this->stockRepository,$this->warehouseRepository,$this->logger);
- $jtl->execute($input,$output);
+ $jtl = new Jtl($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
+ $jtl->createExportFile($jtl->getProducts());
$io->success('Done.');
return Command::SUCCESS;
diff --git a/src/Helper/HiltesImport.php b/src/Helper/HiltesImport.php
index b723379..f4eba73 100644
--- a/src/Helper/HiltesImport.php
+++ b/src/Helper/HiltesImport.php
@@ -12,6 +12,8 @@ use App\Repository\WarehouseRepository;
use Psr\Log\LoggerInterface;
use Symfony\Component\Finder\Finder;
+use App\Helper\App\Helper\SplFileInfo;
+
class HiltesImport
{
private $productRepository;
@@ -38,17 +40,16 @@ class HiltesImport
/**
* @return array|void
*/
- public function startImport()
+ public function startImport($delta = false)
{
#*** Holt alle Dateien
- if($this->getFiles()){
+ if($this->getFiles($delta)){
#*** Holt alle Stocks und setzt ein Array **************
$this->getStocks();
$count = 0;
if(!empty($this->arrData['orgFiles']['data']) && count($this->arrData['orgFiles']['data'])){
foreach ($this->arrData['orgFiles']['data'] as $file) {
-
if(is_file($file['realPath'])){
$count += $this->loadFiles($file['realPath'],$file['fileSize']);
}else{
@@ -57,8 +58,6 @@ class HiltesImport
}
}
dump("Imported $count stocks");
- //remove fertig file
- //unlink($this->currentDirPath.'/hiltes/h2c/WS.FERTIG');
}else
return array('success'=>1,'text'=>'No Files');
@@ -69,34 +68,38 @@ class HiltesImport
/**
* @return bool
*/
- protected function getFiles()
+ protected function getFiles($delta = false)
{
$finder = Finder::create();
$finder
->in($this->currentDirPath.'/hiltes/h2c/')
->depth(0);
- #->filter(static function (SplFileInfo $file) {
- # return $file->isDir() || \preg_match('/\.(php|json)$/', $file->getPathname());
- #});
- $hasFoundFertigFile = false;
+
+ if($delta) {
+ $finder->name('/_D/');
+ }else{
+ $finder->notName('/_D/');
+ }
+
if ($finder->hasResults()) {
#dump($finder);
foreach ($finder as $file) {
-// if($file->getRelativePathname()=='WS.FERTIG'){
- $hasFoundFertigFile = true;
-// continue;
-// }
- $this->arrData['orgFiles']['data'][] = array(
- 'realPath' => $file->getRealPath(),
- 'fileSize' => $file->getFileInfo()->getSize(),
- 'onlyFileName' => $file->getRelativePathname(),
- );
+ if($file->getExtension() != 'Ende') {
+ //prüfen ob Ende Datei vorhanden ist
+ if(file_exists($this->currentDirPath.'/hiltes/h2c/'.$file->getRelativePathname().'.Ende')) {
+ $this->arrData['orgFiles']['data'][] = array(
+ 'realPath' => $file->getRealPath(),
+ 'fileSize' => $file->getFileInfo()->getSize(),
+ 'onlyFileName' => $file->getRelativePathname(),
+ );
+ }
+ }
}
}else{
return false;
}
- return $hasFoundFertigFile;
+ return true;
}
protected function getStocks()
{
@@ -139,7 +142,7 @@ class HiltesImport
}
- unlink($file->getRealPath());
+ //unlink($file->getRealPath());
dump($c . ' Datensätze importiert');
return $c;
@@ -185,7 +188,6 @@ class HiltesImport
#*** Ermitteln ob schon ein ID vorhanden für ProdId und WareHouseId
if(!empty($wareHouse) && !empty($this->cachedStockIds[$gtin][$wareHouse->getId()])){
$stock = $this->cachedStockIds[$gtin][$wareHouse->getId()];
- //dd('JAAAAA');
}else{
$stock = new Stock();
$stock->setProductId($gtin);
@@ -196,9 +198,6 @@ class HiltesImport
#$stock->setWarehouseId($wareHouseId);
//dump($stock);
$this->stockRepository->save($stock,true);
-
-
-
}
/**
@@ -235,8 +234,6 @@ class HiltesImport
/**
* @param string $gtin
- * @param string $modellNr
- * @param string $modellBez
* @return false|int|mixed|null
*/
private function checkProduct(string $gtin){