From 2eaec4fa58a27318a72adddc71fd8a6bb07c2a66 Mon Sep 17 00:00:00 2001 From: "jinling.yang" Date: Wed, 5 Jun 2024 18:03:08 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E7=BC=96=E7=A8=8B=E5=8D=95?= =?UTF-8?q?=E4=B8=8B=E5=8F=91=E6=97=B6=EF=BC=8C=E5=88=A0=E9=99=A4=E5=AE=B9?= =?UTF-8?q?=E5=99=A8=E5=86=85tmp=E7=9B=AE=E5=BD=95=E4=B8=8B=E6=A8=A1?= =?UTF-8?q?=E5=9E=8B=E7=BC=96=E7=A0=81=E5=B7=B2=E6=9C=89=E7=9A=84=E6=96=87?= =?UTF-8?q?=E4=BB=B6?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_mrs_connect/controllers/controllers.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/sf_mrs_connect/controllers/controllers.py b/sf_mrs_connect/controllers/controllers.py index ddaa6fd5..78a0c05a 100644 --- a/sf_mrs_connect/controllers/controllers.py +++ b/sf_mrs_connect/controllers/controllers.py @@ -24,6 +24,7 @@ class Sf_Mrs_Connect(http.Controller): ret = json.loads(datas) ret = json.loads(ret['result']) logging.info('下发编程单:%s' % ret) + is_delete_file = False # 查询状态为进行中且类型为获取CNC加工程序的工单 cnc_production = request.env['mrp.production'].with_user( request.env.ref("base.user_admin")).search([('name', '=', ret['production_order_no'].split(',')[0])]) @@ -31,6 +32,7 @@ class Sf_Mrs_Connect(http.Controller): request.env.ref("base.user_admin")).search( [('programming_no', '=', cnc_production.programming_no), ('id', '!=', cnc_production.id)]) if cnc_production.workorder_ids.filtered(lambda a: a.routing_type == 'CNC加工').cnc_ids: + is_delete_file = True cnc_production.workorder_ids.filtered( lambda a1: a1.routing_type == 'CNC加工').cnc_ids.sudo().unlink() request.env['sf.cam.work.order.program.knife.plan'].sudo().unlink_cam_plan(cnc_production) @@ -45,6 +47,13 @@ class Sf_Mrs_Connect(http.Controller): # if ret['glb_file']: # cnc_production.glb_file = base64.b64encode(ret['glb_file']) # 拉取所有加工面的程序文件 + if is_delete_file is True: + program_path_tmp_r = os.path.join('/tmp', ret['folder_name'], 'return', '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) for r in ret['processing_panel']: download_state = request.env['sf.cnc.processing'].with_user( request.env.ref("base.user_admin")).download_file_tmp(