Accept Merge Request #953: (feature/优化获取CNC程序 -> develop)
Merge Request: 优化获取cnc程序和FTP Created By: @杨金灵 Reviewed By: @马广威 Approved By: @马广威 Accepted By: @杨金灵 URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/953?initial=true
This commit is contained in:
@@ -114,7 +114,7 @@ class Manufacturing_Connect(http.Controller):
|
||||
logging.info('RfidCode:%s' % ret['RfidCode'])
|
||||
if 'RfidCode' in ret:
|
||||
workorder = request.env['mrp.workorder'].sudo().search(
|
||||
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])])
|
||||
[('routing_type', '=', '装夹预调'), ('rfid_code', '=', ret['RfidCode'])], limit=1, order='id asc')
|
||||
if workorder:
|
||||
for item in workorder:
|
||||
if item.material_center_point:
|
||||
@@ -122,8 +122,8 @@ class Manufacturing_Connect(http.Controller):
|
||||
res['Datas'].append({
|
||||
'XOffset': 0 if not item.material_center_point else offset[0],
|
||||
'YOffset': 0 if not item.material_center_point else offset[1],
|
||||
'ZOffet': 0 if not item.material_center_point else offset[2],
|
||||
'COffset': 0 if not item.X_deviation_angle else item.X_deviation_angle,
|
||||
'ZOffset': 0 if not item.material_center_point else offset[2],
|
||||
'COffset': 0,
|
||||
'Coordinate': 'G54'
|
||||
})
|
||||
else:
|
||||
|
||||
@@ -57,6 +57,8 @@ class MrpProduction(models.Model):
|
||||
production_line_state = fields.Selection([('待上产线', '待上产线'), ('已上产线', '已上产线'), ('已下产线', '已下产线')],
|
||||
string='上/下产线', default='待上产线')
|
||||
|
||||
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||
|
||||
@api.depends(
|
||||
'move_raw_ids.state', 'move_raw_ids.quantity_done', 'move_finished_ids.state',
|
||||
'workorder_ids.state', 'product_qty', 'qty_producing', 'schedule_state')
|
||||
@@ -132,6 +134,14 @@ class MrpProduction(models.Model):
|
||||
# cnc程序获取
|
||||
def fetchCNC(self):
|
||||
cnc = self.env['mrp.production'].search([('id', '=', self.id)])
|
||||
quick_order = self.env['quick.easy.order'].search([('id', '=', cnc.product_id.id)])
|
||||
programme_way = False
|
||||
if cnc.manual_quotation is True:
|
||||
programme_way = 'manual operation'
|
||||
else:
|
||||
programme_way = 'auto'
|
||||
if quick_order:
|
||||
programme_way = 'manual operation'
|
||||
try:
|
||||
res = {'model_code': '' if not cnc.product_id.model_code else cnc.product_id.model_code,
|
||||
'production_no': cnc.name,
|
||||
@@ -146,8 +156,9 @@ class MrpProduction(models.Model):
|
||||
'embryo_height': cnc.product_id.bom_ids.bom_line_ids.product_id.height,
|
||||
'embryo_width': cnc.product_id.bom_ids.bom_line_ids.product_id.width,
|
||||
'order_no': cnc.origin,
|
||||
'model_order_no': cnc.product_id.default_code.rsplit(' -', 1)[0],
|
||||
'model_order_no': cnc.product_id.default_code,
|
||||
'user': cnc.env.user.name,
|
||||
'programme_way': programme_way,
|
||||
'model_file': '' if not cnc.product_id.model_file else base64.b64encode(
|
||||
cnc.product_id.model_file).decode('utf-8')
|
||||
}
|
||||
|
||||
@@ -46,6 +46,8 @@ class ResMrpWorkOrder(models.Model):
|
||||
], string="工序类型")
|
||||
results = fields.Char('结果')
|
||||
|
||||
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||
|
||||
@api.onchange('users_ids')
|
||||
def get_user_permissions(self):
|
||||
uid = self.env.uid
|
||||
@@ -813,7 +815,7 @@ class ResMrpWorkOrder(models.Model):
|
||||
production_no_ftp = reportpath.split('/')
|
||||
production_no = workorder.production_id.name.replace('/', '_')
|
||||
# ftp地址
|
||||
remotepath = os.path.join('/', production_no_ftp[1], 'detection')
|
||||
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no_ftp[1], 'detection')
|
||||
logging.info('ftp地址:%s' % remotepath)
|
||||
if reportpath.find(production_no) != -1:
|
||||
# 服务器内临时地址
|
||||
@@ -892,7 +894,7 @@ class CNCprocessing(models.Model):
|
||||
'cutting_tool_handle_type': obj['cutting_tool_handle_type'],
|
||||
'estimated_processing_time': obj['estimated_processing_time'],
|
||||
'remark': obj['remark'],
|
||||
'program_path': program_path.replace('/tmp', '')
|
||||
'program_path': program_path.replace('/tmp', '/home/ftp/ftp_root/NC')
|
||||
})
|
||||
cnc_processing.get_cnc_processing_file(program_path_tmp, cnc_processing, program_path)
|
||||
# cnc_workorder.state = 'done'
|
||||
@@ -931,7 +933,7 @@ class CNCprocessing(models.Model):
|
||||
|
||||
# 将FTP的nc文件下载到临时目录
|
||||
def download_file_tmp(self, production_no, processing_panel):
|
||||
remotepath = os.path.join('/', production_no, 'return', processing_panel)
|
||||
remotepath = os.path.join('/home/ftp/ftp_root/NC', production_no, 'return', processing_panel)
|
||||
serverdir = os.path.join('/tmp', production_no, 'return', processing_panel)
|
||||
ftp_resconfig = self.env['res.config.settings'].get_values()
|
||||
ftp = FtpController(str(ftp_resconfig['ftp_host']), int(ftp_resconfig['ftp_port']), ftp_resconfig['ftp_user'],
|
||||
@@ -984,9 +986,9 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
workorder = self.env['mrp.workorder'].browse(self.ids)
|
||||
# workorder = self.env['mrp.workorder'].search(
|
||||
# [('routing_type', '=', '装夹预调'), ('production_id', '=', self.production_id.id)])
|
||||
# workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
|
||||
# if workorder_old:
|
||||
# raise UserError('该托盘已绑定工件,请先解除绑定!!!')
|
||||
workorder_old = self.env['mrp.workorder'].search([('rfid_code', '=', barcode)])
|
||||
if workorder_old:
|
||||
raise UserError('该托盘已绑定工件,请先解除绑定!!!')
|
||||
if workorder:
|
||||
if workorder.routing_type == '装夹预调':
|
||||
if workorder.state in ['done']:
|
||||
@@ -1046,7 +1048,7 @@ class SfWorkOrderBarcodes(models.Model):
|
||||
for item in workorder_rfid:
|
||||
if item.state == "progress":
|
||||
item.write({'rfid_code': barcode})
|
||||
# raise UserError('该托盘信息不存在!!!')
|
||||
raise UserError('该托盘信息不存在!!!')
|
||||
# stock_move_line = self.env['stock.move.line'].search([('lot_name', '=', barcode)])
|
||||
# if stock_move_line.product_id.categ_type == '夹具':
|
||||
# workorder.write({
|
||||
|
||||
@@ -37,8 +37,22 @@ class FtpController():
|
||||
os.makedirs(serverdir)
|
||||
try:
|
||||
logging.info("进入FTP目录 ")
|
||||
self.ftp.cwd(target_dir) # 切换工作路径
|
||||
logging.info('FTP目录:%s' % target_dir)
|
||||
logging.info('目录:%s' % target_dir)
|
||||
target_dir1 = target_dir.split('/')
|
||||
logging.info('目录1:%s' % target_dir1[1])
|
||||
self.ftp.cwd(target_dir1[1])
|
||||
logging.info('目录2:%s' % target_dir1[2])
|
||||
self.ftp.cwd(target_dir1[2])
|
||||
logging.info('目录3:%s' % target_dir1[3])
|
||||
self.ftp.cwd(target_dir1[3])
|
||||
logging.info('目录4:%s' % target_dir1[4])
|
||||
self.ftp.cwd(target_dir1[4])
|
||||
logging.info('目录5:%s' % target_dir1[5])
|
||||
self.ftp.cwd(target_dir1[5])
|
||||
logging.info('目录6:%s' % target_dir1[6])
|
||||
self.ftp.cwd(target_dir1[6])
|
||||
logging.info('目录7:%s' % target_dir1[7])
|
||||
self.ftp.cwd(target_dir1[7])
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录文件:%s' % remotenames)
|
||||
for file in remotenames:
|
||||
@@ -48,6 +62,9 @@ class FtpController():
|
||||
return 1
|
||||
except Exception:
|
||||
return 0
|
||||
finally:
|
||||
self.ftp.quit()
|
||||
logging.info("ftp已关闭")
|
||||
|
||||
# 下载目录下的检测文件
|
||||
def download_reportfile_tree(self, target_dir, serverdir, reportpath):
|
||||
@@ -61,6 +78,8 @@ class FtpController():
|
||||
self.ftp.cwd(target_dir1[1]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[2])
|
||||
self.ftp.cwd(target_dir1[2]) # 切换工作路径
|
||||
logging.info('目录2:%s' % target_dir1[3])
|
||||
self.ftp.cwd(target_dir1[3]) # 切换工作路径
|
||||
remotenames = self.ftp.nlst()
|
||||
logging.info('FTP目录检测报告文件:%s' % remotenames)
|
||||
for filename in remotenames:
|
||||
|
||||
@@ -8,8 +8,8 @@ from datetime import datetime
|
||||
import requests
|
||||
from odoo import http
|
||||
from odoo.http import request
|
||||
# from OCC.Extend.DataExchange import read_step_file
|
||||
# from OCC.Extend.DataExchange import write_stl_file
|
||||
from OCC.Extend.DataExchange import read_step_file
|
||||
from OCC.Extend.DataExchange import write_stl_file
|
||||
from odoo import models, fields, api
|
||||
from odoo.modules import get_resource_path
|
||||
from odoo.exceptions import ValidationError, UserError
|
||||
|
||||
@@ -142,6 +142,12 @@ class ResaleOrderLine(models.Model):
|
||||
check_status = fields.Selection(related='order_id.check_status')
|
||||
|
||||
|
||||
class ProductTemplate(models.Model):
|
||||
_inherit = 'product.template'
|
||||
|
||||
manual_quotation = fields.Boolean('人工编程', default=False)
|
||||
|
||||
|
||||
class RePurchaseOrder(models.Model):
|
||||
_inherit = 'purchase.order'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user