更新登录页及优化相关功能
This commit is contained in:
@@ -1,6 +1,17 @@
|
||||
from datetime import datetime
|
||||
|
||||
from sqlalchemy import BigInteger, CheckConstraint, Column, DateTime, ForeignKey, Integer, String, UniqueConstraint
|
||||
from sqlalchemy import (
|
||||
JSON,
|
||||
BigInteger,
|
||||
CheckConstraint,
|
||||
Column,
|
||||
Date,
|
||||
DateTime,
|
||||
ForeignKey,
|
||||
Integer,
|
||||
String,
|
||||
UniqueConstraint,
|
||||
)
|
||||
|
||||
from config.database import Base
|
||||
from config.env import DataBaseConfig
|
||||
@@ -99,6 +110,11 @@ class BizFillingRecord(Base):
|
||||
),
|
||||
UniqueConstraint('pallet_id', 'active_slot', name='uq_biz_filling_record_pallet_active_slot'),
|
||||
CheckConstraint('initial_packages > 0', name='ck_biz_filling_record_initial_packages'),
|
||||
CheckConstraint(
|
||||
'(production_date IS NULL AND expiry_date IS NULL) OR '
|
||||
'(production_date IS NOT NULL AND expiry_date IS NOT NULL AND expiry_date >= production_date)',
|
||||
name='ck_biz_filling_record_material_dates',
|
||||
),
|
||||
CheckConstraint(
|
||||
"active_slot IS NULL OR active_slot = 'ACTIVE'",
|
||||
name='ck_biz_filling_record_active_slot',
|
||||
@@ -126,6 +142,8 @@ class BizFillingRecord(Base):
|
||||
strain_code_snapshot = Column(String(64), nullable=False, comment='菌种编码快照')
|
||||
strain_name_snapshot = Column(String(100), nullable=False, comment='菌种名称快照')
|
||||
batch_no = Column(String(64), nullable=False, comment='生产批次')
|
||||
production_date = Column(Date, nullable=True, comment='来源生产日期;历史未登记为空')
|
||||
expiry_date = Column(Date, nullable=True, comment='有效期至;历史未登记为空')
|
||||
package_spec = Column(String(64), nullable=False, comment='包装规格')
|
||||
initial_packages = Column(Integer, nullable=False, comment='初始包数')
|
||||
active_slot = Column(String(16), nullable=True, comment='活动装填槽')
|
||||
@@ -158,6 +176,8 @@ class BizShipmentOrder(Base):
|
||||
name='uq_biz_shipment_order_route_confirm_idempotency',
|
||||
),
|
||||
CheckConstraint("status IN ('DRAFT', 'CONFIRMED')", name='ck_biz_shipment_order_status'),
|
||||
CheckConstraint("receipt_state IN ('PENDING', 'RECEIVED', 'LEGACY')", name='ck_biz_shipment_order_receipt_state'),
|
||||
UniqueConstraint('target_site_id', 'receipt_idempotency_key', name='uq_biz_shipment_receipt_site_key'),
|
||||
{'comment': '整托发货单'},
|
||||
)
|
||||
|
||||
@@ -187,6 +207,11 @@ class BizShipmentOrder(Base):
|
||||
confirm_request_hash = Column(String(64), nullable=True, comment='确认请求摘要')
|
||||
confirmed_by = Column(BigInteger, ForeignKey('sys_user.user_id'), nullable=True, comment='确认人ID')
|
||||
confirmed_at = Column(DateTime, nullable=True, comment='确认时间')
|
||||
receipt_state = Column(String(16), nullable=False, server_default='PENDING', comment='收货状态;LEGACY表示历史未登记')
|
||||
received_by = Column(BigInteger, ForeignKey('sys_user.user_id'), nullable=True, comment='收货核对人ID')
|
||||
received_at = Column(DateTime, nullable=True, comment='实际收货核对时间')
|
||||
receipt_idempotency_key = Column(String(64), nullable=True, comment='收货确认幂等键')
|
||||
receipt_request_hash = Column(String(64), nullable=True, comment='收货核对请求摘要')
|
||||
create_by = Column(String(64), nullable=True, server_default='', comment='创建者')
|
||||
create_time = Column(DateTime, nullable=True, default=datetime.now, comment='创建时间')
|
||||
update_by = Column(String(64), nullable=True, server_default='', comment='更新者')
|
||||
@@ -275,13 +300,23 @@ class BizUsageRecord(Base):
|
||||
comment='活动装填记录ID',
|
||||
)
|
||||
site_id = Column(BigInteger, ForeignKey('biz_customer_site.site_id'), nullable=False, comment='现场ID')
|
||||
line_id = Column(BigInteger, ForeignKey('biz_production_line.line_id'), nullable=False, comment='产线ID')
|
||||
tunnel_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_tunnel.tunnel_id'),
|
||||
nullable=True,
|
||||
comment='隧道ID;历史记录可能为空',
|
||||
)
|
||||
trace_no = Column(String(64), nullable=True, comment='隧道物料内部溯源号;历史记录可能为空')
|
||||
batch_no_snapshot = Column(String(64), nullable=True, comment='生产批次快照;历史记录可能为空')
|
||||
line_id = Column(BigInteger, ForeignKey('biz_production_line.line_id'), nullable=True, comment='产线ID(可选)')
|
||||
used_packages = Column(Integer, nullable=False, comment='本次使用包数')
|
||||
remaining_packages_after = Column(Integer, nullable=False, comment='使用后剩余包数')
|
||||
idempotency_key = Column(String(64), nullable=False, comment='幂等键')
|
||||
request_hash = Column(String(64), nullable=False, comment='请求摘要')
|
||||
operator_id = Column(BigInteger, ForeignKey('sys_user.user_id'), nullable=False, comment='操作人ID')
|
||||
occurred_at = Column(DateTime, nullable=False, comment='发生时间')
|
||||
fifo_skip_reason = Column(String(500), nullable=True, comment='跳过先到托盘原因')
|
||||
fifo_recommendation = Column(JSON, nullable=True, comment='跳过时先到托盘身份及到货时间快照')
|
||||
|
||||
|
||||
class BizReturnOrder(Base):
|
||||
@@ -387,6 +422,14 @@ class BizReturnItem(Base):
|
||||
nullable=True,
|
||||
comment='申请时活动装填记录快照',
|
||||
)
|
||||
tunnel_id_snapshot = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_tunnel.tunnel_id'),
|
||||
nullable=True,
|
||||
comment='申请时隧道ID快照',
|
||||
)
|
||||
trace_no_snapshot = Column(String(64), nullable=True, comment='申请时物料溯源号快照')
|
||||
batch_no_snapshot = Column(String(64), nullable=True, comment='申请时生产批次快照')
|
||||
remaining_packages_snapshot = Column(Integer, nullable=False, comment='申请时剩余包数快照')
|
||||
create_by = Column(String(64), nullable=True, server_default='', comment='创建者')
|
||||
create_time = Column(DateTime, nullable=True, default=datetime.now, comment='创建时间')
|
||||
@@ -399,7 +442,7 @@ class BizPalletInventory(Base):
|
||||
__table_args__ = (
|
||||
CheckConstraint(
|
||||
"flow_state IN ('UNSTOCKED', 'EMPTY_IN_WAREHOUSE', 'FILLED_IN_WAREHOUSE', "
|
||||
"'AT_SITE_UNUSED', 'AT_SITE_PARTIAL', 'AT_SITE_EMPTY', 'RETURNING')",
|
||||
"'IN_TRANSIT', 'AT_SITE_UNUSED', 'AT_SITE_PARTIAL', 'AT_SITE_EMPTY', 'RETURNING')",
|
||||
name='ck_biz_pallet_inventory_flow_state',
|
||||
),
|
||||
CheckConstraint('remaining_packages >= 0', name='ck_biz_pallet_inventory_remaining_packages'),
|
||||
@@ -444,6 +487,13 @@ class BizPalletInventory(Base):
|
||||
nullable=True,
|
||||
comment='当前现场ID',
|
||||
)
|
||||
tunnel_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_tunnel.tunnel_id'),
|
||||
nullable=True,
|
||||
comment='当前隧道ID',
|
||||
)
|
||||
trace_no = Column(String(64), nullable=True, comment='当前隧道物料溯源号')
|
||||
current_line_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_production_line.line_id'),
|
||||
@@ -452,6 +502,7 @@ class BizPalletInventory(Base):
|
||||
)
|
||||
flow_state = Column(String(32), nullable=False, server_default='UNSTOCKED', comment='托盘流转状态')
|
||||
remaining_packages = Column(Integer, nullable=False, server_default='0', comment='当前剩余包数')
|
||||
site_arrived_at = Column(DateTime, nullable=True, comment='本轮实际收货核对时间;历史未登记为空')
|
||||
last_event_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_pallet_event.event_id'),
|
||||
@@ -471,7 +522,7 @@ class BizPalletEvent(Base):
|
||||
UniqueConstraint('pallet_id', 'idempotency_key', name='uq_biz_pallet_event_pallet_idempotency'),
|
||||
CheckConstraint(
|
||||
"event_type IN ('INBOUND_CONFIRMED', 'FILLING_CONFIRMED', 'SHIPMENT_CONFIRMED', "
|
||||
"'USAGE_RECORDED', 'RETURN_REQUESTED', 'RETURN_CONFIRMED')",
|
||||
"'SHIPMENT_RECEIVED', 'TUNNEL_ENTERED', 'USAGE_RECORDED', 'RETURN_REQUESTED', 'RETURN_CONFIRMED')",
|
||||
name='ck_biz_pallet_event_event_type',
|
||||
),
|
||||
{'comment': '托盘只追加流转事件'},
|
||||
@@ -504,6 +555,12 @@ class BizPalletEvent(Base):
|
||||
nullable=True,
|
||||
comment='变更前现场ID',
|
||||
)
|
||||
before_tunnel_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_tunnel.tunnel_id'),
|
||||
nullable=True,
|
||||
comment='变更前隧道ID',
|
||||
)
|
||||
before_line_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_production_line.line_id'),
|
||||
@@ -522,6 +579,12 @@ class BizPalletEvent(Base):
|
||||
nullable=True,
|
||||
comment='变更后现场ID',
|
||||
)
|
||||
after_tunnel_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_tunnel.tunnel_id'),
|
||||
nullable=True,
|
||||
comment='变更后隧道ID',
|
||||
)
|
||||
after_line_id = Column(
|
||||
BigInteger,
|
||||
ForeignKey('biz_production_line.line_id'),
|
||||
@@ -530,6 +593,10 @@ class BizPalletEvent(Base):
|
||||
)
|
||||
before_remaining_packages = Column(Integer, nullable=False, comment='变更前剩余包数')
|
||||
after_remaining_packages = Column(Integer, nullable=False, comment='变更后剩余包数')
|
||||
trace_no = Column(String(64), nullable=True, comment='事件关联物料溯源号')
|
||||
batch_no_snapshot = Column(String(64), nullable=True, comment='事件生产批次快照')
|
||||
fifo_skip_reason = Column(String(500), nullable=True, comment='跳过先到托盘原因')
|
||||
fifo_recommendation = Column(JSON, nullable=True, comment='跳过时先到托盘身份及到货时间快照')
|
||||
operator_id = Column(BigInteger, ForeignKey('sys_user.user_id'), nullable=False, comment='操作人ID')
|
||||
occurred_at = Column(DateTime, nullable=False, comment='发生时间')
|
||||
idempotency_key = Column(String(64), nullable=False, comment='幂等键')
|
||||
|
||||
Reference in New Issue
Block a user