mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2025-06-21 09:35:49 +02:00
Fixed various Partkeepr import issues
On Linux mysql table names can contain uppercase characters, and we expect always lowercase character, so we now normalize the tablenames to lowercase. Also fixed some type errors on part parameters and improved performace for orderdetails import. This fixes issue #286
This commit is contained in:
parent
4a6a3b9269
commit
1c836918ca
2 changed files with 23 additions and 6 deletions
|
@ -69,7 +69,10 @@ class MySQLDumpXMLConverter
|
|||
|
||||
//Iterate over all <table> nodes and convert them to arrays
|
||||
foreach ($tables as $table) {
|
||||
$table_data[$table->getAttribute('name')] = $this->convertTableToArray($table);
|
||||
//Normalize the table name to lowercase. On Linux filesystems the tables sometimes contain uppercase letters
|
||||
//However we expect the table names to be lowercase in the further steps
|
||||
$table_name = strtolower($table->getAttribute('name'));
|
||||
$table_data[$table_name] = $this->convertTableToArray($table);
|
||||
}
|
||||
|
||||
return $table_data;
|
||||
|
|
|
@ -168,11 +168,21 @@ class PKPartImporter
|
|||
$entity->setName($name);
|
||||
|
||||
$entity->setValueText($partparameter['stringValue'] ?? '');
|
||||
$entity->setUnit($this->getUnitSymbol($data, (int) $partparameter['unit_id']));
|
||||
if ($partparameter['unit_id'] === null) {
|
||||
$entity->setUnit($this->getUnitSymbol($data, (int)$partparameter['unit_id']));
|
||||
} else {
|
||||
$entity->setUnit("");
|
||||
}
|
||||
|
||||
$entity->setValueMin($partparameter['normalizedMinValue'] ?? null);
|
||||
$entity->setValueTypical($partparameter['normalizedValue'] ?? null);
|
||||
$entity->setValueMax($partparameter['normalizedMaxValue'] ?? null);
|
||||
if ($partparameter['normalizedMinValue'] !== null) {
|
||||
$entity->setValueMin((float) $partparameter['normalizedMinValue']);
|
||||
}
|
||||
if ($partparameter['normalizedValue'] !== null) {
|
||||
$entity->setValueTypical((float) $partparameter['normalizedValue']);
|
||||
}
|
||||
if ($partparameter['normalizedMaxValue'] !== null) {
|
||||
$entity->setValueMax((float) $partparameter['normalizedMaxValue']);
|
||||
}
|
||||
|
||||
$part = $this->em->find(Part::class, (int) $partparameter['part_id']);
|
||||
if (!$part) {
|
||||
|
@ -226,6 +236,7 @@ class PKPartImporter
|
|||
$orderdetail->setSupplier($supplier);
|
||||
$orderdetail->setSupplierpartnr($spn);
|
||||
$part->addOrderdetail($orderdetail);
|
||||
$this->em->persist($orderdetail);
|
||||
}
|
||||
|
||||
//Add the price information to the orderdetail
|
||||
|
@ -236,10 +247,13 @@ class PKPartImporter
|
|||
$price_per_item = BigDecimal::of($partdistributor['price']);
|
||||
$pricedetail->setPrice($price_per_item->multipliedBy($partdistributor['packagingUnit']));
|
||||
$pricedetail->setPriceRelatedQuantity($partdistributor['packagingUnit'] ?? 1);
|
||||
|
||||
$this->em->persist($pricedetail);
|
||||
}
|
||||
|
||||
//We have to flush the changes in every loop, so the find function can find newly created entities
|
||||
$this->em->flush();
|
||||
//Clear the entity manager to improve performance
|
||||
$this->em->clear();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue