feat(rpa): 收料配置与库存同构并统一站点启停

- 删除收料配置 enabled 与 warehouse_ids_json 列(迁移 rc1a2b3c4d5e、rc2b3c4d5e6f,含存量清单转 Warehouse 条件的数据保全)
- Warehouse 改为查询条件(多值即逐仓拆分维度),排程/按需触发运行时派生仓库清单并在单元快照剥离该条件
- 站点开关即总开关:四处收料门禁只看站点 enabled;校验要求 DBS 恰一条非空 Warehouse 条件,日期禁填不变
- 站点抽屉改纵向折叠卡片与统一「保存更改」,就绪卡压缩为单行状态条并下移
- technical.md 同步设计边界与接口契约
This commit is contained in:
hugo committed 2026-09-18 15:04:33 +08:00
1 parent eed1068ae3
commit 2199370065
18 files changed
+412 -223

No files matched your search

@@ -29,15 +29,16 @@ def _create_users() -> None:
def _dbs_payload() -> dict:
"""构造 DBS 收料配置;日期未出现表示保持系统页面默认 NULL。"""
"""构造 DBS 收料配置;Warehouse 条件即逐仓拆分维度,日期未出现表示保持系统页面默认 NULL。"""
return {
'enabled': True,
'report_path_json': {
'program_group': 'Bison', 'program_label': 'AWSBI',
'report_group': 'Inbound', 'report_name': 'Receipt Detail',
},
'warehouse_ids_json': ['AWSDU', 'AWSDU-02'],
'query_parameters_json': [{'name': 'Owner', 'mode': 'single', 'values': ['AWS'], 'required': False, 'select_all': False}],
'query_parameters_json': [
{'name': 'Warehouse', 'mode': 'multi_text', 'values': ['AWSDU', 'AWSDU-02'], 'required': False, 'select_all': False},
{'name': 'Owner', 'mode': 'single', 'values': ['AWS'], 'required': False, 'select_all': False},
],
}
@@ -65,7 +66,9 @@ def test_admin_saves_independent_dbs_receipt_config_and_audit(app, client):
)
assert response.status_code == 200
config = parse_api_data(response.get_json())
assert config['warehouse_ids_json'] == ['AWSDU', 'AWSDU-02']
# 关键断言:Warehouse 条件原样保存,作为逐仓拆分维度的唯一持久化位置。
warehouse_condition = next(item for item in config['query_parameters_json'] if item['name'] == 'Warehouse')
assert warehouse_condition['values'] == ['AWSDU', 'AWSDU-02']
assert config['report_path_json']['report_group'] == 'Inbound'
with app.app_context():
@@ -78,7 +81,7 @@ def test_admin_saves_independent_dbs_receipt_config_and_audit(app, client):
event_type='shipping_receipt_report_config_saved', aggregate_id=str(source_id),
).one()
assert audit.before_snapshot_json is None
assert audit.after_snapshot_json['warehouse_ids_json'] == ['AWSDU', 'AWSDU-02']
assert audit.after_snapshot_json['query_parameters_json'][0]['values'] == ['AWSDU', 'AWSDU-02']
def test_receipt_config_rejects_date_selector_and_invalid_connector_rules(app, client):
@@ -120,9 +123,40 @@ def test_receipt_config_rejects_date_selector_and_invalid_connector_rules(app, c
assert response.status_code == 400
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
# 关键断言:Warehouse 条件即逐仓拆分维度——缺失、重复、空值都必须拒绝。
missing_warehouse = _dbs_payload()
missing_warehouse['query_parameters_json'] = [{'name': 'Owner', 'mode': 'single', 'values': ['AWS'], 'required': False, 'select_all': False}]
response = client.put(
f'/api/admin/shipping-notice/sources/{dbs_id}/receipt-report-config',
json=missing_warehouse, headers=_headers('receipt-admin', 'admin'),
)
assert response.status_code == 400
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
duplicate_warehouse = _dbs_payload()
duplicate_warehouse['query_parameters_json'] = [
{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU'], 'required': False, 'select_all': False},
{'name': 'Warehouse', 'mode': 'single', 'values': ['AWSDU-02'], 'required': False, 'select_all': False},
]
response = client.put(
f'/api/admin/shipping-notice/sources/{dbs_id}/receipt-report-config',
json=duplicate_warehouse, headers=_headers('receipt-admin', 'admin'),
)
assert response.status_code == 400
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
empty_warehouse = _dbs_payload()
empty_warehouse['query_parameters_json'] = [{'name': 'Warehouse', 'mode': 'multi_text', 'values': [], 'required': False, 'select_all': False}]
response = client.put(
f'/api/admin/shipping-notice/sources/{dbs_id}/receipt-report-config',
json=empty_warehouse, headers=_headers('receipt-admin', 'admin'),
)
assert response.status_code == 400
assert parse_api_error(response.get_json())['code'] == 'SHIPPING.RECEIPT_REPORT_CONFIG_INVALID'
invalid_crane = {
'enabled': True, 'report_path_json': {'report_name': 'Other Report'},
'warehouse_ids_json': ['NOT-ALLOWED'], 'query_parameters_json': [],
'report_path_json': {'report_name': 'Other Report'},
'query_parameters_json': [],
}
response = client.put(
f'/api/admin/shipping-notice/sources/{crane_id}/receipt-report-config',
@@ -153,7 +187,7 @@ def test_crane_receipt_config_rejects_query_parameters(app, client):
crane_id = crane_source.id
default_query = {
'enabled': True, 'report_path_json': {'report_name': 'Inbound Details'}, 'warehouse_ids_json': [],
'report_path_json': {'report_name': 'Inbound Details'},
'query_parameters_json': [],
}
response = client.put(