泛微 OA 工作流批量处理器
> 通用化版本,适用于任何部署了泛微 e-cology(Weaver)的 OA 系统。
> 站点地址、关键词、批示语均通过配置提供,不包含任何单位私有信息。
> 英文别名:Weaver OA Workflow Batch Processor
Configuration (必读)
本技能不含任何硬编码的 OA 地址。运行前需要确定以下站点私有项:
| 配置项 | 说明 | 示例 |
|---|---|---|
base_url |
OA 站点根地址 | https://oa.mycompany.com |
keywords |
需要自动处理的流程标题关键词 | 报销、用章申请 |
comment |
填入签字意见的批示语,默认 OK |
OK、同意 |
解析优先级(高 → 低):
- 命令行参数
--base-url/--keywords/--comment - 环境变量
OA_BASE_URL/OA_KEYWORDS/OA_COMMENT - 用户级配置
~/.workbuddy/oa-config.json - 技能内配置
<skill>/config/oa_config.json(已 gitignore) - 模板
<skill>/config/oa_config.example.json(仅非敏感默认值)
首次运行引导
若以上来源都拿不到 base_url,脚本会主动询问用户并写入
~/.workbuddy/oa-config.json,之后不再打扰。作为 Agent 执行时若无法交互,
脚本会报错退出并给出配置指引——此时应主动询问用户 OA 地址与关键词,
再写入用户级配置文件,不要自己猜测。
查看当前生效配置:
python scripts/process_workflows.py --show-config
Purpose
This skill automates the batch processing of OA workflow notifications. It opens a browser, waits for the user to manually log in (username, password, and captcha), then automatically processes all workflows matching configured keywords by filling in the configured comment as the response and submitting them.
When to Use This Skill
Trigger this skill when:
- Daily workflow processing is needed for specific workflow types
- Multiple pending workflows need to be processed in batch
- User wants to manually log in but automate the repetitive workflow processing
Example user requests:
- "Process all 考勤 workflows in my pending tasks"
- "Run the daily workflow batch processor"
- "Help me batch process today's pending workflows"
How the Skill Works
Workflow Processing Steps
- Launch Browser - Script opens Chromium browser with visible window
- Navigate to Login Page - Automatically opens the configured OA URL (
base_url) - Wait for Manual Login - User manually enters:
- Username
- Password
- Captcha (no OCR, manual input) - Detect Login Success - Script monitors URL and page elements to detect successful login
- Navigate to Workflow List - Automatically jumps to pending workflow list
- Filter by Keywords - Identify workflows containing any of the configured keywords
- Process Each Workflow:
- Click workflow to open in new tab
- Check if signature field is empty
- If empty, click "常用批示语" and select the configured comment
- Click "提 交" (Submit) button
- Click "确 定" (Confirm) button
- Close workflow tab and return to list - Handle Pagination - Process all pages until no more workflows
- Generate Report - Display processing statistics
Key Implementation Details
- Manual Login: User manually inputs all credentials including captcha
- Login Detection: Monitors URL changes and page elements to detect successful login (max 5 minutes wait)
- JavaScript Click Method: Uses JavaScript evaluation for reliable element interaction
- Multi-Keyword Support: Filters workflows for ANY of the specified keywords
- Tab Management: Automatically switches between workflow list and detail pages
- No Waiting: Rapid processing without waiting for page transitions
Target Keywords
由配置 keywords 提供,技能不内置任何默认值(避免泄露单位内部流程名)。
在 ~/.workbuddy/oa-config.json 中配置,或运行时用 --keywords 关键词A,关键词B 覆盖。
Response Comment
由配置 comment 提供,默认 OK。
Scripts
| 脚本 | 作用 |
|---|---|
scripts/run_automation.py |
实际执行:Playwright 有头浏览器自动化,登录→扫描→逐条提交→翻页 |
scripts/process_workflows.py |
配置解析 + JS 片段/步骤清单生成器(不跑浏览器) |
泛微 e-cology 实战要点(2026-09 真机验证)
- 处理顺序必须是:先填签字意见 → 点提交/批准 → 弹「信息确认」→ 点确定。
签字意见编辑器(富文本,标注"必填")在详情页底部,点按钮前就存在;
「常用批示语」是工具栏图标,文案在title属性里而非 innerText。 - 动作按钮文案不固定:有「提 交」也有「批 准 / 退 回 / 保 存 / 转 发」(按流程类型不同)。
匹配时必须把文本去空格后再比对。 - 确认弹窗按钮只认「确定/确认/是/OK」。绝不能把"提交/批准"放进确认候选,
否则会重复点动作按钮导致弹窗不关、流程未提交。 - 列表点击不能拿整行文本反查元素——那只会匹配到
<tr>本身,点了没反应。
正解:从a[onclick](openSPA4Single('/main/workflow/req?requestid=xxx&...'))
或tr[ecid](...@<requestid>_<userid>_tr@)正则提取 requestid,按 requestid 去重后
直开{base}/spa/workflow/static4form/index.html#/main/workflow/req?requestid=xxx。 - 会话过期时 URL 不变:仍停留在
wui/index.html#/main/...,页面正文只有
「登录超时,请重新登录!」。登录判定必须查正文关键词 +input[type=password],
不能只看 URL。 - 提交成功的判据:确认弹窗关闭 + 详情页动作按钮(批准/提交等)消失。
汇总里 submit/confirm 任一未命中都要标记「待人工核对」,严禁计入成功。
Installation
pip install playwright
playwright install chromium
Usage
跑自动化(常用)
python scripts/run_automation.py
常用参数:
| 参数 | 说明 |
|---|---|
--dry-run |
只扫描列出匹配流程,不点提交,用于先确认范围 |
--fresh |
忽略已保存会话,强制重新手动登录 |
--max-pages N |
最多翻 N 页,默认 50 |
--keywords A,B / --comment X |
临时覆盖配置 |
会话复用:首次手动登录后,会话写入 ~/.workbuddy/oa-state.json,
后续运行自动跳过登录(无需再输验证码)。登录态失效时用 --fresh 重登。
安全建议:首次对新的关键词组合运行,先加 --dry-run 看匹配范围,确认无误再正式跑。
Agent / 后台运行注意事项
- 加
-u让日志实时可见:python -u scripts/run_automation.py ...。
stdout 接管道时 Python 是块缓冲,不加-u的话「处理汇总」会滞留在缓冲区,
进程被杀时直接丢失(真机踩过:后台跑完 27 分钟仍看不到任何输出)。 --keep-open只适合人守着终端的场景:它处理完后进入死循环等 Ctrl+C。
无人值守/Agent 后台运行时不要加,让脚本处理完自动关浏览器退出;
事后核对用--shot-dir的截图即可。- 向后台进程发 Ctrl+C 基本无效:Windows 后台任务收不到控制台事件,
GenerateConsoleCtrlEvent 也送达不了 asyncio 循环。要结束只能强杀(丢汇总),
结果核对以截图为准:<requestid>_filled.png= 填好批示语时,
<requestid>_<标题>.png= 提交后的详情页(动作按钮消失即成功)。
配置与 JS 片段
python scripts/process_workflows.py --show-config # 查看生效配置
python scripts/process_workflows.py --init # 交互式初始化
其它用法:
# 查看生效配置
python scripts/process_workflows.py --show-config
# 临时覆盖
python scripts/process_workflows.py --base-url https://oa.mycompany.com --keywords 报销,用章申请
# 无人值守 / 定时任务
OA_BASE_URL=https://oa.mycompany.com OA_KEYWORDS=报销,用章申请 python scripts/process_workflows.py
The script will:
1. Open browser
2. Wait for you to log in manually
3. Automatically process all matching workflows after login
Error Handling
Login Timeout
- Script waits maximum 5 minutes for manual login
- If timeout, script exits gracefully
Workflow Processing Failure
- If a workflow fails, script continues to next workflow
- All errors are logged in console output
Browser Issues
- If browser fails to launch, run:
playwright install chromium
Customization
To process different keywords or use a different comment, change the config — not the script:
// ~/.workbuddy/oa-config.json
{
"base_url": "https://oa.mycompany.com",
"keywords": ["报销", "用章申请"],
"comment": "OK"
}
或运行时临时指定:
python scripts/process_workflows.py --keywords 报销,用章申请 --comment 同意
Security Notes
- No credentials are stored or transmitted
- User manually enters all sensitive information
- Browser closes automatically after completion
- 本技能不含任何单位私有信息:OA 地址、流程关键词、内部系统名一律外置到用户级配置
Publishing Checklist (发布到 skillhub 前)
- [ ] 全目录搜索确认无内网域名残留:
grep -rn "oavpn\|192.168\|10\.\|内网" . - [ ]
config/oa_config.json已 gitignore,不存在于发布包中 - [ ] 文档中的示例地址统一为
https://oa.example.com - [ ] 示例关键词为中性词(报销 / 用章申请 / 请假),不含内部系统名
- [ ]
_user_meta.json不随包发布
目录结构
weaver-oa-workflow-batch/
├── SKILL.md
├── README.md
├── .gitignore # 忽略 config/oa_config.json
├── config/
│ └── oa_config.example.json # 模板,可发布
├── scripts/
│ └── process_workflows.py
├── references/
│ └── workflow_api_guide.md
└── assets/
└── 快速开始指南.md
用户级配置位于技能目录之外:~/.workbuddy/oa-config.json,技能升级不会覆盖。