evoToK3Cloud/script/postman/plm-pdf-zip/README.md
2026-08-11 14:29:31 +08:00

107 lines
2.8 KiB
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# PLM PDF 压缩包接口 Postman 测试
## 接口
| 项 | 值 |
|----|-----|
| 方法 | `POST` |
| URL | `http://localhost:8033/system/material/plm/pdf/zip` |
| Content-Type | `multipart/form-data` |
| 鉴权 | 无(`@SaIgnore` |
> 端口以本地 `application.yml` 为准(默认 `8033`dev 配置可能是 `9101`。
## 表单字段
| Key | 类型 | 说明 |
|-----|------|------|
| `items` | **Text** | `manifest.json` 全文JSON 字符串) |
| `files` | **File** | zip 包,内含 manifest 声明的 PDF |
**注意:** Postman 里 `items` 必须选 **Text**,不要选 File字段名必须是 `items``files`
## manifest JSON 示例
见同目录 `manifest.json`
```json
{
"productionOrderNo": "CP-25-103-XCL",
"IsDrawingChanaged": true,
"items": [
{
"pdfPath": "drawings/part-a.pdf",
"materialCode": "MAT-001",
"materialName": "测试零件A",
"unitQty": 1,
"batchQty": 10
},
{
"pdfPath": "drawings/part-b.pdf",
"dwgPath": "drawings/part-b.dwg",
"materialCode": "MAT-002",
"materialName": "测试零件B",
"unitQty": 2,
"batchQty": 20
}
]
}
```
- `pdfPath`zip 内 PDF 的相对路径(用 `/`,与 zip 里 entry 名一致)
- `dwgPath`可选zip 内 DWG 相对路径
- `IsDrawingChanaged`:根级是否变更图纸(布尔;会回填到各明细;明细也可单独覆盖;亦兼容 `isDrawingChanged`
- zip 里**不能多、不能少** PDF/DWG必须与 `items` 声明一致
## 生成测试 zip
```powershell
cd script\postman\plm-pdf-zip
.\make-demo-zip.ps1
```
得到 `plm-pdf-demo.zip`
## Postman 操作步骤
1. New Request → `POST` → URL 填上表地址
2. Body → **form-data**
3. 第一行Key=`items`,类型 **Text**Value 粘贴 `manifest.json` 内容
4. 第二行Key=`files`,类型 **File**,选择 `plm-pdf-demo.zip`
5. Send
## 成功响应示例
```json
{
"code": 200,
"msg": "操作成功",
"data": {
"productionOrderNo": "CP-25-103-XCL",
"savedDir": "D:/plm/pdf/CP-25-103-XCL",
"count": 2,
"items": [
{
"pdfPath": "drawings/part-a.pdf",
"materialCode": "MAT-001",
"materialName": "测试零件A",
"savedFileName": "MAT-001测试零件A.pdf",
"savedDir": "D:/plm/pdf/CP-25-103-XCL",
"savedPath": "D:/plm/pdf/CP-25-103-XCL/MAT-001测试零件A.pdf"
}
]
}
}
```
保存目录由配置 `plm.pdf.base-dir` 决定(默认 `D:/plm/pdf`)。
## 常见错误
| 返回 | 原因 |
|------|------|
| manifest不能为空 | 未传 `items` 或为空 |
| manifest不是合法JSON | `items` 不是合法 JSON |
| zip缺少以下PDF文件 | zip 里没有对应 `pdfPath` |
| zip包含未在manifest声明的PDF | zip 里多了未列出的 pdf |