From 5cf9a98d9aa01723ca4934a57c3f8df1f827987b Mon Sep 17 00:00:00 2001 From: houhuan Date: Tue, 5 May 2026 02:14:14 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E9=A2=84=E5=A4=84=E7=90=86=E6=96=87?= =?UTF-8?q?=E4=BB=B6=E8=BE=93=E5=87=BA=E5=88=B0=E9=85=8D=E7=BD=AE=E7=9B=AE?= =?UTF-8?q?=E5=BD=95=E8=80=8C=E9=9D=9E=E6=BA=90=E6=96=87=E4=BB=B6=E7=9B=AE?= =?UTF-8?q?=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 烟草/杨碧月/蓉城易购的预处理文件(预处理之后_xxx)之前写入源文件所在目录, 现在改为写入配置的 output_folder 目录。 Co-Authored-By: Claude Opus 4.7 --- app/services/special_suppliers_service.py | 20 +++++++++++++++----- app/services/tobacco_service.py | 5 +++-- 2 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/services/special_suppliers_service.py b/app/services/special_suppliers_service.py index 5cb7444..3d21b93 100644 --- a/app/services/special_suppliers_service.py +++ b/app/services/special_suppliers_service.py @@ -86,12 +86,17 @@ class SpecialSuppliersService: # 过滤掉空的条码行 df_clean = df_clean.dropna(subset=['商品条码']) - # 保存预处理文件 - out_dir = os.path.dirname(src_path) + # 保存预处理文件到输出目录(而非源文件目录) + if self.config_manager and hasattr(self.config_manager, 'get_path'): + out_dir = self.config_manager.get_path('Paths', 'output_folder', fallback='data/output', create=True) + else: + from app.config.settings import ConfigManager + out_dir = ConfigManager().get_path('Paths', 'output_folder', fallback='data/output', create=True) + os.makedirs(out_dir, exist_ok=True) base = os.path.basename(src_path) final_path = os.path.join(out_dir, f"预处理之后_{base}") df_clean.to_excel(final_path, index=False) - + return final_path except Exception as e: logger.error(f"预处理杨碧月订单出错: {e}") @@ -202,8 +207,13 @@ class SpecialSuppliersService: rows.append(row) df2 = pd.DataFrame(rows) - # 保存预处理文件 - out_dir = os.path.dirname(src_path) + # 保存预处理文件到输出目录(而非源文件目录) + if self.config_manager and hasattr(self.config_manager, 'get_path'): + out_dir = self.config_manager.get_path('Paths', 'output_folder', fallback='data/output', create=True) + else: + from app.config.settings import ConfigManager + out_dir = ConfigManager().get_path('Paths', 'output_folder', fallback='data/output', create=True) + os.makedirs(out_dir, exist_ok=True) base = os.path.basename(src_path) final_path = os.path.join(out_dir, f"预处理之后_{base}") df2.to_excel(final_path, index=False) diff --git a/app/services/tobacco_service.py b/app/services/tobacco_service.py index b9107a4..74247da 100644 --- a/app/services/tobacco_service.py +++ b/app/services/tobacco_service.py @@ -132,8 +132,9 @@ class TobaccoService: final_cols = ['商品条码', '商品名称', '数量', '单价', '金额'] df_final = df[final_cols].copy() - # 保存预处理文件 - out_dir = os.path.dirname(file_path) + # 保存预处理文件到输出目录(而非源文件目录) + out_dir = self.output_dir + os.makedirs(out_dir, exist_ok=True) base = os.path.basename(file_path) final_path = os.path.join(out_dir, f"预处理之后_{base}") df_final.to_excel(final_path, index=False)