feat(shipping-notice): 添加识别定义和规则集管理功能,支持客户和站点的可配置识别规则
This commit is contained in:
1 parent
88408490d7
commit
34d489a2d1
167 files changed
+10365
-7978
No files matched your search
@@ -108,7 +108,6 @@ class ShippingInventorySource(Base):
|
||||
# 业务报表定义属于 Source;Driver 的 selector、等待与下载实现不进入数据库配置。
|
||||
report_path_json: Mapped[dict[str, Any]] = mapped_column(JSON, default=dict, server_default=text("'{}'"), nullable=False)
|
||||
query_parameters_json: Mapped[list[dict[str, Any]]] = mapped_column(JSON, default=list, server_default=text("'[]'"), nullable=False)
|
||||
match_aliases_json: Mapped[list[str]] = mapped_column(JSON, default=list, server_default=text("'[]'"), nullable=False)
|
||||
snapshot_ttl_seconds: Mapped[int] = mapped_column(Integer, default=86400, server_default=text('86400'), nullable=False)
|
||||
enabled: Mapped[bool] = mapped_column(default=True, server_default=text('true'), nullable=False)
|
||||
config_version: Mapped[int] = mapped_column(Integer, default=1, server_default=text('1'), nullable=False)
|
||||
@@ -125,6 +124,30 @@ class ShippingInventorySource(Base):
|
||||
)
|
||||
|
||||
|
||||
class ShippingInventorySourceParsingBindingAudit(Base):
|
||||
"""库存站点解析方案绑定的只追加审计;保存绑定前后快照以支持上线追溯。"""
|
||||
|
||||
__tablename__ = 'shipping_inventory_source_parsing_binding_audits'
|
||||
__table_args__ = (
|
||||
Index('ix_inventory_source_parsing_binding_audit_source_created', 'inventory_source_id', 'created_at'),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
inventory_source_id: Mapped[int] = mapped_column(ForeignKey('shipping_inventory_sources.id'), nullable=False)
|
||||
previous_parsing_profile_id: Mapped[Optional[int]] = mapped_column(
|
||||
ForeignKey('shipping_inventory_parsing_profiles.id'), nullable=True,
|
||||
)
|
||||
parsing_profile_id: Mapped[int] = mapped_column(ForeignKey('shipping_inventory_parsing_profiles.id'), nullable=False)
|
||||
operation: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
reason: Mapped[str] = mapped_column(String(500), nullable=False)
|
||||
actor_id: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
|
||||
source_config_version_before: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
source_config_version_after: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
before_snapshot_json: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False, default=dict)
|
||||
after_snapshot_json: Mapped[dict[str, Any]] = mapped_column(JSON, nullable=False, default=dict)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
|
||||
|
||||
class ShippingInventoryParsingProfile(Base):
|
||||
"""可跨库存源复用的库存文件结构、样本证据与订单匹配配置。"""
|
||||
|
||||
@@ -205,6 +228,10 @@ class ShippingInventoryConfigurationTestRun(Base):
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
run_no: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
validation_batch_id: Mapped[Optional[int]] = mapped_column(
|
||||
ForeignKey('shipping_inventory_validation_batches.id'), nullable=True, index=True,
|
||||
)
|
||||
rpa_batch_run_no: Mapped[Optional[str]] = mapped_column(String(64), nullable=True, index=True)
|
||||
inventory_source_id: Mapped[int] = mapped_column(ForeignKey('shipping_inventory_sources.id'), nullable=False, index=True)
|
||||
source_config_version: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
rpa_profile_config_version: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
@@ -218,6 +245,28 @@ class ShippingInventoryConfigurationTestRun(Base):
|
||||
completed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
|
||||
class ShippingInventoryValidationBatch(Base):
|
||||
"""库存站点批量验证的聚合运行;逐站点结果仍由 ConfigurationTestRun 保存。"""
|
||||
|
||||
__tablename__ = 'shipping_inventory_validation_batches'
|
||||
__table_args__ = (UniqueConstraint('batch_no', name='uq_inventory_validation_batches_batch_no'),)
|
||||
|
||||
id: Mapped[int] = mapped_column(primary_key=True)
|
||||
batch_no: Mapped[str] = mapped_column(String(64), nullable=False)
|
||||
status: Mapped[str] = mapped_column(String(32), nullable=False, default='queued', server_default='queued')
|
||||
total_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text('0'))
|
||||
success_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text('0'))
|
||||
empty_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text('0'))
|
||||
failed_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text('0'))
|
||||
stale_count: Mapped[int] = mapped_column(Integer, nullable=False, default=0, server_default=text('0'))
|
||||
created_by: Mapped[Optional[int]] = mapped_column(ForeignKey('users.id'), nullable=True)
|
||||
retry_of_batch_id: Mapped[Optional[int]] = mapped_column(
|
||||
ForeignKey('shipping_inventory_validation_batches.id'), nullable=True,
|
||||
)
|
||||
created_at: Mapped[datetime] = mapped_column(DateTime, default=datetime.utcnow, nullable=False)
|
||||
completed_at: Mapped[Optional[datetime]] = mapped_column(DateTime, nullable=True)
|
||||
|
||||
|
||||
class ShippingInventoryRoutingRule(Base):
|
||||
"""可版本化的库存源路由决策表;仅产出受控 Source 候选。"""
|
||||
|
||||
@@ -252,14 +301,13 @@ class ShippingInventoryRoutingRule(Base):
|
||||
|
||||
|
||||
class ShippingInventoryRoutingRuleCondition(Base):
|
||||
"""库存源路由条件;订单字段引用稳定 field_id,系统事实使用受控 key。"""
|
||||
"""库存源路由条件;仅引用已发布订单 Schema 的稳定 field_id。"""
|
||||
|
||||
__tablename__ = 'shipping_inventory_routing_rule_conditions'
|
||||
__table_args__ = (
|
||||
UniqueConstraint('rule_id', 'sequence', name='uq_shipping_inventory_routing_rule_conditions_sequence'),
|
||||
CheckConstraint(
|
||||
"(source_kind = 'order_field' AND order_field_id IS NOT NULL AND system_fact_key IS NULL) OR "
|
||||
"(source_kind = 'system_fact' AND order_field_id IS NULL AND system_fact_key IS NOT NULL)",
|
||||
"source_kind = 'order_field' AND order_field_id IS NOT NULL",
|
||||
name='ck_inventory_routing_condition_source',
|
||||
),
|
||||
)
|
||||
@@ -269,7 +317,6 @@ class ShippingInventoryRoutingRuleCondition(Base):
|
||||
condition_group: Mapped[int] = mapped_column(Integer, default=1, server_default=text('1'), nullable=False)
|
||||
source_kind: Mapped[str] = mapped_column(String(16), nullable=False, default='order_field')
|
||||
order_field_id: Mapped[Optional[str]] = mapped_column(ForeignKey('shipping_order_fields.id'), nullable=True)
|
||||
system_fact_key: Mapped[Optional[str]] = mapped_column(String(128), nullable=True)
|
||||
operator: Mapped[str] = mapped_column(String(32), nullable=False)
|
||||
expected_value_json: Mapped[Any] = mapped_column(JSON, nullable=True)
|
||||
sequence: Mapped[int] = mapped_column(Integer, nullable=False)
|
||||
|
||||
Reference in new issue
Block a user