added augmented mode to label scanner to use vendor labels for part lookup to see part storage location quickly

This commit is contained in:
swdee 2026-01-16 22:42:20 +13:00
parent 7900d309c5
commit 1571e7565e
7 changed files with 444 additions and 81 deletions

View file

@ -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;
}
}
}