Accept Merge Request #1058: (feature/优化工件上下产线及配送 -> develop)
Merge Request: 优化工件上下产线及配送 Created By: @杨金灵 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @杨金灵 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/1058
This commit is contained in:
@@ -166,11 +166,13 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
if not workorder:
|
if not workorder:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '该工单不存在'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
logging.info('workorder_state:%s' % workorder.state)
|
||||||
if workorder.state != 'ready':
|
if workorder.state != 'ready':
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '工单未就绪'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '工单未就绪'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)],
|
work_equipment_id = request.env['maintenance.equipment'].sudo().search([('name', '=', equipment_id)],
|
||||||
limit=1)
|
limit=1)
|
||||||
|
logging.info('work_equipment_id:%s' % work_equipment_id.name)
|
||||||
if not work_equipment_id:
|
if not work_equipment_id:
|
||||||
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有找到该加工设备'}
|
res = {'Succeed': False, 'ErrorCode': 202, 'Error': '没有找到该加工设备'}
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
@@ -457,19 +459,21 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
logging.info('RfidCode:%s' % rfid_code)
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
domain = [
|
||||||
('feeder_station_destination_id.name', '=', ret['DeviceId']),
|
('rfid_code', '=', rfid_code),
|
||||||
('workorder_id.rfid_code', '=', rfid_code),
|
('routing_type', '=', 'CNC加工')
|
||||||
('status', '=', '已配送'),
|
|
||||||
('type', '=', '上产线')
|
|
||||||
]
|
]
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||||
order='id asc')
|
if workorder:
|
||||||
if workpiece_delivery:
|
for order in workorder:
|
||||||
for wd in workpiece_delivery:
|
if order.production_id.production_line_state == '待上产线':
|
||||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '待上产线':
|
|
||||||
logging.info(
|
logging.info(
|
||||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
||||||
wd.production_id.write({'production_line_state': '已上产线'})
|
order.production_id.write({'production_line_state': '已上产线'})
|
||||||
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
|
||||||
|
('rfid_code', '=', rfid_code),
|
||||||
|
('production_id', '=', order.production_id.id)])
|
||||||
|
if workpiece_delivery.status == '待下发':
|
||||||
|
workpiece_delivery.write({'is_manual_work': True})
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 204,
|
res = {'Succeed': False, 'ErrorCode': 204,
|
||||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||||
@@ -510,19 +514,20 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
rfid_code = ret[f'RfidCode{i}']
|
rfid_code = ret[f'RfidCode{i}']
|
||||||
logging.info('RfidCode:%s' % rfid_code)
|
logging.info('RfidCode:%s' % rfid_code)
|
||||||
domain = [
|
domain = [
|
||||||
('workorder_id.rfid_code', '=', rfid_code),
|
('rfid_code', '=', rfid_code),
|
||||||
('status', '=', '待下发'),
|
('routing_type', '=', 'CNC加工')
|
||||||
('type', '=', '下产线')
|
|
||||||
]
|
]
|
||||||
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search(domain,
|
workorder = request.env['mrp.workorder'].sudo().search(domain, order='id asc')
|
||||||
order='id asc')
|
if workorder:
|
||||||
if workpiece_delivery:
|
for order in workorder:
|
||||||
for wd in workpiece_delivery:
|
if order.production_id.production_line_state == '已上产线':
|
||||||
if wd.workorder_id.state == 'done' and wd.production_id.production_line_state == '已上产线':
|
|
||||||
logging.info(
|
logging.info(
|
||||||
'wd.production_line_state:%s' % wd.production_id.production_line_state)
|
'制造订单产线状态:%s' % order.production_id.production_line_state)
|
||||||
wd.production_id.write({'production_line_state': '已下产线'})
|
order.production_id.write({'production_line_state': '已下产线'})
|
||||||
delivery_Arr.append(wd.id)
|
workpiece_delivery = request.env['sf.workpiece.delivery'].sudo().search([
|
||||||
|
('rfid_code', '=', rfid_code),
|
||||||
|
('production_id', '=', order.production_id.id)])
|
||||||
|
delivery_Arr.append(workpiece_delivery.id)
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 204,
|
res = {'Succeed': False, 'ErrorCode': 204,
|
||||||
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
'Error': 'DeviceId为%s没有对应的已配送工件数据' % ret['DeviceId']}
|
||||||
@@ -532,10 +537,14 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
[('id', 'in', delivery_Arr)])
|
[('id', 'in', delivery_Arr)])
|
||||||
if delivery_workpiece:
|
if delivery_workpiece:
|
||||||
logging.info('开始向agv下发下产线任务')
|
logging.info('开始向agv下发下产线任务')
|
||||||
is_free = delivery_workpiece._check_avgsite_state()
|
agv_site = request.env['sf.agv.site'].sudo().search([])
|
||||||
if is_free is True:
|
if agv_site:
|
||||||
delivery_workpiece._delivery_avg()
|
has_site = agv_site.update_site_state()
|
||||||
logging.info('agv下发下产线任务下发完成')
|
if has_site is True:
|
||||||
|
is_free = delivery_workpiece._check_avgsite_state()
|
||||||
|
if is_free is True:
|
||||||
|
delivery_workpiece._delivery_avg()
|
||||||
|
logging.info('agv下发下产线任务下发完成')
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
res = {'Succeed': False, 'ErrorCode': 203, 'Error': '未传IsComplete字段'}
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
|
|||||||
@@ -26,20 +26,28 @@ class AgvSetting(models.Model):
|
|||||||
timestamp = int(time.time())
|
timestamp = int(time.time())
|
||||||
center_control_url += str(timestamp)
|
center_control_url += str(timestamp)
|
||||||
logging.info('工件配送-请求中控地址:%s' % center_control_url)
|
logging.info('工件配送-请求中控地址:%s' % center_control_url)
|
||||||
center_control_r = requests.get(center_control_url, params={}, headers=headers)
|
try:
|
||||||
ret = center_control_r.json()
|
center_control_r = requests.get(center_control_url, headers=headers, timeout=60) # 设置超时为60秒
|
||||||
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
ret = center_control_r.json()
|
||||||
self.env['center_control.interface.log'].sudo().create(
|
logging.info('工件配送-请求中控站点信息:%s' % ret)
|
||||||
{'content': ret, 'name': 'AutoDeviceApi/GetAgvStationState?date=%s' % str(timestamp)})
|
self.env['center_control.interface.log'].sudo().create(
|
||||||
if ret['Succeed'] is True:
|
{'content': ret, 'name': 'AutoDeviceApi/GetAgvStationState?date=%s' % str(timestamp)})
|
||||||
datas = ret['Datas']
|
if ret['Succeed'] is True:
|
||||||
for item in self:
|
datas = ret['Datas']
|
||||||
for da in datas:
|
for item in self:
|
||||||
if da['DeviceId'] == item.name:
|
for da in datas:
|
||||||
if da['AtHome'] is True:
|
if da['DeviceId'] == item.name:
|
||||||
item.state = '占用'
|
if da['AtHome'] is True:
|
||||||
else:
|
item.state = '占用'
|
||||||
item.state = '空闲'
|
else:
|
||||||
|
item.state = '空闲'
|
||||||
|
return True
|
||||||
|
except requests.exceptions.Timeout:
|
||||||
|
logging.error('工件配送-请求中控接口超时')
|
||||||
|
return False
|
||||||
|
except requests.exceptions.RequestException as e:
|
||||||
|
logging.error('工件配送-请求中控接口错误: %s', e)
|
||||||
|
return False
|
||||||
|
|
||||||
|
|
||||||
class AgvTaskRoute(models.Model):
|
class AgvTaskRoute(models.Model):
|
||||||
|
|||||||
@@ -159,7 +159,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
('已完工', '已完工'),
|
('已完工', '已完工'),
|
||||||
], string='工序状态', default='待装夹', readonly='True')
|
], string='工序状态', default='待装夹', readonly='True')
|
||||||
# 加工图纸
|
# 加工图纸
|
||||||
processing_drawing = fields.Binary(string='加工图纸', related='production_id.part_drawing')
|
processing_drawing = fields.Binary(string='加工图纸')
|
||||||
|
|
||||||
@api.depends('production_id')
|
@api.depends('production_id')
|
||||||
def _compute_save_name(self):
|
def _compute_save_name(self):
|
||||||
@@ -1326,6 +1326,7 @@ class WorkPieceDelivery(models.Model):
|
|||||||
status = fields.Selection(
|
status = fields.Selection(
|
||||||
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
[('待下发', '待下发'), ('待配送', '待配送'), ('已配送', '已配送')], string='状态', default='待下发')
|
||||||
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
is_cnc_program_down = fields.Boolean('程序是否下发', default=False)
|
||||||
|
is_manual_work = fields.Boolean('人工操作', default=False)
|
||||||
active = fields.Boolean(string="有效", default=True)
|
active = fields.Boolean(string="有效", default=True)
|
||||||
|
|
||||||
@api.model
|
@api.model
|
||||||
@@ -1393,6 +1394,8 @@ class WorkPieceDelivery(models.Model):
|
|||||||
is_not_route += 1
|
is_not_route += 1
|
||||||
# else:
|
# else:
|
||||||
# raise UserError('请选择【任务路线】再进行配送')
|
# raise UserError('请选择【任务路线】再进行配送')
|
||||||
|
# if item.production_id.production_line_state == '已下产线' and item.state == '待下发' and item.type == '下产线':
|
||||||
|
# raise UserError('该制造订单已下产线,无需配送')
|
||||||
if production_type != item.type:
|
if production_type != item.type:
|
||||||
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
raise UserError('请选择类型为%s的制造订单进行配送' % production_type)
|
||||||
if down_status != item.status:
|
if down_status != item.status:
|
||||||
@@ -1446,22 +1449,25 @@ class WorkPieceDelivery(models.Model):
|
|||||||
is_free = False
|
is_free = False
|
||||||
agv_site = self.env['sf.agv.site'].search([])
|
agv_site = self.env['sf.agv.site'].search([])
|
||||||
if agv_site:
|
if agv_site:
|
||||||
agv_site.update_site_state()
|
has_site = agv_site.update_site_state()
|
||||||
for item in self:
|
if has_site is True:
|
||||||
logging.info('工件配送-起点状态:%s-%s' % (
|
for item in self:
|
||||||
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
if item.type in ['上产线', '下产线']:
|
||||||
logging.info('工件配送-终点状态:%s-%s' % (
|
logging.info('工件配送-起点状态:%s-%s' % (
|
||||||
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
item.feeder_station_start_id.name, item.feeder_station_start_id.state))
|
||||||
if item.type in ['上产线', '下产线']:
|
logging.info('工件配送-终点状态:%s-%s' % (
|
||||||
if (
|
item.feeder_station_destination_id.name, item.feeder_station_destination_id.state))
|
||||||
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
if (
|
||||||
item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'):
|
item.feeder_station_start_id.state == '占用' and item.feeder_station_destination_id.state == '空闲') or (
|
||||||
is_free = True
|
item.feeder_station_start_id.state == '空闲' and item.feeder_station_destination_id.state == '空闲'):
|
||||||
|
is_free = True
|
||||||
|
else:
|
||||||
|
if item.feeder_station_destination_id.state == '空闲':
|
||||||
|
is_free = True
|
||||||
|
logging.info('is_free:%s' % is_free)
|
||||||
|
return is_free
|
||||||
else:
|
else:
|
||||||
if item.feeder_station_destination_id.state == '空闲':
|
raise UserError("接驳站暂未反馈站点实时状态,请稍后再试")
|
||||||
is_free = True
|
|
||||||
logging.info('is_free:%s' % is_free)
|
|
||||||
return is_free
|
|
||||||
|
|
||||||
# 配送至avg小车
|
# 配送至avg小车
|
||||||
def _delivery_avg(self):
|
def _delivery_avg(self):
|
||||||
|
|||||||
@@ -658,7 +658,9 @@
|
|||||||
<field name="search_view_id" ref="sf_workpiece_delivery_search"/>
|
<field name="search_view_id" ref="sf_workpiece_delivery_search"/>
|
||||||
<field name="context">{'search_default_on_up':1}</field>
|
<field name="context">{'search_default_on_up':1}</field>
|
||||||
<field name="view_mode">tree,search</field>
|
<field name="view_mode">tree,search</field>
|
||||||
<field name="domain">[('type','in',['上产线','下产线']),('workorder_state','=','done')]</field>
|
<field name="domain">
|
||||||
|
[('type','in',['上产线','下产线']),('workorder_state','=','done'),('is_manual_work','=',false)]
|
||||||
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|
||||||
|
|
||||||
@@ -677,7 +679,7 @@
|
|||||||
attrs="{'readonly': [('id', '!=', False)]}" domain="[('route_type', '=', '运送空料架')]"
|
attrs="{'readonly': [('id', '!=', False)]}" domain="[('route_type', '=', '运送空料架')]"
|
||||||
force_save="1"/>
|
force_save="1"/>
|
||||||
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
<field name="feeder_station_start_id" readonly="1" force_save="1"/>
|
||||||
<!-- <field name="type" readonly="1"/>-->
|
<!-- <field name="type" readonly="1"/>-->
|
||||||
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
<field name="feeder_station_destination_id" readonly="1" force_save="1"/>
|
||||||
<button name="action_delivery_history" type="object" class="btn btn-link text-info" icon="fa-history"
|
<button name="action_delivery_history" type="object" class="btn btn-link text-info" icon="fa-history"
|
||||||
string="历史"/>
|
string="历史"/>
|
||||||
|
|||||||
@@ -67,6 +67,9 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
logging.info('cnc_processing_arr:%s' % cnc_processing_arr)
|
||||||
if cnc_program and cnc_processing_arr:
|
if cnc_program and cnc_processing_arr:
|
||||||
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
cnc_program.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
|
cnc_program.workorder_ids.filtered(lambda b1: b1.routing_type == '装夹预调').write(
|
||||||
|
{'processing_drawing': cnc_production.workorder_ids.filtered(
|
||||||
|
lambda b1: b1.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
cnc_program.workorder_ids.filtered(lambda b: b.routing_type == 'CNC加工').write(
|
||||||
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
{'cnc_ids': cnc_processing_arr, 'cnc_worksheet': cnc_production.workorder_ids.filtered(
|
||||||
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
lambda b: b.routing_type == 'CNC加工').cnc_worksheet})
|
||||||
|
|||||||
Reference in New Issue
Block a user