add fixed export
Some checks failed
continuous-integration/drone/push Build is failing

This commit is contained in:
Marko
2023-11-23 16:54:04 +01:00
parent 231e9390b8
commit 6e98fca7ad
13 changed files with 101 additions and 158 deletions

View File

@@ -53,12 +53,13 @@ class HiltesExportCommand extends Command
if (!$l) {
dd('Login faild' . 'STOP ' . __METHOD__ . ' / ' . __LINE__);
}
$orders = $this->orderRepository->findAll();
#dump($orders);
/**
* @var Order
*/
$order = false;
$orders = $this->orderRepository->findAll();
#dump($orders);
foreach ($orders as $order) {
if ($order->getStatus() > 0) continue;
$tA = $order->getData();#json_decode($order->getData());

View File

@@ -57,7 +57,7 @@ class HiltesImportCommand extends Command
$hiltesImport = new HiltesImport($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger);
$r = $hiltesImport->startImport($input->getOption('delta'));
$hiltesImport->startImport($input->getOption('delta'));
if (isset($r['error'])) {
$io->error($r['text']);
@@ -67,7 +67,9 @@ class HiltesImportCommand extends Command
$io->info('Start Hiltes Push JTL');
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger);
$jtl->createExportFile($jtl->getProducts());
$jtl->createExportFile($jtl->getProducts(0), 'standard');
$jtl->createExportFile($jtl->getProducts(8), 'wms');
$io->success('Done.');
return Command::SUCCESS;

View File

@@ -51,18 +51,6 @@ class JtlExportCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
// $arg1 = $input->getArgument('arg1');
//
// if ($arg1) {
// $io->note(sprintf('You passed an argument: %s', $arg1));
// }
//
// if ($input->getOption('option1')) {
// // ...
// }
$io = new SymfonyStyle($input, $output);
$io->success('Start JTL Export');
/**

View File

@@ -1,57 +0,0 @@
<?php
namespace App\Command;
use Symfony\Component\Console\Attribute\AsCommand;
use Symfony\Component\Console\Command\Command;
use Symfony\Component\Console\Input\InputArgument;
use Symfony\Component\Console\Input\InputInterface;
use Symfony\Component\Console\Input\InputOption;
use Symfony\Component\Console\Output\OutputInterface;
use Symfony\Component\Console\Style\SymfonyStyle;
use Symfony\Component\Notifier\Chatter;
use Symfony\Component\Notifier\Message\ChatMessage;
use Symfony\Component\Notifier\Transport;
#[AsCommand(
name: 'jtl:import',
description: 'Add a short description for your command',
)]
class JtlImportCommand extends Command
{
protected function configure(): void
{
$this
->addArgument('arg1', InputArgument::OPTIONAL, 'Argument description')
->addOption('option1', null, InputOption::VALUE_NONE, 'Option description');
}
protected function execute(InputInterface $input, OutputInterface $output): int
{
$io = new SymfonyStyle($input, $output);
$arg1 = $input->getArgument('arg1');
if ($arg1) {
$io->note(sprintf('You passed an argument: %s', $arg1));
}
if ($input->getOption('option1')) {
// ...
}
$chatter = new Chatter(new Transport('xoxb-1234-56789abcdefghijklmnopqrstuv'));
$message = (new ChatMessage('You got a new invoice for 15 EUR.'))
// if not set explicitly, the message is sent to the
// default transport (the first one configured)
->transport('slack');
$sentMessage = $chatter->send($message);
$io->success('You have a new command! Now make it your own! Pass --help to see your options.');
return Command::SUCCESS;
}
}

View File

@@ -31,19 +31,19 @@ class Hiltes
$this->hiltesPass = $_ENV['HILTES_API_PASS'];
}
public function import()
{
$finder = new Finder();
$finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
foreach ($finder as $file) {
$contents = $file->getContents();
//var_dump($contents);
}
}
// public function import()
// {
//
// $finder = new Finder();
// $finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
//
// foreach ($finder as $file) {
// $contents = $file->getContents();
//
// //var_dump($contents);
// }
//
// }
/**
* @param string $data
@@ -84,13 +84,14 @@ class Hiltes
public function createRequest($orderData)
{
$data = array();
$this->loginToHiltes('', '');
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
/**
* @var Order
*/
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
if ($order) {
//foreach ($orders as $order) {
if ($order->getStatus() != 2) return false;
@@ -116,9 +117,12 @@ class Hiltes
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
$tSalNr = array();
foreach ($tA['positions'] as $v) {
if ($v['type'] == 'versandposition') {
$SalesNumber = '000001';
$SalesGoodsGroupNumber = 9350;
if ($v['type'] == 'versandposition' || $v['sku'] == '') {
// $SalesNumber = '000001';
// $SalesGoodsGroupNumber = 9350;
// Versandkosten werden nicht übermittelt
continue;
} else {
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) {

View File

@@ -40,7 +40,7 @@ class HiltesImport
/**
* @return array|void
* @return void
*/
public function startImport($delta = false)
{
@@ -182,10 +182,8 @@ class HiltesImport
$warehouse->setId((int)$warehouseName);
$warehouse->setName($warehouseName);
$this->warehouseRepository->save($warehouse, true);
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
} else {
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
}
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
}
if (!empty($this->cachedWarehouseIds[$warehouseName])) {

View File

@@ -42,15 +42,19 @@ class Jtl
* Holt alle Produkte und deren Lagerbestände
* @return array
*/
public function getProducts(): array
public function getProducts(int $warehouseId): array
{
$r = $this->productRepository->findAll();
$data = array();
foreach ($r as $product) {
$stock = $this->stockRepository->findBy(['product_id' => $product->getId()]);
if ($warehouseId != 0) {
$stock = $this->stockRepository->findBy(['product_id' => $product->getId(), 'warehouse_id' => $warehouseId]);
} else {
$stock = $this->stockRepository->findBy(['product_id' => $product->getId()]);
}
if ($stock) {
foreach ($stock as $s) {
@@ -83,17 +87,17 @@ class Jtl
* @param $data
* @return void
*/
public function createExportFile($data): void
public function createExportFile($data, $warehouse): void
{
try {
$writer = Writer::createFromPath(getcwd() . '/www/jtl/cds-export.csv', 'w+');
$writer = Writer::createFromPath(getcwd() . '/www/jtl/' . $warehouse . '.csv', 'w+');
$bytes = $writer->insertAll(new ArrayIterator($data));
if ($bytes) {
$this->logger->info('Exported ' . $bytes . ' bytes');
$FTP = new Ftp();
$FTP->uploadFile(getcwd() . '/www/jtl/cds-export.csv');
$FTP->uploadFile(getcwd() . '/www/jtl/' . $warehouse . '.csv');
}
} catch (Exception $e) {

View File

@@ -1,30 +0,0 @@
<?php
namespace App\Helper;
use Symfony\Component\Notifier\ChatterInterface;
use Symfony\Component\Notifier\Exception\TransportExceptionInterface;
use Symfony\Component\Notifier\Message\ChatMessage;
class Slack
{
private $chatter;
public function __construct(ChatterInterface $chatter)
{
$this->chatter = $chatter;
}
public function sendMessage(string $message): void
{
$message = (new ChatMessage($message))
->transport('slack');
try {
$sentMessage = $this->chatter->send($message);
} catch (TransportExceptionInterface $e) {
}
}
}