115 lines
4.4 KiB
Markdown
115 lines
4.4 KiB
Markdown
# 华夏银行钉钉验证码填写
|
||
|
||
标准流程已改为一次性填写链接:华夏任务发送银行短信后,向钉钉“华夏验证码”群发送一个按钮链接。用户在链接内填写 6 位验证码,任务轮询财务系统后继续登录。此方式不依赖钉钉窗口 OCR。
|
||
|
||
链接默认 5 分钟有效、只能提交一次;验证码加密暂存,任务读取后立即删除,不写入日志。
|
||
|
||
运行任务的电脑需要能够访问正式财务系统。钉钉无需停留在验证码群,只需保持群机器人 Webhook 可用。
|
||
|
||
## 旧版钉钉截图读取
|
||
|
||
从本机钉钉“华夏验证码”群读取华夏银行刚收到的 6 位短信验证码。脚本只截取钉钉窗口右侧聊天区域,在内存中使用 Windows OCR 识别,不保存截图或完整聊天文本。
|
||
|
||
## 使用要求
|
||
|
||
- 仅在 Windows 台式机使用。
|
||
- 钉钉保持登录,并停在“华夏验证码”群。
|
||
- 钉钉窗口保持正常尺寸,不要最小化。
|
||
- 使用 Windows PowerShell 5.1 运行,不要使用 PowerShell 7。
|
||
|
||
## 标准等待流程
|
||
|
||
先启动读取器,再发送银行短信验证码和钉钉提示:
|
||
|
||
```powershell
|
||
scripts\hxb-bank\read-dingtalk-otp.cmd
|
||
```
|
||
|
||
读取器会先忽略屏幕上已有的验证码,再等待新验证码出现。成功后只输出一行 JSON,例如:
|
||
|
||
```json
|
||
{"ok":true,"code":"123456","window":"钉钉","observedAt":"2026-11-27T16:30:00.0000000+08:00"}
|
||
```
|
||
|
||
常用参数:
|
||
|
||
```powershell
|
||
# 等待 180 秒
|
||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts\hxb-bank\read-dingtalk-otp.ps1 `
|
||
-TimeoutSeconds 180
|
||
|
||
# 已经收到新验证码后立即读取,并允许返回当前最新验证码
|
||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts\hxb-bank\read-dingtalk-otp.ps1 `
|
||
-IncludeExisting
|
||
|
||
# 避免重复使用某个旧验证码
|
||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts\hxb-bank\read-dingtalk-otp.ps1 `
|
||
-IncludeExisting -IgnoreCode 123456
|
||
|
||
# 当前只允许读取指定群
|
||
powershell.exe -NoProfile -ExecutionPolicy Bypass -File scripts\hxb-bank\read-dingtalk-otp.ps1 `
|
||
-GroupMarker 华夏
|
||
```
|
||
|
||
## 识别规则
|
||
|
||
- 右边聊天气泡中的 6 位数字是主要识别位置。
|
||
- 默认还会核对聊天窗口标题必须包含“华夏”,避免误读其他会话。
|
||
- 中文 OCR 会把部分数字识别错,因此脚本使用 Windows 英文 OCR,并在 4、5、6 倍放大下交叉校验。
|
||
- 同一验证码需要在不同放大结果里获得至少两次一致识别,并连续两轮截图都出现,才会输出。
|
||
- 开始监听前已经存在的验证码默认全部排除。
|
||
- 超时、窗口找不到、尺寸过小或 OCR 语言包缺失时返回非零退出码。
|
||
|
||
## 故障排查
|
||
|
||
查看系统 OCR 语言包:
|
||
|
||
```powershell
|
||
[Windows.Media.Ocr.OcrEngine]::AvailableRecognizerLanguages | Select LanguageTag,DisplayName
|
||
```
|
||
|
||
必须包含 `en-US`。如果没有,请在 Windows“语言和区域”中安装英语语言及光学字符识别组件。
|
||
|
||
## 每日自动导入
|
||
|
||
完整流程是:
|
||
|
||
1. 使用独立 Edge 登录态打开华夏企业网银。
|
||
2. 必要时自动填写手机号、密码并发送短信验证码。
|
||
3. 向钉钉“华夏验证码”群发送一次性填写链接。
|
||
4. 用户提交验证码后,任务通过正式系统受限接口读取并完成登录。
|
||
5. 查询昨天至今天的全部账户交易明细。
|
||
6. 自动下载 XLSX,并核对日期、流水条数、收入与支出。
|
||
7. 以“华夏银行 / 银企直连账户账单”执行 dry-run。
|
||
8. 核对 dry-run 的账务日期范围;条数以文件实际解析结果为准,校验通过后导入本地财务系统。
|
||
|
||
手动运行:
|
||
|
||
```powershell
|
||
scripts\hxb-bank\run-hxb-daily.cmd
|
||
```
|
||
|
||
只下载不导入:
|
||
|
||
```powershell
|
||
scripts\hxb-bank\run-hxb-daily.cmd -SkipImport
|
||
```
|
||
|
||
安装每天 00:01、09:10 的 Windows 定时任务:
|
||
|
||
```powershell
|
||
powershell.exe -NoProfile -ExecutionPolicy Bypass `
|
||
-File scripts\hxb-bank\install-daily-task.ps1
|
||
```
|
||
|
||
任务名称为 `CaiWuXiTong-HxbBankDaily`。电脑关机时无法执行;任务设置为“错过计划后在下次可用时启动”,但必须在用户已登录且未注销的 Windows 会话中运行。
|
||
|
||
运行前只需保证“华夏验证码”群机器人可以正常发送消息,并确保点击链接后能访问正式财务系统。
|
||
|
||
如需改为其他时间,可显式传入多个时间:
|
||
|
||
```powershell
|
||
powershell.exe -NoProfile -ExecutionPolicy Bypass `
|
||
-File scripts\hxb-bank\install-daily-task.ps1 -Times 00:01,09:10
|
||
```
|