feat: 在制品加业务序列号 + 追溯码改名为身份证
1. 在制品行: 显示 external_serial(业务序列号) 优先 external_serial → 兜底 product_sn 旧: 装配 A1B2C3D4 张三 新: 装配 25022 张三 2. 留言板: 追溯码 → 身份证 旧: 追溯码: 000000000000000D 新: 身份证: 000000000000000D 3. 后端: WipTask 新增 external_serial 字段 关联查询 Product.external_serial
This commit is contained in:
@ -29,6 +29,7 @@ class WipTask(BaseModel):
|
||||
task_name: str
|
||||
assignee: str
|
||||
product_sn: str
|
||||
external_serial: str | None # 业务序列号
|
||||
status: str
|
||||
received_at: str
|
||||
duration_hours: float
|
||||
@ -131,7 +132,7 @@ async def get_wip_tasks(db: AsyncSession, limit: int = 20) -> list[WipTask]:
|
||||
from app.core.time_utils import get_beijing_time, BEIJING_TZ
|
||||
|
||||
stmt = (
|
||||
select(Task, Product.serial_number)
|
||||
select(Task, Product.serial_number, Product.external_serial)
|
||||
.join(Product, Task.product_id == Product.id)
|
||||
.where(Task.status.in_([TASK_STATUS_PENDING, TASK_STATUS_WIP]))
|
||||
.limit(limit * 2) # 多取一些,后面 Python 统一排序
|
||||
@ -147,7 +148,7 @@ async def get_wip_tasks(db: AsyncSession, limit: int = 20) -> list[WipTask]:
|
||||
|
||||
now = get_beijing_time()
|
||||
wip_list: list[WipTask] = []
|
||||
for task, product_sn in rows:
|
||||
for task, product_sn, ext_sn in rows:
|
||||
start = task.received_at or task.created_at
|
||||
if start:
|
||||
if start.tzinfo is None:
|
||||
@ -165,6 +166,7 @@ async def get_wip_tasks(db: AsyncSession, limit: int = 20) -> list[WipTask]:
|
||||
task_name=task.task_name,
|
||||
assignee=name_map.get(task.assignee_id or "", task.assignee_id or "未分配"),
|
||||
product_sn=product_sn or "",
|
||||
external_serial=ext_sn or None,
|
||||
status=task.status,
|
||||
received_at=recv_str,
|
||||
duration_hours=hours,
|
||||
|
||||
Reference in New Issue
Block a user