From 52b045b6589548015d79dd6df3328764d5cf200c Mon Sep 17 00:00:00 2001 From: mgw <1392924357@qq.com> Date: Thu, 23 Feb 2023 10:57:42 +0800 Subject: [PATCH] =?UTF-8?q?=E5=90=88=E5=B9=B6=E4=B8=8B=E5=8F=91=E6=9C=AC?= =?UTF-8?q?=E5=9C=B0=E6=B5=8B=E8=AF=95=E5=B7=B2=E6=88=90=E5=8A=9F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- sf_machine_connect/wizard/action_up.py | 50 ++++++++++++++++++++++++-- 1 file changed, 48 insertions(+), 2 deletions(-) diff --git a/sf_machine_connect/wizard/action_up.py b/sf_machine_connect/wizard/action_up.py index 00e5068b..f3741c8a 100644 --- a/sf_machine_connect/wizard/action_up.py +++ b/sf_machine_connect/wizard/action_up.py @@ -20,11 +20,57 @@ class UpSelectWizard(models.TransientModel): _name = 'up.select.wizard' workorder_id = fields.Many2one('mrp.workorder', string='工单', readonly=True) - workcenter_id = fields.Many2one('mrp.workcenter', string='工作中心', related='workorder_id.workcenter_id', readonly=True) + workcenter_id = fields.Many2one('mrp.workcenter', string='工作中心', related='workorder_id.workcenter_id', + readonly=True) program_ids = fields.Many2many('sf.cnc.processing', string='程序列表') + program_name = [] + def confirm_up(self): - pass + + + host = self.workcenter_id.machine_tool_id.ftp_host + port = self.workcenter_id.machine_tool_id.ftp_port + username = self.workcenter_id.machine_tool_id.ftp_num + pwd = self.workcenter_id.machine_tool_id.ftp_pwd + remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path + print(host, port, username, pwd, remote_path) + # ftp = ftp_operate.FtpController(host, port, username, pwd) + try: + # 给文件名 + begin_name1 = self.program_ids[0].cnc_id.display_name.split('-') + temp_name1 = begin_name1[-1].split('.') + final_name = '%s-MERGE.%s' % (begin_name1[0], temp_name1[-1]) + print(final_name) + + for item in self.program_ids: + # print(item.program_name) + # print(item.cnc_id) + a = item.cnc_id + print(a.display_name) + _logger.info(a.public) + _logger.info(a.display_name) + datas = base64.standard_b64decode(a.datas) + # print(datas) + # file_path_local = '{}/{}'.format('/nc2machine', final_name) + # print(file_path_local) + + # 本地测试合并下发 + file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name) + # file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name) + # file_path_remote = '{}\{}'.format(remote_path, a.display_name) + # 合并文件 + with open(file_path_local, mode='wb+') as file: + file.write(datas) + + # 存在本地的文件下发到机床 + # _logger.info("=====================11================") + # # ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local) + # item.button_state = True + # _logger.info("=====================22================") + except Exception as e: + _logger.info("=====================================", e) + raise UserError('NC下发执行超时, 请检查下发状态') # cnc_id1 = fields.Many2one('ir.attachment', compute='_compute_cnc_id') # sequence_number1 = fields.Char('序号', compute='_compute_cnc_id', default='0')