修改工件拆卸
This commit is contained in:
@@ -477,7 +477,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('LocationChange error:%s' % e)
|
logging.info('LocationChange error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/AGVToProduct', type='json', auth='public', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def AGVToProduct(self, **kw):
|
def AGVToProduct(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -549,7 +549,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
logging.info('AGVToProduct error:%s' % e)
|
logging.info('AGVToProduct error:%s' % e)
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
|
|
||||||
@http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/AGVDownProduct', type='json', auth='public', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def AGVDownProduct(self, **kw):
|
def AGVDownProduct(self, **kw):
|
||||||
"""
|
"""
|
||||||
@@ -668,7 +668,7 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
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/AgvStationState', type='json', auth='sf_token', methods=['GET', 'POST'], csrf=False,
|
@http.route('/AutoDeviceApi/AgvStationState', type='json', auth='public', methods=['GET', 'POST'], csrf=False,
|
||||||
cors="*")
|
cors="*")
|
||||||
def AGVStationState(self, **kw):
|
def AGVStationState(self, **kw):
|
||||||
"""
|
"""
|
||||||
|
|||||||
@@ -270,6 +270,7 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
"""
|
"""
|
||||||
获取关联的制造订单下产线的agv任务
|
获取关联的制造订单下产线的agv任务
|
||||||
"""
|
"""
|
||||||
|
self.ensure_one()
|
||||||
workorder_ids = self.production_id.workorder_ids
|
workorder_ids = self.production_id.workorder_ids
|
||||||
cnc_workorder = workorder_ids.filtered(
|
cnc_workorder = workorder_ids.filtered(
|
||||||
lambda w: w.routing_type == 'CNC加工' and w.state == 'done' and w.processing_panel == self.processing_panel
|
lambda w: w.routing_type == 'CNC加工' and w.state == 'done' and w.processing_panel == self.processing_panel
|
||||||
|
|||||||
@@ -1351,23 +1351,23 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
return res
|
return res
|
||||||
|
|
||||||
def button_delivery(self):
|
def button_delivery(self):
|
||||||
production_ids = []
|
# production_ids = []
|
||||||
workorder_ids = []
|
# workorder_ids = []
|
||||||
delivery_type = '运送空料架'
|
delivery_type = '运送空料架'
|
||||||
max_num = 4 # 最大配送数量
|
# max_num = 4 # 最大配送数量
|
||||||
feeder_station_start_id = False
|
# feeder_station_start_id = False
|
||||||
if len(self) > max_num:
|
# if len(self) > max_num:
|
||||||
raise UserError('仅限于拆卸1-4个制造订单,请重新选择')
|
# raise UserError('仅限于拆卸1-4个制造订单,请重新选择')
|
||||||
for item in self:
|
# for item in self:
|
||||||
if item.state != 'ready':
|
# if item.state != 'ready':
|
||||||
raise UserError('请选择状态为【就绪】的工单进行解除装夹')
|
# raise UserError('请选择状态为【就绪】的工单进行解除装夹')
|
||||||
|
#
|
||||||
production_ids.append(item.production_id.id)
|
# production_ids.append(item.production_id.id)
|
||||||
workorder_ids.append(item.id)
|
# workorder_ids.append(item.id)
|
||||||
if not feeder_station_start_id:
|
# if not feeder_station_start_id:
|
||||||
down_product_agv_scheduling = self.get_down_product_agv_scheduling()
|
# down_product_agv_scheduling = item.get_down_product_agv_scheduling()
|
||||||
if down_product_agv_scheduling:
|
# if down_product_agv_scheduling:
|
||||||
feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
|
# feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
|
||||||
return {
|
return {
|
||||||
'name': _('确认'),
|
'name': _('确认'),
|
||||||
'type': 'ir.actions.act_window',
|
'type': 'ir.actions.act_window',
|
||||||
@@ -1376,12 +1376,12 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
'target': 'new',
|
'target': 'new',
|
||||||
'context': {
|
'context': {
|
||||||
# 'default_delivery_ids': [(6, 0, delivery_ids)],
|
# 'default_delivery_ids': [(6, 0, delivery_ids)],
|
||||||
'default_production_ids': [(6, 0, production_ids)],
|
# 'default_production_ids': [(6, 0, production_ids)],
|
||||||
'default_delivery_type': delivery_type,
|
'default_delivery_type': delivery_type,
|
||||||
'default_workorder_ids': [(6, 0, workorder_ids)],
|
# 'default_workorder_ids': [(6, 0, workorder_ids)],
|
||||||
'default_workcenter_id': self.env.context.get('default_workcenter_id'),
|
'default_workcenter_id': self.env.context.get('default_workcenter_id'),
|
||||||
'default_confirm_button': '确认解除',
|
'default_confirm_button': '确认解除',
|
||||||
'default_feeder_station_start_id': feeder_station_start_id,
|
# 'default_feeder_station_start_id': feeder_station_start_id,
|
||||||
}}
|
}}
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -185,7 +185,11 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
|||||||
# 判断是否是AGV接驳站名称
|
# 判断是否是AGV接驳站名称
|
||||||
agv_site = self.env['sf.agv.site'].search([('name', '=', barcode)])
|
agv_site = self.env['sf.agv.site'].search([('name', '=', barcode)])
|
||||||
if agv_site:
|
if agv_site:
|
||||||
self.feeder_station_start_id = agv_site.id
|
if not self.feeder_station_start_id:
|
||||||
|
self.feeder_station_start_id = agv_site.id
|
||||||
|
else:
|
||||||
|
if self.feeder_station_start_id.id != agv_site.id:
|
||||||
|
raise UserError('接驳站不匹配!')
|
||||||
return
|
return
|
||||||
delivery_type = self.env.context.get('default_delivery_type')
|
delivery_type = self.env.context.get('default_delivery_type')
|
||||||
if delivery_type == '上产线':
|
if delivery_type == '上产线':
|
||||||
@@ -211,10 +215,14 @@ class WorkpieceDeliveryWizard(models.TransientModel):
|
|||||||
self.production_ids |= workorder.production_id
|
self.production_ids |= workorder.production_id
|
||||||
self.workorder_ids |= workorder
|
self.workorder_ids |= workorder
|
||||||
|
|
||||||
if not self.feeder_station_start_id:
|
down_product_agv_scheduling = self.get_down_product_agv_scheduling()
|
||||||
down_product_agv_scheduling = self.get_down_product_agv_scheduling()
|
if down_product_agv_scheduling:
|
||||||
if down_product_agv_scheduling:
|
if not self.feeder_station_start_id:
|
||||||
self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
|
self.feeder_station_start_id = down_product_agv_scheduling.end_site_id.id
|
||||||
|
else:
|
||||||
|
if self.feeder_station_start_id.id != down_product_agv_scheduling.end_site_id.id:
|
||||||
|
raise UserError('该rfid不在%s接驳站内', self.feeder_station_start_id.name)
|
||||||
|
|
||||||
else:
|
else:
|
||||||
raise UserError('该rfid码对应的工单不存在')
|
raise UserError('该rfid码对应的工单不存在')
|
||||||
return
|
return
|
||||||
|
|||||||
@@ -31,67 +31,67 @@ class Sf_Mrs_Connect(http.Controller):
|
|||||||
request.env.ref("base.user_admin")).search(domain)
|
request.env.ref("base.user_admin")).search(domain)
|
||||||
if productions:
|
if productions:
|
||||||
# 拉取所有加工面的程序文件
|
# 拉取所有加工面的程序文件
|
||||||
for r in ret['processing_panel'].split(','):
|
# for r in ret['processing_panel'].split(','):
|
||||||
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
# program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
|
||||||
if os.path.exists(program_path_tmp_r):
|
# if os.path.exists(program_path_tmp_r):
|
||||||
files_r = os.listdir(program_path_tmp_r)
|
# files_r = os.listdir(program_path_tmp_r)
|
||||||
if files_r:
|
# if files_r:
|
||||||
for file_name in files_r:
|
# for file_name in files_r:
|
||||||
file_path = os.path.join(program_path_tmp_r, file_name)
|
# file_path = os.path.join(program_path_tmp_r, file_name)
|
||||||
os.remove(file_path)
|
# os.remove(file_path)
|
||||||
download_state = request.env['sf.cnc.processing'].with_user(
|
# download_state = request.env['sf.cnc.processing'].with_user(
|
||||||
request.env.ref("base.user_admin")).download_file_tmp(
|
# request.env.ref("base.user_admin")).download_file_tmp(
|
||||||
ret['folder_name'], r)
|
# ret['folder_name'], r)
|
||||||
if download_state is False:
|
# if download_state is False:
|
||||||
res['status'] = -2
|
# res['status'] = -2
|
||||||
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
|
||||||
return json.JSONEncoder().encode(res)
|
# return json.JSONEncoder().encode(res)
|
||||||
for production in productions:
|
for production in productions:
|
||||||
if not production.workorder_ids:
|
if not production.workorder_ids:
|
||||||
production.product_id.model_processing_panel = ret['processing_panel']
|
production.product_id.model_processing_panel = ret['processing_panel']
|
||||||
production._create_workorder(ret)
|
production._create_workorder(ret)
|
||||||
productions.process_range_time()
|
productions.process_range_time()
|
||||||
else:
|
# else:
|
||||||
for panel in ret['processing_panel'].split(','):
|
# for panel in ret['processing_panel'].split(','):
|
||||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
# # 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
cnc_workorder_has = production.workorder_ids.filtered(
|
# cnc_workorder_has = production.workorder_ids.filtered(
|
||||||
lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
|
# lambda ach: ach.routing_type == 'CNC加工' and ach.state not in ['progress', 'done',
|
||||||
'rework',
|
# 'rework',
|
||||||
'cancel'] and ach.processing_panel == panel)
|
# 'cancel'] and ach.processing_panel == panel)
|
||||||
if cnc_workorder_has:
|
# if cnc_workorder_has:
|
||||||
if cnc_workorder_has.cnc_ids:
|
# if cnc_workorder_has.cnc_ids:
|
||||||
cnc_workorder_has.cmm_ids.sudo().unlink()
|
# cnc_workorder_has.cmm_ids.sudo().unlink()
|
||||||
cnc_workorder_has.cnc_ids.sudo().unlink()
|
# cnc_workorder_has.cnc_ids.sudo().unlink()
|
||||||
request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
|
# request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(
|
||||||
production)
|
# production)
|
||||||
cnc_workorder_has.write(
|
# cnc_workorder_has.write(
|
||||||
{'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
# {'cnc_ids': cnc_workorder_has.cnc_ids.sudo()._json_cnc_processing(panel, ret),
|
||||||
'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
|
# 'cmm_ids': cnc_workorder_has.cmm_ids.sudo()._json_cmm_program(panel, ret)})
|
||||||
for panel in ret['processing_panel'].split(','):
|
# for panel in ret['processing_panel'].split(','):
|
||||||
# 查询状态为进行中且工序类型为CNC加工的工单
|
# # 查询状态为进行中且工序类型为CNC加工的工单
|
||||||
cnc_workorder = productions.workorder_ids.filtered(
|
# cnc_workorder = productions.workorder_ids.filtered(
|
||||||
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
|
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
|
||||||
'cancel'] and ac.processing_panel == panel)
|
# 'cancel'] and ac.processing_panel == panel)
|
||||||
if cnc_workorder:
|
# if cnc_workorder:
|
||||||
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
|
||||||
# panel)
|
# # panel)
|
||||||
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
# program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
|
||||||
logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
# logging.info('program_path_tmp_panel:%s' % program_path_tmp_panel)
|
||||||
files_panel = os.listdir(program_path_tmp_panel)
|
# files_panel = os.listdir(program_path_tmp_panel)
|
||||||
if files_panel:
|
# if files_panel:
|
||||||
for file in files_panel:
|
# for file in files_panel:
|
||||||
file_extension = os.path.splitext(file)[1]
|
# file_extension = os.path.splitext(file)[1]
|
||||||
logging.info('file_extension:%s' % file_extension)
|
# logging.info('file_extension:%s' % file_extension)
|
||||||
if file_extension.lower() == '.pdf':
|
# if file_extension.lower() == '.pdf':
|
||||||
panel_file_path = os.path.join(program_path_tmp_panel, file)
|
# panel_file_path = os.path.join(program_path_tmp_panel, file)
|
||||||
logging.info('panel_file_path:%s' % panel_file_path)
|
# logging.info('panel_file_path:%s' % panel_file_path)
|
||||||
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
pre_workorder = productions.workorder_ids.filtered(
|
# pre_workorder = productions.workorder_ids.filtered(
|
||||||
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
|
||||||
'cancel'] and ap.processing_panel == panel)
|
# 'cancel'] and ap.processing_panel == panel)
|
||||||
if pre_workorder:
|
# if pre_workorder:
|
||||||
pre_workorder.write(
|
# pre_workorder.write(
|
||||||
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
|
||||||
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
|
||||||
return json.JSONEncoder().encode(res)
|
return json.JSONEncoder().encode(res)
|
||||||
else:
|
else:
|
||||||
|
|||||||
Reference in New Issue
Block a user