refactor(shipping-inventory): 统一库存准备事实来源与门禁状态
This commit is contained in:
1 parent
761a06e21a
commit
eb55f407ae
62 files changed
+4242
-1471
No files matched your search
@@ -13,7 +13,9 @@ from app.models import (
|
||||
ShippingInventoryCandidateLine,
|
||||
ShippingInventoryCandidateSet,
|
||||
ShippingInventoryCandidateSource,
|
||||
ShippingNotice,
|
||||
ShippingOrderTask,
|
||||
ShippingOrderSnapshot,
|
||||
ShippingOrderSnapshotLine,
|
||||
ShippingNoticeLineInventoryMatch,
|
||||
ShippingInventoryFile,
|
||||
)
|
||||
@@ -23,17 +25,18 @@ from app.services.shipping_notice.inventory_candidate_projection import (
|
||||
from app.services.shipping_notice.stp_line_inventory_match import prepare_candidate_inventory_lines
|
||||
|
||||
|
||||
def _task(task_no: str) -> ShippingNotice:
|
||||
task = ShippingNotice(
|
||||
def _task(task_no: str) -> ShippingOrderTask:
|
||||
task = ShippingOrderTask(
|
||||
task_no=task_no,
|
||||
source_type='manual',
|
||||
source_type='direct_pdf',
|
||||
user_id=1,
|
||||
)
|
||||
db.session.add(task)
|
||||
db.session.flush()
|
||||
return task
|
||||
|
||||
|
||||
def _candidate_set(task: ShippingNotice, version: int = 1) -> ShippingInventoryCandidateSet:
|
||||
def _candidate_set(task: ShippingOrderTask, version: int = 1) -> ShippingInventoryCandidateSet:
|
||||
row = ShippingInventoryCandidateSet(
|
||||
task_id=int(task.id),
|
||||
set_version=version,
|
||||
@@ -120,9 +123,19 @@ def test_project_inventory_candidate_facts_marks_stale_current_match(app):
|
||||
)
|
||||
db.session.add(new_line)
|
||||
db.session.flush()
|
||||
snapshot = ShippingOrderSnapshot(
|
||||
task_id=int(task.id), extraction_id=1, schema_version_id=1,
|
||||
order_data_version=1, source_manifest_json={}, header_values_json={},
|
||||
)
|
||||
db.session.add(snapshot)
|
||||
db.session.flush()
|
||||
snapshot_line = ShippingOrderSnapshotLine(snapshot_id=int(snapshot.id), line_no=1, position=0)
|
||||
db.session.add(snapshot_line)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
task_id=int(task.id),
|
||||
line_key='line-1',
|
||||
snapshot_line_id=int(snapshot_line.id),
|
||||
line_no=1,
|
||||
line_index=0,
|
||||
candidate_set_id=int(old_set.id),
|
||||
candidate_set_version=1,
|
||||
@@ -152,16 +165,26 @@ def test_project_inventory_candidate_facts_reads_file_evidence_from_snapshot(app
|
||||
candidate_set_id=int(candidate_set.id), line_no=1, source_codes_json=['DBS_DUB'],
|
||||
))
|
||||
db.session.flush()
|
||||
snapshot = ShippingInventoryFile(
|
||||
inventory_file = ShippingInventoryFile(
|
||||
inventory_file_no='INV-CAND-EVIDENCE', storage_path='memory://evidence.xlsx',
|
||||
source_code='DBS_DUB', snapshot_status='ready', file_sha256='b' * 64,
|
||||
)
|
||||
db.session.add(inventory_file)
|
||||
db.session.flush()
|
||||
snapshot = ShippingOrderSnapshot(
|
||||
task_id=int(task.id), extraction_id=1, schema_version_id=1,
|
||||
order_data_version=1, source_manifest_json={}, header_values_json={},
|
||||
)
|
||||
db.session.add(snapshot)
|
||||
db.session.flush()
|
||||
snapshot_line = ShippingOrderSnapshotLine(snapshot_id=int(snapshot.id), line_no=1, position=0)
|
||||
db.session.add(snapshot_line)
|
||||
db.session.flush()
|
||||
db.session.add(ShippingNoticeLineInventoryMatch(
|
||||
task_id=int(task.id), line_key='line-1', candidate_set_id=int(candidate_set.id),
|
||||
candidate_set_version=1, inventory_snapshot_id=int(snapshot.id), match_result='matched',
|
||||
inventory_status='ready', inventory_source_code='DBS_DUB', matched_file_no=snapshot.inventory_file_no,
|
||||
task_id=int(task.id), snapshot_line_id=int(snapshot_line.id), line_no=1,
|
||||
candidate_set_id=int(candidate_set.id),
|
||||
candidate_set_version=1, inventory_snapshot_id=int(inventory_file.id), match_result='matched',
|
||||
inventory_status='ready', inventory_source_code='DBS_DUB', matched_file_no=inventory_file.inventory_file_no,
|
||||
matched_row_index=9, is_current=True, detail_json={},
|
||||
))
|
||||
db.session.commit()
|
||||
|
||||
Reference in new issue
Block a user