feat(backend): expose pound QR items on driver transport page
Enrich inventory links with business type/partner and attach poundQrcodeItems for the public driver footer button. Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
87ed40512c
commit
10183dabc2
7 files changed
+120
No files matched your search
@@ -2141,6 +2141,8 @@ def get_plan_arrange_info(
|
||||
plan_no=plan.plan_no or "",
|
||||
stop_type=link.stop_type,
|
||||
stop_id=link.stop_id,
|
||||
business_type=(inventory.business_type if inventory else None),
|
||||
partner_company=(inventory.partner_company if inventory else None),
|
||||
)
|
||||
)
|
||||
|
||||
|
||||
@@ -496,6 +496,17 @@ def _build_public_page(db: Session, transport: PlTransport) -> PublicTransportPa
|
||||
)
|
||||
]
|
||||
|
||||
pound_items = []
|
||||
if plan:
|
||||
from app.services.db.pound_qr_public import build_pound_qrcode_items_for_plan
|
||||
|
||||
pound_items = build_pound_qrcode_items_for_plan(
|
||||
db,
|
||||
tenant_no=transport.tenant_no,
|
||||
plan_id=plan.id,
|
||||
transport_id=transport.id,
|
||||
)
|
||||
|
||||
return PublicTransportPageRead(
|
||||
plan_no=plan.plan_no if plan else transport.transport_no,
|
||||
plan_date=_format_plan_date(plan.plan_date if plan else None),
|
||||
@@ -527,6 +538,7 @@ def _build_public_page(db: Session, transport: PlTransport) -> PublicTransportPa
|
||||
feedback_time=transport.feedback_time,
|
||||
plan_voided=plan_voided,
|
||||
plan_archived=plan_archived,
|
||||
pound_qrcode_items=pound_items,
|
||||
)
|
||||
|
||||
|
||||
|
||||
@@ -1002,6 +1002,25 @@ def arrange_transport(
|
||||
user_id=user.id,
|
||||
dept_id=user.dept_id or "",
|
||||
)
|
||||
inv_ids = [
|
||||
(item.db_inventory_id or "").strip()
|
||||
for item in link_results
|
||||
if (item.db_inventory_id or "").strip()
|
||||
]
|
||||
inv_by_id: dict = {}
|
||||
if inv_ids:
|
||||
from app.models.db_models import DbInboundOutbound
|
||||
|
||||
inv_rows = (
|
||||
db.query(DbInboundOutbound)
|
||||
.filter(
|
||||
DbInboundOutbound.id.in_(inv_ids),
|
||||
DbInboundOutbound.tenant_no == tenant_no,
|
||||
DbInboundOutbound.del_flag == 0,
|
||||
)
|
||||
.all()
|
||||
)
|
||||
inv_by_id = {row.id: row for row in inv_rows}
|
||||
inventory_records = [
|
||||
build_transport_inventory_link_read(
|
||||
db,
|
||||
@@ -1011,6 +1030,16 @@ def arrange_transport(
|
||||
db_inventory_id=item.db_inventory_id,
|
||||
batch_no=item.batch_no,
|
||||
plan_no=item.plan_no,
|
||||
business_type=(
|
||||
inv_by_id[item.db_inventory_id].business_type
|
||||
if item.db_inventory_id in inv_by_id
|
||||
else None
|
||||
),
|
||||
partner_company=(
|
||||
inv_by_id[item.db_inventory_id].partner_company
|
||||
if item.db_inventory_id in inv_by_id
|
||||
else None
|
||||
),
|
||||
)
|
||||
for item in link_results
|
||||
]
|
||||
|
||||
Reference in new issue
Block a user