From 440c9965fd438b2d782819b3531577dc0ed7724f Mon Sep 17 00:00:00 2001 From: ZiWei <131428629+ZiWei09@users.noreply.github.com> Date: Thu, 18 Dec 2025 11:40:59 +0800 Subject: [PATCH] =?UTF-8?q?fix=EF=BC=9A=E8=87=AA=E5=8A=A8=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=89=A9=E6=96=99=E7=BC=93=E5=AD=98=E5=8A=9F=E8=83=BD?= =?UTF-8?q?=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=89=A9=E6=96=99=E6=97=B6=E6=9B=B4?= =?UTF-8?q?=E6=96=B0=E7=BC=93=E5=AD=98=E5=B9=B6=E5=9C=A8=E5=88=A0=E9=99=A4?= =?UTF-8?q?=E6=97=B6=E7=A7=BB=E9=99=A4=E7=BC=93=E5=AD=98=E9=A1=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../workstation/bioyond_studio/bioyond_rpc.py | 20 ++++++++++++++++++- 1 file changed, 19 insertions(+), 1 deletion(-) diff --git a/unilabos/devices/workstation/bioyond_studio/bioyond_rpc.py b/unilabos/devices/workstation/bioyond_studio/bioyond_rpc.py index afd515a..d7f63bf 100644 --- a/unilabos/devices/workstation/bioyond_studio/bioyond_rpc.py +++ b/unilabos/devices/workstation/bioyond_studio/bioyond_rpc.py @@ -176,7 +176,17 @@ class BioyondV1RPC(BaseRequest): return {} print(f"add material data: {response['data']}") - return response.get("data", {}) + + # 自动更新缓存 + data = response.get("data", {}) + if data: + name = data.get("name") or params.get("name") + mat_id = data.get("id") + if name and mat_id: + self.material_cache[name] = mat_id + print(f"已自动更新缓存: {name} -> {mat_id}") + + return data def query_matial_type_id(self, data) -> list: """查找物料typeid""" @@ -273,6 +283,14 @@ class BioyondV1RPC(BaseRequest): if not response or response['code'] != 1: return {} + + # 自动更新缓存 - 移除被删除的物料 + for name, mid in list(self.material_cache.items()): + if mid == material_id: + del self.material_cache[name] + print(f"已从缓存移除物料: {name}") + break + return response.get("data", {}) def material_outbound(self, material_id: str, location_name: str, quantity: int) -> dict: