feat: 报工保存后刷新归属明细

This commit is contained in:
souplearn
2026-07-25 04:16:08 +08:00
parent 5918b5ddde
commit ebb490590f
5 changed files with 327 additions and 2 deletions
+7 -1
View File
@@ -39,6 +39,7 @@ from app.services.display_names import mold_process_display_name
from app.services.metrics import calculate_report_metrics, minutes_between, release_at_caps_work_time
from app.services.misc_work import is_misc_product
from app.services.mold_locks import release_session_locks
from app.services.report_allocations import refresh_report_allocations
from app.services.report_lifecycle import purge_expired_voided_reports
from app.services.reporting_window import REPORTING_EXPIRED_DETAIL, is_reporting_expired
from app.services.serializers import equipment_option, product_option, report_out
@@ -456,6 +457,8 @@ def submit_report(
release_session_locks(session, user.phone, "报工提交释放占用", submitted_at)
session.status = SessionStatus.submitted
db.add(report)
db.flush()
refresh_report_allocations(db, report, schedule=schedule, commit=False)
db.commit()
saved = _get_report_or_404(db, report.id)
@@ -602,10 +605,13 @@ def submit_cleaning_report(
items=report_items,
)
db.add(report)
schedule = get_work_schedule_config(db, point_name)
db.flush()
refresh_report_allocations(db, report, schedule=schedule, commit=False)
db.commit()
saved = _get_report_or_404(db, report.id)
return report_out(saved, get_work_schedule_config(db, saved.attendance_point_name))
return report_out(saved, schedule)
@router.get("/mine", response_model=PageResponse)
+2
View File
@@ -29,6 +29,7 @@ from app.services.continuous_die import is_continuous_die_item, is_continuous_di
from app.services.display_names import mold_process_display_name
from app.services.metrics import calculate_report_metrics
from app.services.misc_work import is_misc_item, is_misc_product
from app.services.report_allocations import refresh_report_allocations
from app.services.report_lifecycle import (
can_edit_report,
mark_report_voided,
@@ -528,6 +529,7 @@ def approve_report(
_validate_normal_report_devices(db, report)
_apply_metrics(report, schedule)
refresh_report_allocations(db, report, schedule=schedule, commit=False)
reviewed_at = now()
was_pending = report.status == ReportStatus.pending
report.status = ReportStatus.approved