feat(freight-rpa): 库存/收料改名在手/入站,报表归属RPA,类名统一FreightRpa
把 shipping 侧 inventory/receipt 词根迁到 onhand/inbound,29 张表与 枚举/权限/前端/i18n 同步改名;在手与入站报表配置及文件改由 freight_rpa 持有,发货与调拨仅按 source_code 消费;ORM 类加 FreightRpa 前缀, 上传动作改为 freight_rpa_upload。含类名与上传动作改名规格文档。 Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
1 parent
ffc0d4a430
commit
39fe3c05f2
453 files changed
+17945
-8646
No files matched your search
@@ -0,0 +1,73 @@
|
||||
"""用途:验证库存恢复只失效当前任务关联的 Mapping/下游事实。
|
||||
依赖:recovery_invalidation_service 与库存谱系模型。
|
||||
逻辑:通过最小模型级约束检查和服务分支合同,禁止跨任务失效。
|
||||
"""
|
||||
|
||||
from app.models import FreightRpaOnhandMapping
|
||||
|
||||
|
||||
def test_mapping_status_contract_allows_invalidation_without_delete():
|
||||
"""Mapping 失效必须保留记录,状态使用正式 invalidated 枚举。"""
|
||||
allowed = next(
|
||||
constraint.sqltext.text
|
||||
for constraint in FreightRpaOnhandMapping.__table__.constraints
|
||||
if getattr(constraint, 'name', '') == 'ck_shipping_inventory_mapping_status'
|
||||
)
|
||||
assert 'invalidated' in allowed
|
||||
|
||||
|
||||
def test_candidate_refreeze_invalidates_artifact_and_live_upload_attempt(app):
|
||||
"""候选版本切换后,旧 Artifact 不可下载,未终态上传 Attempt 不得继续使用。"""
|
||||
from app import db
|
||||
from app.models import (
|
||||
ShippingExcelTemplate, ShippingExportArtifact, FreightRpaParsingProfile,
|
||||
ShippingNotice, ShippingOrderExtraction, ShippingOrderSchema, ShippingOrderSchemaVersion,
|
||||
ShippingOrderTask, ShippingUploadAttempt,
|
||||
)
|
||||
from app.services.shipping_notice.onhand_candidate_freeze_service import _invalidate_task_candidate_outputs
|
||||
|
||||
task = ShippingOrderTask(task_no='OT-CANDIDATE-INVALIDATE-1', user_id=1)
|
||||
notice = ShippingNotice(task_no='SN-CANDIDATE-INVALIDATE-1')
|
||||
template = ShippingExcelTemplate(
|
||||
template_code='CANDIDATE-INVALIDATE', display_name='Candidate invalidate', version=1,
|
||||
status='published', storage_bucket='test', storage_key='template.xlsx',
|
||||
original_filename='template.xlsx', file_checksum='a' * 64, definition_json={},
|
||||
)
|
||||
profile = FreightRpaParsingProfile(
|
||||
profile_code='CANDIDATE-INVALIDATE', display_name='Candidate invalidate', version=1,
|
||||
status='published', file_format='xlsx', definition_json={},
|
||||
)
|
||||
schema = ShippingOrderSchema(schema_code='CANDIDATE_INVALIDATE', display_name='Candidate invalidate')
|
||||
db.session.add_all([task, notice, template, profile, schema])
|
||||
db.session.flush()
|
||||
notice.order_task_id = task.id
|
||||
version = ShippingOrderSchemaVersion(schema_id=schema.id, version=1, status='published', definition_json={})
|
||||
db.session.add(version)
|
||||
db.session.flush()
|
||||
extraction = ShippingOrderExtraction(schema_version_id=version.id, input_snapshot_hash='b' * 64, status='accepted')
|
||||
db.session.add(extraction)
|
||||
db.session.flush()
|
||||
artifact = ShippingExportArtifact(
|
||||
artifact_no='EXP-CANDIDATE-INVALIDATE', task_id=notice.id, template_id=template.id,
|
||||
order_schema_version_id=version.id, order_extraction_id=extraction.id,
|
||||
inventory_parsing_profile_id=profile.id, input_checksum='c' * 64,
|
||||
file_path='artifact.xlsx', file_name='artifact.xlsx', file_checksum='d' * 64,
|
||||
file_size=1, status='ready',
|
||||
)
|
||||
db.session.add(artifact)
|
||||
db.session.flush()
|
||||
attempt = ShippingUploadAttempt(
|
||||
artifact_id=artifact.id, attempt_no=1, mode='manual', idempotency_key='candidate-invalidate-1',
|
||||
status='running',
|
||||
)
|
||||
db.session.add(attempt)
|
||||
db.session.flush()
|
||||
|
||||
_invalidate_task_candidate_outputs(task, old_candidate_set_id=1, session=db.session)
|
||||
|
||||
db.session.refresh(artifact)
|
||||
db.session.refresh(attempt)
|
||||
assert artifact.status == 'superseded'
|
||||
assert attempt.status == 'failed'
|
||||
assert attempt.invalidated_at is not None
|
||||
assert attempt.invalidation_reason == 'candidate_set_refrozen'
|
||||
Reference in new issue
Block a user