feat(in-transit-transfer): 自动调拨联动收料就绪并分层来源错误
- 调度整合:退役 in_transit_receipt_file_job,收料归档收敛 shipping_receipt_rpa_archive,排程注册表统一 - 自动调拨 Job:调拨前确保各来源当日收料文件就绪(缺失自动触发收料 RPA),严格等量匹配后生成 ERP 调拨单 - worker 手动唤醒:排程工作台支持手动唤醒与 runs 透视,heartbeat 协议同步 - 收料缺失幸存 T2:parse_failed 状态落库(迁移 q4c5) - 来源错误分层与 stale 时钟换源:改挂 inventory_checked_at 库存查得时刻,展示阈值与执行门禁解耦(迁移 t5a6) - 新增 wecom_sender 企微通知:每非空 Run 汇总一条,通知失败不影响 ERP 结果 - 同步排程工作台/调拨卡片前端、chat/admin 文案四语言、RPA 脚本与测试全家
This commit is contained in:
1 parent
993e581135
commit
abf3d48927
144 files changed
+10161
-2132
No files matched your search
@@ -198,15 +198,10 @@ def test_empty_configuration_export_is_successful_but_marks_data_validation_pend
|
||||
assert result['result']['data_validation'] == 'pending_first_non_empty_export'
|
||||
assert not ShippingInventoryFile.query.count()
|
||||
current = next(item for item in shipping_inventory_service.list_sources() if item['id'] == source['id'])
|
||||
checks = {item['code']: item for item in current['activation']['checks']}
|
||||
# 关键断言:连接测试已通过;数量与匹配字段仅待首次非空文件验证,不能伪装成失败。
|
||||
assert checks['configuration_test']['status'] == 'empty'
|
||||
assert checks['configuration_test']['blocking'] is False
|
||||
assert checks['parsing_validation']['status'] == 'pending'
|
||||
assert checks['parsing_validation']['blocking'] is False
|
||||
assert checks['warehouse_mapping']['blocking'] is False
|
||||
# 关键断言:无库存不会被行级解析或调拨映射阻断;本例仍缺发货模板,因此尚不可启用。
|
||||
# 关键断言:空结果测试不自动启用;本例仍缺发货模板,硬门槛阻断启用。
|
||||
assert current['enabled'] is False
|
||||
assert current['activation']['missing_requirements'] == ['excel_template']
|
||||
assert 'configuration_test' not in {item['code'] for item in current['activation']['checks']}
|
||||
|
||||
|
||||
def test_empty_configuration_export_without_published_profile_is_rejected(app):
|
||||
@@ -246,8 +241,8 @@ def test_configuration_test_automatically_verifies_compatible_bound_profile(app,
|
||||
assert verified['result']['confirmed_profile_id'] == profile['id']
|
||||
|
||||
|
||||
def test_verified_current_profile_automatically_enables_ready_source(app, tmp_path):
|
||||
"""当前解析验证通过且必要条件齐全时,站点无需人工确认即可自动启用。"""
|
||||
def test_verified_current_profile_does_not_auto_enable_ready_source(app, tmp_path):
|
||||
"""当前解析验证通过且硬门槛齐全时,测试回调仍不得自动启用;启停只走显式开关。"""
|
||||
app.config['FREIGHT_RPA_CREDENTIAL_KEY'] = Fernet.generate_key().decode('ascii')
|
||||
with app.app_context(), patch(
|
||||
'app.services.shipping_notice.rpa.write_inventory_export_batch_trigger', return_value='trigger.json',
|
||||
@@ -263,9 +258,10 @@ def test_verified_current_profile_automatically_enables_ready_source(app, tmp_pa
|
||||
|
||||
verified = _complete_test_run(source, tmp_path)
|
||||
source_model = db.session.get(ShippingInventorySource, source['id'])
|
||||
# 关键断言:测试证据与完整门禁在同一事务提交,避免页面看到已验证但仍需手动启用。
|
||||
# 关键断言:测试只写入验证事实,站点保持停用直至管理员显式启用。
|
||||
assert verified['stage'] == 'current_profile_verified'
|
||||
assert source_model.enabled is True
|
||||
assert source_model.enabled is False
|
||||
assert shipping_inventory_service.get_source_activation_status(source_model)['ready'] is True
|
||||
|
||||
|
||||
def test_verified_current_profile_keeps_source_disabled_without_template(app, tmp_path):
|
||||
@@ -289,8 +285,8 @@ def test_verified_current_profile_keeps_source_disabled_without_template(app, tm
|
||||
assert shipping_inventory_service.get_source_activation_status(source_model)['missing_requirements'] == ['excel_template']
|
||||
|
||||
|
||||
def test_empty_export_automatically_enables_ready_fixed_source(app, tmp_path):
|
||||
"""固定仓查询成功但无库存时,也能在完整门禁下自动启用站点。"""
|
||||
def test_empty_export_does_not_auto_enable_ready_fixed_source(app, tmp_path):
|
||||
"""固定仓查询成功但无库存时,只写入验证事实,不得自动启用站点。"""
|
||||
app.config['FREIGHT_RPA_CREDENTIAL_KEY'] = Fernet.generate_key().decode('ascii')
|
||||
with app.app_context(), patch(
|
||||
'app.services.shipping_notice.rpa.write_inventory_export_batch_trigger', return_value='trigger.json',
|
||||
@@ -307,9 +303,10 @@ def test_empty_export_automatically_enables_ready_fixed_source(app, tmp_path):
|
||||
started = inventory_configuration_test.start_test_export(source['id'], actor_id=None)
|
||||
completed = inventory_configuration_test.report_test_export({'run_no': started['run_no'], 'status': 'empty'})
|
||||
source_model = db.session.get(ShippingInventorySource, source['id'])
|
||||
# 关键断言:无库存是成功查询事实,完整门禁下不再要求人工启用。
|
||||
# 关键断言:空库存是成功查询事实;硬门槛齐备时仍保持停用,等待显式开关。
|
||||
assert completed['status'] == 'completed_empty'
|
||||
assert source_model.enabled is True
|
||||
assert source_model.enabled is False
|
||||
assert shipping_inventory_service.get_source_activation_status(source_model)['ready'] is True
|
||||
|
||||
|
||||
def test_batch_configuration_test_groups_profiles_and_isolates_site_results(app, tmp_path):
|
||||
@@ -572,14 +569,13 @@ def test_confirming_test_profile_binds_only_compatible_published_profile(app, tm
|
||||
db.session.commit()
|
||||
assert shipping_inventory_service.get_source_activation_status(source_model)['ready'] is True
|
||||
assert shipping_inventory_service.activate_source(source['id'], actor_id=None)['enabled'] is True
|
||||
assert next(
|
||||
item for item in shipping_inventory_service.get_source_activation_status(source_model)['checks']
|
||||
if item['code'] == 'configuration_test'
|
||||
)['status'] == 'passed'
|
||||
assert 'configuration_test' not in {
|
||||
item['code'] for item in shipping_inventory_service.get_source_activation_status(source_model)['checks']
|
||||
}
|
||||
|
||||
|
||||
def test_rpa_profile_change_stales_completed_configuration_test(app, tmp_path):
|
||||
"""连接凭据或登录配置变更后,旧测试不得继续作为当前库存站点的启用证据。"""
|
||||
def test_rpa_profile_change_does_not_block_activation_hard_gates(app, tmp_path):
|
||||
"""连接变更后测试证据可能过期,但启用硬门槛不再依赖测试导出。"""
|
||||
app.config['SHIPPING_NOTICE_STORAGE_ROOT'] = str(tmp_path / 'shipping')
|
||||
app.config['FREIGHT_RPA_CREDENTIAL_KEY'] = Fernet.generate_key().decode('ascii')
|
||||
with app.app_context(), patch(
|
||||
@@ -589,6 +585,10 @@ def test_rpa_profile_change_stales_completed_configuration_test(app, tmp_path):
|
||||
completed = _complete_test_run(source, tmp_path)
|
||||
profile = _publish_profile_from_analysis(completed['analysis_id'], _published_order_field(), code='PROFILE_STALE')
|
||||
inventory_configuration_test.confirm_test_profile(source['id'], completed['run_no'], profile['id'], actor_id=None)
|
||||
template = _published_template(code='PROFILE_STALE_TEMPLATE')
|
||||
source_model = db.session.get(ShippingInventorySource, source['id'])
|
||||
source_model.excel_template_id = template.id
|
||||
db.session.commit()
|
||||
|
||||
rpa_profile = db.session.get(ShippingRpaProfile, source['rpa_profile_id'])
|
||||
shipping_inventory_service.save_profile({
|
||||
@@ -599,13 +599,11 @@ def test_rpa_profile_change_stales_completed_configuration_test(app, tmp_path):
|
||||
}, actor_id=None, profile_id=rpa_profile.id)
|
||||
|
||||
source_model = db.session.get(ShippingInventorySource, source['id'])
|
||||
test_check = next(
|
||||
item for item in shipping_inventory_service.get_source_activation_status(source_model)['checks']
|
||||
if item['code'] == 'configuration_test'
|
||||
)
|
||||
# 关键断言:连接配置版本变更使已完成测试失效,不能继续放行正式运行。
|
||||
assert test_check['status'] == 'stale'
|
||||
assert test_check['blocking'] is True
|
||||
status = shipping_inventory_service.get_source_activation_status(source_model)
|
||||
# 关键断言:连接变更不再把测试导出塞进启用门禁;硬门槛齐备即可启用。
|
||||
assert 'configuration_test' not in {item['code'] for item in status['checks']}
|
||||
assert status['ready'] is True
|
||||
assert shipping_inventory_service.activate_source(source['id'], actor_id=None)['enabled'] is True
|
||||
|
||||
|
||||
def test_configuration_test_rejects_enabled_source_and_stale_confirmation(app, tmp_path):
|
||||
@@ -625,15 +623,6 @@ def test_configuration_test_rejects_enabled_source_and_stale_confirmation(app, t
|
||||
inventory_configuration_test.confirm_test_profile(source['id'], completed['run_no'], profile['id'], actor_id=None)
|
||||
assert stale.value.code == 'SHIPPING.INVENTORY_CONFIGURATION_TEST_STALE'
|
||||
|
||||
# 关键断言:旧配置版本的测试只能作为过期证据展示,不能被误判为当前测试通过。
|
||||
stale_status = shipping_inventory_service.get_source_activation_status(
|
||||
db.session.get(ShippingInventorySource, source['id']),
|
||||
)
|
||||
test_check = next(item for item in stale_status['checks'] if item['code'] == 'configuration_test')
|
||||
assert test_check['status'] == 'stale'
|
||||
assert test_check['blocking'] is True
|
||||
assert test_check['evidence']['run_no'] == completed['run_no']
|
||||
|
||||
source_model = db.session.get(ShippingInventorySource, source['id'])
|
||||
source_model.parsing_profile_id = profile['id']
|
||||
template = ShippingExcelTemplate(
|
||||
|
||||
Reference in new issue
Block a user