1
0
forked from erp-dev/erp

feat: added n-to-1 relation between sales_order_item and printing_job model

This commit is contained in:
2025-12-11 18:09:10 +08:00
parent 633031d7cb
commit 1a8c446365
30 changed files with 41736 additions and 40 deletions

View File

@@ -0,0 +1,74 @@
# 印染任务查询(按客户+日期范围)- API v2
> 说明:接口视图为 `api_v2.views.printing.PrintingJobByCustomerView`URL 需在 `api_v2/urls.py` 绑定后生效(例如 `/api/v2/printing/jobs/`)。
## 请求
- 方法:`GET`
- Query 参数(必填)
- `customer_id`:客户 ID
- `date_from`:开始日期,格式 `YYYY-MM-DD`
- `date_to`:结束日期,格式 `YYYY-MM-DD`(闭区间,包含当日 23:59:59.999999
- Query 参数(可选过滤)
- `printing_order`:按印染主订单 ID
- `product_id`:按产品 ID
- `product_name`:按产品名称(模糊)
- `product_human_id`:按产品编号(模糊)
- `product_width_size`:按产品幅宽(精确数值)
- `product_color`:按产品颜色(模糊)
### 时间范围说明
`date_from``date_to` 为闭区间,等价于:
- `created_at >= date_from 00:00:00`
- `created_at <= date_to 23:59:59.999999`
## 响应
- 成功:`200 OK`
- 失败:`400 Bad Request`(参数缺失或格式错误)
### 响应字段(列表,每个元素)
- `id`:印染任务 ID
- `printing_order`:印染主订单 ID
- `product`:产品 ID
- `work_state`:业务进展(枚举值)
- `quantity`:数量
- `unit`:单位
- `size`:一段尺寸
- `pieces`:件数
- `description`:备注
- `business_object_id`:流程实例 ID
- `created_at` / `updated_at`
- `billed_quantity`:开单数量(关联全部 `SalesOrderItem.quantity` 之和)
## 示例
### 请求
```
GET /api/v2/printing/jobs/?customer_id=12&date_from=2025-12-01&date_to=2025-12-10&product_name=花布
```
### 成功响应(示例)
```json
[
{
"id": 101,
"printing_order": 55,
"product": 2001,
"work_state": 1,
"quantity": 300,
"unit": "米",
"size": "150cm",
"pieces": 10,
"description": "加急",
"business_object_id": 888,
"created_at": "2025-12-05T10:00:00Z",
"updated_at": "2025-12-06T08:00:00Z",
"billed_quantity": "120.00"
}
]
```