feat: 报工保存后刷新归属明细
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
@@ -18,6 +18,7 @@ from app.models import (
|
||||
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.work_schedule import DEFAULT_AUTO_SUBMIT_HOURS, get_work_schedule, get_work_schedule_config
|
||||
from app.timezone import now
|
||||
|
||||
@@ -171,6 +172,8 @@ def auto_submit_session(db: Session, session: WorkSession, submitted_at: datetim
|
||||
items=items,
|
||||
)
|
||||
db.add(report)
|
||||
db.flush()
|
||||
refresh_report_allocations(db, report, schedule=schedule, commit=False)
|
||||
return report
|
||||
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ from app.models import (
|
||||
MoldLockFeedback,
|
||||
Personnel,
|
||||
ProductionReport,
|
||||
ProductionReportAllocation,
|
||||
ProductionReportItem,
|
||||
ReportAuditLog,
|
||||
WorkSession,
|
||||
@@ -86,6 +87,7 @@ def purge_expired_voided_reports(db: Session) -> int:
|
||||
)
|
||||
)
|
||||
db.execute(delete(ReportAuditLog).where(ReportAuditLog.report_id == report.id))
|
||||
db.execute(delete(ProductionReportAllocation).where(ProductionReportAllocation.report_id == report.id))
|
||||
db.execute(delete(ProductionReportItem).where(ProductionReportItem.report_id == report.id))
|
||||
db.delete(report)
|
||||
if session is not None:
|
||||
|
||||
Reference in New Issue
Block a user