From 366e81626809cc6d3f081ad4fba112db8fca8193 Mon Sep 17 00:00:00 2001 From: yuxianghui <3437689193@qq.com> Date: Thu, 15 Aug 2024 16:45:39 +0800 Subject: [PATCH] =?UTF-8?q?1=E3=80=81=E4=BC=98=E5=8C=96=E8=B4=A7=E4=BD=8D?= =?UTF-8?q?=E5=8F=98=E6=9B=B4=E6=8E=A5=E5=8F=A3=E3=80=81=E4=BC=98=E5=8C=96?= =?UTF-8?q?=E5=90=8C=E6=AD=A5=E5=BA=93=E5=AD=98=E4=BF=A1=E6=81=AF=E6=8E=A5?= =?UTF-8?q?=E5=8F=A3=EF=BC=9B2=E3=80=81=E9=9A=90=E8=97=8F=E5=B7=B2?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E7=8A=B6=E6=80=81=E7=9A=84=E9=94=80=E5=94=AE?= =?UTF-8?q?=E8=AE=A2=E5=8D=95=E7=9A=84=E3=80=90=E7=A1=AE=E8=AE=A4=E6=8E=A5?= =?UTF-8?q?=E5=8D=95=E3=80=91=E5=92=8C=E3=80=90=E5=8F=96=E6=B6=88=E3=80=91?= =?UTF-8?q?=E6=8C=89=E9=92=AE=EF=BC=9B3=E3=80=81=E5=A4=84=E7=90=86?= =?UTF-8?q?=E5=8A=9F=E8=83=BD=E5=88=80=E5=85=B7=E4=BB=8E=E7=BA=BF=E8=BE=B9?= =?UTF-8?q?=E5=88=80=E5=BA=93=E5=88=B0=E5=88=80=E5=85=B7=E6=88=BF=E6=B2=A1?= =?UTF-8?q?=E6=9C=89=E7=94=9F=E6=88=90=E7=A7=BB=E5=8A=A8=E5=8E=86=E5=8F=B2?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 29 +++-- sf_sale/views/sale_order_view.xml | 6 +- sf_tool_management/models/functional_tool.py | 41 +++---- .../models/maintenance_equipment.py | 2 +- sf_warehouse/models/sync_common.py | 111 ++++++++++-------- 5 files changed, 104 insertions(+), 85 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 8075f126..50ad39b1 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -386,7 +386,7 @@ class Manufacturing_Connect(http.Controller): ret = json.loads(datas) request.env['center_control.interface.log'].sudo().create( {'content': ret, 'name': 'AutoDeviceApi/LocationChange'}) - logging.info('LocationChange_ret===========:%s' % ret) + logging.info('库位变更LocationChange_ret:%s' % ret) RfidCode = ret['RfidCode'] ChangeType = ret['ChangeType'] OldDeciveId = ret['OldDeciveId'] @@ -429,25 +429,36 @@ class Manufacturing_Connect(http.Controller): # 对功能刀具库位变更信息进行更改 def write_tool(DeciveId): if 'Tool' in DeciveId: - shelfinfo = self.env['sf.shelf.location'].get_sf_shelf_location_info(DeciveId) + shelfinfo = list(filter(lambda x: x.get('DeviceId') == DeciveId, + request.env['sf.shelf.location'].sudo().get_sf_shelf_location_info( + DeciveId))) + total_data = request.env['sf.shelf.location.datasync'].sudo().get_total_data() for item in shelfinfo: - shelf_barcode = self.env['sf.shelf.location.datasync'].find_our_code(item['Postion']) - location_id = self.env['sf.shelf.location'].search([('barcode', '=', shelf_barcode)], - limit=1) + shelf_barcode = request.env['sf.shelf.location.datasync'].sudo().find_our_code( + total_data, item['Postion']) + location_id = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', shelf_barcode)], + limit=1) if location_id: # 如果是线边刀库信息,则对功能刀具移动生成记录 if 'Tool' in item['Postion']: - tool = self.env['sf.functional.cutting.tool.entity'].sudo().search( + tool = request.env['sf.functional.cutting.tool.entity'].sudo().search( [('rfid', '=', item['RfidCode']), ('functional_tool_status', '!=', '已拆除')]) - tool.tool_in_out_stock_location(location_id) + tool.sudo().tool_in_out_stock_location(location_id) if tool: location_id.product_sn_id = tool.barcode_id.id + # 修改功能刀具状态 + # tool_install_time = {'Nomal': '正常', 'Warning': '报警'} + # tool.write({ + # 'functional_tool_status': tool_install_time.get(item['State']) + # }) else: location_id.product_sn_id = False + logging.info('货架已获取信息:%s' % item) else: - equipment_id = self.env['maintenance.equipment'].search([('name', '=', DeciveId)]) + equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', DeciveId)]) if equipment_id: - equipment_id.register_equipment_tool() + equipment_id.sudo().register_equipment_tool() else: res_1 = {'Succeed': False, 'ErrorCode': 202, 'Error': f'设备【{DeciveId}】不存在'} return json.JSONEncoder().encode(res_1) diff --git a/sf_sale/views/sale_order_view.xml b/sf_sale/views/sale_order_view.xml index 75e2d0c1..ce27a4df 100644 --- a/sf_sale/views/sale_order_view.xml +++ b/sf_sale/views/sale_order_view.xml @@ -42,12 +42,12 @@