Accept Merge Request #847: (feature/修复质检接口 -> develop)

Merge Request: 修复质检接口

Created By: @杨金灵
Reviewed By: @马广威
Approved By: @马广威 
Accepted By: @杨金灵
URL: https://jikimo-hn.coding.net/p/jikimo_sfs/d/jikimo_sf/git/merge/847?initial=true
This commit is contained in:
杨金灵
2024-02-23 16:33:21 +08:00
committed by Coding
2 changed files with 21 additions and 16 deletions

View File

@@ -640,6 +640,23 @@ class ResMrpWorkOrder(models.Model):
logging.info('download_state:%s' % download_state)
return download_state
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
def get_detection_file(self, workorder, reportPath):
logging.info('workorder:%s' % workorder.name)
logging.info('制造订单:%s' % workorder.production_id.name)
logging.info('reportPath:%s' % reportPath)
serverdir = os.path.join('/tmp', reportPath).replace('//', '/')
logging.info('serverdir:%s' % serverdir)
for root, dirs, files in os.walk(serverdir):
for f in files:
logging.info('f:%s' % f)
if os.path.splitext(f)[1] == ".pdf":
full_path = os.path.join(serverdir, root, f)
logging.info('检测文件路径:%s' % full_path)
if full_path is not False:
workorder.detection_report = base64.b64encode(
open(full_path, 'rb').read())
class CNCprocessing(models.Model):
_name = 'sf.cnc.processing'
@@ -719,22 +736,7 @@ class CNCprocessing(models.Model):
logging.info('cnc_file_path:%s' % cnc_file_path)
self.write_file(cnc_file_path, cnc_processing)
# 根据中控系统提供的检测文件地址去ftp里对应的制造订单里获取
def get_detection_file(self, workorder, reportPath):
logging.info('workorder:%s' % workorder.name)
logging.info('制造订单:%s' % workorder.production_id.name)
logging.info('reportPath:%s' % reportPath)
serverdir = os.path.join('/tmp', reportPath).replace('//', '/')
logging.info('serverdir:%s' % serverdir)
for root, dirs, files in os.walk(serverdir):
for f in files:
logging.info('f:%s' % f)
if os.path.splitext(f)[1] == ".pdf":
full_path = os.path.join(serverdir, root, f)
logging.info('检测文件路径:%s' % full_path)
if full_path is not False:
workorder.detection_report = base64.b64encode(
open(full_path, 'rb').read())
# 创建附件(nc文件)
def attachment_create(self, name, data):

View File

@@ -44,6 +44,9 @@ class FtpController():
def download_reportfile_tree(self, target_dir, serverdir, reportpath):
try:
logging.info("进入FTP目录 ")
logging.info('FTP目录1:%s' % target_dir)
logging.info('serverdir:%s' % serverdir)
logging.info('reportpath:%s' % reportpath)
self.ftp.cwd(target_dir) # 切换工作路径
logging.info('FTP目录:%s' % target_dir)
remotenames = self.ftp.nlst()