优化agv及工件配送
This commit is contained in:
@@ -419,11 +419,14 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': True}
|
res = {'Succeed': True}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
|
logging.info('ret:%s' % ret)
|
||||||
if 'DeviceId' in ret:
|
if 'DeviceId' in ret:
|
||||||
logging.info('DeviceId:%s' % ret['DeviceId'])
|
logging.info('DeviceId:%s' % ret['DeviceId'])
|
||||||
for i in range(1, 5):
|
for i in range(1, 5):
|
||||||
|
logging.info('F-RfidCode:%s' % i)
|
||||||
if f'RfidCode{i}' in ret:
|
if f'RfidCode{i}' in ret:
|
||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
domain = [
|
||||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
||||||
('workorder_id.rfid_code', '=', rfid_code),
|
('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 == '待上产线':
|
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)
|
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||||
wd.production_id.write({'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:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该DeviceId没有对应的已配送工件数据'}
|
||||||
else:
|
else:
|
||||||
@@ -461,13 +472,17 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
res = {'Succeed': True}
|
res = {'Succeed': True}
|
||||||
datas = request.httprequest.data
|
datas = request.httprequest.data
|
||||||
ret = json.loads(datas)
|
ret = json.loads(datas)
|
||||||
|
logging.info('ret:%s' % ret)
|
||||||
if 'DeviceId' in ret:
|
if 'DeviceId' in ret:
|
||||||
logging.info('DeviceId:%s' % ret['DeviceId'])
|
logging.info('DeviceId:%s' % ret['DeviceId'])
|
||||||
|
delivery_Arr = []
|
||||||
for i in range(1, 5):
|
for i in range(1, 5):
|
||||||
|
logging.info('F-RfidCode:%s' % i)
|
||||||
if f'RfidCode{i}' in ret:
|
if f'RfidCode{i}' in ret:
|
||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
domain = [
|
||||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
('feeder_station_start_id.name', '=', ret['DeviceId']),
|
||||||
('workorder_id.rfid_code', '=', rfid_code),
|
('workorder_id.rfid_code', '=', rfid_code),
|
||||||
('status', '=', '待下发'),
|
('status', '=', '待下发'),
|
||||||
('type', '=', '下产线')
|
('type', '=', '下产线')
|
||||||
@@ -479,15 +494,27 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
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)
|
logging.info('wd.production_line_state:%s' % wd.production_id.production_line_state)
|
||||||
wd.production_id.write({'production_line_state': '已下产线'})
|
wd.production_id.write({'production_line_state': '已下产线'})
|
||||||
logging.info('开始向agv下发下产线任务')
|
delivery_Arr.append({wd.id})
|
||||||
wd._delivery_avg()
|
next_workpiece = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
logging.info('agv下发下产线任务已配送')
|
[('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:
|
except Exception as e:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': e}
|
||||||
logging.info('AGVDownProduct error:%s' % e)
|
logging.info('AGVDownProduct error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
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="*")
|
cors="*")
|
||||||
def PutEquipmentBaseCoordinate(self, **kw):
|
def PutEquipmentBaseCoordinate(self, **kw):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -26,19 +26,16 @@ class Workpiece(http.Controller):
|
|||||||
if 'method' in ret:
|
if 'method' in ret:
|
||||||
if ret['method'] == 'end':
|
if ret['method'] == 'end':
|
||||||
logging.info('backfeed-ret:%s' % ret['reqCode'].rsplit('-', 1)[0])
|
logging.info('backfeed-ret:%s' % ret['reqCode'].rsplit('-', 1)[0])
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
req_codes = ret['reqCode'].split(',')
|
||||||
[('production_id.name', '=', ret['reqCode'].rsplit('-', 1)[0]), ('delivery_num', '=',
|
for req_code in req_codes:
|
||||||
ret['reqCode'])])
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(
|
||||||
if workpiece_delivery:
|
[('production_id.name', '=', ret['reqCode'].rsplit('-', 1)[0]),
|
||||||
# for item in workpiece_delivery.sametransport_production_ids:
|
('delivery_num', '=', req_code)])
|
||||||
# sametransport_workpiece = request.env['sf.workpiece.delivery'].search(
|
if workpiece_delivery:
|
||||||
# [('production_id', '=', item.id), ('type', '=', workpiece_delivery.type)])
|
workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']})
|
||||||
# if sametransport_workpiece:
|
else:
|
||||||
# sametransport_workpiece.write(
|
res = {'Succeed': False, 'ErrorCode': 203,
|
||||||
# {'task_delivery_time': datetime.now(), 'status': '已配送'})
|
'Error': '该reqCode暂未查到对应的工件配送记录'}
|
||||||
workpiece_delivery.write({'status': '已配送', 'task_completion_time': ret['reqTime']})
|
|
||||||
else:
|
|
||||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '该reqCode暂未查到对应的工件配送记录'}
|
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '未传method字段'}
|
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '未传method字段'}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -420,10 +420,8 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
for item in self.workpiece_delivery_ids:
|
for item in self.workpiece_delivery_ids:
|
||||||
if not item.route_id:
|
if not item.route_id:
|
||||||
raise UserError('【工件配送】明细中请选择【任务路线】')
|
raise UserError('【工件配送】明细中请选择【任务路线】')
|
||||||
# if not item.workpiece_code:
|
|
||||||
# raise UserError('请对【同运工件】进行扫描')
|
|
||||||
else:
|
else:
|
||||||
if self.is_cnc_program_down is True:
|
if item.is_cnc_program_down is True:
|
||||||
if item.status == '待下发':
|
if item.status == '待下发':
|
||||||
return {
|
return {
|
||||||
'name': _('确认'),
|
'name': _('确认'),
|
||||||
@@ -774,6 +772,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
raise UserError("请对前置三元检测定位参数进行计算定位")
|
raise UserError("请对前置三元检测定位参数进行计算定位")
|
||||||
if not self.rfid_code:
|
if not self.rfid_code:
|
||||||
raise UserError("请扫RFID码进行绑定")
|
raise UserError("请扫RFID码进行绑定")
|
||||||
|
self.workpiece_delivery_ids[0].write({'status': '待下发'})
|
||||||
if self.picking_out_id:
|
if self.picking_out_id:
|
||||||
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
|
picking_out = self.env['stock.picking'].search([('id', '=', self.picking_out_id.id)])
|
||||||
if picking_out.workorder_out_id:
|
if picking_out.workorder_out_id:
|
||||||
@@ -1107,15 +1106,14 @@ class WorkPieceDelivery(models.Model):
|
|||||||
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
|
[('上产线', '上产线'), ('下产线', '下产线'), ('运送空料架', '运送空料架')], string='类型')
|
||||||
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
|
delivery_duration = fields.Float('配送时长', compute='_compute_delivery_duration')
|
||||||
status = fields.Selection(
|
status = fields.Selection(
|
||||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态',
|
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', )
|
||||||
default='待下发')
|
|
||||||
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
||||||
|
|
||||||
@api.onchange('route_id')
|
@api.onchange('route_id')
|
||||||
def onchange_route(self):
|
def onchange_route(self):
|
||||||
if self.route_id:
|
if self.route_id:
|
||||||
self.feeder_station_start_id = self.route_id.start_site_id
|
self.feeder_station_start_id = self.route_id.start_site_id.id
|
||||||
self.feeder_station_destination_id = self.route_id.end_site_id
|
self.feeder_station_destination_id = self.route_id.end_site_id.id
|
||||||
|
|
||||||
# 工件配送
|
# 工件配送
|
||||||
def button_delivery(self):
|
def button_delivery(self):
|
||||||
@@ -1125,14 +1123,24 @@ class WorkPieceDelivery(models.Model):
|
|||||||
is_not_route = 0
|
is_not_route = 0
|
||||||
same_production_line_id = None
|
same_production_line_id = None
|
||||||
same_route_id = None
|
same_route_id = None
|
||||||
|
down_status = '待下发'
|
||||||
|
production_type = '上产线'
|
||||||
|
num = 0
|
||||||
for item in self:
|
for item in self:
|
||||||
|
num += 1
|
||||||
|
if num > 4:
|
||||||
|
raise UserError('仅限于配送1-4个制造订单,请重新选择')
|
||||||
if item.route_id:
|
if item.route_id:
|
||||||
if same_route_id is None:
|
if same_route_id is None:
|
||||||
same_route_id = item.route_id.id
|
same_route_id = item.route_id.id
|
||||||
if item.route_id.id != same_route_id:
|
if item.route_id.id != same_route_id:
|
||||||
is_not_route += 1
|
is_not_route += 1
|
||||||
else:
|
else:
|
||||||
raise UserError('请选择任务路线再进行配送')
|
raise UserError('请选择【任务路线】再进行配送')
|
||||||
|
if production_type != item.type:
|
||||||
|
raise UserError('请选择类型为【上产线】的制造订单进行配送')
|
||||||
|
if down_status != item.status:
|
||||||
|
raise UserError('请选择状态为【待下发】的制造订单进行配送')
|
||||||
if same_production_line_id is None:
|
if same_production_line_id is None:
|
||||||
same_production_line_id = item.production_line_id.id
|
same_production_line_id = item.production_line_id.id
|
||||||
if item.production_line_id.id != same_production_line_id:
|
if item.production_line_id.id != same_production_line_id:
|
||||||
@@ -1140,13 +1148,13 @@ class WorkPieceDelivery(models.Model):
|
|||||||
if item.is_cnc_program_down is False:
|
if item.is_cnc_program_down is False:
|
||||||
is_cnc_down += 1
|
is_cnc_down += 1
|
||||||
if is_cnc_down == 0 and is_not_production_line == 0 and is_not_route == 0:
|
if is_cnc_down == 0 and is_not_production_line == 0 and is_not_route == 0:
|
||||||
delivery_ids.append(item.production_id.id)
|
delivery_ids.append(item.id)
|
||||||
if is_cnc_down >= 1:
|
if is_cnc_down >= 1:
|
||||||
raise UserError('您所选择制造订单的CNC程序暂未下发,请在程序下发后再进行配送')
|
raise UserError('您所选择制造订单的【CNC程序】暂未下发,请在程序下发后再进行配送')
|
||||||
if is_not_production_line >= 1:
|
if is_not_production_line >= 1:
|
||||||
raise UserError('您所选择制造订单的目的生产线不一致,请重新确认')
|
raise UserError('您所选择制造订单的【目的生产线】不一致,请重新确认')
|
||||||
if is_not_route >= 1:
|
if is_not_route >= 1:
|
||||||
raise UserError('您所选择制造订单的任务路线不一致,请重新确认')
|
raise UserError('您所选择制造订单的【任务路线】不一致,请重新确认')
|
||||||
if delivery_ids:
|
if delivery_ids:
|
||||||
return {
|
return {
|
||||||
'name': _('确认'),
|
'name': _('确认'),
|
||||||
@@ -1172,7 +1180,7 @@ class WorkPieceDelivery(models.Model):
|
|||||||
if feeder_station_start is None:
|
if feeder_station_start is None:
|
||||||
feeder_station_start = item.feeder_station_start_id.name
|
feeder_station_start = item.feeder_station_start_id.name
|
||||||
if feeder_station_destination is None:
|
if feeder_station_destination is None:
|
||||||
feeder_station_destination = item.feeder_station_start_id.name
|
feeder_station_destination = item.feeder_station_destination_id.name
|
||||||
delivery_Arr.append(item.delivery_num)
|
delivery_Arr.append(item.delivery_num)
|
||||||
delivery_str = ', '.join(map(str, delivery_Arr))
|
delivery_str = ', '.join(map(str, delivery_Arr))
|
||||||
if feeder_station_start is not None:
|
if feeder_station_start is not None:
|
||||||
|
|||||||
@@ -269,7 +269,7 @@
|
|||||||
placeholder="如有预调程序信息请在此处输入....."/>
|
placeholder="如有预调程序信息请在此处输入....."/>
|
||||||
</group>
|
</group>
|
||||||
<group string="加工图纸">
|
<group string="加工图纸">
|
||||||
<!-- 隐藏加工图纸字段名 -->
|
<!-- 隐藏加工图纸字段名 -->
|
||||||
<field name="processing_drawing" widget="pdf_viewer" string=""/>
|
<field name="processing_drawing" widget="pdf_viewer" string=""/>
|
||||||
</group>
|
</group>
|
||||||
</page>
|
</page>
|
||||||
@@ -440,6 +440,7 @@
|
|||||||
<field name="production_line_id"/>
|
<field name="production_line_id"/>
|
||||||
<field name="task_delivery_time" readonly="1"/>
|
<field name="task_delivery_time" readonly="1"/>
|
||||||
<field name="task_completion_time" readonly="1"/>
|
<field name="task_completion_time" readonly="1"/>
|
||||||
|
<field name="status"/>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</page>
|
</page>
|
||||||
@@ -535,7 +536,8 @@
|
|||||||
<field name="is_ok"/>
|
<field name="is_ok"/>
|
||||||
<field name="processing_user_id"/>
|
<field name="processing_user_id"/>
|
||||||
<field name="inspection_user_id"/>
|
<field name="inspection_user_id"/>
|
||||||
<field name="save_name" widget="CopyClipboardChar" attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
<field name="save_name" widget="CopyClipboardChar"
|
||||||
|
attrs="{'invisible':[('routing_type','!=','装夹预调')]}"/>
|
||||||
<label for="material_length" string="物料尺寸"/>
|
<label for="material_length" string="物料尺寸"/>
|
||||||
<div class="o_address_format">
|
<div class="o_address_format">
|
||||||
<label for="material_length" string="长"/>
|
<label for="material_length" string="长"/>
|
||||||
@@ -586,8 +588,9 @@
|
|||||||
decoration-success="status == '已配送'"
|
decoration-success="status == '已配送'"
|
||||||
decoration-warning="status == '待下发'"
|
decoration-warning="status == '待下发'"
|
||||||
decoration-danger="status == '待配送'"/>
|
decoration-danger="status == '待配送'"/>
|
||||||
<field name="production_id" />
|
<field name="production_id"/>
|
||||||
<field name="type" />
|
<field name="type"/>
|
||||||
|
<!-- <field name="delivery_num" />-->
|
||||||
<field name="production_line_id" options="{'no_create': True}"/>
|
<field name="production_line_id" options="{'no_create': True}"/>
|
||||||
<field name="route_id" options="{'no_create': True}"/>
|
<field name="route_id" options="{'no_create': True}"/>
|
||||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||||
@@ -625,6 +628,7 @@
|
|||||||
<field name="name">工件配送</field>
|
<field name="name">工件配送</field>
|
||||||
<field name="res_model">sf.workpiece.delivery</field>
|
<field name="res_model">sf.workpiece.delivery</field>
|
||||||
<field name="view_mode">tree,search</field>
|
<field name="view_mode">tree,search</field>
|
||||||
|
<!-- <field name="domain">[('type','in',['上产线']),('status','in',['待下发'])]</field>-->
|
||||||
</record>
|
</record>
|
||||||
</odoo>
|
</odoo>
|
||||||
|
|
||||||
|
|||||||
@@ -5,7 +5,7 @@
|
|||||||
<field name="model">sf.workpiece.delivery.wizard</field>
|
<field name="model">sf.workpiece.delivery.wizard</field>
|
||||||
<field name="arch" type="xml">
|
<field name="arch" type="xml">
|
||||||
<form>
|
<form>
|
||||||
<field name="delivery_ids" invisible="True"/>
|
<field name="delivery_ids" />
|
||||||
<field name="workorder_id" invisible="True"/>
|
<field name="workorder_id" invisible="True"/>
|
||||||
<div>是否确定配送?</div>
|
<div>是否确定配送?</div>
|
||||||
<footer>
|
<footer>
|
||||||
|
|||||||
@@ -14,6 +14,6 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
|||||||
|
|
||||||
def confirm(self):
|
def confirm(self):
|
||||||
if self.workorder_id:
|
if self.workorder_id:
|
||||||
self.workorder_id.workpiece_delivery_ids._delivery_avg()
|
self.workorder_id.workpiece_delivery_ids[0]._delivery_avg()
|
||||||
else:
|
else:
|
||||||
self.delivery_ids._delivery_avg()
|
self.delivery_ids._delivery_avg()
|
||||||
|
|||||||
Reference in New Issue
Block a user