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
@@ -28,7 +28,7 @@ from app.models import (
|
||||
ShippingInventoryField,
|
||||
ShippingInventorySource,
|
||||
ShippingOrderSnapshot,
|
||||
ShippingTask,
|
||||
ShippingNotice,
|
||||
)
|
||||
from app.path_utils import resolve_backend_relative_path
|
||||
from app.services.file_assets.storage import file_asset_storage
|
||||
@@ -42,7 +42,7 @@ def _storage_root() -> Path:
|
||||
return Path(current_app.instance_path) / 'shipping_notice'
|
||||
|
||||
|
||||
def order_field_id_values(task: ShippingTask) -> tuple[dict[str, Any], list[dict[str, Any]]]:
|
||||
def order_field_id_values(task: ShippingNotice) -> tuple[dict[str, Any], list[dict[str, Any]]]:
|
||||
"""从冻结 Snapshot 按稳定 field_id 返回 Header/Line 值,禁止履约阶段读取 FieldValue。"""
|
||||
from app.services.shipping_notice.task_supersession_service import assert_task_not_supersession_blocked
|
||||
assert_task_not_supersession_blocked(task)
|
||||
@@ -58,7 +58,7 @@ def order_field_id_values(task: ShippingTask) -> tuple[dict[str, Any], list[dict
|
||||
return header, lines
|
||||
|
||||
|
||||
def _system_fact(task: ShippingTask, key: str, *, export_sequence: int | None = None) -> Any:
|
||||
def _system_fact(task: ShippingNotice, key: str, *, export_sequence: int | None = None) -> Any:
|
||||
"""
|
||||
读取受控任务事实,模板不能通过任意属性路径访问 ORM。
|
||||
|
||||
@@ -107,7 +107,7 @@ def _format_value(value: Any, formatter: str) -> Any:
|
||||
|
||||
|
||||
def _mapping_value(
|
||||
mapping: dict[str, Any], *, task: ShippingTask, order_values: dict[str, Any], inventory_values: dict[str, Any],
|
||||
mapping: dict[str, Any], *, task: ShippingNotice, order_values: dict[str, Any], inventory_values: dict[str, Any],
|
||||
header_values: dict[str, Any] | None = None, export_sequence: int | None = None,
|
||||
) -> Any:
|
||||
"""
|
||||
@@ -251,7 +251,7 @@ def _safe_filename(name: str) -> str:
|
||||
return cleaned if cleaned.lower().endswith('.xlsx') else f'{cleaned}.xlsx'
|
||||
|
||||
|
||||
def _filename(task: ShippingTask, template: ShippingExcelTemplate) -> str:
|
||||
def _filename(task: ShippingNotice, template: ShippingExcelTemplate) -> str:
|
||||
"""按发布模板规则命名,模板未定义时才使用受控环境变量默认规则。"""
|
||||
pattern = str((template.definition_json or {}).get('filename_pattern') or '').strip()
|
||||
if not pattern:
|
||||
@@ -277,7 +277,7 @@ def _filename(task: ShippingTask, template: ShippingExcelTemplate) -> str:
|
||||
|
||||
|
||||
def _input_checksum(
|
||||
task: ShippingTask, source: ShippingInventorySource, template: ShippingExcelTemplate,
|
||||
task: ShippingNotice, source: ShippingInventorySource, template: ShippingExcelTemplate,
|
||||
snapshot: ShippingOrderSnapshot, header: dict[str, Any], lines: list[dict[str, Any]],
|
||||
) -> str:
|
||||
"""计算完整生成输入指纹,供审计和重复生成差异判断。"""
|
||||
@@ -292,7 +292,7 @@ def _input_checksum(
|
||||
return hashlib.sha256(raw.encode('utf-8')).hexdigest()
|
||||
|
||||
|
||||
def generate_shipment_excel(task: ShippingTask) -> tuple[str, str, ShippingExportArtifact]:
|
||||
def generate_shipment_excel(task: ShippingNotice) -> tuple[str, str, ShippingExportArtifact]:
|
||||
"""
|
||||
按库存源发布模板生成 Excel,并在当前事务新增不可变 Artifact。
|
||||
【AI 触发时机】:仅由 generate_excel Tool 在库存匹配完成后调用;Agent 禁止传模板或字段映射。
|
||||
@@ -398,7 +398,7 @@ def generate_shipment_excel(task: ShippingTask) -> tuple[str, str, ShippingExpor
|
||||
# 滚动履约允许同一任务按后续库存分批导出;已就绪 Artifact 仍是
|
||||
# 已占用预约单的审计事实,不能被新一轮导出整体覆盖为 superseded。
|
||||
artifact = ShippingExportArtifact(
|
||||
artifact_no=artifact_no, task_id=task.id, batch_id=task.batch_id, template_id=template.id,
|
||||
artifact_no=artifact_no, task_id=task.id, template_id=template.id,
|
||||
order_schema_version_id=snapshot.schema_version_id, order_extraction_id=snapshot.extraction_id,
|
||||
inventory_parsing_profile_id=source.parsing_profile_id, inventory_snapshot_id=task.inventory_snapshot_id,
|
||||
input_checksum=_input_checksum(task, source, template, snapshot, header_values, line_values),
|
||||
|
||||
Reference in new issue
Block a user