优化编程单下发接口

This commit is contained in:
jinling.yang
2024-06-19 15:39:28 +08:00
parent c035ab8156
commit b390712308

View File

@@ -47,28 +47,31 @@ class Sf_Mrs_Connect(http.Controller):
# if ret['glb_file']: # if ret['glb_file']:
# cnc_production.glb_file = base64.b64encode(ret['glb_file']) # cnc_production.glb_file = base64.b64encode(ret['glb_file'])
# 拉取所有加工面的程序文件 # 拉取所有加工面的程序文件
if is_delete_file is True: # for r in ret['processing_panel'].split(','):
program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', 'R') # if is_delete_file is True:
files_r = os.listdir(program_path_tmp_r) # program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', r)
if files_r: # files_r = os.listdir(program_path_tmp_r)
for file_name in files_r: # if files_r:
file_path = os.path.join(program_path_tmp_r, file_name) # for file_name in files_r:
os.remove(file_path) # file_path = os.path.join(program_path_tmp_r, file_name)
for r in ret['processing_panel']: # 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 == 0: # if download_state == 0:
res['status'] = -2 # res['status'] = -2
res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name) # res['message'] = '制造订单号为%s的CNC程序文件从FTP拉取失败' % (cnc_production.name)
return json.JSONEncoder().encode(res) # return json.JSONEncoder().encode(res)
logging.info('创建cnc工单') logging.info('创建cnc工单')
program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', r)
# program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis"
files = os.listdir(program_path_tmp)
cnc_processing_arr = [] cnc_processing_arr = []
for f in files: cmm_program_arr = []
program_path = os.path.join(program_path_tmp, f) for panel in ret['processing_panel'].split(','):
program_path_tmp = os.path.join('/tmp', ret['folder_name'], 'return', panel)
# program_path_tmp = "C://Users//43484//Desktop//机企猫工作文档//其他//model_analysis"
files = os.listdir(program_path_tmp)
cnc_processing_arr = []
for f in files:
program_path = os.path.join(program_path_tmp, f)
logging.info('cnc程序路径 :%s' % program_path) logging.info('cnc程序路径 :%s' % program_path)
if f.endswith(".doc"): if f.endswith(".doc"):
# 插入cmm程序数据 # 插入cmm程序数据