AGV任务调度开发
This commit is contained in:
@@ -8,11 +8,12 @@ from odoo import models, api, fields, _
|
||||
|
||||
class WorkpieceDeliveryWizard(models.TransientModel):
|
||||
_name = 'sf.workpiece.delivery.wizard'
|
||||
_inherit = ["barcodes.barcode_events_mixin"]
|
||||
_description = '工件配送'
|
||||
|
||||
delivery_ids = fields.Many2many('sf.workpiece.delivery', string='配送')
|
||||
# delivery_ids = fields.Many2many('sf.workpiece.delivery', string='配送')
|
||||
rfid_code = fields.Char('rfid码')
|
||||
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||
workorder_ids = fields.Many2many('mrp.workorder', string='工单')
|
||||
production_ids = fields.Many2many('mrp.production', string='制造订单号')
|
||||
destination_production_line_id = fields.Many2one('sf.production.line', '目的生产线')
|
||||
route_id = fields.Many2one('sf.agv.task.route', '任务路线', domain=[('route_type', 'in', ['上产线', '下产线'])])
|
||||
@@ -51,29 +52,27 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
||||
|
||||
def confirm(self):
|
||||
try:
|
||||
if self.workorder_id:
|
||||
self.workorder_id.workpiece_delivery_ids[0].agv_scheduling_id()
|
||||
# if self.workorder_id:
|
||||
# self.workorder_id.workpiece_delivery_ids[0].agv_scheduling_id()
|
||||
# else:
|
||||
is_not_production_line = 0
|
||||
same_production_line_id = None
|
||||
notsame_production_line_arr = []
|
||||
for item in self.production_ids:
|
||||
if same_production_line_id is None:
|
||||
same_production_line_id = item.production_line_id.id
|
||||
if item.production_line_id.id != same_production_line_id:
|
||||
notsame_production_line_arr.append(item.name)
|
||||
notsame_production_line_str = ','.join(map(str, notsame_production_line_arr))
|
||||
if is_not_production_line >= 1:
|
||||
raise UserError('制造订单号为%s的目的生产线不一致' % notsame_production_line_str)
|
||||
else:
|
||||
is_not_production_line = 0
|
||||
same_production_line_id = None
|
||||
notsame_production_line_arr = []
|
||||
for item in self.production_ids:
|
||||
if same_production_line_id is None:
|
||||
same_production_line_id = item.production_line_id.id
|
||||
if item.production_line_id.id != same_production_line_id:
|
||||
notsame_production_line_arr.append(item.name)
|
||||
notsame_production_line_str = ','.join(map(str, notsame_production_line_arr))
|
||||
if is_not_production_line >= 1:
|
||||
raise UserError('制造订单号为%s的目的生产线不一致' % notsame_production_line_str)
|
||||
else:
|
||||
# self.delivery_ids._delivery_avg()
|
||||
agv_scheduling_id = self.env['sf.agv.scheduling'].add_scheduling(
|
||||
agv_start_site_id=self.feeder_station_start_id.id,
|
||||
agv_route_type=self.type,
|
||||
productions=self.production_ids,
|
||||
deliveries=self.delivery_ids
|
||||
)
|
||||
self.delivery_ids.agv_scheduling_id = agv_scheduling_id
|
||||
self.env['sf.agv.scheduling'].add_scheduling(
|
||||
agv_start_site_id=self.feeder_station_start_id.id,
|
||||
agv_route_type=self.type,
|
||||
workorders=self.workorder_ids,
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
logging.info('工件配送任务下发失败:%s' % e)
|
||||
raise UserError('工件配送任务下发失败:%s' % e)
|
||||
@@ -122,3 +121,18 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
||||
if self.route_id:
|
||||
self.feeder_station_start_id = self.route_id.start_site_id.id
|
||||
self.feeder_station_destination_id = self.route_id.end_site_id.id
|
||||
|
||||
def on_barcode_scanned(self, barcode):
|
||||
workorder = self.env['mrp.workorder'].search(
|
||||
[('production_line_state', '=', '待上产线'), ('rfid_code', '=', barcode),
|
||||
('state', '=', 'done')])
|
||||
if workorder:
|
||||
if len(self.production_ids) > 0 and workorder.production_line_id.id != self.production_ids[0].production_line_id.id:
|
||||
raise UserError('该rfid对应的制造订单号为%s的目的生产线不一致' % workorder.production_id.name)
|
||||
|
||||
# 将对象添加到对应的同模型且是多对多类型里
|
||||
self.production_ids |= workorder.production_id
|
||||
self.workorder_ids |= workorder
|
||||
else:
|
||||
raise UserError('该rfid码对应的工单不存在')
|
||||
return
|
||||
|
||||
Reference in New Issue
Block a user