From 86f28121aa8765010b2afa717ff1d2df1e3831d4 Mon Sep 17 00:00:00 2001 From: Marko <52066939+HeX87@users.noreply.github.com> Date: Tue, 19 Sep 2023 15:29:22 +0200 Subject: [PATCH] fix Hiltes import --- .idea/CdsConnector.iml | 1 - .idea/php.xml | 1 - composer.json | 4 +- composer.lock | 133 +++++--------------- config/bundles.php | 1 - config/packages/sensio_framework_extra.yaml | 3 - src/ApiResource/.gitignore | 0 src/Command/HiltesImportCommand.php | 2 - src/Helper/Ftp.php | 93 ++++++++++++++ src/Helper/HiltesImport.php | 4 +- symfony.lock | 12 -- 11 files changed, 127 insertions(+), 127 deletions(-) delete mode 100644 config/packages/sensio_framework_extra.yaml create mode 100644 src/ApiResource/.gitignore diff --git a/.idea/CdsConnector.iml b/.idea/CdsConnector.iml index 1c965bb..1a1a9a7 100644 --- a/.idea/CdsConnector.iml +++ b/.idea/CdsConnector.iml @@ -25,7 +25,6 @@ - diff --git a/.idea/php.xml b/.idea/php.xml index 2b89575..d8f4958 100644 --- a/.idea/php.xml +++ b/.idea/php.xml @@ -32,7 +32,6 @@ - diff --git a/composer.json b/composer.json index a49fc3d..97cf478 100644 --- a/composer.json +++ b/composer.json @@ -6,6 +6,8 @@ "require": { "php": ">=8.1", "ext-ctype": "*", + "ext-curl": "*", + "ext-ftp": "*", "ext-iconv": "*", "api-platform/core": "^3.1", "doctrine/annotations": "^1.0", @@ -16,7 +18,6 @@ "nelmio/cors-bundle": "^2.2", "phpdocumentor/reflection-docblock": "^5.3", "phpstan/phpdoc-parser": "^1.6", - "sensio/framework-extra-bundle": "^6.2", "symfony/apache-pack": "^1.0", "symfony/asset": "6.1.*", "symfony/console": "6.1.*", @@ -52,6 +53,7 @@ "config": { "allow-plugins": { "composer/package-versions-deprecated": true, + "php-http/discovery": true, "symfony/flex": true, "symfony/runtime": true }, diff --git a/composer.lock b/composer.lock index 9520c94..83fa534 100644 --- a/composer.lock +++ b/composer.lock @@ -4,20 +4,20 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "6dabdf9e03663a32cc97a8533121e3cc", + "content-hash": "f834752699bf667645cf22b5cd2c6aa2", "packages": [ { "name": "api-platform/core", - "version": "v3.1.17", + "version": "v3.1.18", "source": { "type": "git", "url": "https://github.com/api-platform/core.git", - "reference": "850f7356b6732d0edccf3ee773113c457afc771e" + "reference": "198ca0f1f1c9f730a15e85762b04af43eb43424e" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/api-platform/core/zipball/850f7356b6732d0edccf3ee773113c457afc771e", - "reference": "850f7356b6732d0edccf3ee773113c457afc771e", + "url": "https://api.github.com/repos/api-platform/core/zipball/198ca0f1f1c9f730a15e85762b04af43eb43424e", + "reference": "198ca0f1f1c9f730a15e85762b04af43eb43424e", "shasum": "" }, "require": { @@ -44,11 +44,10 @@ "elasticsearch/elasticsearch": ">=8.0", "phpspec/prophecy": "<1.15", "phpunit/phpunit": "<9.5", - "symfony/service-contracts": "<3", "symfony/var-exporter": "<6.1.1" }, "require-dev": { - "behat/behat": "^3.1", + "behat/behat": "^3.11", "behat/mink": "^1.9", "doctrine/cache": "^1.11 || ^2.1", "doctrine/common": "^3.2.2", @@ -166,7 +165,7 @@ ], "support": { "issues": "https://github.com/api-platform/core/issues", - "source": "https://github.com/api-platform/core/tree/v3.1.17" + "source": "https://github.com/api-platform/core/tree/v3.1.18" }, "funding": [ { @@ -174,7 +173,7 @@ "type": "tidelift" } ], - "time": "2023-09-08T14:11:23+00:00" + "time": "2023-09-15T13:45:54+00:00" }, { "name": "doctrine/annotations", @@ -2028,16 +2027,16 @@ }, { "name": "phpstan/phpdoc-parser", - "version": "1.24.0", + "version": "1.24.1", "source": { "type": "git", "url": "https://github.com/phpstan/phpdoc-parser.git", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6" + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/3510b0a6274cc42f7219367cb3abfc123ffa09d6", - "reference": "3510b0a6274cc42f7219367cb3abfc123ffa09d6", + "url": "https://api.github.com/repos/phpstan/phpdoc-parser/zipball/9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", + "reference": "9f854d275c2dbf84915a5c0ec9a2d17d2cd86b01", "shasum": "" }, "require": { @@ -2069,9 +2068,9 @@ "description": "PHPDoc parser with support for nullable, intersection and generic types", "support": { "issues": "https://github.com/phpstan/phpdoc-parser/issues", - "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.0" + "source": "https://github.com/phpstan/phpdoc-parser/tree/1.24.1" }, - "time": "2023-09-07T20:46:32+00:00" + "time": "2023-09-18T12:18:02+00:00" }, { "name": "psr/cache", @@ -2331,84 +2330,6 @@ }, "time": "2021-07-14T16:46:02+00:00" }, - { - "name": "sensio/framework-extra-bundle", - "version": "v6.2.10", - "source": { - "type": "git", - "url": "https://github.com/sensiolabs/SensioFrameworkExtraBundle.git", - "reference": "2f886f4b31f23c76496901acaedfedb6936ba61f" - }, - "dist": { - "type": "zip", - "url": "https://api.github.com/repos/sensiolabs/SensioFrameworkExtraBundle/zipball/2f886f4b31f23c76496901acaedfedb6936ba61f", - "reference": "2f886f4b31f23c76496901acaedfedb6936ba61f", - "shasum": "" - }, - "require": { - "doctrine/annotations": "^1.0|^2.0", - "php": ">=7.2.5", - "symfony/config": "^4.4|^5.0|^6.0", - "symfony/dependency-injection": "^4.4|^5.0|^6.0", - "symfony/framework-bundle": "^4.4|^5.0|^6.0", - "symfony/http-kernel": "^4.4|^5.0|^6.0" - }, - "conflict": { - "doctrine/doctrine-cache-bundle": "<1.3.1", - "doctrine/persistence": "<1.3" - }, - "require-dev": { - "doctrine/dbal": "^2.10|^3.0", - "doctrine/doctrine-bundle": "^1.11|^2.0", - "doctrine/orm": "^2.5", - "symfony/browser-kit": "^4.4|^5.0|^6.0", - "symfony/doctrine-bridge": "^4.4|^5.0|^6.0", - "symfony/dom-crawler": "^4.4|^5.0|^6.0", - "symfony/expression-language": "^4.4|^5.0|^6.0", - "symfony/finder": "^4.4|^5.0|^6.0", - "symfony/monolog-bridge": "^4.0|^5.0|^6.0", - "symfony/monolog-bundle": "^3.2", - "symfony/phpunit-bridge": "^4.4.9|^5.0.9|^6.0", - "symfony/security-bundle": "^4.4|^5.0|^6.0", - "symfony/twig-bundle": "^4.4|^5.0|^6.0", - "symfony/yaml": "^4.4|^5.0|^6.0", - "twig/twig": "^1.34|^2.4|^3.0" - }, - "type": "symfony-bundle", - "extra": { - "branch-alias": { - "dev-master": "6.1.x-dev" - } - }, - "autoload": { - "psr-4": { - "Sensio\\Bundle\\FrameworkExtraBundle\\": "src/" - }, - "exclude-from-classmap": [ - "/tests/" - ] - }, - "notification-url": "https://packagist.org/downloads/", - "license": [ - "MIT" - ], - "authors": [ - { - "name": "Fabien Potencier", - "email": "fabien@symfony.com" - } - ], - "description": "This bundle provides a way to configure your controllers with annotations", - "keywords": [ - "annotations", - "controllers" - ], - "support": { - "source": "https://github.com/sensiolabs/SensioFrameworkExtraBundle/tree/v6.2.10" - }, - "abandoned": "Symfony", - "time": "2023-02-24T14:57:12+00:00" - }, { "name": "symfony/apache-pack", "version": "v1.0.1", @@ -7268,16 +7189,16 @@ }, { "name": "phpunit/php-code-coverage", - "version": "9.2.28", + "version": "9.2.29", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/php-code-coverage.git", - "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef" + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", - "reference": "7134a5ccaaf0f1c92a4f5501a6c9f98ac4dcc0ef", + "url": "https://api.github.com/repos/sebastianbergmann/php-code-coverage/zipball/6a3a87ac2bbe33b25042753df8195ba4aa534c76", + "reference": "6a3a87ac2bbe33b25042753df8195ba4aa534c76", "shasum": "" }, "require": { @@ -7334,7 +7255,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/php-code-coverage/issues", "security": "https://github.com/sebastianbergmann/php-code-coverage/security/policy", - "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.28" + "source": "https://github.com/sebastianbergmann/php-code-coverage/tree/9.2.29" }, "funding": [ { @@ -7342,7 +7263,7 @@ "type": "github" } ], - "time": "2023-09-12T14:36:20+00:00" + "time": "2023-09-19T04:57:46+00:00" }, { "name": "phpunit/php-file-iterator", @@ -7587,16 +7508,16 @@ }, { "name": "phpunit/phpunit", - "version": "9.6.12", + "version": "9.6.13", "source": { "type": "git", "url": "https://github.com/sebastianbergmann/phpunit.git", - "reference": "a122c2ebd469b751d774aa0f613dc0d67697653f" + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/a122c2ebd469b751d774aa0f613dc0d67697653f", - "reference": "a122c2ebd469b751d774aa0f613dc0d67697653f", + "url": "https://api.github.com/repos/sebastianbergmann/phpunit/zipball/f3d767f7f9e191eab4189abe41ab37797e30b1be", + "reference": "f3d767f7f9e191eab4189abe41ab37797e30b1be", "shasum": "" }, "require": { @@ -7670,7 +7591,7 @@ "support": { "issues": "https://github.com/sebastianbergmann/phpunit/issues", "security": "https://github.com/sebastianbergmann/phpunit/security/policy", - "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.12" + "source": "https://github.com/sebastianbergmann/phpunit/tree/9.6.13" }, "funding": [ { @@ -7686,7 +7607,7 @@ "type": "tidelift" } ], - "time": "2023-09-12T14:39:31+00:00" + "time": "2023-09-19T05:39:22+00:00" }, { "name": "sebastian/cli-parser", @@ -9473,6 +9394,8 @@ "platform": { "php": ">=8.1", "ext-ctype": "*", + "ext-curl": "*", + "ext-ftp": "*", "ext-iconv": "*" }, "platform-dev": [], diff --git a/config/bundles.php b/config/bundles.php index 23af7f3..2085fcc 100644 --- a/config/bundles.php +++ b/config/bundles.php @@ -11,6 +11,5 @@ return [ Symfony\Bundle\MakerBundle\MakerBundle::class => ['dev' => true], Symfony\Bundle\SecurityBundle\SecurityBundle::class => ['all' => true], Nelmio\CorsBundle\NelmioCorsBundle::class => ['all' => true], - Sensio\Bundle\FrameworkExtraBundle\SensioFrameworkExtraBundle::class => ['all' => true], ApiPlatform\Symfony\Bundle\ApiPlatformBundle::class => ['all' => true], ]; diff --git a/config/packages/sensio_framework_extra.yaml b/config/packages/sensio_framework_extra.yaml deleted file mode 100644 index 1821ccc..0000000 --- a/config/packages/sensio_framework_extra.yaml +++ /dev/null @@ -1,3 +0,0 @@ -sensio_framework_extra: - router: - annotations: false diff --git a/src/ApiResource/.gitignore b/src/ApiResource/.gitignore new file mode 100644 index 0000000..e69de29 diff --git a/src/Command/HiltesImportCommand.php b/src/Command/HiltesImportCommand.php index 6b801b6..d53170c 100644 --- a/src/Command/HiltesImportCommand.php +++ b/src/Command/HiltesImportCommand.php @@ -65,8 +65,6 @@ class HiltesImportCommand extends Command return Command::FAILURE; }else{ $io->info('Start Hiltes Push JTL'); -// $pushStock = new SwPushStockCommand($this->productRepository,$this->logger); -// $pushStock->execute($input,$output); $jtl = new JtlExportCommand($this->productRepository,$this->stockRepository,$this->warehouseRepository,$this->logger); $jtl->execute($input,$output); diff --git a/src/Helper/Ftp.php b/src/Helper/Ftp.php index c9cf55b..082b2f9 100644 --- a/src/Helper/Ftp.php +++ b/src/Helper/Ftp.php @@ -1,8 +1,101 @@ setHost($_ENV['FTP_HOST']); + $this->setPort((int)$_ENV['FTP_PORT']); + $this->setUser($_ENV['FTP_USER']); + $this->setPassword($_ENV['FTP_PASSWORD']); + + $this->setRemoteDir($_ENV['FTP_REMOTE_DIR']); + + } + + public function getHost(): string + { + return $this->host; + } + + public function setHost(string $host): void + { + $this->host = $host; + } + public function getPort(): int + { + return $this->port; + } + + public function setPort(int $port): void + { + $this->port = $port; + } + + public function getUser(): string + { + return $this->user; + } + + public function setUser(string $user): void + { + $this->user = $user; + } + + public function getPassword(): string + { + return $this->password; + } + + public function setPassword(string $password): void + { + $this->password = $password; + } + + public function getRemoteDir(): string + { + return $this->remoteDir; + } + + public function setRemoteDir(string $remoteDir): void + { + $this->remoteDir = $remoteDir; + } + + /** + * @param string $localFile + * @return bool + */ + public function uploadFile(string $localFile): bool + { + #dd(array($localFile,$this->getHost(),$this->getUser(), $this->getPassword(),$this->getRemoteDir())); + $sftp = new SFTP($this->getHost(),$this->getPort()); + $sftp_login = $sftp->login($this->getUser(), $this->getPassword()); + //dump(array('$sftp_login'=>$sftp_login,'Line'=>__LINE__,'Method'=>__METHOD__)); + $remoteFile = 'order_'.date('YmdHis').'.csv'; + if($sftp_login){ + $r = $sftp->put($this->getRemoteDir().$remoteFile.'.tmp', $localFile, SFTP::SOURCE_LOCAL_FILE); + //dump(array('$r'=>$r,$this->getRemoteDir().$remoteFile, $localFile,'Line'=>__LINE__)); + if($r){ + if($sftp->rename($this->getRemoteDir().$remoteFile.'.tmp',$this->getRemoteDir().$remoteFile)) + return unlink($localFile); # löschen der datei + else + return false; + }else + return false; + } + + return false; + + } } \ No newline at end of file diff --git a/src/Helper/HiltesImport.php b/src/Helper/HiltesImport.php index 2a66675..b723379 100644 --- a/src/Helper/HiltesImport.php +++ b/src/Helper/HiltesImport.php @@ -47,6 +47,8 @@ class HiltesImport $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{ @@ -56,7 +58,7 @@ class HiltesImport } dump("Imported $count stocks"); //remove fertig file - unlink($this->currentDirPath.'/hiltes/h2c/WS.FERTIG'); + //unlink($this->currentDirPath.'/hiltes/h2c/WS.FERTIG'); }else return array('success'=>1,'text'=>'No Files'); diff --git a/symfony.lock b/symfony.lock index 0759f6a..8afdd7e 100644 --- a/symfony.lock +++ b/symfony.lock @@ -74,18 +74,6 @@ "tests/bootstrap.php" ] }, - "sensio/framework-extra-bundle": { - "version": "6.2", - "recipe": { - "repo": "github.com/symfony/recipes", - "branch": "main", - "version": "5.2", - "ref": "fb7e19da7f013d0d422fa9bce16f5c510e27609b" - }, - "files": [ - "config/packages/sensio_framework_extra.yaml" - ] - }, "symfony/apache-pack": { "version": "1.0", "recipe": {