feat: 输出报工归属摘要
This commit is contained in:
@@ -23,6 +23,7 @@ from app.schemas import (
|
||||
PersonnelOut,
|
||||
ProductOption,
|
||||
ProductOut,
|
||||
ReportAllocationOut,
|
||||
ReportDeviceSegmentOut,
|
||||
ReportItemOut,
|
||||
ReportMetrics,
|
||||
@@ -36,6 +37,7 @@ from app.services.metrics import build_result_text, calculate_report_metrics
|
||||
from app.services.misc_work import is_misc_item, is_misc_product
|
||||
from app.services.multi_person import is_multi_person_item, is_multi_person_product
|
||||
from app.services.process_names import export_process_name
|
||||
from app.services.report_allocations import allocation_summary_text
|
||||
from app.services.report_lifecycle import can_edit_report, can_unvoid_report
|
||||
from app.services.work_schedule import WorkScheduleConfig
|
||||
from app.timezone import now
|
||||
@@ -341,6 +343,21 @@ def report_device_segment_out(
|
||||
)
|
||||
|
||||
|
||||
def report_allocation_out(row) -> ReportAllocationOut:
|
||||
return ReportAllocationOut(
|
||||
allocation_date=row.allocation_date,
|
||||
day_minutes=as_float(row.day_minutes),
|
||||
overtime_minutes=as_float(row.overtime_minutes),
|
||||
night_minutes=as_float(row.night_minutes),
|
||||
effective_minutes=as_float(row.effective_minutes),
|
||||
good_qty=as_float(row.good_qty),
|
||||
defect_qty=as_float(row.defect_qty),
|
||||
scrap_qty=as_float(row.scrap_qty),
|
||||
changeover_count=as_float(row.changeover_count),
|
||||
reference_wage=as_float(row.reference_wage),
|
||||
)
|
||||
|
||||
|
||||
def report_item_out(item: ProductionReportItem, corrections: dict | None = None) -> ReportItemOut:
|
||||
return ReportItemOut(
|
||||
id=item.id,
|
||||
@@ -367,6 +384,7 @@ def report_item_out(item: ProductionReportItem, corrections: dict | None = None)
|
||||
is_continuous_die=is_continuous_die_item(item),
|
||||
is_multi_person=is_multi_person_item(item),
|
||||
remark=item.remark,
|
||||
allocations=[report_allocation_out(row) for row in getattr(item, "allocations", []) or []],
|
||||
corrections=corrections or {},
|
||||
)
|
||||
|
||||
@@ -486,5 +504,6 @@ def report_out(report: ProductionReport, schedule: WorkScheduleConfig | None = N
|
||||
if is_cleaning_report
|
||||
else ("处理杂活已提交,等待管理员审核" if _report_is_misc_only(report) else build_result_text(metrics))
|
||||
),
|
||||
allocation_summary_text=allocation_summary_text(list(getattr(report, "allocations", []) or [])),
|
||||
corrections=report_corrections,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user