feat: 新增交通银行数据导出插件及测试通道机制
This commit is contained in:
@@ -63,17 +63,27 @@ def check_directory():
|
||||
add("资料根目录", base_ok, base if base_ok else f"目录不存在:{base}")
|
||||
|
||||
# ---- 1. 名单制作 / 系统办理:源名单 ----
|
||||
src_file = None
|
||||
src_file, src_error = None, ""
|
||||
candidates = []
|
||||
if base_ok:
|
||||
candidates = [p for p in os.listdir(base)
|
||||
if p.lower().endswith(".xlsx") and not p.startswith("~$")
|
||||
and config.SOURCE_KEYWORD in p]
|
||||
add(f"源名单(*{config.SOURCE_KEYWORD}*.xlsx)", bool(candidates),
|
||||
"、".join(sorted(candidates)[:3]) or "未找到,请放入当月《社保变更及增减名单》")
|
||||
if candidates:
|
||||
src_file = os.path.join(base, max(
|
||||
candidates, key=lambda n: os.path.getmtime(os.path.join(base, n))))
|
||||
# 逐文件带上有效性/大小,便于一眼看出哪个文件坏了(0 KB / .xls 改名 / 被占用)
|
||||
detail_items = []
|
||||
for n in sorted(candidates, key=lambda x: os.path.getmtime(os.path.join(base, x)),
|
||||
reverse=True)[:5]:
|
||||
ok_f, info = config._xlsx_valid(os.path.join(base, n))
|
||||
detail_items.append(f"{n}({info})" if ok_f else f"{n}(无效:{info})")
|
||||
add(f"源名单(*{config.SOURCE_KEYWORD}*.xlsx)", True, ";".join(detail_items))
|
||||
try:
|
||||
src_file = config._latest_file(base, config.SOURCE_GLOB)
|
||||
except (ValueError, FileNotFoundError) as e:
|
||||
src_error = str(e)
|
||||
else:
|
||||
add(f"源名单(*{config.SOURCE_KEYWORD}*.xlsx)", False,
|
||||
"未找到,请放入当月《社保变更及增减名单》")
|
||||
|
||||
# ---- 2. 告知书数据源:当月文件 ----
|
||||
if base_ok:
|
||||
@@ -85,7 +95,11 @@ def check_directory():
|
||||
# ---- 3. 源名单关键 sheet ----
|
||||
if src_file:
|
||||
ok, missing = _check_sheets(src_file, ["参保名单", "停保名单"])
|
||||
add("源名单关键 sheet(参保名单/停保名单)", ok, "缺失:" + "、".join(missing) if missing else "齐备")
|
||||
add("源名单关键 sheet(参保名单/停保名单)", ok,
|
||||
"缺失:" + "、".join(missing) if missing else
|
||||
f"齐备({os.path.basename(src_file)})")
|
||||
elif src_error:
|
||||
add("源名单关键 sheet(参保名单/停保名单)", False, f"无法读取:{src_error}")
|
||||
else:
|
||||
add("源名单关键 sheet(参保名单/停保名单)", False, "源名单缺失,跳过校验")
|
||||
|
||||
|
||||
@@ -66,8 +66,8 @@ def _write_template_add(template_file, output_path, unit_no, unit_name, records)
|
||||
orig_rows = rb.sheet_by_index(0).nrows
|
||||
wb = xl_copy(rb)
|
||||
ws = wb.get_sheet(0) # 批量导入
|
||||
ws.write(0, 1, unit_no) # B1 社保号
|
||||
ws.write(0, 3, unit_name) # D1 参保单位全称
|
||||
ws.write(0, 1, config._clean_value(unit_no)) # B1 社保号
|
||||
ws.write(0, 3, config._clean_value(unit_name)) # D1 参保单位全称
|
||||
for i, rec in enumerate(records):
|
||||
r = config.TPL_DATA_START_ROW - 1 + i # 0-based:模板第4行 → index 3
|
||||
for c, col in enumerate(config.TPL_COLS_ADD):
|
||||
@@ -183,8 +183,8 @@ def _write_template_stop(template_file, output_path, unit_no, unit_full_name, re
|
||||
orig_rows = rb.sheet_by_index(0).nrows
|
||||
wb = xl_copy(rb)
|
||||
ws = wb.get_sheet(0) # 批量导入
|
||||
ws.write(0, 1, unit_no) # B1 单位社保号
|
||||
ws.write(0, 3, unit_full_name) # D1 单位全称
|
||||
ws.write(0, 1, config._clean_value(unit_no)) # B1 单位社保号
|
||||
ws.write(0, 3, config._clean_value(unit_full_name)) # D1 单位全称
|
||||
for i, rec in enumerate(records):
|
||||
r = config.TPL_DATA_START_ROW - 1 + i
|
||||
for c, col in enumerate(config.TPL_COLS_STOP):
|
||||
|
||||
Reference in New Issue
Block a user