feat(plugin XQ0008): 支持增员按参保类型分目录存储回盘文件
更新插件版本至1.0.2,调整增员核查逻辑按参保类型分组,回盘文件按类型分目录存储,适配不同参保类型的办理需求
This commit is contained in:
@@ -68,7 +68,8 @@ CHECK_LIMIT = None # 每次运行最多核查的单位数(No
|
||||
RUN_400_CLEAR = True # 400系统错误:True=运行结束后统一清空办理状态回待办(重新走8号+增员)
|
||||
|
||||
# ---- 回盘打印下载与核对 ----
|
||||
DISK_DIR = r"D:\资料\人资\重庆社保增减员办理\回盘打印\新参保-增员" # 回盘文件保存目录
|
||||
DISK_DIR = r"D:\资料\人资\重庆社保增减员办理\回盘打印" # 回盘文件根目录(按参保类型分子目录)
|
||||
HUIPAN_SUBS = {"新参保": "新参保-增员", "转移参保": "转移参保-增员"} # 参保类型 → 回盘子目录
|
||||
REPLAY_PREFIX = "人员增减申请回盘表" # 保存文件名:前缀_单位_日期.xlsx
|
||||
INS_STATUSES = ["养老参保状态", "失业参保状态", "医疗参保状态",
|
||||
"工伤参保状态", "生育参保状态"] # 需核对的三险五项状态列
|
||||
@@ -77,9 +78,10 @@ INS_OK = "参保缴费" # 正
|
||||
|
||||
# ==================== 2. 核查任务读取 ====================
|
||||
def load_check_tasks(exclude_ids=frozenset()):
|
||||
"""读取源名单,筛选 办理状态=待审核 的行,按参保单位分组。
|
||||
"""读取源名单,筛选 办理状态=待审核 的行,按参保类型+参保单位分组。
|
||||
|
||||
返回 [{unit, count, cids(set)}];同时把源文件信息写回 import_add 全局
|
||||
返回 [{unit, type, count, cids(set)}](type=参保类型,回盘文件按类型分目录存放);
|
||||
同时把源文件信息写回 import_add 全局
|
||||
(flush_writeback 依赖 SOURCE_FILE_USED / SOURCE_SHEET_USED)。
|
||||
exclude_ids:上次运行已回写的人员身份证号(防重复核查)。
|
||||
"""
|
||||
@@ -94,7 +96,7 @@ def load_check_tasks(exclude_ids=frozenset()):
|
||||
status = df[import_add.STATUS_COL].astype(str).str.strip()
|
||||
mask = (
|
||||
(df[import_add.REGION_COL].astype(str).str.strip() == import_add.REGION)
|
||||
& (df[import_add.TYPE_COL].astype(str).str.strip() == import_add.OPERATION_TYPE)
|
||||
& (df[import_add.TYPE_COL].astype(str).str.strip().isin(import_add.OPERATION_TYPES))
|
||||
& (status == CHECK_STATUS)
|
||||
)
|
||||
sub = df[mask].copy()
|
||||
@@ -106,16 +108,20 @@ def load_check_tasks(exclude_ids=frozenset()):
|
||||
if dropped:
|
||||
print(f" 已排除 {dropped} 行上次运行已回写的人员(防重复核查)")
|
||||
if sub.empty:
|
||||
print(f"没有筛选到数据({import_add.REGION} ∩ {import_add.OPERATION_TYPE} ∩ 办理状态={CHECK_STATUS})")
|
||||
print(f"没有筛选到数据({import_add.REGION} ∩ {'/'.join(import_add.OPERATION_TYPES)} "
|
||||
f"∩ 办理状态={CHECK_STATUS})")
|
||||
return []
|
||||
|
||||
tasks = []
|
||||
for unit, g in sub.groupby(sub[import_add.UNIT_COL].astype(str).str.strip()):
|
||||
sub["_unit"] = sub[import_add.UNIT_COL].astype(str).str.strip()
|
||||
sub["_type"] = sub[import_add.TYPE_COL].astype(str).str.strip()
|
||||
for (unit, t), g in sub.groupby(["_unit", "_type"]):
|
||||
cids = {import_add._norm_id(v) for v in g['身份证号码']}
|
||||
cids.discard('')
|
||||
tasks.append({"unit": unit, "count": len(cids), "cids": cids})
|
||||
tasks.sort(key=lambda t: t['unit'])
|
||||
print(f"核查范围:共 {sum(t['count'] for t in tasks)} 人 / {len(tasks)} 个参保单位(办理状态={CHECK_STATUS})")
|
||||
tasks.append({"unit": unit, "type": t, "count": len(cids), "cids": cids})
|
||||
tasks.sort(key=lambda x: (x['unit'], x['type']))
|
||||
print(f"核查范围:共 {sum(t['count'] for t in tasks)} 人 / "
|
||||
f"{len(tasks)} 个(参保类型+单位)分组(办理状态={CHECK_STATUS})")
|
||||
return tasks
|
||||
|
||||
|
||||
@@ -322,10 +328,10 @@ def _clean_cell(v):
|
||||
return str(v).strip()
|
||||
|
||||
|
||||
def _download_huipan(page, biz_tab, unit):
|
||||
def _download_huipan(page, biz_tab, unit, op_type):
|
||||
"""左侧菜单「回盘打印」→ 页内「回盘打印」按钮,等下载完成后重命名为规范文件名。
|
||||
返回保存的文件 Path。"""
|
||||
save_dir = Path(DISK_DIR)
|
||||
按参保类型存入 回盘打印/<类型>-增员/ 子目录。返回保存的文件 Path。"""
|
||||
save_dir = Path(DISK_DIR) / HUIPAN_SUBS.get(op_type, "新参保-增员")
|
||||
save_dir.mkdir(parents=True, exist_ok=True)
|
||||
target = save_dir / f"{REPLAY_PREFIX}_{unit}_{datetime.now():%Y%m%d}.xlsx"
|
||||
menu_sel = ['tag:li@@text()=回盘打印', 'text=回盘打印']
|
||||
@@ -439,7 +445,7 @@ def _do_huipan(page, biz_tab, task, res, unit_full="", fail_cids=()):
|
||||
if unit_full and unit_full != task['unit']:
|
||||
print(f" 使用平台单位全称命名:{unit_full}")
|
||||
print(" 开始回盘打印下载...")
|
||||
hp_file = _download_huipan(page, biz_tab, name_for_file)
|
||||
hp_file = _download_huipan(page, biz_tab, name_for_file, task.get('type'))
|
||||
print(f" 回盘文件已保存:{hp_file}")
|
||||
hp_remarks, hp_logs = _verify_huipan(hp_file, task['cids'])
|
||||
for line in hp_logs:
|
||||
|
||||
Reference in New Issue
Block a user