diff --git a/test/resources/test copy.json b/test/resources/test copy.json new file mode 100644 index 00000000..f9e9aa0d --- /dev/null +++ b/test/resources/test copy.json @@ -0,0 +1,99 @@ + { + "typeId": "3a190c8b-3284-af78-d29f-9a69463ad047", + "code": "", + "barCode": "", + "name": "test", + "unit": "", + "parameters": "{}", + "quantity": "", + "details": [ + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)11", + "quantity": "1", + "x": 1, + "y": 1, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)21", + "quantity": "1", + "x": 2, + "y": 1, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)12", + "quantity": "1", + "x": 1, + "y": 2, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)22", + "quantity": "1", + "x": 2, + "y": 2, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)13", + "quantity": "1", + "x": 1, + "y": 3, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)23", + "quantity": "1", + "x": 2, + "y": 3, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)14", + "quantity": "1", + "x": 1, + "y": 4, + "z": 1, + "unit": "", + "parameters": "{}" + }, + { + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", + "code": "", + "name": "配液瓶(小)24", + "quantity": "1", + "x": 2, + "y": 4, + "z": 1, + "unit": "", + "parameters": "{}" + } + ] + } \ No newline at end of file diff --git a/test/resources/test.json b/test/resources/test.json index 9fa92372..ee1be0f1 100644 --- a/test/resources/test.json +++ b/test/resources/test.json @@ -1,191 +1,114 @@ -{ - "data": [ - { - "orderCode": "BSO2025103100006", - "orderName": "DP20250927001", - "errorMessage": null, - "usedMaterials": [ - { - "id": "3a1d4b13-25a6-cfb2-7315-159f14b32425", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-23cb-63e5-10df-6a1d38335163", - "materialId": "3a1d4b13-2467-e64d-d8bc-3957fb6e3240", - "materialName": "适配器块", - "materialCode": "0018-00065", - "quantity": "1块", - "materialTypeId": "efc3bb32-d504-4890-91c0-b64ed3ac80cf", - "materialTypeCode": "0018", - "materialTypeMode": "Consumables", - "materialTypeName": "适配器块", - "locationId": "3a1abd46-18fe-1f56-6ced-a1f7fe08e36c", - "locationCode": "0014-0001", - "locationShowName": "0014-0001" - }, - { - "id": "3a1d4b13-2420-8cfe-17f1-5f77a6ff6dc3", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-23cb-63e5-10df-6a1d38335163", - "materialId": "3a1d4b11-e448-bf90-d0bd-b20758425370", - "materialName": "test1", - "materialCode": "0001-00063", - "quantity": "1块", - "materialTypeId": "3a190c8b-3284-af78-d29f-9a69463ad047", - "materialTypeCode": "0001", - "materialTypeMode": "Sample", - "materialTypeName": "配液瓶(小)板", - "locationId": "3a19deae-2c7a-2426-6d71-e9de3cb158b1", - "locationCode": "4", - "locationShowName": "4" - }, - { - "id": "3a1d4b13-2420-73a1-2b4d-7bf6dd993c36", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-23cb-63e5-10df-6a1d38335163", - "materialId": "3a1d4b11-e448-fea3-8291-0b66ecd06d72", - "materialName": "test1", - "materialCode": "0002-00282", - "quantity": "1块", - "materialTypeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", - "materialTypeCode": "0002", - "materialTypeMode": "Sample", - "materialTypeName": "配液瓶(小)", - "locationId": "3a19deae-2c7a-2426-6d71-e9de3cb158b1", - "locationCode": "4-1/1", - "locationShowName": "4-1/1" - }, - { - "id": "3a1d4b13-2420-e45f-192d-639887ad73b7", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-23cb-63e5-10df-6a1d38335163", - "materialId": "3a1d4b12-67fc-5f91-13ed-c223d0155399", - "materialName": "test2", - "materialCode": "0010-00059", - "quantity": "1块", - "materialTypeId": "3a192fa4-007d-ec7b-456e-2a8be7a13f23", - "materialTypeCode": "0010", - "materialTypeMode": "Sample", - "materialTypeName": "5ml分液瓶板", - "locationId": "3a19deae-2c7a-79b0-5e44-efaafd1e4cf3", - "locationCode": "5", - "locationShowName": "5" - }, - { - "id": "3a1d4b13-2420-c052-93cc-002f0aae79fc", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-23cb-63e5-10df-6a1d38335163", - "materialId": "3a1d4b12-67fc-60f7-1129-3d1ef2a2d1f8", - "materialName": "test2", - "materialCode": "0007-00211", - "quantity": "1块", - "materialTypeId": "3a192c2a-ebb7-58a1-480d-8b3863bf74f4", - "materialTypeCode": "0007", - "materialTypeMode": "Sample", - "materialTypeName": "5ml分液瓶", - "locationId": "3a19deae-2c7a-79b0-5e44-efaafd1e4cf3", - "locationCode": "5-1/1", - "locationShowName": "5-1/1" - } - ] - }, - { - "orderCode": "BSO2025103100007", - "orderName": "DP20250927002", - "errorMessage": null, - "usedMaterials": [ - { - "id": "3a1d4b13-264b-aca7-9e97-ab4df186d5c2", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-260c-9239-5c8a-ecb6fd96dc86", - "materialId": "3a1d4b13-2467-e64d-d8bc-3957fb6e3240", - "materialName": "适配器块", - "materialCode": "0018-00065", - "quantity": "1块", - "materialTypeId": "efc3bb32-d504-4890-91c0-b64ed3ac80cf", - "materialTypeCode": "0018", - "materialTypeMode": "Consumables", - "materialTypeName": "适配器块", - "locationId": "3a1abd46-18fe-1f56-6ced-a1f7fe08e36c", - "locationCode": "0014-0001", - "locationShowName": "0014-0001" - }, - { - "id": "3a1d4b13-263e-873e-1331-7e668b411e98", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-260c-9239-5c8a-ecb6fd96dc86", - "materialId": "3a1d4b11-e448-bf90-d0bd-b20758425370", - "materialName": "test1", - "materialCode": "0001-00063", - "quantity": "1块", - "materialTypeId": "3a190c8b-3284-af78-d29f-9a69463ad047", - "materialTypeCode": "0001", - "materialTypeMode": "Sample", - "materialTypeName": "配液瓶(小)板", - "locationId": "3a19deae-2c7a-2426-6d71-e9de3cb158b1", - "locationCode": "4", - "locationShowName": "4" - }, - { - "id": "3a1d4b13-263e-7884-d9e0-b010478b7448", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-260c-9239-5c8a-ecb6fd96dc86", - "materialId": "3a1d4b11-e448-82e0-6a64-6230ee1bf0a9", - "materialName": "test1", - "materialCode": "0002-00283", - "quantity": "1块", - "materialTypeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb", - "materialTypeCode": "0002", - "materialTypeMode": "Sample", - "materialTypeName": "配液瓶(小)", - "locationId": "3a19deae-2c7a-2426-6d71-e9de3cb158b1", - "locationCode": "4-1/2", - "locationShowName": "4-1/2" - }, - { - "id": "3a1d4b13-263e-6e99-b513-66047191643f", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-260c-9239-5c8a-ecb6fd96dc86", - "materialId": "3a1d4b12-67fc-5f91-13ed-c223d0155399", - "materialName": "test2", - "materialCode": "0010-00059", - "quantity": "1块", - "materialTypeId": "3a192fa4-007d-ec7b-456e-2a8be7a13f23", - "materialTypeCode": "0010", - "materialTypeMode": "Sample", - "materialTypeName": "5ml分液瓶板", - "locationId": "3a19deae-2c7a-79b0-5e44-efaafd1e4cf3", - "locationCode": "5", - "locationShowName": "5" - }, - { - "id": "3a1d4b13-263e-5b21-2c41-53e4ea7fe947", - "destinationType": "TempOrder", - "destinationId": "3a1d4b13-260c-9239-5c8a-ecb6fd96dc86", - "materialId": "3a1d4b12-67fc-131a-82ff-87e9e7708f9f", - "materialName": "test2", - "materialCode": "0007-00212", - "quantity": "1块", - "materialTypeId": "3a192c2a-ebb7-58a1-480d-8b3863bf74f4", - "materialTypeCode": "0007", - "materialTypeMode": "Sample", - "materialTypeName": "5ml分液瓶", - "locationId": "3a19deae-2c7a-79b0-5e44-efaafd1e4cf3", - "locationCode": "5-1/2", - "locationShowName": "5-1/2" - } - ] - } - ], - "code": 1, - "message": "", - "timestamp": 1761891208109 -} - -25-10-31 [14:27:52,203] [ERROR] 从Bioyond同步物料数据失败: 'BottleCarrier' object has no attribute 'tracker' [sync_from_external:83] [unilabos.utils.log.station] -Traceback (most recent call last): - File "C:\ML\GitHub\Uni-Lab-OS\unilabos\devices\workstation\bioyond_studio\station.py", line 73, in sync_from_external - unilab_resources = resource_bioyond_to_plr( - ^^^^^^^^^^^^^^^^^^^^^^^^ - File "C:\ML\GitHub\Uni-Lab-OS\unilabos\resources\graphio.py", line 661, in resource_bioyond_to_plr - bottle.tracker.liquids = [ - ^^^^^^^^^^^^^^ -AttributeError: 'BottleCarrier' object has no attribute 'tracker' \ No newline at end of file +[ + { + "id": "3a1d4b7e-4bdc-16bf-7169-f60350d03c7e", + "typeName": "配液瓶(小)板", + "code": "0001-00088", + "barCode": "", + "name": "test1", + "quantity": 1.0, + "lockQuantity": 0.0, + "unit": "块", + "status": 1, + "isUse": false, + "locations": [ + { + "id": "3a19deae-2c7a-2426-6d71-e9de3cb158b1", + "whid": "3a19deae-2c79-05a3-9c76-8e6760424841", + "whName": "手动堆栈", + "code": "4", + "x": 2, + "y": 1, + "z": 1, + "quantity": 0 + } + ], + "detail": [ + { + "id": "3a1d4b7e-4bdc-12e8-4d26-dddc77b03f63", + "detailMaterialId": "3a1d4b7e-4bdc-4e9e-8a3c-e9ba4a26457e", + "code": null, + "name": "test1", + "quantity": "1", + "lockQuantity": "0", + "unit": "块", + "x": 1, + "y": 2, + "z": 1, + "associateId": null, + "typeName": "配液瓶(小)", + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb" + }, + { + "id": "3a1d4b7e-4bdc-35b6-22d4-e6f3235e1c27", + "detailMaterialId": "3a1d4b7e-4bdc-ce0f-1fbb-b88de76fce98", + "code": null, + "name": "test1", + "quantity": "1", + "lockQuantity": "0", + "unit": "块", + "x": 1, + "y": 1, + "z": 1, + "associateId": null, + "typeName": "配液瓶(小)", + "typeId": "3a190c8c-fe8f-bf48-0dc3-97afc7f508eb" + } + ] + }, + { + "id": "3a1d4b7e-ee61-ae87-9cd0-31c7e6621b18", + "typeName": "5ml分液瓶板", + "code": "0010-00089", + "barCode": "", + "name": "test2", + "quantity": 1.0, + "lockQuantity": 0.0, + "unit": "块", + "status": 1, + "isUse": false, + "locations": [ + { + "id": "3a19deae-2c7a-79b0-5e44-efaafd1e4cf3", + "whid": "3a19deae-2c79-05a3-9c76-8e6760424841", + "whName": "手动堆栈", + "code": "5", + "x": 2, + "y": 2, + "z": 1, + "quantity": 0 + } + ], + "detail": [ + { + "id": "3a1d4b7e-ee61-8fb3-9a39-2c2841c3c8d0", + "detailMaterialId": "3a1d4b7e-ee61-305c-fe30-2620017ca1bd", + "code": null, + "name": "test2", + "quantity": "1", + "lockQuantity": "0", + "unit": "块", + "x": 1, + "y": 1, + "z": 1, + "associateId": null, + "typeName": "5ml分液瓶", + "typeId": "3a192c2a-ebb7-58a1-480d-8b3863bf74f4" + }, + { + "id": "3a1d4b7e-ee61-ef5f-a7d1-f9399a4d3145", + "detailMaterialId": "3a1d4b7e-ee61-2f1d-6969-202ad3cbe226", + "code": null, + "name": "test2", + "quantity": "1", + "lockQuantity": "0", + "unit": "块", + "x": 1, + "y": 2, + "z": 1, + "associateId": null, + "typeName": "5ml分液瓶", + "typeId": "3a192c2a-ebb7-58a1-480d-8b3863bf74f4" + } + ] + } +] \ No newline at end of file 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 c40945e7..092a87fe 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 @@ -968,7 +968,7 @@ class BioyondCellWorkstation(BioyondWorkstation): logger.error(f"✗ 执行失败: {e}") return {"success": False, "error": str(e)} -def create_material( + def create_material( self, material_name: str, type_id: str, @@ -985,8 +985,7 @@ def create_material( 包含创建结果、物料ID以及入库结果的字典。 """ material_name = (material_name or "").strip() - if not material_name: - raise ValueError("material_name 不能为空") + resolved_type_id = (type_id or "").strip() # 优先从 SOLID_LIQUID_MAPPINGS 中获取模板数据 template = SOLID_LIQUID_MAPPINGS.get(material_name) @@ -1082,14 +1081,68 @@ def create_material( } -# -------------------------------- + def create_sample( + self, + name: str, + board_type: str, + bottle_type: str, + location_code: str + ) -> Dict[str, Any]: + """创建配液板物料并自动入库。 + Args: + material_name: 物料名称,支持 "5ml分液瓶板"/"5ml分液瓶"、"配液瓶(小)板"/"配液瓶(小)"。 + quantity: 主物料与明细的数量,默认 1。 + location_code: 库位编号,例如 "A01",将自动映射为 "手动堆栈" 下的 UUID。 + """ + carrier_type_id = MATERIAL_TYPE_MAPPINGS[board_type][1] + bottle_type_id = MATERIAL_TYPE_MAPPINGS[bottle_type][1] + location_id = WAREHOUSE_MAPPING["手动堆栈"]["site_uuids"][location_code] + + # 新建小瓶 + details = [] + for y in range(1, 5): + for x in range(1, 3): + details.append({ + "typeId": bottle_type_id, + "code": "", + "name": str(bottle_type) + str(x) + str(y), + "quantity": "1", + "x": x, + "y": y, + "z": 1, + "unit": "个", + "parameters": json.dumps({"unit": "个"}, ensure_ascii=False), + }) + + data = { + "typeId": carrier_type_id, + "code": "", + "barCode": "", + "name": name, + "unit": "块", + "parameters": json.dumps({"unit": "块"}, ensure_ascii=False), + "quantity": "1", + "details": details, + } + # print("xxx:",data) + create_result = self._post_lims("/api/lims/storage/material", data) + sample_uuid = create_result.get("data") + + final_result = self._post_lims("/api/lims/storage/inbound", { + "materialId": sample_uuid, + "locationId": location_id, + }) + return final_result + + if __name__ == "__main__": lab_registry.setup() ws = BioyondCellWorkstation() + ws.create_sample(name="test", board_type="配液瓶(小)板", bottle_type="配液瓶(小)", location_code="B01") # logger.info(ws.scheduler_stop()) - logger.info(ws.scheduler_start()) + # logger.info(ws.scheduler_start()) # results = ws.create_materials(SOLID_LIQUID_MAPPINGS) # for r in results: @@ -1098,11 +1151,11 @@ if __name__ == "__main__": # result = ws.create_and_inbound_materials() # 继续后续流程 - logger.info(ws.auto_feeding4to3()) #搬运物料到3号箱 - # # 使用正斜杠或 Path 对象来指定文件路径 - excel_path = Path("unilabos\\devices\\workstation\\bioyond_studio\\bioyond_cell\\2025092701.xlsx") - logger.info(ws.create_orders(excel_path)) - logger.info(ws.transfer_3_to_2_to_1()) + # logger.info(ws.auto_feeding4to3()) #搬运物料到3号箱 + # # # 使用正斜杠或 Path 对象来指定文件路径 + # excel_path = Path("unilabos\\devices\\workstation\\bioyond_studio\\bioyond_cell\\2025092701.xlsx") + # logger.info(ws.create_orders(excel_path)) + # logger.info(ws.transfer_3_to_2_to_1()) # logger.info(ws.transfer_1_to_2()) # logger.info(ws.scheduler_start()) diff --git a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx index 844fc84d..abaf145e 100644 Binary files a/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx and b/unilabos/devices/workstation/bioyond_studio/bioyond_cell/material_template.xlsx differ