From fd737311308041fb5ecd0d2995448597c0a3eff2 Mon Sep 17 00:00:00 2001 From: calvincao Date: Thu, 23 Oct 2025 18:02:49 +0800 Subject: [PATCH] =?UTF-8?q?=E5=A2=9E=E5=BC=BA=E6=89=B9=E9=87=8F=E5=85=A5?= =?UTF-8?q?=E5=BA=93=E5=8A=9F=E8=83=BD=EF=BC=8C=E6=B7=BB=E5=8A=A0=E7=89=A9?= =?UTF-8?q?=E6=96=99=E6=95=B0=E6=8D=AE=E5=90=8C=E6=AD=A5=E9=80=BB=E8=BE=91?= =?UTF-8?q?=EF=BC=9B=E4=BC=98=E5=8C=96=E6=97=A5=E5=BF=97=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=E4=BB=A5=E6=8F=90=E4=BE=9B=E6=9B=B4=E8=AF=A6=E7=BB=86=E7=9A=84?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E7=8A=B6=E6=80=81=E4=BF=A1=E6=81=AF=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../bioyond_cell/bioyond_cell_workstation.py | 37 ++++++++++++++++++- 1 file changed, 35 insertions(+), 2 deletions(-) diff --git a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py index 4a343e71..3e4fcce1 100644 --- a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py +++ b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/bioyond_cell_workstation.py @@ -1007,9 +1007,42 @@ class BioyondCellWorkstation(BioyondWorkstation): logger.info(f"\n正在执行批量入库,共 {len(inbound_items)} 条记录...") result = self.storage_batch_inbound(inbound_items) - if result.get("code") == 1: + inbound_success = result.get("code") == 1 + + if inbound_success: logger.info(f"✓ 批量入库成功!") logger.info(f" 响应数据: {result.get('data', {})}") + + # 步骤3: 同步物料数据 + logger.info(f"\n【步骤3/3】同步物料数据到系统...") + if hasattr(self, 'resource_synchronizer') and self.resource_synchronizer: + try: + # 尝试同步不同类型的物料 + # typeMode: 0=耗材, 1=样品, 2=试剂 + sync_success = False + for type_mode in [0, 1, 2]: + try: + logger.info(f" 尝试同步 typeMode={type_mode} 的物料...") + bioyond_data = self.hardware_interface.stock_material( + f'{{"typeMode": {type_mode}, "includeDetail": true}}' + ) + if bioyond_data: + logger.info(f" ✓ 获取到 {len(bioyond_data) if isinstance(bioyond_data, list) else 1} 条物料数据") + sync_success = True + except Exception as e: + logger.debug(f" typeMode={type_mode} 同步失败: {e}") + continue + + if sync_success: + logger.info(f"✓ 物料数据同步完成") + else: + logger.warning(f"⚠ 物料数据同步未获取到数据(这是正常的,新创建的物料可能需要时间才能查询到)") + + except Exception as e: + logger.warning(f"⚠ 物料数据同步出错: {e}") + logger.info(f" 提示:新创建的物料已成功入库,同步失败不影响使用") + else: + logger.warning("⚠ 资源同步器未初始化,跳过同步") else: logger.error(f"✗ 批量入库失败!") logger.error(f" 响应: {result}") @@ -1019,7 +1052,7 @@ class BioyondCellWorkstation(BioyondWorkstation): logger.info("=" * 60 + "\n") return { - "success": result.get("code") == 1, + "success": inbound_success, "created_materials": created_materials, "inbound_result": result, "total_created": len(created_materials),