21 Commits

Author SHA1 Message Date
Niko
2518b922af fix file name 2026-05-22 09:42:52 +08:00
Niko
c4829156a9 use Headless 2026-05-05 22:27:29 +08:00
Niko
1b7ebb4325 fix download excel 2026-05-05 22:05:32 +08:00
Niko
b86d0bf82f Use createReadStream instead of saveAs for Excel download
Bypasses saveAs filesystem path which can produce 0-byte files in headless server environments.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 19:36:30 +08:00
Niko
a393653497 format 2026-05-05 19:27:47 +08:00
Niko
9174a4cc40 Skip download and import directly if file for the date already exists
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 16:06:48 +08:00
Niko
c7a4683340 Set browser to headless, viewport 1920x1080, macOS Chrome UA
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 16:02:57 +08:00
Niko
3877d51560 Remove default values for CLI arguments, all params except -h now required
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:57:25 +08:00
Niko
01505285b0 Add CLI argument parsing and fat jar build support
- Add -s/-u/-p/-d/-h command line options
- Add maven-shade-plugin for fat jar packaging
- Fix proxyImport signature to accept proxyHost parameter

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:54:27 +08:00
Niko
9ef9f8bce4 Remove unused findInput and findSubmit methods
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:46:07 +08:00
Niko
28c2263601 Refactor test to reuse EtsScraper proxyLogin/proxyImport directly
- Make proxyLogin accept (proxyHost, username, password) parameters
- Remove duplicated HTTP logic from ImportTest
- Test now calls same methods as production code

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:44:24 +08:00
Niko
b5ecdde2ab Add import test and fix Bearer token format
- Add ImportTest to verify Excel import via ets-proxy API
- Fix authorization header: use raw token without Bearer prefix
  (UserInterceptor reads authorization header directly, not Bearer-prefixed)
- Rename downloaded file to date-based naming style

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:31:34 +08:00
Niko
d30fb5cdf3 Add auto-import to ets-proxy after downloading Excel
After successful export download, automatically login to ets-proxy to get
JWT token and upload the file via /api/bill/import endpoint.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:26:30 +08:00
Niko
0d43fbbfbb fix: 导出文件按日期命名
文件名从 dl.suggestedFilename() 改为 "三联单列表_yyyyMMdd.xls"

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:13:08 +08:00
Niko
ea0f566e12 fix: 修复导出下载 — 使用 waitForDownload 并输出绝对路径
- 用 page.waitForDownload 替代 onDownload + sleep,正确捕获下载事件
- 增加 5 分钟超时,等待服务器生成大文件
- 输出文件绝对路径和大小,不再找不到下载文件
- 只触发一次下载,不再重复

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 15:06:13 +08:00
Niko
b9e17a2588 fix: 修复导出下载逻辑 — 使用 onDownload + saveAs 替代 sleep
之前只 sleep(5000) 就关浏览器,不配置下载目录也不等待下载完成。
现在用 page.onDownload 捕获下载事件,saveAs 阻塞等待完成,
并校验文件大小防止空文件。

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 14:32:54 +08:00
Niko
f1d3036c7a feat: 添加自动登录测试类并暴露测试所需方法
- 新增 AutoLoginTest 集成测试类
- 暴露以下方法供测试使用:
  - public static void downloadCaptcha(Page)
  - public static void closeNotificationDialog(Page)
  - public static boolean doLoginWithCaptcha(Page)
  - public static void sleep(long)
  - public static final String FRAME_URL / LOGIN_URL

验证码识别已通过测试:9347
2026-05-05 10:12:32 +08:00
Niko
0bd4065230 fix: 修复验证码识别模块
- 添加图像放大功能 (缩放到至少 200px 宽度)
- 修复流式响应解析 (逐行解析 JSON,累加 content 字段)
- 添加 Graphics2D 导入用于图像缩放

验证结果:验证码 9347 识别成功
2026-05-05 10:02:32 +08:00
Niko
6abec1860b 添加验证码识别单元测试:GIF转PNG、Base64编码、OCR调用逻辑
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-05 00:07:26 +08:00
Niko
437dbe78db 集成验证码 OCR 识别:添加 doLoginWithCaptcha 方法,通过 Ollama qwen3-vl:4b 自动识别验证码并登录
Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-04 23:59:50 +08:00
Niko
882c1b9b38 Initial commit: ETS web scraper with Playwright
- Maven + Java 25 + Playwright 1.55.0
- Login automation for ETS construction waste management platform
- Captcha download via waitForResponse
- Notification dialog auto-close

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
2026-05-04 23:48:33 +08:00