还原代码

This commit is contained in:
jinling.yang
2024-11-18 11:40:24 +08:00
parent e8c006d495
commit a2855f1f08
4 changed files with 51 additions and 61 deletions

View File

@@ -28,27 +28,27 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
domain = [('programming_no', '=', ret['programming_no'])]
if ret['manufacturing_type'] in ('scrap', 'invalid_tool_rework'):
domain += [('state', 'not in', ['done', 'scrap', 'cancel'])]
else:
domain += [('state', '=', 'confirmed')]
productions = request.env['mrp.production'].with_user(
request.env.ref("base.user_admin")).search(domain)
production_technology_comfirm = request.env['mrp.production'].with_user(
request.env.ref("base.user_admin")).search([('programming_no', '=', ret['programming_no']),('state','=','confirmed')])
if productions:
# 拉取所有加工面的程序文件
# for r in ret['processing_panel'].split(','):
# program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
# if os.path.exists(program_path_tmp_r):
# files_r = os.listdir(program_path_tmp_r)
# if files_r:
# for file_name in files_r:
# file_path = os.path.join(program_path_tmp_r, file_name)
# os.remove(file_path)
# download_state = request.env['sf.cnc.processing'].with_user(
# request.env.ref("base.user_admin")).download_file_tmp(
# ret['folder_name'], r)
# if download_state is False:
# res['status'] = -2
# res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
# return json.JSONEncoder().encode(res)
for r in ret['processing_panel'].split(','):
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
if os.path.exists(program_path_tmp_r):
files_r = os.listdir(program_path_tmp_r)
if files_r:
for file_name in files_r:
file_path = os.path.join(program_path_tmp_r, file_name)
os.remove(file_path)
download_state = request.env['sf.cnc.processing'].with_user(
request.env.ref("base.user_admin")).download_file_tmp(
ret['folder_name'], r)
if download_state is False:
res['status'] = -2
res['message'] = '编程单号为%s的CNC程序文件从FTP拉取失败' % (ret['programming_no'])
return json.JSONEncoder().encode(res)
for production in productions:
for panel in ret['processing_panel'].split(','):
# 查询状态为进行中且工序类型为CNC加工的工单
@@ -65,30 +65,29 @@ class Sf_Mrs_Connect(http.Controller, MultiInheritController):
cnc_workorder_has.write(
{'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)})
# for panel in ret['processing_panel'].split(','):
# # 查询状态为进行中且工序类型为CNC加工的工单
# cnc_workorder = productions.workorder_ids.filtered(
# lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
# 'cancel'] and ac.processing_panel == panel)
# if cnc_workorder:
# # program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# # 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)
# files_panel = os.listdir(program_path_tmp_panel)
# if files_panel:
# for file in files_panel:
# file_extension = os.path.splitext(file)[1]
# if file_extension.lower() == '.pdf':
# panel_file_path = os.path.join(program_path_tmp_panel, file)
# logging.info('panel_file_path:%s' % panel_file_path)
# cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
# pre_workorder = productions.workorder_ids.filtered(
# lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
# 'cancel'] and ap.processing_panel == panel)
# if pre_workorder:
# pre_workorder.write(
# {'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
for panel in ret['processing_panel'].split(','):
# 查询状态为进行中且工序类型为CNC加工的工单
cnc_workorder = productions.workorder_ids.filtered(
lambda ac: ac.routing_type == 'CNC加工' and ac.state not in ['progress', 'done', 'rework'
'cancel'] and ac.processing_panel == panel)
if cnc_workorder:
# program_path_tmp_panel = os.path.join('C://Users//43484//Desktop//fsdownload//test',
# panel)
program_path_tmp_panel = os.path.join('/tmp', ret['folder_name'], 'return', panel)
files_panel = os.listdir(program_path_tmp_panel)
if files_panel:
for file in files_panel:
file_extension = os.path.splitext(file)[1]
if file_extension.lower() == '.pdf':
panel_file_path = os.path.join(program_path_tmp_panel, file)
logging.info('panel_file_path:%s' % panel_file_path)
cnc_workorder.write({'cnc_worksheet': base64.b64encode(open(panel_file_path, 'rb').read())})
pre_workorder = productions.workorder_ids.filtered(
lambda ap: ap.routing_type == '装夹预调' and ap.state not in ['done', 'rework'
'cancel'] and ap.processing_panel == panel)
if pre_workorder:
pre_workorder.write(
{'processing_drawing': base64.b64encode(open(panel_file_path, 'rb').read())})
productions.write({'programming_state': '已编程', 'work_state': '已编程'})
logging.info('已更新制造订单编程状态:%s' % productions.ids)
res.update({