feat(ui): simplify interface by removing dedicated tobacco/rongcheng buttons and optimizing auto-routing
This commit is contained in:
@@ -113,11 +113,21 @@ class OrderService:
|
||||
return special_svc.preprocess_rongcheng_yigou(file_path)
|
||||
|
||||
# 3. 识别:杨碧月 (Yang Biyue)
|
||||
from .special_suppliers_service import SpecialSuppliersService
|
||||
special_svc = SpecialSuppliersService(self.config)
|
||||
# 我们直接复用 SpecialSuppliersService 里的逻辑,但要确保它只返回路径
|
||||
# 修改 SpecialSuppliersService.process_yang_biyue 使其支持仅返回预处理路径
|
||||
return special_svc.process_yang_biyue_only(file_path)
|
||||
# 特征:经手人列包含“杨碧月”
|
||||
handler_col = None
|
||||
for col in df_head.columns:
|
||||
# 在前50行中搜索“经手人”关键字
|
||||
if df_head[col].astype(str).str.contains('经手人').any():
|
||||
handler_col = col
|
||||
break
|
||||
|
||||
if handler_col is not None:
|
||||
# 检查该列是否有“杨碧月”
|
||||
if df_head[handler_col].astype(str).str.contains('杨碧月').any():
|
||||
logger.info("识别到杨碧月订单,执行专用预处理...")
|
||||
from .special_suppliers_service import SpecialSuppliersService
|
||||
special_svc = SpecialSuppliersService(self.config)
|
||||
return special_svc.process_yang_biyue_only(file_path)
|
||||
|
||||
except Exception as e:
|
||||
logger.warning(f"智能预处理识别失败: {e}")
|
||||
|
||||
@@ -37,24 +37,41 @@ class SpecialSuppliersService:
|
||||
if handler_col is None or not df[handler_col].astype(str).str.contains('杨碧月').any():
|
||||
return None
|
||||
|
||||
# 识别到杨碧月订单,执行专用清洗
|
||||
logger.info("识别到杨碧月订单,正在执行专用清洗...")
|
||||
|
||||
# 定义列映射关系
|
||||
# 定义列映射关系 (映射到 ExcelProcessor 期望的中文列名)
|
||||
# 使用精确匹配优先,防止“结算单位”匹配到“单位”
|
||||
column_map = {
|
||||
'商品条码': 'barcode',
|
||||
'商品名称': 'name',
|
||||
'商品规格': 'specification',
|
||||
'单位': 'unit',
|
||||
'数量': 'quantity',
|
||||
'含税单价': 'unit_price',
|
||||
'含税金额': 'total_price'
|
||||
'商品条码': '商品条码',
|
||||
'商品名称': '商品名称',
|
||||
'商品规格': '规格',
|
||||
'单位': '单位',
|
||||
'数量': '数量',
|
||||
'含税单价': '单价',
|
||||
'含税金额': '金额'
|
||||
}
|
||||
|
||||
# 提取并重命名列
|
||||
found_cols = {}
|
||||
# 1. 第一遍:尝试精确匹配
|
||||
for target_zh, std_name in column_map.items():
|
||||
for col in df.columns:
|
||||
if target_zh in str(col):
|
||||
if str(col).strip() == target_zh:
|
||||
found_cols[col] = std_name
|
||||
break
|
||||
|
||||
# 2. 第二遍:对未匹配成功的列尝试模糊匹配(但要排除特定干扰词)
|
||||
for target_zh, std_name in column_map.items():
|
||||
if std_name in found_cols.values():
|
||||
continue
|
||||
for col in df.columns:
|
||||
col_str = str(col)
|
||||
if target_zh in col_str:
|
||||
# 排除干扰列
|
||||
if target_zh == '单位' and '结算单位' in col_str:
|
||||
continue
|
||||
if target_zh == '数量' and '基本单位数量' in col_str:
|
||||
continue
|
||||
found_cols[col] = std_name
|
||||
break
|
||||
|
||||
@@ -66,7 +83,7 @@ class SpecialSuppliersService:
|
||||
df_clean = df_clean.rename(columns=found_cols)
|
||||
|
||||
# 过滤掉空的条码行
|
||||
df_clean = df_clean.dropna(subset=['barcode'])
|
||||
df_clean = df_clean.dropna(subset=['商品条码'])
|
||||
|
||||
# 保存预处理文件
|
||||
out_dir = os.path.dirname(src_path)
|
||||
|
||||
Reference in New Issue
Block a user