feat: 重构控制台为37du自动化平台,新增权限授权与通知中心功能
- 更新系统名称、登录页宣传文案为37du平台相关内容 - 移除聊天功能相关代码与配置 - 新增客户端版本上报字段与设备统计接口 - 新增通知中心功能(60s轮询、localStorage已读标记) - 新增权限授权工作台相关接口与页面 - 新增统一页头组件ArtPageHeader - 调整快速入口配置指向真实功能页面 - 修复控制面地址为内网生产库
This commit is contained in:
@@ -17,9 +17,12 @@
|
||||
「本月发起名单」对应行「发起日期」列(openpyxl 直写,试算模式不写);
|
||||
6. 回写完成(新增成功或 AI 表已有)-> 从待办工号列表移除,列表清空即链路收尾。
|
||||
|
||||
字段映射注意:AI 表「现单位名称/原单位名称」是 singleSelect 且选项为会馆名
|
||||
(四级部门级),取名单表「现四级部门/原四级部门」列,不是「现单位/原单位」
|
||||
(事业部级名称不在选项集,写入报 invalid)。
|
||||
字段映射注意:AI 表「现单位名称/原单位名称」是 singleSelect,选项为 124 个
|
||||
单位名(会馆名 + 石桥铺系「石桥铺会馆-前厅部」式路径名 + 经营中心等),不是
|
||||
「现单位/原单位」(事业部级名称不在选项集,写入报 invalid)。取值按选项集
|
||||
匹配(fetch_field_choices + pick_unit):候选依次 四级部门 -> 二级-三级 ->
|
||||
二级 -> 三级,首个命中选项集者即用;全不命中留空并告警,保证批次不被
|
||||
单个无效选项卡死(裸「石桥铺会馆」「礼宾组」均不在选项集)。
|
||||
date 字段写毫秒时间戳(XQ0035 同款口径);singleSelect 写入传选项名字符串
|
||||
(读取才返回 {"name","id"} 对象)。
|
||||
|
||||
@@ -61,8 +64,8 @@ RECORDS_ADD_URL = (f"https://api.dingtalk.com/v1.0/notable/bases/{AITABLE_BASE_I
|
||||
|
||||
# 名单表「本月发起名单」所需列(按表头名解析,列序无关)
|
||||
ROSTER_COLS = ("姓名", "工号", "调动时间",
|
||||
"现四级部门", "现岗位", "现技师工号",
|
||||
"原四级部门", "原岗位", "原技师工号")
|
||||
"现二级部门", "现三级部门", "现四级部门", "现岗位", "现技师工号",
|
||||
"原二级部门", "原三级部门", "原四级部门", "原岗位", "原技师工号")
|
||||
|
||||
FIELD_INITIATED = "是否已发起改签离职"
|
||||
FIELD_INIT_TIME = "发起时间"
|
||||
@@ -77,6 +80,37 @@ def _s(v):
|
||||
return str(v).strip() if v is not None else ""
|
||||
|
||||
|
||||
def fetch_field_choices():
|
||||
"""「现/原单位名称」字段选项集(两字段选项一致,取并集兜底)。
|
||||
|
||||
fields 接口响应结构 {"value": [field...]},单选选项在 property.choices。
|
||||
"""
|
||||
url = (f"https://api.dingtalk.com/v1.0/notable/bases/{AITABLE_BASE_ID}"
|
||||
f"/sheets/{TABLE_ID}/fields")
|
||||
d = _aitable_request("GET", url, params={"operatorId": AITABLE_OPERATOR_UNIONID})
|
||||
names = set()
|
||||
for f in d.get("value") or []:
|
||||
if f.get("name") in ("现单位名称", "原单位名称"):
|
||||
names |= {c["name"] for c in (f.get("property") or {}).get("choices") or []
|
||||
if c.get("name")}
|
||||
return names
|
||||
|
||||
|
||||
def pick_unit(row, prefix, choices):
|
||||
"""单位名称候选依次 四级 -> 二级-三级 -> 二级 -> 三级,首个命中选项集者。
|
||||
|
||||
金色印象系四级=会馆名直接命中;石桥铺会馆直管体系选项为
|
||||
「石桥铺会馆-前厅部」式路径名,由 二级-三级 拼接命中。
|
||||
"""
|
||||
l2 = row[f"{prefix}二级部门"]
|
||||
l3 = row[f"{prefix}三级部门"]
|
||||
l4 = row[f"{prefix}四级部门"]
|
||||
for cand in (l4, f"{l2}-{l3}" if l2 and l3 else "", l2, l3):
|
||||
if cand and cand in choices:
|
||||
return cand
|
||||
return ""
|
||||
|
||||
|
||||
def _ms_day(value):
|
||||
"""datetime / 'yyyy-MM-dd…' / 毫秒时间戳(int) -> 当天 0 点毫秒;失败 None。
|
||||
|
||||
@@ -118,9 +152,13 @@ def load_roster_rows():
|
||||
"姓名": _s(ws.cell(r, header["姓名"]).value),
|
||||
"工号": code,
|
||||
"调动时间": ws.cell(r, header["调动时间"]).value,
|
||||
"现二级部门": _s(ws.cell(r, header["现二级部门"]).value),
|
||||
"现三级部门": _s(ws.cell(r, header["现三级部门"]).value),
|
||||
"现四级部门": _s(ws.cell(r, header["现四级部门"]).value),
|
||||
"现岗位": _s(ws.cell(r, header["现岗位"]).value),
|
||||
"现技师工号": _s(ws.cell(r, header["现技师工号"]).value),
|
||||
"原二级部门": _s(ws.cell(r, header["原二级部门"]).value),
|
||||
"原三级部门": _s(ws.cell(r, header["原三级部门"]).value),
|
||||
"原四级部门": _s(ws.cell(r, header["原四级部门"]).value),
|
||||
"原岗位": _s(ws.cell(r, header["原岗位"]).value),
|
||||
"原技师工号": _s(ws.cell(r, header["原技师工号"]).value),
|
||||
@@ -214,10 +252,11 @@ def backfill_init_dates(rows, items):
|
||||
return done
|
||||
|
||||
|
||||
def build_fields(row, today_ms):
|
||||
"""名单行 + 发起时间 -> AI 表新增行 fields(空值字段不写)。
|
||||
def build_fields(row, today_ms, choices):
|
||||
"""名单行 + 发起时间 + 选项集 -> AI 表新增行 fields(空值字段不写)。
|
||||
|
||||
singleSelect(是否已发起改签离职/现单位名称/原单位名称)写入传选项名字符串。
|
||||
singleSelect(是否已发起改签离职/现单位名称/原单位名称)写入传选项名字符串;
|
||||
单位名称经 pick_unit 匹配选项集,未命中不写该字段(留空告警)。
|
||||
"""
|
||||
fields = {
|
||||
"姓名": row["姓名"],
|
||||
@@ -228,14 +267,16 @@ def build_fields(row, today_ms):
|
||||
t = _ms_day(row["调动时间"])
|
||||
if t:
|
||||
fields["调动时间"] = t
|
||||
if row["现四级部门"]:
|
||||
fields["现单位名称"] = row["现四级部门"]
|
||||
u = pick_unit(row, "现", choices)
|
||||
if u:
|
||||
fields["现单位名称"] = u
|
||||
if row["现岗位"]:
|
||||
fields["现岗位"] = row["现岗位"]
|
||||
if row["现技师工号"]:
|
||||
fields["现技师工号"] = str(row["现技师工号"])
|
||||
if row["原四级部门"]:
|
||||
fields["原单位名称"] = row["原四级部门"]
|
||||
u = pick_unit(row, "原", choices)
|
||||
if u:
|
||||
fields["原单位名称"] = u
|
||||
if row["原岗位"]:
|
||||
fields["原岗位"] = row["原岗位"]
|
||||
if row["原技师工号"]:
|
||||
@@ -305,6 +346,9 @@ def main(dry_run=None):
|
||||
f"{'(试算模式)' if dry_run else ''}")
|
||||
return stats
|
||||
|
||||
choices = fetch_field_choices()
|
||||
if not choices:
|
||||
raise RuntimeError("未能获取「现/原单位名称」字段选项集,终止回写以免单位名称写空")
|
||||
add_items, done_codes, init_items = [], [], []
|
||||
today_ms = _ms_day(datetime.now())
|
||||
for code in sorted(initiated):
|
||||
@@ -323,9 +367,11 @@ def main(dry_run=None):
|
||||
done_codes.append(code)
|
||||
init_items.append((code, dup[2]))
|
||||
continue
|
||||
fields = build_fields(row, today_ms)
|
||||
_log(f"[回写] {code} {row['姓名']} | 现单位 {row['现四级部门'] or '空'} | "
|
||||
f"原单位 {row['原四级部门'] or '空'} | 调动 {row['调动时间']}")
|
||||
fields = build_fields(row, today_ms, choices)
|
||||
warn = "" if ("现单位名称" in fields and "原单位名称" in fields) \
|
||||
else "(存在无匹配选项的单位名称,已留空待人工核对)"
|
||||
_log(f"[回写] {code} {row['姓名']} | 现单位 {fields.get('现单位名称') or '空'} | "
|
||||
f"原单位 {fields.get('原单位名称') or '空'} | 调动 {row['调动时间']}{warn}")
|
||||
add_items.append(fields)
|
||||
|
||||
if add_items and not dry_run:
|
||||
|
||||
Reference in New Issue
Block a user