合并下发已完成,正在增加下发记录对象
This commit is contained in:
@@ -18,7 +18,8 @@
|
|||||||
# 权限组
|
# 权限组
|
||||||
'security/ir.model.access.csv',
|
'security/ir.model.access.csv',
|
||||||
'wizard/up_select.xml',
|
'wizard/up_select.xml',
|
||||||
'views/cnc.xml',
|
'views/default_delivery.xml',
|
||||||
|
'views/delivery_record.xml',
|
||||||
|
|
||||||
'views/compensation.xml',
|
'views/compensation.xml',
|
||||||
'views/ftp_button.xml',
|
'views/ftp_button.xml',
|
||||||
@@ -28,7 +29,6 @@
|
|||||||
'views/Stock_picking_Barcodes.xml',
|
'views/Stock_picking_Barcodes.xml',
|
||||||
'views/machine_monitor.xml',
|
'views/machine_monitor.xml',
|
||||||
'views/machine_info_present.xml',
|
'views/machine_info_present.xml',
|
||||||
'views/delivery_record.xml',
|
|
||||||
|
|
||||||
],
|
],
|
||||||
|
|
||||||
|
|||||||
@@ -63,37 +63,43 @@ class FtpButton(models.Model):
|
|||||||
# 点击下发按钮自动补偿三元检测偏差值
|
# 点击下发按钮自动补偿三元检测偏差值
|
||||||
|
|
||||||
try:
|
try:
|
||||||
try:
|
# try:
|
||||||
if self.sequence_number == '1':
|
# if self.sequence_number == '1':
|
||||||
self.check_compensation_before_up()
|
# self.check_compensation_before_up()
|
||||||
except Exception:
|
# except Exception:
|
||||||
raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
|
# raise UserError("补偿值写入执行超时,请检查机床状态或者写入状态")
|
||||||
|
#
|
||||||
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
# # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||||
host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host
|
# host = self.workorder_id.workcenter_id.machine_tool_id.ftp_host
|
||||||
port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
|
# port = self.workorder_id.workcenter_id.machine_tool_id.ftp_port
|
||||||
username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
|
# username = self.workorder_id.workcenter_id.machine_tool_id.ftp_num
|
||||||
pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd
|
# pwd = self.workorder_id.workcenter_id.machine_tool_id.ftp_pwd
|
||||||
remote_path = self.workorder_id.workcenter_id.machine_tool_id.ftp_remote_path
|
# remote_path = self.workorder_id.workcenter_id.machine_tool_id.ftp_remote_path
|
||||||
print(host, port, username, pwd, remote_path)
|
# print(host, port, username, pwd, remote_path)
|
||||||
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
# ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||||
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
# # ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
||||||
a = self.cnc_id
|
a = self.cnc_id
|
||||||
_logger.info(a.public)
|
# _logger.info(a.public)
|
||||||
_logger.info(a.display_name)
|
# _logger.info(a.display_name)
|
||||||
datas = base64.standard_b64decode(a.datas)
|
# datas = base64.standard_b64decode(a.datas)
|
||||||
|
#
|
||||||
# file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
# # file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||||
file_path_local = '{}/{}'.format('/nc2machine', a.display_name)
|
# file_path_local = '{}/{}'.format('/nc2machine', a.display_name)
|
||||||
# file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', 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)
|
# file_path_remote = '{}\{}'.format(remote_path, a.display_name)
|
||||||
|
#
|
||||||
with open(file_path_local, mode='wb+') as file:
|
# with open(file_path_local, mode='wb+') as file:
|
||||||
file.write(datas)
|
# file.write(datas)
|
||||||
# 存在本地的文件下发到机床
|
# # 存在本地的文件下发到机床
|
||||||
_logger.info("=====================11================")
|
# _logger.info("=====================11================")
|
||||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
# ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
||||||
_logger.info("=====================22================")
|
# _logger.info("=====================22================")
|
||||||
|
up_time = str(datetime.now())
|
||||||
|
self.workorder_id.delivery_records.create({
|
||||||
|
'delivery_type': '单个下发',
|
||||||
|
'delivery_time': 'up_time',
|
||||||
|
'influence_record': 'self.sequence_number',
|
||||||
|
})
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
_logger.info("=====================================", e)
|
||||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||||
@@ -218,6 +224,7 @@ class WorkCenterBarcode(models.Model):
|
|||||||
string='切削状态', compute='_run_info', readonly=True, default='0')
|
string='切削状态', compute='_run_info', readonly=True, default='0')
|
||||||
machine_tool_compensation_value_x = fields.Char('x补偿值', compute='_run_info', readonly=True)
|
machine_tool_compensation_value_x = fields.Char('x补偿值', compute='_run_info', readonly=True)
|
||||||
machine_tool_compensation_value_y = fields.Char('y补偿值', compute='_run_info', readonly=True)
|
machine_tool_compensation_value_y = fields.Char('y补偿值', compute='_run_info', readonly=True)
|
||||||
|
delivery_records = fields.One2many('delivery.record', 'workorder_id', string="下发记录")
|
||||||
|
|
||||||
@api.depends('workcenter_id.machine_tool_id.timestamp')
|
@api.depends('workcenter_id.machine_tool_id.timestamp')
|
||||||
def _run_info(self):
|
def _run_info(self):
|
||||||
@@ -260,48 +267,58 @@ class WorkCenterBarcode(models.Model):
|
|||||||
此函数用于将NC代码全部下发到机床
|
此函数用于将NC代码全部下发到机床
|
||||||
:return:
|
:return:
|
||||||
"""
|
"""
|
||||||
try:
|
# try:
|
||||||
filepath = '/nc2machine'
|
# filepath = '/nc2machine'
|
||||||
del_list = os.listdir(filepath)
|
# del_list = os.listdir(filepath)
|
||||||
_logger.info("=====================================", del_list)
|
# _logger.info("=====================================", del_list)
|
||||||
for f in del_list:
|
# for f in del_list:
|
||||||
file_path = os.path.join(filepath, f)
|
# file_path = os.path.join(filepath, f)
|
||||||
if os.path.isfile(file_path):
|
# if os.path.isfile(file_path):
|
||||||
os.remove(file_path)
|
# os.remove(file_path)
|
||||||
except Exception as e:
|
# except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
# _logger.info("=====================================", e)
|
||||||
raise UserError('程序删除失败,请重试')
|
# raise UserError('程序删除失败,请重试')
|
||||||
# host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
# # host="192.168.2.158", port=8080, username="MITSUBISHI", password="CNC"
|
||||||
host = self.workcenter_id.machine_tool_id.ftp_host
|
sequence_collect = []
|
||||||
port = self.workcenter_id.machine_tool_id.ftp_port
|
# host = self.workcenter_id.machine_tool_id.ftp_host
|
||||||
username = self.workcenter_id.machine_tool_id.ftp_num
|
# port = self.workcenter_id.machine_tool_id.ftp_port
|
||||||
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
# username = self.workcenter_id.machine_tool_id.ftp_num
|
||||||
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
# pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
||||||
print(host, port, username, pwd, remote_path)
|
# remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
||||||
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
# print(host, port, username, pwd, remote_path)
|
||||||
# ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
# ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||||
|
# # ftp.delAllfile('C://Users//马广威//Desktop//ftp')
|
||||||
try:
|
try:
|
||||||
for item in self.cnc_ids:
|
for item in self.cnc_ids:
|
||||||
a = item.cnc_id
|
a = item.cnc_id
|
||||||
print(a.display_name)
|
print(a.display_name)
|
||||||
_logger.info(a.public)
|
sequence_collect.append(item.sequence_number)
|
||||||
_logger.info(a.display_name)
|
# _logger.info(a.public)
|
||||||
datas = base64.standard_b64decode(a.datas)
|
# _logger.info(a.display_name)
|
||||||
|
# datas = base64.standard_b64decode(a.datas)
|
||||||
|
#
|
||||||
|
# # file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
||||||
|
# file_path_local = '{}/{}'.format('/nc2machine', a.display_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, 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
|
||||||
|
up_time = str(datetime.now())
|
||||||
|
sequence_str = ','.join(sequence_collect)
|
||||||
|
|
||||||
# file_path = '{}\{}\{}'.format(a._filestore(), a.store_fname.split('/'[0]), a.display_name)
|
self.delivery_records.create({
|
||||||
file_path_local = '{}/{}'.format('/nc2machine', a.display_name)
|
'delivery_type': '一键下发',
|
||||||
# 本地测试一键下发
|
'delivery_time': up_time,
|
||||||
# file_path_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
'influence_record': sequence_str,
|
||||||
# file_path_remote = '{}\{}'.format('//M80(192,168,2,142)//DS', a.display_name)
|
})
|
||||||
file_path_remote = '{}\{}'.format(remote_path, a.display_name)
|
_logger.info("=====================22================")
|
||||||
|
|
||||||
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:
|
except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
_logger.info("=====================================", e)
|
||||||
raise UserError('NC下发执行超时, 请检查下发状态')
|
raise UserError('NC下发执行超时, 请检查下发状态')
|
||||||
@@ -339,15 +356,30 @@ class WorkCenterBarcode(models.Model):
|
|||||||
url = 'https://bfm.cs.jikimo.com/api/get/state'
|
url = 'https://bfm.cs.jikimo.com/api/get/state'
|
||||||
requests.post(url, json=json, data=None)
|
requests.post(url, json=json, data=None)
|
||||||
|
|
||||||
def action_up_select(self):
|
|
||||||
return {
|
|
||||||
'name': '选择要下发的程序文件',
|
|
||||||
'view_mode': 'tree,form',
|
|
||||||
# 'res_model': self._name,
|
|
||||||
'res_model': 'sf_tray_form_inherit',
|
|
||||||
'target': 'main', # 打开方式
|
|
||||||
# 'domain': [('project_num', '=', self.project_num), ('state', '=', 'done')], # 域
|
|
||||||
'type': 'ir.actions.act_window', # 返回的类型
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
|
class DeliveryRecord(models.Model):
|
||||||
|
"""
|
||||||
|
扫码托盘码可查到制造订单,由制造订单查工单
|
||||||
|
"""
|
||||||
|
# _inherit = "mrp.workorder"
|
||||||
|
_name = "delivery.record"
|
||||||
|
|
||||||
|
delivery_type = fields.Char(string='下发方式', readonly=True)
|
||||||
|
delivery_time = fields.Char(string='下发时间', readonly=True)
|
||||||
|
influence_record = fields.Char(string='影响记录', readonly=True)
|
||||||
|
workorder_id = fields.Many2one('mrp.workorder', string='工单')
|
||||||
|
|
||||||
|
# @api.model
|
||||||
|
# def create(self, values):
|
||||||
|
# try:
|
||||||
|
# values['order_code'] = self.env['ir.sequence'].next_by_code('sf_machine_connect.delivery.record')
|
||||||
|
# stock = self.env['sunrise.u.stock']
|
||||||
|
# if 'order_items' in values.keys():
|
||||||
|
# for item in values['order_items']:
|
||||||
|
# stock_commodity = stock.search([('commodity', '=', item[2]['commodity'])])
|
||||||
|
# stock_commodity.amount += item[2]['amount']
|
||||||
|
# return super().create(values)
|
||||||
|
# except:
|
||||||
|
# raise Exception('b_purchase_order.py:create()')
|
||||||
|
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
id,name,model_id:id,group_id:id,perm_read,perm_write,perm_create,perm_unlink
|
||||||
|
|
||||||
access_up_select_wizard,up.select.wizard,model_up_select_wizard,base.group_user,1,1,1,1
|
access_up_select_wizard,up.select.wizard,model_up_select_wizard,base.group_user,1,1,1,1
|
||||||
|
access_delivery_record,delivery.record,model_delivery_record,base.group_user,1,1,1,1
|
||||||
|
access_mrp_workorder,mrp.workorder,model_mrp_workorder,base.group_user,1,1,1,1
|
||||||
|
|||||||
|
@@ -1,27 +0,0 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
|
||||||
<odoo>
|
|
||||||
|
|
||||||
|
|
||||||
<record id="sf_cnc_tree_view" model="ir.ui.view">
|
|
||||||
<field name="name">sf.cnc.tree</field>
|
|
||||||
<field name="model">sf.cnc.processing</field>
|
|
||||||
<field name="arch" type="xml">
|
|
||||||
<tree>
|
|
||||||
<field name="sequence_number"/>
|
|
||||||
<field name="program_name"/>
|
|
||||||
<field name="cnc_id" string="文件"/>
|
|
||||||
<field name="cutting_tool_name"/>
|
|
||||||
<field name="cutting_tool_no"/>
|
|
||||||
<field name="processing_type"/>
|
|
||||||
<field name="margin_x_y"/>
|
|
||||||
<field name="margin_z"/>
|
|
||||||
<field name="depth_of_processing_z"/>
|
|
||||||
<field name="cutting_tool_extension_length"/>
|
|
||||||
<field name="cutting_tool_handle_type"/>
|
|
||||||
<field name="estimated_processing_time"/>
|
|
||||||
<field name="remark"/>
|
|
||||||
</tree>
|
|
||||||
|
|
||||||
</field>
|
|
||||||
</record>
|
|
||||||
</odoo>
|
|
||||||
@@ -22,8 +22,7 @@
|
|||||||
<!-- <field name="button_up_all_state" attrs='{"invisible": ["|",-->
|
<!-- <field name="button_up_all_state" attrs='{"invisible": ["|",-->
|
||||||
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
<!-- ("state","!=","progress"),("user_permissions","=",False)]}'/>-->
|
||||||
<button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"
|
<button string="一键下发" name="up_all" type="object" style="text-align: right;" confirm="是否确认一键下发"
|
||||||
class="btn-primary" attrs='{"invisible": ["|",
|
class="btn-primary" context="{'default_workorder_id': id}"/>
|
||||||
("state","!=","progress"),("user_permissions","=",False)]}'/>
|
|
||||||
<span> </span>
|
<span> </span>
|
||||||
<button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d" type="action" class="btn-primary" context="{'default_workorder_id': id}"/>
|
<button string="合并下发" id="action_up_select" name="%(sf_machine_connect.action_up_select)d" type="action" class="btn-primary" context="{'default_workorder_id': id}"/>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
28
sf_machine_connect/views/default_delivery.xml
Normal file
28
sf_machine_connect/views/default_delivery.xml
Normal file
@@ -0,0 +1,28 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
<odoo>
|
||||||
|
|
||||||
|
<record id="delivery_tree" model="ir.ui.view">
|
||||||
|
<field name="name">delivery.record.tree</field>
|
||||||
|
<field name="model">delivery.record</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<tree>
|
||||||
|
<field name="delivery_type"/>
|
||||||
|
<field name="delivery_time"/>
|
||||||
|
<field name="influence_record"/>
|
||||||
|
</tree>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
<record id="delivery_tree" model="ir.ui.view">
|
||||||
|
<field name="name">delivery.record.tree</field>
|
||||||
|
<field name="model">delivery.record</field>
|
||||||
|
<field name="arch" type="xml">
|
||||||
|
<form>
|
||||||
|
<field name="delivery_type"/>
|
||||||
|
<field name="delivery_time"/>
|
||||||
|
<field name="influence_record"/>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
</field>
|
||||||
|
</record>
|
||||||
|
</odoo>
|
||||||
@@ -8,25 +8,25 @@
|
|||||||
<xpath expr="//page[last()-3]" position="before">
|
<xpath expr="//page[last()-3]" position="before">
|
||||||
<!-- <page string="下发记录" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>-->
|
<!-- <page string="下发记录" attrs='{"invisible": [("routing_type","!=","CNC加工")]}'>-->
|
||||||
<page string="下发记录">
|
<page string="下发记录">
|
||||||
<group string="机床信息">
|
<field name="delivery_records">
|
||||||
<field name="machine_tool_name"/>
|
<tree create="false">
|
||||||
<field name="machine_tool_type_id"/>
|
<field name="delivery_type"/>
|
||||||
<field name="machine_tool_machine_ip"/>
|
<field name="delivery_time"/>
|
||||||
</group>
|
<field name="influence_record"/>
|
||||||
<group string="运行信息">
|
</tree>
|
||||||
<field name="machine_tool_timestamp"/>
|
</field>
|
||||||
<field name="machine_tool_status"/>
|
|
||||||
<field name="machine_tool_run_status"/>
|
|
||||||
<field name="machine_tool_time_on"/>
|
|
||||||
<field name="machine_tool_time_on_now"/>
|
|
||||||
<field name="machine_tool_tool_num"/>
|
|
||||||
<field name="machine_tool_program"/>
|
|
||||||
<field name="machine_tool_cut_status"/>
|
|
||||||
<field name="machine_tool_compensation_value_x"/>
|
|
||||||
<field name="machine_tool_compensation_value_y"/>
|
|
||||||
</group>
|
|
||||||
</page>
|
</page>
|
||||||
</xpath>
|
</xpath>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
<!-- <record id="seqence_b_purchase_order" model='ir.sequence'> -->
|
||||||
|
<!-- <field name='name'>Purchase Order</field> -->
|
||||||
|
<!-- <field name='code'>sf_machine_connect.delivery.record</field> -->
|
||||||
|
<!-- <field name='prefix'>%(year)s%(month)s%(day)s</field> -->
|
||||||
|
<!-- <field name='padding'>5</field> -->
|
||||||
|
<!-- </record> -->
|
||||||
|
|
||||||
</odoo>
|
</odoo>
|
||||||
@@ -15,9 +15,10 @@
|
|||||||
<field name="state" invisible="1"/>
|
<field name="state" invisible="1"/>
|
||||||
<field name="button_state" attrs='{"invisible": ["|",("state","!=","progress"),
|
<field name="button_state" attrs='{"invisible": ["|",("state","!=","progress"),
|
||||||
("user_permissions","!=",True)]}' optional="show"/>
|
("user_permissions","!=",True)]}' optional="show"/>
|
||||||
<button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"
|
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序" -->
|
||||||
attrs='{"invisible": ["|",("state","!=","progress"),
|
<!-- attrs='{"invisible": ["|",("state","!=","progress"), -->
|
||||||
("user_permissions","!=",True)]}'/>
|
<!-- ("user_permissions","!=",True)]}'/> -->
|
||||||
|
<button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序" context="{'default_workorder_id': id}"/>
|
||||||
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"/>-->
|
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"/>-->
|
||||||
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"-->
|
<!-- <button string="下发" name="up" type="object" class="btn-primary" confirm="是否确认下发此程序"-->
|
||||||
<!-- />-->
|
<!-- />-->
|
||||||
|
|||||||
13
sf_machine_connect/views/project_sequence.xml
Normal file
13
sf_machine_connect/views/project_sequence.xml
Normal file
@@ -0,0 +1,13 @@
|
|||||||
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
|
|
||||||
|
<odoo noupdate="1">
|
||||||
|
|
||||||
|
<record id="seq_test" model="ir.sequence">
|
||||||
|
<field name="name">Test</field>
|
||||||
|
<field name="code">sf_machine_connect.delivery.record</field>
|
||||||
|
<field name="prefix">T%(range_year)s</field>
|
||||||
|
<field name="padding">4</field>
|
||||||
|
<field name="company_id" eval="False"/>
|
||||||
|
</record>
|
||||||
|
|
||||||
|
</odoo>
|
||||||
@@ -24,7 +24,6 @@ class UpSelectWizard(models.TransientModel):
|
|||||||
readonly=True)
|
readonly=True)
|
||||||
program_ids = fields.Many2many('sf.cnc.processing', string='程序列表')
|
program_ids = fields.Many2many('sf.cnc.processing', string='程序列表')
|
||||||
|
|
||||||
program_name = []
|
|
||||||
|
|
||||||
def confirm_up(self):
|
def confirm_up(self):
|
||||||
|
|
||||||
@@ -33,8 +32,9 @@ class UpSelectWizard(models.TransientModel):
|
|||||||
username = self.workcenter_id.machine_tool_id.ftp_num
|
username = self.workcenter_id.machine_tool_id.ftp_num
|
||||||
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
pwd = self.workcenter_id.machine_tool_id.ftp_pwd
|
||||||
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
remote_path = self.workcenter_id.machine_tool_id.ftp_remote_path
|
||||||
print(host, port, username, pwd, remote_path)
|
# print(host, port, username, pwd, remote_path)
|
||||||
ftp = ftp_operate.FtpController(host, port, username, pwd)
|
# ftp = ftp_operate.FtpController(host, port, username, pwd)
|
||||||
|
sequence_collect = []
|
||||||
try:
|
try:
|
||||||
# 给文件名
|
# 给文件名
|
||||||
begin_name1 = self.program_ids[0].cnc_id.display_name.split('-')
|
begin_name1 = self.program_ids[0].cnc_id.display_name.split('-')
|
||||||
@@ -45,28 +45,34 @@ class UpSelectWizard(models.TransientModel):
|
|||||||
for item in self.program_ids:
|
for item in self.program_ids:
|
||||||
# print(item.program_name)
|
# print(item.program_name)
|
||||||
# print(item.cnc_id)
|
# print(item.cnc_id)
|
||||||
|
sequence_collect.append(item.sequence_number)
|
||||||
a = item.cnc_id
|
a = item.cnc_id
|
||||||
print(a.display_name)
|
print(a.display_name)
|
||||||
_logger.info(a.public)
|
# _logger.info(a.public)
|
||||||
_logger.info(a.display_name)
|
# _logger.info(a.display_name)
|
||||||
datas = base64.standard_b64decode(a.datas)
|
# datas = base64.standard_b64decode(a.datas)
|
||||||
# print(datas)
|
# file_path_local = '{}/{}'.format('/nc2machine', final_name)
|
||||||
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_local = '{}/{}'.format('D:\\jikimo', a.display_name)
|
# file_path_remote = '{}\{}'.format(remote_path, final_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)
|
||||||
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("==========存在服务器成功,准备下发===========")
|
# # # 下发成功标识
|
||||||
ftp.upload_file(remotepath=file_path_remote, localpath=file_path_local)
|
# # item.button_state = True
|
||||||
# 下发成功标识
|
up_time = str(datetime.now())
|
||||||
item.button_state = True
|
sequence_str = ','.join(sequence_collect)
|
||||||
|
self.workorder_id.delivery_records.create({
|
||||||
|
'delivery_type': '合并下发',
|
||||||
|
'delivery_time': up_time,
|
||||||
|
'influence_record': sequence_str,
|
||||||
|
})
|
||||||
_logger.info("==============合并下发成功==============")
|
_logger.info("==============合并下发成功==============")
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
_logger.info("=====================================", e)
|
_logger.info("=====================================", e)
|
||||||
|
|||||||
@@ -51,7 +51,7 @@
|
|||||||
<tree position="attributes">
|
<tree position="attributes">
|
||||||
<attribute name="multi_edit"></attribute>
|
<attribute name="multi_edit"></attribute>
|
||||||
<attribute name="editable"></attribute>
|
<attribute name="editable"></attribute>
|
||||||
<attribute name="create">false</attribute>
|
<attribute name="create">False</attribute>
|
||||||
</tree>
|
</tree>
|
||||||
</field>
|
</field>
|
||||||
</record>
|
</record>
|
||||||
|
|||||||
Reference in New Issue
Block a user