This commit is contained in:
zlwu committed 2026-08-04 14:02:01 +08:00
1 parent 012a2ad68e
commit 5fe53c5481
4775 files changed
+2190111 -40277

No files matched your search

+25 -8
View File
@@ -24,6 +24,7 @@ from app.schemas.db.plans import (
from app.schemas.db.weighing import WeighingSlipRead
from app.services.db.mappers import (
inventory_to_read,
load_user_display_name_map,
parse_date_str,
parse_datetime_str,
plan_to_read,
@@ -177,6 +178,7 @@ def list_plans(
total += executed
return total
user_name_map = load_user_display_name_map(db, [p.create_by for p in plans])
result_list: list[PurchasePlanWithFillLink] = []
for plan in plans:
result_list.append(
@@ -184,6 +186,7 @@ def list_plans(
plan,
executed_quantity=calc_executed_for_plan(plan),
fill_link_inventory_id=plan_id_to_inv_id.get(plan.id),
user_name_map=user_name_map,
)
)
return result_list
@@ -236,7 +239,7 @@ def create_plan(
db.add(plan)
db.commit()
db.refresh(plan)
return plan_to_read(plan)
return plan_to_read(plan, db=db)
class AutoGenerateMonthlyResult(BaseModel):
@@ -267,7 +270,7 @@ def get_plan(
) -> PurchasePlanRead:
tenant_no = get_tenant_no(db, user.to_tenant_user_dict())
plan = _get_plan(db, tenant_no, id, user)
return plan_to_read(plan)
return plan_to_read(plan, db=db)
@router.patch("/{id}", response_model=PurchasePlanRead)
@@ -285,7 +288,7 @@ def update_plan(
plan.update_by = user.id
db.commit()
db.refresh(plan)
return plan_to_read(plan)
return plan_to_read(plan, db=db)
@router.delete("/{id}", status_code=status.HTTP_204_NO_CONTENT)
@@ -418,9 +421,13 @@ def get_plan_related(
weighing_query = weighing_query.filter(DbWeighingSlip.purchase_plan_id == plan.id)
weighings = weighing_query.order_by(DbWeighingSlip.create_time.desc()).all()
user_name_map = load_user_display_name_map(
db,
[inv.create_by for inv in inventories] + [w.create_by for w in weighings],
)
return PlanRelatedData(
inventories=[inventory_to_read(inv) for inv in inventories],
weighings=[weighing_to_read(w) for w in weighings],
inventories=[inventory_to_read(inv, user_name_map=user_name_map) for inv in inventories],
weighings=[weighing_to_read(w, user_name_map=user_name_map) for w in weighings],
)
@@ -482,8 +489,18 @@ def get_third_party_plan_page(
.all()
)
user_name_map = load_user_display_name_map(
db,
[plan.create_by]
+ [inv.create_by for inv in inventories]
+ [inv.create_by for inv in month_history],
)
return ThirdPartyPlanPageData(
plan=plan_to_read(plan),
today_inventories=[inventory_to_read(inv) for inv in inventories],
month_inventories=[inventory_to_read(inv) for inv in month_history],
plan=plan_to_read(plan, user_name_map=user_name_map),
today_inventories=[
inventory_to_read(inv, user_name_map=user_name_map) for inv in inventories
],
month_inventories=[
inventory_to_read(inv, user_name_map=user_name_map) for inv in month_history
],
)