From 5e97f0ef2d2671c56d3497834714682581e107a7 Mon Sep 17 00:00:00 2001 From: "qihao.gong@jikimo.com" Date: Fri, 23 Feb 2024 18:15:28 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E5=BA=93=E4=BD=8D=E5=8F=98?= =?UTF-8?q?=E6=9B=B4=E6=8E=A5=E5=8F=A3?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_manufacturing/controllers/controllers.py | 50 ++++++++++++++------- 1 file changed, 33 insertions(+), 17 deletions(-) diff --git a/sf_manufacturing/controllers/controllers.py b/sf_manufacturing/controllers/controllers.py index 0a5e2d0d..4f378fcc 100644 --- a/sf_manufacturing/controllers/controllers.py +++ b/sf_manufacturing/controllers/controllers.py @@ -317,23 +317,39 @@ class Manufacturing_Connect(http.Controller): NewPosition = ret['NewPosition'] OldDeciveStart = ret['OldDeciveStart'] OldDeciveEnd = ret['OldDeciveEnd'] - workorder = request.env['mrp.workorder'].sudo().search( - [('rfid_code', '=', RfidCode)], limit=1) - if not workorder: - res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该工单'} - return json.JSONEncoder().encode(res) - old_localtion = request.env['sf.shelf.location'].sudo().search( - [('barcode', '=', OldPosition)], limit=1) - new_localtion = request.env['sf.shelf.location'].sudo().search( - [('barcode', '=', NewPosition)], limit=1) - if not new_localtion: - res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'} - return json.JSONEncoder().encode(res) - if old_localtion: - old_localtion.location_status = '空闲' - old_localtion.production_id = False - new_localtion.location_status = '占用' - new_localtion.production_id = workorder.production_id.id + # Part、Tool + if ChangeType == 'Part': + workorder = request.env['mrp.workorder'].sudo().search( + [('rfid_code', '=', RfidCode)], limit=1) + if not workorder: + res = {'Succeed': False, 'ErrorCode': 202, 'Error': '未根据RfidCode找到该工单'} + return json.JSONEncoder().encode(res) + old_localtion = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', OldPosition)], limit=1) + new_localtion = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', NewPosition)], limit=1) + if not new_localtion: + res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'} + return json.JSONEncoder().encode(res) + if old_localtion: + old_localtion.location_status = '空闲' + old_localtion.production_id = False + new_localtion.location_status = '占用' + new_localtion.production_id = workorder.production_id.id + if ChangeType == 'Tool': + old_localtion = request.env['sf.shelf.location'].sudo().search( + [('barcode', '=', OldPosition)], limit=1) + equipment_id = request.env['maintenance.equipment'].sudo().search( + [('name', '=', NewPosition)], limit=1) + equipment_id.register_equipment_tool() + if not new_localtion: + res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有该目标位置'} + return json.JSONEncoder().encode(res) + if old_localtion: + old_localtion.location_status = '空闲' + old_localtion.production_id = False + + # return json.JSONEncoder().encode(res) # else: # res = {'Succeed': False, 'ErrorCode': 201, 'Error': '未传RfidCode字段'}