agv调度开发

This commit is contained in:
胡尧
2024-08-15 17:41:25 +08:00
parent 1532184008
commit aecf2121a1
7 changed files with 68 additions and 24 deletions

View File

@@ -13,6 +13,7 @@ class WorkpieceDeliveryWizard(models.TransientModel):
# delivery_ids = fields.Many2many('sf.workpiece.delivery', string='配送')
rfid_code = fields.Char('rfid码')
delivery_ids = fields.Many2many('sf.workpiece.delivery', string='配送单')
workorder_ids = fields.Many2many('mrp.workorder', string='工单')
production_ids = fields.Many2many('mrp.production', string='制造订单号')
destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线')
@@ -70,17 +71,37 @@ class WorkpieceDeliveryWizard(models.TransientModel):
# if is_not_production_line >= 1:
# raise UserError('制造订单号为%s的目的生产线不一致' % notsame_production_line_str)
# else:
self.env['sf.agv.scheduling'].add_scheduling(
scheduling = self.env['sf.agv.scheduling'].add_scheduling(
agv_start_site_id=self.feeder_station_start_id.id,
agv_route_type=self.delivery_type,
workorders=self.workorder_ids,
)
# 如果关联了工件配送单,则修改状态为已下发
if self.delivery_ids:
self.delivery_ids.write({
'status': '已下发',
'agv_scheduling_id': scheduling.id,
'feeder_station_start_id': scheduling.start_site_id.id,
})
# 如果是解除装夹工单,则需要处理工单逻辑
for item in self.workorder_ids:
if item.routing_type == '解除装夹' and item.state == 'ready':
item.button_start()
item.button_finish()
# 显示通知
return {
'type': 'ir.actions.client',
'tag': 'display_notification',
'target': 'new',
'params': {
'message': '任务下发成功AGV任务调度编号为【%s' % scheduling.name,
'type': 'success',
'sticky': False,
'next': {'type': 'ir.actions.act_window_close'},
}
}
except Exception as e:
logging.info('%s任务下发失败:%s' % (self.delivery_type, e))
raise UserError('%s任务下发失败:%s' % (self.delivery_type, e))