通过质检接口的质检文件路径获取

This commit is contained in:
jinling.yang
2024-02-23 15:29:21 +08:00
parent f015cbb9fd
commit 2e62915b41
4 changed files with 54 additions and 16 deletions

View File

@@ -157,7 +157,8 @@ class Manufacturing_Connect(http.Controller):
if workorder.state != 'ready':
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '工单未就绪'}
return json.JSONEncoder().encode(res)
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)], limit=1)
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)],
limit=1)
if not work_equipment_id:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有找到该加工设备'}
return json.JSONEncoder().encode(res)
@@ -212,8 +213,18 @@ class Manufacturing_Connect(http.Controller):
ret = json.loads(datas)
production_id = ret['BillId']
routing_type = ret['CraftId']
request.env['mrp.workorder'].sudo().search(
workorder = request.env['mrp.workorder'].sudo().search(
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
if workorder:
if 'ReportPaht' in ret:
download_state = request.env['mrp.workorder'].sudo().download_reportfile_tmp(workorder,
ret['ReportPaht'])
if download_state is not False:
request.env['mrp.workorder'].sudo().get_detection_file(workorder, ret['ReportPaht'])
else:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '检测报告文件从FTP拉取失败'}
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传ReportPaht字段'}
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('PartQualityInspect error:%s' % e)
@@ -338,8 +349,10 @@ class Manufacturing_Connect(http.Controller):
[('feeder_station_destination', '=', ret['DeviceId'])])
if workpiece_delivery:
for wd in workpiece_delivery:
if wd.production_id.production_line_state == '待上产线':
logging.info('wd.production_id:%s' % workpiece_delivery.production_id.id)
logging.info('wd.workorder_id:%s' % wd.workorder_id.name)
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
logging.info('wd.production_id:%s' % wd.production_id.name)
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已上产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}
@@ -370,8 +383,10 @@ class Manufacturing_Connect(http.Controller):
[('feeder_station_destination', '=', ret['DeviceId'])])
if workpiece_delivery:
for wd in workpiece_delivery:
if wd.production_id.production_line_state == '已上产线':
logging.info('wd.production_id:%s' % workpiece_delivery.production_id.id)
logging.info('wd.workorder_id:%s' % wd.workorder_id.name)
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
logging.info('wd.production_id:%s' % wd.production_id.name)
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已下产线'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的工件配送数据'}