feat(shipping-notice): 落地 XFA 拆分、版面签名、统一进度与处理域履约
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
3a9fbac2fc
commit
d2b3d74def
571 files changed
+78064
-24681
No files matched your search
@@ -2,7 +2,7 @@
|
||||
backend/app/services/file_assets/cleanup.py
|
||||
|
||||
用途:过期未引用 FileAsset 与关联 intake 的清理编排。
|
||||
依赖:file_assets.storage、models.FileAsset/ShippingNoticeIntake。
|
||||
依赖:file_assets.storage、models.FileAsset/ShippingOrderIntake。
|
||||
逻辑:由排程或 file_asset_cleanup Job 调用;先标记 expired → 删 MinIO → 成功后 mark deleted;
|
||||
MinIO 删除失败不伪装成功,保留记录供下次重试。
|
||||
"""
|
||||
@@ -15,7 +15,7 @@ from datetime import datetime
|
||||
from sqlalchemy import or_
|
||||
|
||||
from app import db
|
||||
from app.models import FileAsset, ShippingNoticeIntake
|
||||
from app.models import FileAsset, ShippingOrderIntake
|
||||
from app.services.file_assets.storage import file_asset_storage
|
||||
|
||||
_LOGGER = logging.getLogger(__name__)
|
||||
@@ -49,10 +49,10 @@ def cleanup_expired_temporary_assets(*, limit: int = 100) -> dict[str, int]:
|
||||
stats = {'scanned': len(assets), 'expired': 0, 'deleted': 0, 'errors': 0}
|
||||
for asset in assets:
|
||||
consumed = (
|
||||
db.session.query(ShippingNoticeIntake.id)
|
||||
db.session.query(ShippingOrderIntake.id)
|
||||
.filter(
|
||||
ShippingNoticeIntake.asset_id == asset.id,
|
||||
ShippingNoticeIntake.parse_status == 'consumed',
|
||||
ShippingOrderIntake.asset_id == asset.id,
|
||||
ShippingOrderIntake.parse_status == 'consumed',
|
||||
)
|
||||
.first()
|
||||
)
|
||||
@@ -61,11 +61,11 @@ def cleanup_expired_temporary_assets(*, limit: int = 100) -> dict[str, int]:
|
||||
stats['expired'] += 1
|
||||
asset.lifecycle_status = 'expired'
|
||||
(
|
||||
db.session.query(ShippingNoticeIntake)
|
||||
db.session.query(ShippingOrderIntake)
|
||||
.filter(
|
||||
ShippingNoticeIntake.asset_id == asset.id,
|
||||
ShippingNoticeIntake.consumed_at.is_(None),
|
||||
ShippingNoticeIntake.parse_status.notin_(('consumed', 'cancelled')),
|
||||
ShippingOrderIntake.asset_id == asset.id,
|
||||
ShippingOrderIntake.consumed_at.is_(None),
|
||||
ShippingOrderIntake.parse_status.notin_(('consumed', 'cancelled')),
|
||||
)
|
||||
.update({'parse_status': 'expired', 'updated_at': now}, synchronize_session=False)
|
||||
)
|
||||
|
||||
Reference in new issue
Block a user