优化代码,恢复屏蔽代码,准备去测试新的NC下发

This commit is contained in:
mgw
2023-02-27 09:43:24 +08:00
parent 6ae0abac94
commit 8247acb79a
2 changed files with 72 additions and 201 deletions

View File

@@ -32,8 +32,8 @@ class UpSelectWizard(models.TransientModel):
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)
print(host, port, username, pwd, remote_path)
ftp = ftp_operate.FtpController(host, port, username, pwd)
sequence_collect = []
try:
# 给文件名
@@ -48,24 +48,25 @@ class UpSelectWizard(models.TransientModel):
sequence_collect.append(item.sequence_number)
a = item.cnc_id
print(a.display_name)
# _logger.info(a.public)
# _logger.info(a.display_name)
# datas = base64.standard_b64decode(a.datas)
# file_path_local = '{}/{}'.format('/nc2machine', final_name)
#
# # 本地测试合并下发
# # 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, final_name)
# # 合并文件
# with open(file_path_local, mode='ab+') as file:
# file.write(datas)
#
# # 存在本地的文件下发到机床
# _logger.info("==========存在服务器成功,准备下发===========")
# # ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
# # # 下发成功标识
# # item.button_state = True
_logger.info(a.public)
_logger.info(a.display_name)
datas = base64.standard_b64decode(a.datas)
file_path_local = '{}/{}'.format('/nc2machine', final_name)
# 本地测试合并下发
# 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, final_name)
# 合并文件
with open(file_path_local, mode='ab+') as file:
file.write(datas)
# 存在本地的文件下发到机床
_logger.info("==========存在服务器成功,准备下发===========")
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
_logger.info("======%s下发成功======" % a.display_name)
# 下发成功标识
item.button_state = True
up_time = str(datetime.now())
sequence_str = ','.join(sequence_collect)
self.workorder_id.delivery_records.create({
@@ -78,91 +79,3 @@ class UpSelectWizard(models.TransientModel):
_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')
# program_name1 = fields.Char('程序名', compute='_compute_cnc_id')
# cutting_tool_name1 = fields.Char('刀具名称', compute='_compute_cnc_id')
# cutting_tool_no1 = fields.Char('刀号', compute='_compute_cnc_id')
# processing_type1 = fields.Char('加工类型', compute='_compute_cnc_id')
# margin_x_y1 = fields.Char('余量_X/Y', compute='_compute_cnc_id')
# margin_z1 = fields.Char('余量_Z', compute='_compute_cnc_id')
# depth_of_processing_z1 = fields.Char('加工深度(Z)', compute='_compute_cnc_id')
# cutting_tool_extension_length1 = fields.Char('刀具伸出长度', compute='_compute_cnc_id')
# cutting_tool_handle_type1 = fields.Char('刀柄型号', compute='_compute_cnc_id')
# estimated_processing_time1 = fields.Char('预计加工时间', compute='_compute_cnc_id')
# remark1 = fields.Text('备注', compute='_compute_cnc_id')
# cnc_id = fields.Many2one('sf.cnc.processing', '工单')
# num = fields.Integer('索引', default=0)
# cnc_id1 = fields.Many2one('ir.attachment')
# sequence_number1 = fields.Char('序号', compute='_compute_cnc_id', default='1')
# program_name1 = fields.Char('程序名')
# cutting_tool_name1 = fields.Char('刀具名称')
# cutting_tool_no1 = fields.Char('刀号')
# processing_type1 = fields.Char('加工类型')
# margin_x_y1 = fields.Char('余量_X/Y')
# margin_z1 = fields.Char('余量_Z')
# depth_of_processing_z1 = fields.Char('加工深度(Z)')
# cutting_tool_extension_length1 = fields.Char('刀具伸出长度')
# cutting_tool_handle_type1 = fields.Char('刀柄型号')
# estimated_processing_time1 = fields.Char('预计加工时间')
# remark1 = fields.Text('备注')
# cnc_id = fields.Many2one('sf.cnc.processing', '工单')
# num = fields.Integer('索引', default=0)
# print(11111111111111111111111111111111111111111111111)
# # @api.depends('program_ids')
# def _compute_cnc_id(self):
# print(222222222222222222222222222222222222222222)
# workorder_id = self.env.context.get('default_workorder_id')
# workorder = self.env['mrp.workorder'].sudo().search([('id', '=', workorder_id)])
# # self.workcenter_id = workorder.workcent_id
# print(workorder_id)
#
# lines = []
# print(lines)
# for item in workorder.cnc_ids:
# # lines.append((4,item.id,0))
# lines.append((4, item.id, 0))
# print(lines)
#
# # print(self.cnc_id1, self.sequence_number1, self.program_name1, self.processing_type1,
# # self.cutting_tool_handle_type1
# # , self.cutting_tool_extension_length1, self.margin_z1, self.margin_z1, self.depth_of_processing_z1,
# # self.cutting_tool_no1, self.cutting_tool_name1, self.estimated_processing_time1, self.remark1)
# # else:
# # self.write({
# #
# # # 'cnc_id1': item.cnc_id or '',
# # # 'sequence_number1': item.sequence_number or '',
# # # 'program_name1': item.program_name or '',
# # # 'cutting_tool_name1': item.cutting_tool_name or '',
# # # 'cutting_tool_no1': item.cutting_tool_no or '',
# # # 'processing_type1': item.processing_type or '',
# # # 'margin_x_y1': item.margin_x_y or '',
# # # 'margin_z1': item.margin_z or '',
# # # 'depth_of_processing_z1': item.depth_of_processing_z or '',
# # # 'cutting_tool_extension_length1': item.cutting_tool_extension_length or '',
# # # 'cutting_tool_handle_type1': item.cutting_tool_handle_type or '',
# # # 'estimated_processing_time1': item.estimated_processing_time or '',
# # # 'remark1': item.remark or '',
# # 'id': item.sequence_number,
# # 'cnc_id1': item.cnc_id,
# # 'sequence_number1': item.sequence_number,
# # 'program_name1': item.program_name,
# # 'cutting_tool_name1': item.cutting_tool_name,
# # 'cutting_tool_no1': item.cutting_tool_no,
# # 'processing_type1': item.processing_type,
# # 'margin_x_y1': item.margin_x_y,
# # 'margin_z1': item.margin_z,
# # 'depth_of_processing_z1': item.depth_of_processing_z,
# # 'cutting_tool_extension_length1': item.cutting_tool_extension_length,
# # 'cutting_tool_handle_type1': item.cutting_tool_handle_type,
# # 'estimated_processing_time1': item.estimated_processing_time,
# # 'remark1': item.remark,
# # })
# # print(self.cnc_id1, self.sequence_number1, self.program_name1, self.processing_type1,
# # self.cutting_tool_handle_type1
# # , self.cutting_tool_extension_length1, self.margin_z1, self.margin_z1,
# # self.depth_of_processing_z1,
# # self.cutting_tool_no1, self.cutting_tool_name1, self.estimated_processing_time1, self.remark1)
#
# self.update({'program_ids': lines})