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,
|
||||
|
||||
@ -89,7 +89,9 @@ function WipRow({ t }: { t: WipTask }) {
|
||||
<div className="min-w-0 flex-1">
|
||||
<div className="flex items-baseline gap-2">
|
||||
<span className="text-sm font-medium text-gray-700 truncate">{t.task_name}</span>
|
||||
<span className="font-mono text-xs text-gray-400 shrink-0">{t.product_sn}</span>
|
||||
<span className="text-xs text-gray-500 shrink-0">
|
||||
{t.external_serial || t.product_sn}
|
||||
</span>
|
||||
<span className="text-xs text-gray-400 shrink-0">{t.assignee}</span>
|
||||
</div>
|
||||
<div className="mt-0.5 flex items-center gap-2 text-[11px] text-gray-400">
|
||||
@ -135,7 +137,7 @@ function MsgRow({ m }: { m: ProductMessageItem }) {
|
||||
<span className="font-medium text-gray-600">{m.external_serial || "未录入"}</span>
|
||||
</span>
|
||||
)}
|
||||
<span className="text-[10px] text-gray-300 font-mono">追溯码: {m.product_sn}</span>
|
||||
<span className="text-[10px] text-gray-300 font-mono">身份证: {m.product_sn}</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
@ -20,6 +20,7 @@ export interface WipTask {
|
||||
task_name: string;
|
||||
assignee: string;
|
||||
product_sn: string;
|
||||
external_serial: string | null;
|
||||
status: string;
|
||||
received_at: string;
|
||||
duration_hours: number;
|
||||
|
||||
Reference in New Issue
Block a user