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
No known key found for this signature in database
13 changed files with 101 additions and 158 deletions

View File

@ -0,0 +1,19 @@
name: Qodana
on:
workflow_dispatch:
pull_request:
push:
branches:
- master
jobs:
qodana:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: 'Qodana Scan'
uses: JetBrains/qodana-action@v2023.2
env:
QODANA_TOKEN: ${{ secrets.QODANA_TOKEN }}

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="5149739e-7c31-440b-a2ab-9c77c78be0cd"> <data-source source="LOCAL" name="DDEV" uuid="7b0f1ac1-319c-4672-b16e-eb385d06e6e9">
<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:55034/db?user=db&amp;password=db</jdbc-url> <jdbc-url>jdbc:mariadb://127.0.0.1:55000/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

@ -17,9 +17,9 @@ services:
image: adminer image: adminer
restart: always restart: always
ports: ports:
- 8080:8080 - "8080:8080"
###> doctrine/doctrine-bundle ### ###> doctrine/doctrine-bundle ###
database: database:
image: postgres:${POSTGRES_VERSION:-15}-alpine image: postgres:${POSTGRES_VERSION:-15}-alpine
environment: environment:
@ -34,6 +34,6 @@ services:
###< doctrine/doctrine-bundle ### ###< doctrine/doctrine-bundle ###
volumes: volumes:
###> doctrine/doctrine-bundle ### ###> doctrine/doctrine-bundle ###
database_data: database_data:
###< doctrine/doctrine-bundle ### ###< doctrine/doctrine-bundle ###

34
qodana.yaml Normal file
View File

@ -0,0 +1,34 @@
#-------------------------------------------------------------------------------#
# Qodana analysis is configured by qodana.yaml file #
# https://www.jetbrains.com/help/qodana/qodana-yaml.html #
#-------------------------------------------------------------------------------#
version: "1.0"
#Specify inspection profile for code analysis
profile:
name: qodana.starter
#Enable inspections
#include:
# - name: <SomeEnabledInspectionId>
#Disable inspections
#exclude:
# - name: <SomeDisabledInspectionId>
# paths:
# - <path/where/not/run/inspection>
php:
version: 8.1 #(Applied in CI/CD pipeline)
#Execute shell command before Qodana execution (Applied in CI/CD pipeline)
#bootstrap: sh ./prepare-qodana.sh
#Install IDE plugins before Qodana execution (Applied in CI/CD pipeline)
#plugins:
# - id: <plugin.id> #(plugin id can be found at https://plugins.jetbrains.com)
#Specify Qodana linter for analysis (Applied in CI/CD pipeline)
linter: jetbrains/qodana-php:latest
include:
- name: PhpRedundantOptionalArgumentInspection
- name: PhpUnhandledExceptionInspection
- name: PhpReturnDocTypeMismatchInspection
- name: PhpUnusedLocalVariableInspection
exclude:
- name: All
paths:
- public

View File

