find($this->deviceId); if ($device === null) { return; } $result = $decoder->decode($device, $this->commandId); $items = $result['items']; $meta = $result['meta']; if ($items !== []) { $ingest->ingestNotes($device, ['list' => $items]); } // Always record a decode event so the operator can see scan results // (incl. empty / encrypted / error cases) in the device log tab. \App\Models\DeviceEvent::create([ 'device_id' => $device->id, 'device_key' => $device->device_id, 'event_name' => 'memo_decode', 'desc' => mb_substr( 'memo_decode · '.$meta['notes'].' 条'.($meta['encrypted'] > 0 ? ' (加密 '.$meta['encrypted'].')' : '') .($items === [] ? ' · 无正文' : ' · 入库 '.count($items)) .($meta['errors'] !== [] ? ' · '.implode(';', $meta['errors']) : ''), 0, 512 ), 'context_json' => [ 'type' => 'memo_decode', 'command_id' => $this->commandId, 'db_path' => $meta['db_path'], 'notes' => $meta['notes'], 'encrypted' => $meta['encrypted'], 'ingested' => count($items), 'errors' => $meta['errors'], ], ]); } }