优化agv及工件配送

This commit is contained in:
jinling.yang
2024-04-26 09:56:42 +08:00
parent da22015d35
commit 9eb891dd0b
6 changed files with 74 additions and 38 deletions

View File

@@ -419,11 +419,14 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('ret:%s' % ret)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
for i in range(1, 5):
logging.info('F-RfidCode:%s' % i)
if f'RfidCode{i}' in ret:
rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code)
domain = [
('feeder_station_destination_id.name', '=', ret['DeviceId']),
('workorder_id.rfid_code', '=', rfid_code),
@@ -437,7 +440,15 @@ class Manufacturing_Connect(http.Controller):
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已上产线'})
wd.write({'production_line_state': '已上产线'})
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
[('workorder_id.rfid_code', '=', rfid_code), ('type', '=', '下产线'),
('production_id', '=', wd.production_id.id)])
if next_workpiece:
logging.info('next_workpiece:%s' % next_workpiece.delivery_num)
next_workpiece.write({'status': '待下发'})
else:
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
else:
@@ -461,13 +472,17 @@ class Manufacturing_Connect(http.Controller):
res = {'Succeed': True}
datas = request.httprequest.data
ret = json.loads(datas)
logging.info('ret:%s' % ret)
if 'DeviceId' in ret:
logging.info('DeviceId:%s' % ret['DeviceId'])
delivery_Arr = []
for i in range(1, 5):
logging.info('F-RfidCode:%s' % i)
if f'RfidCode{i}' in ret:
rfid_code = ret[f'RfidCode{i}']
logging.info('RfidCode:%s' % rfid_code)
domain = [
('feeder_station_destination_id.name', '=', ret['DeviceId']),
('feeder_station_start_id.name', '=', ret['DeviceId']),
('workorder_id.rfid_code', '=', rfid_code),
('status', '=', '待下发'),
('type', '=', '下产线')
@@ -479,15 +494,27 @@ class Manufacturing_Connect(http.Controller):
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
wd.production_id.write({'production_line_state': '已下产线'})
logging.info('开始向agv下发下产线任务')
wd._delivery_avg()
logging.info('agv下发下产线任务已配送')
delivery_Arr.append({wd.id})
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
[('workorder_id.rfid_code', '=', rfid_code), ('type', '=', '运送空料架'),
('production_id', '=', wd.production_id.id)])
if next_workpiece:
logging.info('next_workpiece:%s' % next_workpiece.delivery_num)
next_workpiece.write({'status': '待下发'})
if delivery_Arr:
logging.info('delivery_Arr:%s' % delivery_Arr)
delivery_workpiece = request.env['sf.workpiece.delivery'].sudo().search([('id','in',delivery_Arr)])
if delivery_workpiece:
logging.info('开始向agv下发下产线任务')
delivery_workpiece._delivery_avg()
logging.info('agv下发下产线任务已配送')
except Exception as e:
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
logging.info('AGVDownProduct error:%s' % e)
return json.JSONEncoder().encode(res)
@http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
@http.route('/AutoDeviceApi/EquipmentBaseCoordinate', type='json', auth='sf_token', methods=['GET', 'POST'],
csrf=False,
cors="*")
def PutEquipmentBaseCoordinate(self, **kw):
"""