refactor: 重构影刀脚本目录结构,按需求单归档并清理冗余文件
- 将影刀脚本从按系统分组的oa/hr/employer_insurance等目录迁移到XQ00xx命名的需求单目录,与docs/需求单一一对应 - 删除原employer_insurance目录下冗余的export_change_sheet.py,将其迁移到XQ0002目录 - 清理已废弃的XQ0020标准化门店手续相关文档与XQ0021离职电子签重复文档 - 更新需求单总索引、README文档与影刀脚本目录说明,修正路径引用 - 修复雇主险导入模板校验逻辑与增员导入异常捕获逻辑
This commit is contained in:
@@ -946,10 +946,12 @@ def _write_import_file(template_path, out_path, rows):
|
||||
template_path: 官方导入模板路径。
|
||||
out_path: 生成的目标文件路径(类别文件夹内)。
|
||||
rows: 数据行列表,每行为 [序号, 工号/身份证, ...]。
|
||||
|
||||
Raises:
|
||||
FileNotFoundError: 导入模板不存在(导入文件为硬前提,缺失必须报错而非静默跳过)。
|
||||
"""
|
||||
if not os.path.isfile(template_path):
|
||||
logger.warning("导入模板不存在:%s,跳过生成 %s", template_path, out_path)
|
||||
return
|
||||
raise FileNotFoundError(f"导入模板不存在:{template_path},无法生成导入文件 {out_path}")
|
||||
wb = load_workbook(template_path)
|
||||
ws = wb[wb.sheetnames[0]]
|
||||
for i, row_vals in enumerate(rows):
|
||||
@@ -1058,6 +1060,21 @@ def export_add_sub_import(category, biz_df, in_param_df, final_records, reused_s
|
||||
# ============================================================
|
||||
# 六、入口(步骤2:调度)
|
||||
# ============================================================
|
||||
def _check_import_templates():
|
||||
"""前置校验增减员导入模板是否存在,任一缺失立即抛错。
|
||||
|
||||
模板在调度开始时校验(而非生成导入文件时才报),避免完整调度跑完后
|
||||
才发现模板缺失、需要重做的浪费。_write_import_file 内的检查作为兜底保留。
|
||||
"""
|
||||
missing = [
|
||||
path for path in (ADD_IMPORT_TEMPLATE, SUB_IMPORT_TEMPLATE)
|
||||
if not os.path.isfile(path)
|
||||
]
|
||||
if missing:
|
||||
raise FileNotFoundError(
|
||||
"增减员导入模板缺失,请先补充模板后再调度:\n - " + "\n - ".join(missing))
|
||||
|
||||
|
||||
def schedule_category(category):
|
||||
"""对单个类别执行调度全流程(读取已刷新公式的目标文件,输出结果)。
|
||||
|
||||
@@ -1086,6 +1103,9 @@ def schedule_category(category):
|
||||
return
|
||||
logger.info("文件结构检查通过。")
|
||||
|
||||
# 前置校验:增减员导入模板必须存在,避免调度全部完成后才发现模板缺失、需重做
|
||||
_check_import_templates()
|
||||
|
||||
# ---------- 读取并清洗花名册数据 ----------
|
||||
biz_df = pd.read_excel(target_file, sheet_name=SHEET_BIZ, header=3)
|
||||
logger.info("原始花名册数据:%d 行", len(biz_df))
|
||||
|
||||
Reference in New Issue
Block a user