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>
<working-dir>$ProjectFileDir$</working-dir>
</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>
<synchronize>true</synchronize>
<configured-by-url>true</configured-by-url>
<remarks>DDEV generated data source</remarks>
<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>
</data-source>
</component>

View File

@ -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;

View File

@ -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){