修复质检接口
This commit is contained in:
@@ -217,10 +217,12 @@ class Manufacturing_Connect(http.Controller):
|
|||||||
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
|
||||||
if workorder:
|
if workorder:
|
||||||
if 'ReportPaht' in ret:
|
if 'ReportPaht' in ret:
|
||||||
download_state = request.env['mrp.workorder'].sudo().download_reportfile_tmp(workorder,
|
download_state = request.env['mrp.workorder'].with_user(
|
||||||
ret['ReportPaht'])
|
request.env.ref("base.user_admin")).download_reportfile_tmp(workorder,
|
||||||
|
ret['ReportPaht'])
|
||||||
if download_state is not False:
|
if download_state is not False:
|
||||||
request.env['mrp.workorder'].sudo().get_detection_file(workorder, ret['ReportPaht'])
|
request.env['mrp.workorder'].with_user(
|
||||||
|
request.env.ref("base.user_admin")).get_detection_file(workorder, ret['ReportPaht'])
|
||||||
else:
|
else:
|
||||||
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '检测报告文件从FTP拉取失败'}
|
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '检测报告文件从FTP拉取失败'}
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -627,6 +627,19 @@ class ResMrpWorkOrder(models.Model):
|
|||||||
self.production_id.button_mark_done1()
|
self.production_id.button_mark_done1()
|
||||||
# self.production_id.state = 'done'
|
# self.production_id.state = 'done'
|
||||||
|
|
||||||
|
# 将FTP的检测报告文件下载到临时目录
|
||||||
|
def download_reportfile_tmp(self, workorder, reportpath):
|
||||||
|
production_no = workorder.production_id.name.replace('/', '_')
|
||||||
|
remotepath = os.path.join('/', production_no, 'detection')
|
||||||
|
serverdir = os.path.join('/tmp', production_no, 'detection')
|
||||||
|
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'],
|
||||||
|
ftp_resconfig['ftp_password'])
|
||||||
|
download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath)
|
||||||
|
logging.info('download_state:%s' % download_state)
|
||||||
|
return download_state
|
||||||
|
|
||||||
|
|
||||||
class CNCprocessing(models.Model):
|
class CNCprocessing(models.Model):
|
||||||
_name = 'sf.cnc.processing'
|
_name = 'sf.cnc.processing'
|
||||||
@@ -745,18 +758,6 @@ class CNCprocessing(models.Model):
|
|||||||
logging.info('download_state:%s' % download_state)
|
logging.info('download_state:%s' % download_state)
|
||||||
return download_state
|
return download_state
|
||||||
|
|
||||||
# 将FTP的检测报告文件下载到临时目录
|
|
||||||
def download_reportfile_tmp(self, workorder, reportpath):
|
|
||||||
production_no = workorder.production_id.name.replace('/','_')
|
|
||||||
remotepath = os.path.join('/', production_no, 'detection')
|
|
||||||
serverdir = os.path.join('/tmp', production_no, 'detection')
|
|
||||||
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'],
|
|
||||||
ftp_resconfig['ftp_password'])
|
|
||||||
download_state = ftp.download_reportfile_tree(remotepath, serverdir, reportpath)
|
|
||||||
logging.info('download_state:%s' % download_state)
|
|
||||||
return download_state
|
|
||||||
|
|
||||||
# 将nc文件存到attach的datas里
|
# 将nc文件存到attach的datas里
|
||||||
def write_file(self, nc_file_path, cnc):
|
def write_file(self, nc_file_path, cnc):
|
||||||
if os.path.exists(nc_file_path):
|
if os.path.exists(nc_file_path):
|
||||||
|
|||||||
Reference in New Issue
Block a user