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
+48
-39
@@ -90,7 +90,7 @@ def _shipping_notice_stable_auto_config(request, monkeypatch):
|
||||
tmp_path / "shipping_notice" / "freight_rpa" / "upload_triggers"
|
||||
)
|
||||
if request.node.get_closest_marker("auto_rpa"):
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_ONHAND_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_BATCH_ORCHESTRATOR_ENABLED"] = False
|
||||
monkeypatch.setattr(
|
||||
@@ -102,7 +102,7 @@ def _shipping_notice_stable_auto_config(request, monkeypatch):
|
||||
lambda: None,
|
||||
)
|
||||
return
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = False
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_ONHAND_ENABLED"] = False
|
||||
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = False
|
||||
# 货代自动上传默认 fail-closed;单测与产品默认一致关闭。
|
||||
app.config["SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED"] = False
|
||||
@@ -123,9 +123,9 @@ def _shipping_notice_stable_auto_config(request, monkeypatch):
|
||||
def _shipping_test_default_destination(monkeypatch, request):
|
||||
"""
|
||||
为未提供目的地线索的发货通知单测注入 Dublin,以唯一命中 DSV360_AWSDU。
|
||||
标记 inventory_source_gate 的用例跳过,避免干扰库存源门禁专项测试。
|
||||
标记 onhand_source_gate 的用例跳过,避免干扰库存源门禁专项测试。
|
||||
"""
|
||||
if request.node.get_closest_marker("inventory_source_gate"):
|
||||
if request.node.get_closest_marker("onhand_source_gate"):
|
||||
return
|
||||
|
||||
from app.services.shipping_notice import extract as extract_mod
|
||||
@@ -170,9 +170,9 @@ def seed_task_inventory_source(
|
||||
owner = task if isinstance(task, ShippingOrderTask) else db.session.get(ShippingOrderTask, getattr(task, 'order_task_id', None))
|
||||
if owner is None:
|
||||
raise ValueError('test task must be linked to ShippingOrderTask')
|
||||
from app.services.shipping_notice.inventory_candidate_freeze_service import freeze_candidates_for_task
|
||||
from app.services.shipping_notice.inventory_source_rules import InventorySourceAdjudication
|
||||
from app.services.shipping_notice.inventory_source_repository import (
|
||||
from app.services.shipping_notice.onhand_candidate_freeze_service import freeze_candidates_for_task
|
||||
from app.services.shipping_notice.onhand_source_rules import InventorySourceAdjudication
|
||||
from app.services.shipping_notice.onhand_source_repository import (
|
||||
get_database_inventory_source,
|
||||
inventory_sources_runtime_version,
|
||||
)
|
||||
@@ -391,7 +391,7 @@ def seed_rpa_inventory_trigger(
|
||||
run_no: str = "RUN-TEST-001",
|
||||
trigger_path: str | None = None,
|
||||
) -> None:
|
||||
"""测试辅助:写入 inventory_rpa_triggered 事件,供单任务回调 run_no 校验。"""
|
||||
"""测试辅助:写入 onhand_rpa_triggered 事件,供单任务回调 run_no 校验。"""
|
||||
from app import db
|
||||
from app.services.shipping_notice.tool_common import log_task_event
|
||||
|
||||
@@ -401,7 +401,7 @@ def seed_rpa_inventory_trigger(
|
||||
trigger = trigger_path or f"inventory_export_batch_{run_no}.json"
|
||||
log_task_event(
|
||||
task,
|
||||
"inventory_rpa_triggered",
|
||||
"onhand_rpa_triggered",
|
||||
{"trigger": trigger, "run_no": run_no, "attempt": 1, "manual_retry_round": False},
|
||||
)
|
||||
|
||||
@@ -448,10 +448,10 @@ def inventory_csv_with_warehouse(
|
||||
|
||||
def batch_rpa_item_identity(task: "ShippingNotice") -> dict[str, str]:
|
||||
"""构造 batch 成功回调 item 须携带的 Source/Warehouse 身份字段。"""
|
||||
from app.services.shipping_notice.inventory_source_repository import get_database_inventory_source
|
||||
from app.services.shipping_notice.stp_inventory_freeze import task_frozen_inventory_source_codes
|
||||
from app.services.shipping_notice.onhand_source_repository import get_database_inventory_source
|
||||
from app.services.shipping_notice.stp_onhand_freeze import task_frozen_onhand_source_codes
|
||||
|
||||
source_code = next(iter(task_frozen_inventory_source_codes(task)), '')
|
||||
source_code = next(iter(task_frozen_onhand_source_codes(task)), '')
|
||||
source = get_database_inventory_source(source_code) or {}
|
||||
return {
|
||||
"source_code": str(source_code or ""),
|
||||
@@ -461,7 +461,7 @@ def batch_rpa_item_identity(task: "ShippingNotice") -> dict[str, str]:
|
||||
|
||||
def scheduled_rpa_batch_item(source_code: str, **overrides) -> dict[str, str]:
|
||||
"""构造定时 batch 成功回调 item 的 Source/Warehouse 身份(与数据库配置一致)。"""
|
||||
from app.services.shipping_notice.inventory_source_repository import get_database_inventory_source
|
||||
from app.services.shipping_notice.onhand_source_repository import get_database_inventory_source
|
||||
|
||||
source = get_database_inventory_source(source_code)
|
||||
if not source:
|
||||
@@ -492,10 +492,10 @@ def rpa_callback_payload(
|
||||
status: str = "success",
|
||||
) -> dict:
|
||||
"""构造通过单源 RPA v2 身份/run_no 校验的最小成功 payload。"""
|
||||
from app.services.shipping_notice.inventory_source_repository import get_database_inventory_source
|
||||
from app.services.shipping_notice.stp_inventory_freeze import task_frozen_inventory_source_codes
|
||||
from app.services.shipping_notice.onhand_source_repository import get_database_inventory_source
|
||||
from app.services.shipping_notice.stp_onhand_freeze import task_frozen_onhand_source_codes
|
||||
|
||||
source_code = next(iter(task_frozen_inventory_source_codes(task)), '')
|
||||
source_code = next(iter(task_frozen_onhand_source_codes(task)), '')
|
||||
source = get_database_inventory_source(source_code) or {}
|
||||
return {
|
||||
"schema_version": "freight_rpa.onhand.v1",
|
||||
@@ -528,7 +528,7 @@ def pytest_configure(config):
|
||||
)
|
||||
config.addinivalue_line(
|
||||
"markers",
|
||||
"inventory_source_gate: 库存源门禁专项测试,跳过默认 Dublin 注入",
|
||||
"onhand_source_gate: 库存源门禁专项测试,跳过默认 Dublin 注入",
|
||||
)
|
||||
config.addinivalue_line(
|
||||
"markers",
|
||||
@@ -572,13 +572,17 @@ def app():
|
||||
|
||||
|
||||
def _seed_test_inventory_configuration() -> None:
|
||||
"""为发货测试创建数据库库存源与发布路由规则,测试运行期不读取 YAML。"""
|
||||
"""为发货测试创建数据库库存源、在手报表配置与发布路由规则,测试运行期不读取 YAML。
|
||||
|
||||
s18 起:报表路径/查询条件/解析方案挂在 FreightRpaOnhandReportConfig 上,
|
||||
站点行只剩连接、模板绑定与启停。
|
||||
"""
|
||||
from app import db
|
||||
from app.models import (
|
||||
ShippingExcelTemplate, ShippingInventoryField, ShippingInventoryParsingProfile, ShippingInventorySource,
|
||||
ShippingRpaProfile,
|
||||
ShippingExcelTemplate, FreightRpaOnhandField, FreightRpaOnhandReportConfig,
|
||||
FreightRpaParsingProfile, FreightRpaSource, FreightRpaProfile,
|
||||
)
|
||||
from app.services.shipping_notice.inventory_structure_fingerprint import (
|
||||
from app.services.shipping_notice.onhand_structure_fingerprint import (
|
||||
FINGERPRINT_VERSION,
|
||||
compatibility_fingerprint,
|
||||
exact_fingerprint,
|
||||
@@ -586,24 +590,24 @@ def _seed_test_inventory_configuration() -> None:
|
||||
)
|
||||
|
||||
# 各测试显式创建所需用户字段;生产目录本身保持零预置。
|
||||
if not ShippingInventoryField.query.filter_by(field_code='part_number').first():
|
||||
if not FreightRpaOnhandField.query.filter_by(field_code='part_number').first():
|
||||
db.session.add_all([
|
||||
ShippingInventoryField(field_code='part_number', display_name='内部料号', value_type='text', usage_type='match_identity', status='active', sort_order=10),
|
||||
ShippingInventoryField(field_code='reservation_id', display_name='预约号', value_type='text', usage_type='match_identity', status='active', sort_order=20),
|
||||
ShippingInventoryField(field_code='available_qty', display_name='可用库存数量', value_type='decimal', usage_type='inventory_quantity', status='active', sort_order=30),
|
||||
ShippingInventoryField(field_code='warehouse_id', display_name='仓库标识', value_type='text', usage_type='warehouse_identity', status='active', sort_order=40),
|
||||
ShippingInventoryField(field_code='aws_part_number', display_name='AWS 料号', value_type='text', usage_type='general', status='active', sort_order=100),
|
||||
ShippingInventoryField(field_code='odm_id', display_name='ODM 编号', value_type='text', usage_type='general', status='active', sort_order=110),
|
||||
ShippingInventoryField(field_code='warehouse_code', display_name='仓库编码', value_type='text', usage_type='general', status='active', sort_order=120),
|
||||
ShippingInventoryField(field_code='lot_no', display_name='批次号', value_type='text', usage_type='general', status='active', sort_order=130),
|
||||
ShippingInventoryField(field_code='location', display_name='库位', value_type='text', usage_type='general', status='active', sort_order=140),
|
||||
FreightRpaOnhandField(field_code='part_number', display_name='内部料号', value_type='text', usage_type='match_identity', status='active', sort_order=10),
|
||||
FreightRpaOnhandField(field_code='reservation_id', display_name='预约号', value_type='text', usage_type='match_identity', status='active', sort_order=20),
|
||||
FreightRpaOnhandField(field_code='available_qty', display_name='可用库存数量', value_type='decimal', usage_type='inventory_quantity', status='active', sort_order=30),
|
||||
FreightRpaOnhandField(field_code='warehouse_id', display_name='仓库标识', value_type='text', usage_type='warehouse_identity', status='active', sort_order=40),
|
||||
FreightRpaOnhandField(field_code='aws_part_number', display_name='AWS 料号', value_type='text', usage_type='general', status='active', sort_order=100),
|
||||
FreightRpaOnhandField(field_code='odm_id', display_name='ODM 编号', value_type='text', usage_type='general', status='active', sort_order=110),
|
||||
FreightRpaOnhandField(field_code='warehouse_code', display_name='仓库编码', value_type='text', usage_type='general', status='active', sort_order=120),
|
||||
FreightRpaOnhandField(field_code='lot_no', display_name='批次号', value_type='text', usage_type='general', status='active', sort_order=130),
|
||||
FreightRpaOnhandField(field_code='location', display_name='库位', value_type='text', usage_type='general', status='active', sort_order=140),
|
||||
])
|
||||
|
||||
db.session.flush()
|
||||
inventory_fields = {
|
||||
item.field_code: item
|
||||
for item in ShippingInventoryField.query.filter(
|
||||
ShippingInventoryField.field_code.in_([
|
||||
for item in FreightRpaOnhandField.query.filter(
|
||||
FreightRpaOnhandField.field_code.in_([
|
||||
'part_number', 'reservation_id', 'available_qty', 'warehouse_id',
|
||||
])
|
||||
).all()
|
||||
@@ -641,7 +645,7 @@ def _seed_test_inventory_configuration() -> None:
|
||||
checksum = hashlib.sha256(
|
||||
json.dumps(definition, ensure_ascii=True, sort_keys=True, separators=(',', ':')).encode()
|
||||
).hexdigest()
|
||||
parsing_profile = ShippingInventoryParsingProfile(
|
||||
parsing_profile = FreightRpaParsingProfile(
|
||||
profile_code='TEST_RUNTIME', display_name='Test Runtime', version=1, status='published',
|
||||
file_format='xlsx', definition_json=definition, checksum=checksum,
|
||||
structure_definition_json=structure,
|
||||
@@ -658,14 +662,20 @@ def _seed_test_inventory_configuration() -> None:
|
||||
file_checksum='0' * 64, definition_json={}, definition_checksum='0' * 64,
|
||||
)
|
||||
|
||||
profile = ShippingRpaProfile(
|
||||
profile = FreightRpaProfile(
|
||||
profile_code='DBS_DUB_TEST', display_name='DBS Dublin', connector_type='dbs',
|
||||
login_url='https://test.invalid/dbs', login_config_json={'auth_mode': 'password'},
|
||||
)
|
||||
source = ShippingInventorySource(
|
||||
source = FreightRpaSource(
|
||||
source_code='DSV360_AWSDU', display_name='DBS Dublin AWSDU', connector_type='dbs',
|
||||
rpa_profile=profile, parsing_profile=parsing_profile, excel_template=excel_template,
|
||||
rpa_profile=profile, excel_template=excel_template,
|
||||
warehouse_resolution_mode='fixed', fixed_warehouse_id='AWSDU',
|
||||
enabled=True,
|
||||
)
|
||||
# s18 起报表路径/查询条件/解析方案绑定归 FreightRpaOnhandReportConfig,站点行不再承载。
|
||||
report_config = FreightRpaOnhandReportConfig(
|
||||
source=source,
|
||||
parsing_profile=parsing_profile,
|
||||
report_path_json={
|
||||
'program_group': 'Bison', 'program_label': 'AWSBI',
|
||||
'report_group': 'Inventory', 'report_name': 'On Hand Inventory By Location 3lv',
|
||||
@@ -673,9 +683,8 @@ def _seed_test_inventory_configuration() -> None:
|
||||
query_parameters_json=[
|
||||
{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU'], 'required': True, 'select_all': False},
|
||||
],
|
||||
enabled=True,
|
||||
)
|
||||
db.session.add_all([profile, parsing_profile, excel_template, source])
|
||||
db.session.add_all([profile, parsing_profile, excel_template, source, report_config])
|
||||
db.session.commit()
|
||||
|
||||
|
||||
|
||||
Reference in new issue
Block a user