feat(xq0002): 新增钉钉群通知推送功能,优化雇主险增减操作流程

This commit is contained in:
2026-10-05 09:42:56 +08:00
parent 2e514d54d1
commit 23e8082511
83 changed files with 11419 additions and 180 deletions
@@ -49,8 +49,11 @@ def load_records(kind, operation_type=None, status_filter="empty", exclude_ids=f
if kind == 'add':
status_col = "办理状态"
# 增员可传单值或元组(如 config.WEB_ADD_TYPES 两类都办)
op_types = operation_type if isinstance(operation_type, (tuple, list, set)) \
else (operation_type,)
mask = (df["区域"].astype(str).str.strip() == config.TARGET_REGION)
mask &= (df["参保类型"].astype(str).str.strip() == operation_type)
mask &= (df["参保类型"].astype(str).str.strip().isin(op_types))
else:
status_col = config.STOP_PROCESSED_COL
mask = (df["区域"].astype(str).str.strip() == config.TARGET_REGION)
@@ -74,21 +77,34 @@ def load_records(kind, operation_type=None, status_filter="empty", exclude_ids=f
def load_units(kind, operation_type=None, status_filter="empty", exclude_ids=frozenset()):
"""读取名单并筛选,返回 [(参保单位, 人数), ...](按单位分组,名称排序)。"""
"""读取名单并筛选,返回 [(参保类型, 参保单位, 人数), ...](按类型+单位分组,名称排序)。
减员(kind='stop')参保类型恒为 None(停保/转移停保合并按单位分组)。
"""
sub, source_file, sheet_name, status_col = load_records(
kind, operation_type, status_filter, exclude_ids)
print_source = os.path.basename(source_file)
if kind == 'add':
desc = f"{config.TARGET_REGION} ∩ 参保类型={operation_type}"
desc = f"{config.TARGET_REGION} ∩ 参保类型∈{'/'.join(config.WEB_ADD_TYPES)}"
else:
desc = f"{config.TARGET_REGION} ∩ 类型∈{'/'.join(config.STOP_TYPES)}"
config.log(f"源名单:{print_source}(sheet: {sheet_name})")
if sub.empty:
config.log(f"没有筛选到数据({desc} ∩ {status_col}={'空' if status_filter == 'empty' else status_filter})")
return [], source_file, sheet_name
grouped = sub.groupby(sub["参保单位"].astype(str).str.strip()).size()
units = sorted(grouped.items(), key=lambda t: t[0])
config.log(f"筛选结果:共 {sum(n for _, n in units)} 人 / {len(units)} 个参保单位")
if kind == 'add':
sub["_type"] = sub["参保类型"].astype(str).str.strip()
sub["_unit"] = sub["参保单位"].astype(str).str.strip()
grouped = sub.groupby(["_type", "_unit"]).size()
units = [(t, u, int(n)) for (t, u), n in grouped.items()]
units.sort(key=lambda x: (x[0], x[1]))
unit_desc = "个(类型+单位)分组"
else:
grouped = sub.groupby(sub["参保单位"].astype(str).str.strip()).size()
units = [(None, u, int(n)) for u, n in grouped.items()]
units.sort(key=lambda x: x[1])
unit_desc = "个参保单位"
config.log(f"筛选结果:共 {sum(n for _, _, n in units)} 人 / {len(units)} {unit_desc}")
return units, source_file, sheet_name