修复质检接口

This commit is contained in:
jinling.yang
2024-02-23 16:01:19 +08:00
parent 1c2b50a343
commit 998900955d
2 changed files with 18 additions and 15 deletions

View File

@@ -217,10 +217,12 @@ class Manufacturing_Connect(http.Controller):
[('production_id', '=', production_id), ('routing_type', '=', routing_type)], limit=1)
if workorder:
if 'ReportPaht' in ret:
download_state = request.env['mrp.workorder'].sudo().download_reportfile_tmp(workorder,
ret['ReportPaht'])
download_state = request.env['mrp.workorder'].with_user(
request.env.ref("base.user_admin")).download_reportfile_tmp(workorder,
ret['ReportPaht'])
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:
res = {'Succeed': False, 'ErrorCode': 204, 'Error': '检测报告文件从FTP拉取失败'}
else:

View File

@@ -627,6 +627,19 @@ class ResMrpWorkOrder(models.Model):
self.production_id.button_mark_done1()
# 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):
_name = 'sf.cnc.processing'
@@ -745,18 +758,6 @@ class CNCprocessing(models.Model):
logging.info('download_state:%s' % 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里
def write_file(self, nc_file_path, cnc):
if os.path.exists(nc_file_path):