fix Hiltes import
This commit is contained in:
0
src/ApiResource/.gitignore
vendored
Normal file
0
src/ApiResource/.gitignore
vendored
Normal file
@@ -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);
|
||||
|
||||
@@ -1,8 +1,101 @@
|
||||
<?php
|
||||
|
||||
namespace App\Helper;
|
||||
use phpseclib3\Net\SFTP;
|
||||
|
||||
class Ftp
|
||||
{
|
||||
private string $host;
|
||||
private int $port;
|
||||
private string $user;
|
||||
private string $password;
|
||||
private string $remoteDir;
|
||||
|
||||
|
||||
public function __construct()
|
||||
{
|
||||
$this->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;
|
||||
|
||||
}
|
||||
}
|
||||
@@ -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');
|
||||
|
||||
Reference in New Issue
Block a user