feat: 增加报工归属明细表
This commit is contained in:
@@ -277,6 +277,10 @@ class ProductionReport(Base):
|
||||
back_populates="report",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
allocations: Mapped[list["ProductionReportAllocation"]] = relationship(
|
||||
back_populates="report",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
audit_logs: Mapped[list["ReportAuditLog"]] = relationship(
|
||||
order_by="ReportAuditLog.created_at",
|
||||
)
|
||||
@@ -317,6 +321,10 @@ class ProductionReportItem(Base):
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=now, nullable=False)
|
||||
|
||||
report: Mapped[ProductionReport] = relationship(back_populates="items")
|
||||
allocations: Mapped[list["ProductionReportAllocation"]] = relationship(
|
||||
back_populates="item",
|
||||
cascade="all, delete-orphan",
|
||||
)
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_report_items_report", "report_id"),
|
||||
@@ -324,6 +332,44 @@ class ProductionReportItem(Base):
|
||||
)
|
||||
|
||||
|
||||
class ProductionReportAllocation(Base):
|
||||
__tablename__ = "production_report_allocations"
|
||||
|
||||
id: Mapped[int] = mapped_column(BigInteger, primary_key=True, autoincrement=True)
|
||||
report_id: Mapped[int] = mapped_column(
|
||||
ForeignKey("production_reports.id", ondelete="CASCADE"),
|
||||
nullable=False,
|
||||
)
|
||||
report_item_id: Mapped[int | None] = mapped_column(
|
||||
ForeignKey("production_report_items.id", ondelete="CASCADE"),
|
||||
)
|
||||
attendance_point_name: Mapped[str] = mapped_column(String(128), nullable=False, default="")
|
||||
employee_phone: Mapped[str] = mapped_column(String(20), nullable=False, default="")
|
||||
allocation_date: Mapped[date] = mapped_column(Date, nullable=False)
|
||||
day_minutes: Mapped[float] = mapped_column(Numeric(10, 2), nullable=False, default=0)
|
||||
overtime_minutes: Mapped[float] = mapped_column(Numeric(10, 2), nullable=False, default=0)
|
||||
night_minutes: Mapped[float] = mapped_column(Numeric(10, 2), nullable=False, default=0)
|
||||
effective_minutes: Mapped[float] = mapped_column(Numeric(10, 2), nullable=False, default=0)
|
||||
good_qty: Mapped[float] = mapped_column(Numeric(12, 2), nullable=False, default=0)
|
||||
defect_qty: Mapped[float] = mapped_column(Numeric(12, 2), nullable=False, default=0)
|
||||
scrap_qty: Mapped[float] = mapped_column(Numeric(12, 2), nullable=False, default=0)
|
||||
changeover_count: Mapped[float] = mapped_column(Numeric(12, 2), nullable=False, default=0)
|
||||
reference_wage: Mapped[float] = mapped_column(Numeric(12, 2), nullable=False, default=0)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=now, nullable=False)
|
||||
updated_at: Mapped[datetime] = mapped_column(DateTime, default=now, onupdate=now, nullable=False)
|
||||
|
||||
report: Mapped[ProductionReport] = relationship(back_populates="allocations")
|
||||
item: Mapped[ProductionReportItem | None] = relationship(back_populates="allocations")
|
||||
|
||||
__table_args__ = (
|
||||
Index("idx_report_allocations_report", "report_id"),
|
||||
Index("idx_report_allocations_item", "report_item_id"),
|
||||
Index("idx_report_allocations_date", "allocation_date"),
|
||||
Index("idx_report_allocations_point_date", "attendance_point_name", "allocation_date"),
|
||||
Index("idx_report_allocations_employee_date", "employee_phone", "allocation_date"),
|
||||
)
|
||||
|
||||
|
||||
class ReportAuditLog(Base):
|
||||
__tablename__ = "report_audit_logs"
|
||||
|
||||
|
||||
Reference in New Issue
Block a user