feat: add pcf analysis web app and api
This commit is contained in:
@@ -0,0 +1,120 @@
|
||||
# PCF 焊接数据导入生成工具
|
||||
|
||||
这是一个 Windows 本地/内网 Web 工具。用户在浏览器上传多个 `.pcf` 文件后,系统解析 `WELD` 焊口段,并生成基于 `焊接数据导入模版.xls` 的导入文件。
|
||||
|
||||
## 功能
|
||||
|
||||
- 多文件上传 `.pcf`
|
||||
- 按规则解析标准 PCF 字段
|
||||
- 使用 `deepseek-v4-flash` 辅助识别非标准字段名
|
||||
- 生成 `.xls`、问题清单 `.csv`、解析报告 `.json`
|
||||
- 不依赖 Microsoft Excel
|
||||
|
||||
## 启动
|
||||
|
||||
首次离线安装:
|
||||
|
||||
```powershell
|
||||
.\scripts\install_offline.ps1
|
||||
```
|
||||
|
||||
启动服务:
|
||||
|
||||
```powershell
|
||||
.\scripts\run.ps1
|
||||
```
|
||||
|
||||
浏览器打开:
|
||||
|
||||
```text
|
||||
http://127.0.0.1:8000
|
||||
```
|
||||
|
||||
## DeepSeek 配置
|
||||
|
||||
未配置密钥时,系统仍会按规则生成 Excel,只跳过智能字段映射。密钥在 `config/mapping.yaml` 中配置:
|
||||
|
||||
```yaml
|
||||
deepseek:
|
||||
model: deepseek-v4-flash
|
||||
base_url: https://api.deepseek.com
|
||||
api_key: "你的密钥"
|
||||
confidence_threshold: 0.85
|
||||
```
|
||||
|
||||
默认模型是:
|
||||
|
||||
```text
|
||||
deepseek-v4-flash
|
||||
```
|
||||
|
||||
## 离线依赖包
|
||||
|
||||
`vendor/wheels/` 用于存放离线 wheel。联网开发机可运行:
|
||||
|
||||
```powershell
|
||||
.\scripts\download_wheels.ps1
|
||||
```
|
||||
|
||||
然后把整个项目目录复制到离线 Windows 环境。
|
||||
|
||||
## 测试
|
||||
|
||||
```powershell
|
||||
.\.venv\Scripts\python.exe -m pytest
|
||||
```
|
||||
|
||||
## 第三方接口调用
|
||||
|
||||
页面上传和 URL 接口复用同一套解析逻辑。
|
||||
|
||||
```http
|
||||
POST /api/AnalysisPcf
|
||||
Content-Type: application/json
|
||||
```
|
||||
|
||||
请求体:
|
||||
|
||||
```json
|
||||
{
|
||||
"attachment_url": "https://example.com/demo.pcf"
|
||||
}
|
||||
```
|
||||
|
||||
`attachment_url` 也支持服务端可访问的本地文件:
|
||||
|
||||
```json
|
||||
{
|
||||
"attachment_url": "D:\\数据\\样例\\demo.pcf"
|
||||
}
|
||||
```
|
||||
|
||||
或 `file:///`:
|
||||
|
||||
```json
|
||||
{
|
||||
"attachment_url": "file:///D:/数据/样例/demo.pcf"
|
||||
}
|
||||
```
|
||||
|
||||
也可以传多个附件:
|
||||
|
||||
```json
|
||||
{
|
||||
"attachment_urls": [
|
||||
"https://example.com/a.pcf",
|
||||
"https://example.com/b.zip"
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
返回内容包含:
|
||||
|
||||
- `tables.import_columns`:导入数据列定义,包含英文 `key` 和中文 `label`
|
||||
- `tables.import_rows`:导入文件数据,字段名使用英文 `key`
|
||||
- `tables.issue_rows`:问题清单数据
|
||||
- `report`:解析报告 JSON
|
||||
|
||||
该接口只返回 JSON 数据,不生成下载文件,也不返回 `downloads`。
|
||||
|
||||
附件引用支持 `.pcf` 和包含 `.pcf` 的 `.zip`。本地文件路径按服务端机器的文件系统解析。
|
||||
Reference in New Issue
Block a user