fix: 预处理文件输出到配置目录而非源文件目录
烟草/杨碧月/蓉城易购的预处理文件(预处理之后_xxx)之前写入源文件所在目录, 现在改为写入配置的 output_folder 目录。 Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user