@ -53,12 +53,13 @@ class HiltesExportCommand extends Command
if (!$l) { if (!$l) {
dd('Login faild' . 'STOP ' . __METHOD__ . ' / ' . __LINE__); dd('Login faild' . 'STOP ' . __METHOD__ . ' / ' . __LINE__);
} }
$orders = $this->orderRepository->findAll();
#dump($orders);
/** /**
* @var Order * @var Order
*/ */
$order = false; $orders = $this->orderRepository->findAll();
#dump($orders);
foreach ($orders as $order) { foreach ($orders as $order) {
if ($order->getStatus() > 0) continue; if ($order->getStatus() > 0) continue;
$tA = $order->getData();#json_decode($order->getData()); $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); $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'])) { if (isset($r['error'])) {
$io->error($r['text']); $io->error($r['text']);
@ -67,7 +67,9 @@ class HiltesImportCommand extends Command
$io->info('Start Hiltes Push JTL'); $io->info('Start Hiltes Push JTL');
$jtl = new Jtl($this->productRepository, $this->warehouseRepository, $this->stockRepository, $this->logger); $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.'); $io->success('Done.');
return Command::SUCCESS; return Command::SUCCESS;

View File

@ -51,18 +51,6 @@ class JtlExportCommand extends Command
protected function execute(InputInterface $input, OutputInterface $output): int protected function execute(InputInterface $input, OutputInterface $output): int
{ {
$io = new SymfonyStyle($input, $output); $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'); $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']; $this->hiltesPass = $_ENV['HILTES_API_PASS'];
} }
public function import() // public function import()
{ // {
//
$finder = new Finder(); // $finder = new Finder();
$finder->files()->in($this->current_dir_path . "/hiltes/h2c/"); // $finder->files()->in($this->current_dir_path . "/hiltes/h2c/");
//
foreach ($finder as $file) { // foreach ($finder as $file) {
$contents = $file->getContents(); // $contents = $file->getContents();
//
//var_dump($contents); // //var_dump($contents);
} // }
//
} // }
/** /**
* @param string $data * @param string $data
@ -84,13 +84,14 @@ class Hiltes
public function createRequest($orderData) public function createRequest($orderData)
{ {
$data = array();
$this->loginToHiltes('', ''); $this->loginToHiltes('', '');
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
/** /**
* @var Order * @var Order
*/ */
$order = $this->orderRepository->findOneBy(array('orderId' => $orderData->getOrderId()));
if ($order) { if ($order) {
//foreach ($orders as $order) { //foreach ($orders as $order) {
if ($order->getStatus() != 2) return false; if ($order->getStatus() != 2) return false;
@ -116,9 +117,12 @@ class Hiltes
# "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis # "AchievedSalesPrice" => 0, #X Erzielter Verkaufspreis
$tSalNr = array(); $tSalNr = array();
foreach ($tA['positions'] as $v) { foreach ($tA['positions'] as $v) {
if ($v['type'] == 'versandposition') { if ($v['type'] == 'versandposition' || $v['sku'] == '') {
$SalesNumber = '000001'; // $SalesNumber = '000001';
$SalesGoodsGroupNumber = 9350; // $SalesGoodsGroupNumber = 9350;
// Versandkosten werden nicht übermittelt
continue;
} else { } else {
$SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']); $SalesNumber = (!empty($v['gtin']) ? $v['gtin'] : $v['sku']);
if (preg_match('/^([0-9]+)_/', $SalesNumber, $tP)) { 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) public function startImport($delta = false)
{ {
@ -182,10 +182,8 @@ class HiltesImport
$warehouse->setId((int)$warehouseName); $warehouse->setId((int)$warehouseName);
$warehouse->setName($warehouseName); $warehouse->setName($warehouseName);
$this->warehouseRepository->save($warehouse, true); $this->warehouseRepository->save($warehouse, true);
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
} else {
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
} }
$this->cachedWarehouseIds[$warehouseName] = $warehouse;
} }
if (!empty($this->cachedWarehouseIds[$warehouseName])) { if (!empty($this->cachedWarehouseIds[$warehouseName])) {

View File

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

View File

@ -1,20 +0,0 @@
{% extends 'base.html.twig' %}
{% block title %}Hello SlackController!{% endblock %}
{% block body %}
<style>
.example-wrapper { margin: 1em auto; max-width: 800px; width: 95%; font: 18px/1.5 sans-serif; }
.example-wrapper code { background: #F5F5F5; padding: 2px 6px; }
</style>
<div class="example-wrapper">
<h1>Hello {{ controller_name }}! ✅</h1>
This friendly message is coming from:
<ul>
<li>Your controller at <code><a href="{{ '/Users/markomoller/code/CdsConnector/src/Controller/SlackController.php'|file_link(0) }}">src/Controller/SlackController.php</a></code></li>
<li>Your template at <code><a href="{{ '/Users/markomoller/code/CdsConnector/templates/slack/index.html.twig'|file_link(0) }}">templates/slack/index.html.twig</a></code></li>
</ul>
</div>
{% endblock %}