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