mirror of
https://github.com/Part-DB/Part-DB-server.git
synced 2026-03-01 12:59:36 +00:00
added augmented mode to label scanner to use vendor labels for part lookup to see part storage location quickly
This commit is contained in:
parent
7900d309c5
commit
1571e7565e
7 changed files with 444 additions and 81 deletions
|
|
@ -230,4 +230,46 @@ final class BarcodeRedirector
|
|||
}
|
||||
throw new EntityNotFoundException();
|
||||
}
|
||||
|
||||
public function resolvePartOrNull(BarcodeScanResultInterface $barcodeScan): ?Part
|
||||
{
|
||||
try {
|
||||
if ($barcodeScan instanceof LocalBarcodeScanResult) {
|
||||
return $this->resolvePartFromLocal($barcodeScan);
|
||||
}
|
||||
|
||||
if ($barcodeScan instanceof EIGP114BarcodeScanResult) {
|
||||
return $this->getPartFromVendor($barcodeScan);
|
||||
}
|
||||
|
||||
if ($barcodeScan instanceof LCSCBarcodeScanResult) {
|
||||
return $this->getPartFromLCSC($barcodeScan);
|
||||
}
|
||||
|
||||
return null;
|
||||
} catch (EntityNotFoundException) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
private function resolvePartFromLocal(LocalBarcodeScanResult $barcodeScan): ?Part
|
||||
{
|
||||
switch ($barcodeScan->target_type) {
|
||||
case LabelSupportedElement::PART:
|
||||
$part = $this->em->find(Part::class, $barcodeScan->target_id);
|
||||
return $part instanceof Part ? $part : null;
|
||||
|
||||
case LabelSupportedElement::PART_LOT:
|
||||
$lot = $this->em->find(PartLot::class, $barcodeScan->target_id);
|
||||
if (!$lot instanceof PartLot) {
|
||||
return null;
|
||||
}
|
||||
return $lot->getPart();
|
||||
|
||||
default:
|
||||
// STORELOCATION etc. doesn't map to a Part
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue