refactor: 统一所有缓存/会话文件的存储路径
1. 重构会话管理模块,新增app.common.app_paths统一管理缓存路径,所有登录态与缓存统一迁移至%LOCALAPPDATA%\37duAutomation\.sessions 2. 更新所有涉及文件存储路径的代码,包括考勤、工资卡、社保、审批等模块 3. 新增银行字典缓存功能,统一管理银行编码映射 4. 添加雇主险业务模块,实现花名册筛选复制功能 5. 更新.gitignore,将所有.sessions目录纳入忽略列表 6. 删除影刀脚本旧的本地缓存文件 7. 优化加班审批校验逻辑,新增提前到岗型加班校验规则 8. 完善工资卡核对功能,补充开卡银行信息展示
This commit is contained in:
@@ -27,6 +27,7 @@ if _root not in sys.path:
|
||||
sys.path.insert(0, _root)
|
||||
|
||||
from app.utils.logger import get_logger, setup_logging # noqa: E402
|
||||
from app.service.hrbp.ehr.common.hr_api import get_bank_dict, bank_type_to_name # noqa: E402
|
||||
|
||||
try:
|
||||
import pandas as pd
|
||||
@@ -166,6 +167,7 @@ COL_CARD_IDCARD = "开户人身份证"
|
||||
COL_STAFF_NAME = "员工姓名"
|
||||
COL_CARD_NAME = "开户人姓名"
|
||||
COL_BANK_ACCOUNT = "银行卡号"
|
||||
COL_BANK_NAME = "开卡银行"
|
||||
|
||||
COL_BANK_STATUS = "银行卡状态"
|
||||
COL_BANK_REASON = "银行卡说明"
|
||||
@@ -199,11 +201,10 @@ def _normalize_id(val) -> str:
|
||||
def check_wage_card(input_path: str, output_path: str = None) -> str:
|
||||
"""读取工资卡汇总表,执行核对并保存结果。
|
||||
|
||||
核对逻辑(按 4 类异常分类):
|
||||
1. 开户人信息或银行卡空白
|
||||
2. 员工身份证与开户人身份证不一致(单独存『身份证不一致表』)
|
||||
3. 员工姓名与开户人姓名不一致(仅身份证一致时比对)
|
||||
4. 银行卡信息异常(银行卡非空但格式/位数错误)
|
||||
输出文件:
|
||||
- {汇总表}_核对结果.xlsx:全量核对结果
|
||||
- 无银行卡表.xlsx:未提供银行卡号(银行卡空白)的人员
|
||||
- 工资卡异常名单.xlsx:除无银行卡外的其他异常人员(含身份证不一致)
|
||||
|
||||
Args:
|
||||
input_path: 工资卡汇总表 Excel 路径
|
||||
@@ -218,7 +219,12 @@ def check_wage_card(input_path: str, output_path: str = None) -> str:
|
||||
df = pd.read_excel(input_path)
|
||||
logger.info("读取工资卡汇总表:%s(%d 行)", input_path, len(df))
|
||||
|
||||
id_mismatch_rows = []
|
||||
# 汇总表未带开卡银行列时,按银行编码(BANK_TYPE)补充(aa.md 银行字典接口)
|
||||
if COL_BANK_NAME not in df.columns and "银行编码" in df.columns:
|
||||
_, bank_map = get_bank_dict()
|
||||
df[COL_BANK_NAME] = df["银行编码"].apply(lambda c: bank_type_to_name(c, bank_map))
|
||||
|
||||
no_bank_rows = []
|
||||
|
||||
for idx, row in df.iterrows():
|
||||
idcard = _normalize_id(row.get(COL_IDCARD, ""))
|
||||
@@ -227,11 +233,11 @@ def check_wage_card(input_path: str, output_path: str = None) -> str:
|
||||
card_name = str(row.get(COL_CARD_NAME, "")).strip()
|
||||
bank_account = row.get(COL_BANK_ACCOUNT, "")
|
||||
|
||||
issues, basis, id_inconsistent, bk = classify_card_issue(
|
||||
issues, basis, _, bk = classify_card_issue(
|
||||
idcard, card_idcard, staff_name, card_name, bank_account,
|
||||
)
|
||||
if id_inconsistent:
|
||||
id_mismatch_rows.append(idx)
|
||||
if _is_empty(bank_account):
|
||||
no_bank_rows.append(idx)
|
||||
|
||||
df.at[idx, COL_CHECK_RESULT] = "、".join(issues) if issues else "通过"
|
||||
df.at[idx, COL_CHECK_BASIS] = ";".join(basis) if basis else ""
|
||||
@@ -262,17 +268,17 @@ def check_wage_card(input_path: str, output_path: str = None) -> str:
|
||||
df.to_excel(output_path, index=False)
|
||||
logger.info("核对结果已保存:%s", output_path)
|
||||
|
||||
# 身份证不一致单独存表(独立文件,供人工校验)
|
||||
if id_mismatch_rows:
|
||||
# 无银行卡人员单独存表(独立文件)
|
||||
if no_bank_rows:
|
||||
base, ext = os.path.splitext(output_path)
|
||||
id_path = os.path.join(os.path.dirname(base), f"身份证不一致表{ext}")
|
||||
df.loc[id_mismatch_rows].to_excel(id_path, index=False)
|
||||
logger.info("身份证不一致表已保存:%s(%d 条)", id_path, len(id_mismatch_rows))
|
||||
no_bank_path = os.path.join(os.path.dirname(base), f"无银行卡表{ext}")
|
||||
df.loc[no_bank_rows].to_excel(no_bank_path, index=False)
|
||||
logger.info("无银行卡表已保存:%s(%d 条)", no_bank_path, len(no_bank_rows))
|
||||
else:
|
||||
logger.info("无身份证不一致记录")
|
||||
logger.info("无银行卡空白记录,跳过无银行卡表生成")
|
||||
|
||||
# ---- 生成异常名单(排除已单独成表的身份证不一致记录) ----
|
||||
mask = (df[COL_CHECK_RESULT] != "通过") & (~df.index.isin(id_mismatch_rows))
|
||||
# ---- 生成异常名单(含身份证不一致,排除已单独成表的无银行卡记录) ----
|
||||
mask = (df[COL_CHECK_RESULT] != "通过") & (~df.index.isin(no_bank_rows))
|
||||
abnormal = df[mask]
|
||||
if len(abnormal) > 0:
|
||||
base, ext = os.path.splitext(output_path)
|
||||
|
||||
Reference in New Issue
Block a user