add Delta

This commit is contained in:
Marko 2023-09-25 17:36:06 +02:00
parent 2395c1a638
commit 30b675e999
No known key found for this signature in database
3 changed files with 30 additions and 32 deletions

View File

@ -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="5334865a-0afb-4bee-bdea-8112a8ca3fb7"> <data-source source="LOCAL" name="DDEV" uuid="4f0eac1b-a05a-46ad-b191-45cbcbad373f">
<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:60219/db?user=db&amp;password=db</jdbc-url> <jdbc-url>jdbc:mariadb://127.0.0.1:55567/db?user=db&amp;password=db</jdbc-url>
<working-dir>$ProjectFileDir$</working-dir> <working-dir>$ProjectFileDir$</working-dir>
</data-source> </data-source>
</component> </component>

View File

@ -3,6 +3,7 @@
namespace App\Command; namespace App\Command;
use App\Helper\HiltesImport; use App\Helper\HiltesImport;
use App\Helper\Jtl;
use App\Repository\ProductRepository; use App\Repository\ProductRepository;
use App\Repository\StockRepository; use App\Repository\StockRepository;
use App\Repository\WarehouseRepository; use App\Repository\WarehouseRepository;
@ -57,7 +58,7 @@ class HiltesImportCommand extends Command
$hiltesImport = new HiltesImport($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger); $hiltesImport = new HiltesImport($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
$r = $hiltesImport->startImport(); $r = $hiltesImport->startImport($input->getOption('delta'));
if(isset($r['error'])){ if(isset($r['error'])){
$io->error($r['text']); $io->error($r['text']);
@ -66,8 +67,8 @@ class HiltesImportCommand extends Command
}else{ }else{
$io->info('Start Hiltes Push JTL'); $io->info('Start Hiltes Push JTL');
$jtl = new JtlExportCommand($this->productRepository,$this->stockRepository,$this->warehouseRepository,$this->logger); $jtl = new Jtl($this->productRepository,$this->warehouseRepository,$this->stockRepository,$this->logger);
$jtl->execute($input,$output); $jtl->createExportFile($jtl->getProducts());
$io->success('Done.'); $io->success('Done.');
return Command::SUCCESS; return Command::SUCCESS;

View File

@ -12,6 +12,8 @@ use App\Repository\WarehouseRepository;
use Psr\Log\LoggerInterface; use Psr\Log\LoggerInterface;
use Symfony\Component\Finder\Finder; use Symfony\Component\Finder\Finder;
use App\Helper\App\Helper\SplFileInfo;
class HiltesImport class HiltesImport
{ {
private $productRepository; private $productRepository;
@ -38,17 +40,16 @@ class HiltesImport
/** /**
* @return array|void * @return array|void
*/ */
public function startImport() public function startImport($delta = false)
{ {
#*** Holt alle Dateien #*** Holt alle Dateien
if($this->getFiles()){ if($this->getFiles($delta)){
#*** Holt alle Stocks und setzt ein Array ************** #*** Holt alle Stocks und setzt ein Array **************
$this->getStocks(); $this->getStocks();
$count = 0; $count = 0;
if(!empty($this->arrData['orgFiles']['data']) && count($this->arrData['orgFiles']['data'])){ if(!empty($this->arrData['orgFiles']['data']) && count($this->arrData['orgFiles']['data'])){
foreach ($this->arrData['orgFiles']['data'] as $file) { foreach ($this->arrData['orgFiles']['data'] as $file) {
if(is_file($file['realPath'])){ if(is_file($file['realPath'])){
$count += $this->loadFiles($file['realPath'],$file['fileSize']); $count += $this->loadFiles($file['realPath'],$file['fileSize']);
}else{ }else{
@ -57,8 +58,6 @@ class HiltesImport
} }
} }
dump("Imported $count stocks"); dump("Imported $count stocks");
//remove fertig file
//unlink($this->currentDirPath.'/hiltes/h2c/WS.FERTIG');
}else }else
return array('success'=>1,'text'=>'No Files'); return array('success'=>1,'text'=>'No Files');
@ -69,34 +68,38 @@ class HiltesImport
/** /**
* @return bool * @return bool
*/ */
protected function getFiles() protected function getFiles($delta = false)
{ {
$finder = Finder::create(); $finder = Finder::create();
$finder $finder
->in($this->currentDirPath.'/hiltes/h2c/') ->in($this->currentDirPath.'/hiltes/h2c/')
->depth(0); ->depth(0);
#->filter(static function (SplFileInfo $file) {
# return $file->isDir() || \preg_match('/\.(php|json)$/', $file->getPathname()); if($delta) {
#}); $finder->name('/_D/');
$hasFoundFertigFile = false; }else{
$finder->notName('/_D/');
}
if ($finder->hasResults()) { if ($finder->hasResults()) {
#dump($finder); #dump($finder);
foreach ($finder as $file) { foreach ($finder as $file) {
// if($file->getRelativePathname()=='WS.FERTIG'){ if($file->getExtension() != 'Ende') {
$hasFoundFertigFile = true; //prüfen ob Ende Datei vorhanden ist
// continue; if(file_exists($this->currentDirPath.'/hiltes/h2c/'.$file->getRelativePathname().'.Ende')) {
// }
$this->arrData['orgFiles']['data'][] = array( $this->arrData['orgFiles']['data'][] = array(
'realPath' => $file->getRealPath(), 'realPath' => $file->getRealPath(),
'fileSize' => $file->getFileInfo()->getSize(), 'fileSize' => $file->getFileInfo()->getSize(),
'onlyFileName' => $file->getRelativePathname(), 'onlyFileName' => $file->getRelativePathname(),
); );
} }
}
}
}else{ }else{
return false; return false;
} }
return $hasFoundFertigFile; return true;
} }
protected function getStocks() protected function getStocks()
{ {
@ -139,7 +142,7 @@ class HiltesImport
} }
unlink($file->getRealPath()); //unlink($file->getRealPath());
dump($c . ' Datensätze importiert'); dump($c . ' Datensätze importiert');
return $c; return $c;
@ -185,7 +188,6 @@ class HiltesImport
#*** Ermitteln ob schon ein ID vorhanden für ProdId und WareHouseId #*** Ermitteln ob schon ein ID vorhanden für ProdId und WareHouseId
if(!empty($wareHouse) && !empty($this->cachedStockIds[$gtin][$wareHouse->getId()])){ if(!empty($wareHouse) && !empty($this->cachedStockIds[$gtin][$wareHouse->getId()])){
$stock = $this->cachedStockIds[$gtin][$wareHouse->getId()]; $stock = $this->cachedStockIds[$gtin][$wareHouse->getId()];
//dd('JAAAAA');
}else{ }else{
$stock = new Stock(); $stock = new Stock();
$stock->setProductId($gtin); $stock->setProductId($gtin);
@ -196,9 +198,6 @@ class HiltesImport
#$stock->setWarehouseId($wareHouseId); #$stock->setWarehouseId($wareHouseId);
//dump($stock); //dump($stock);
$this->stockRepository->save($stock,true); $this->stockRepository->save($stock,true);
} }
/** /**
@ -235,8 +234,6 @@ class HiltesImport
/** /**
* @param string $gtin * @param string $gtin
* @param string $modellNr
* @param string $modellBez
* @return false|int|mixed|null * @return false|int|mixed|null
*/ */
private function checkProduct(string $gtin){ private function checkProduct(string $gtin){