docs: 更新 AGENTS/README 平台架构说明与月度总结,运行日志视图支持已取消状态

This commit is contained in:
2026-10-31 17:55:25 +08:00
parent e1b4097573
commit b976b80d9d
201 changed files with 11049 additions and 7398 deletions
@@ -9,8 +9,8 @@
签署单位(金色湖畔事业部特殊判断;后浪新天地LIFE+主题会馆按现岗位细分
(餐饮)/(非餐饮),2026-10-16 拍板)、新合同模板(未达龄按序列选劳动合同档 + 廉政协议
+ 放弃社保申明;已达龄按员工取超龄人员用工协议 + 超龄专用保密/廉政/食品安全承诺)
4. 未达龄但按期限签会超退休日时:实际开始日到退休日 > 3 个月 -> 直接签至退休日;
<= 3 个月才写「改签异常名单.xlsx」并跳过(2026-10-21 调整);
4. 未达龄但按期限签会超退休日时:终止日直接签至退休日(2026-10-31 取消原「距退休日
<= 3 个月写异常并跳过」限制,一律签至退休日、不再转人工);
签署单位字典未命中的写入异常名单并跳过;已达法定退休年龄的不算异常,正常走流程(统一签 12 个月)
5. saveWorkform 保存表单 + sendNextWeTask 提交送审,复查任务完成
@@ -312,18 +312,15 @@ def calc_plan(session, biz, roster_row):
end_time = _defer_months(start, months)
end = end_time - timedelta(days=1)
# 退休分段(2026-10-21 调整):实际开始日到退休日 > 3 个月 -> 直接签至退休日(不再报异常);
# 不足/等于 3 个月才报「超龄需分段」转人工
if not overage and end >= retire:
if _defer_months(start, 3) < retire:
months = _month_span(start, retire)
end = retire
end_time = retire + timedelta(days=1)
_log(f"[分段] 开始日 {start:%Y-%m-%d} 距退休日 {retire:%Y-%m-%d} 超过 3 个月,"
f"直接签至退休日(按 {months} 个月登记期限)")
else:
return None, (f"合同终止日 {end:%Y-%m-%d} 超退休日 {retire:%Y-%m-%d},"
f"距退休日不足/等于 3 个月,超龄需分段签订")
# 退休封顶(2026-10-31 调整):未达龄但按期限签会越过退休日 -> 终止日直接签至退休日
# (取消原「距退休日 <= 3 个月转人工」限制,一律签至退休日、不再报异常)
if not overage and end >= retire and start < retire:
plan_months = months
months = _month_span(start, retire)
end = retire
end_time = retire + timedelta(days=1)
_log(f"[封顶] 按 {plan_months} 个月签名会越过退休日 {retire:%Y-%m-%d},"
f"直接签至退休日(按 {months} 个月登记期限)")
# 签署单位:金色湖畔事业部按现职位序列是否含"职能"二分,其余用现四级部门;
# 后浪新天地LIFE+主题会馆按现岗位细分(餐饮)/(非餐饮)(2026-10-16 拍板)
@@ -484,7 +481,10 @@ def write_abnormal(code, name, title, kind, note, dry_run=False):
# ---------- 主流程 ----------
def process_one(session, flow, task, launch_rows, dry_run, pending=None):
"""处理单个完善信息任务。返回 (result, code)。
"""处理单个完善信息任务。返回 (result, code, detail)。
detail 为该条的异常/失败明细 dict(群通知展示用):{"code","name","kind","note"},
正常结果返回 None。
pending 传入时仅处理列表内工号(本批次作用域闸门),
列表外(人工单/其他批次)静默跳过,不读名单不写异常。
@@ -498,12 +498,13 @@ def process_one(session, flow, task, launch_rows, dry_run, pending=None):
name = str(biz.get("staff_name") or "").strip()
title = str(flow.get("title") or "")
if pending is not None and code not in pending:
return "skip", code
return "skip", code, None
row = launch_rows.get(code)
if row is None:
write_abnormal(code, name, title, "名单缺失", "发起名单中未找到该工号",
dry_run)
return "abnormal", code
note = "发起名单中未找到该工号"
write_abnormal(code, name, title, "名单缺失", note, dry_run)
return "abnormal", code, {"code": code, "name": name,
"kind": "名单缺失", "note": note}
is_venue = UNIT_TRAINING_VENUE in (
str(row.get("现四级部门") or ""), str(row.get("原四级部门") or ""))
if is_venue:
@@ -514,28 +515,31 @@ def process_one(session, flow, task, launch_rows, dry_run, pending=None):
else:
plan, abnormal = calc_plan(session, biz, row)
if abnormal:
write_abnormal(code, name, title, "超龄/规则异常", abnormal, dry_run)
return "abnormal", code
write_abnormal(code, name, title, "规则异常", abnormal, dry_run)
return "abnormal", code, {"code": code, "name": name,
"kind": "规则异常", "note": abnormal}
if not is_venue:
_log(f"[计算] {code} {name} | {row.get('现职位序列')} | {plan['months']}月 | "
f"{plan['start']}~{plan['end']} | {plan['unit_name']} | "
f"模板{plan['templates'].count(',') + 1}个")
if dry_run:
return "dry", code
return "dry", code, None
submit_task(session, task, biz, plan)
done = verify_done(session, task)
_log(f"[提交] {code} {name} 任务 {'已完成' if done else '状态待确认'}")
return ("done" if done else "submitted"), code
return ("done" if done else "submitted"), code, None
except Exception as e: # noqa: BLE001
_log(f"[失败] {code} {name}: {type(e).__name__}: {e}")
note = f"{type(e).__name__}: {e}"
_log(f"[失败] {code} {name}: {note}")
try:
write_abnormal(code, name, str(flow.get("title") or ""),
"处理异常", f"{type(e).__name__}: {e}", dry_run)
"处理异常", note, dry_run)
except Exception:
pass
return "error", code
return "error", code, {"code": code, "name": name,
"kind": "处理异常", "note": note}
def main(dry_run=None):
@@ -544,26 +548,36 @@ def main(dry_run=None):
if not pending:
_log("[待办] 待办工号列表为空(本批次无人待办),无事可做")
return {"done": 0, "submitted": 0, "abnormal": 0, "dry": 0,
"error": 0, "skip": 0}
"error": 0, "skip": 0, "issues": [], "abnormal_path": "",
"dry_run": bool(dry_run)}
_log("[待办] 本批待办 {} 人:{}".format(
len(pending), "、".join(f"{c}{n}" for c, n in sorted(pending.items()))))
session = _hr_session()
launch_rows = load_launch_rows()
stats = {"done": 0, "submitted": 0, "abnormal": 0, "dry": 0,
"error": 0, "skip": 0}
issues = [] # 异常/失败明细(群通知逐条展示,详情落异常表)
done_codes = []
for flow, task in find_worker_tasks(session):
result, code = process_one(session, flow, task, launch_rows,
dry_run, pending)
result, code, detail = process_one(session, flow, task, launch_rows,
dry_run, pending)
stats[result] = stats.get(result, 0) + 1
if result in ("abnormal", "error") and detail:
issues.append(dict(detail, result=result))
# 异常落名单即转人工,从待办列表移除,避免重跑重复记异常
if result == "abnormal" and not dry_run and code:
done_codes.append(code)
if done_codes:
remove_pending(done_codes)
_log("[待办] 异常转人工,已从待办列表移除:{}".format("、".join(done_codes)))
for it in issues:
_log(f"[异常明细] {it.get('code')} {it.get('name')} | "
f"{it.get('kind')} | {it.get('note')}")
_log(f"[汇总] 完成={stats['done']} 已送审={stats['submitted']} "
f"异常={stats['abnormal']} 试算={stats['dry']} 失败={stats['error']} "
f"列表外跳过={stats['skip']}"
f"{'(试算模式,未提交)' if dry_run else ''}")
stats["issues"] = issues
stats["abnormal_path"] = _abnormal_path()
stats["dry_run"] = bool(dry_run)
return stats