feat(shipping-notice): 新增发货通知重复检测与处理接口,支持重复决策保存与重新执行检测

This commit is contained in:
hugo committed 2026-07-14 21:12:36 +08:00
1 parent 729546a7b7
commit ceb49461e8
72 files changed
+14270 -460

No files matched your search

+20 -1
View File
@@ -11,7 +11,7 @@ from __future__ import annotations
from datetime import datetime
from typing import Optional
from sqlalchemy import DateTime, ForeignKey, Index, Integer, JSON, String, Text
from sqlalchemy import DateTime, ForeignKey, Index, Integer, JSON, String, Text, text
from sqlalchemy.orm import Mapped, mapped_column, relationship
from app.models.base import Base
@@ -29,6 +29,25 @@ class Job(Base):
Index('ix_jobs_type_status_created', 'job_type', 'status', 'created_at'),
Index('ix_jobs_business_ref', 'domain', 'job_type', 'business_ref'),
Index('ix_jobs_locked_at', 'locked_at'),
# 仅预解析 Job:同业务锚点同时只允许一条 queued
# (不含 running:retry 可在旧 running 残留时另建 queued;RUN 复查也不受限)
Index(
'uq_jobs_shipping_parse_queued_ref',
'domain',
'job_type',
'business_ref',
unique=True,
postgresql_where=text(
"job_type = 'shipping_notice_parse' "
"AND status = 'queued' "
"AND business_ref IS NOT NULL"
),
sqlite_where=text(
"job_type = 'shipping_notice_parse' "
"AND status = 'queued' "
"AND business_ref IS NOT NULL"
),
),
)
id: Mapped[int] = mapped_column(primary_key=True)