feat(queue): 添加旧知识库任务入队兼容入口
- 增加 enqueue_kb_job 和 enqueue_clean_job 函数以支持旧 KB 清洗任务入队 - 在 enqueue 函数中处理 KB_CLEAN 和 KB_DIFY_SYNC 类型的任务 - 引入 ValidationError 以处理 job_id 缺失的情况 feat(shipping_notice): 更新库存 RPA 工作流逻辑 - 修改 ensure_inventory_via_rpa 函数以支持手动重试逻辑 - 优化库存导出触发和状态更新的消息提示 fix(i18n): 更新任务未找到的提示信息 - 修改中文和英文提示,明确用户操作要求 feat(shipping_notice): 增强任务解析逻辑 - 添加缺失 Reservation ID 的检查,阻止任务进入确认阶段 - 更新 get_task_status 函数以处理多票会话的任务解析
This commit is contained in:
1 parent
eb0466245b
commit
4cd987eef6
45 files changed
+2748
-1406
No files matched your search
@@ -21,6 +21,7 @@ from app.services.shipping_notice.progress_workflow import auto_progress
|
||||
|
||||
|
||||
def _tool_headers(app):
|
||||
app.config["SHIPPING_NOTICE_TOOL_API_KEY"] = ""
|
||||
app.config["INTEGRATION_API_KEY"] = "test-integration-key"
|
||||
return {
|
||||
"Content-Type": "application/json",
|
||||
@@ -123,6 +124,46 @@ def test_create_batch_tasks_and_switch_focus(app, client):
|
||||
assert task_rows[1].batch_total == 2
|
||||
|
||||
|
||||
def test_contract_batch_status_keeps_single_focus_without_advancing_other_tasks(app, client):
|
||||
"""契约:多任务会话只暴露一个 focus 指针;读取批次状态不能推进整批任务。"""
|
||||
headers = _tool_headers(app)
|
||||
create_res = client.post(
|
||||
"/api/shipping-notice/tools/create_batch",
|
||||
headers=headers,
|
||||
json={
|
||||
"conversation_id": "conv-contract-focus",
|
||||
"notice_items": [
|
||||
{"raw_text": "客户A 料号A001 x 1", "source_file_name": "A.pdf"},
|
||||
{"raw_text": "客户B 料号B001 x 2", "source_file_name": "B.pdf"},
|
||||
],
|
||||
},
|
||||
)
|
||||
data = create_res.get_json()
|
||||
batch_no = data["batch_no"]
|
||||
task_refs = [item["task_id"] for item in data["data"]["tasks"]]
|
||||
focus_task_no, other_task_no = task_refs
|
||||
|
||||
status_res = client.post(
|
||||
"/api/shipping-notice/tools/get_batch_status",
|
||||
headers=headers,
|
||||
json={"batch_no": batch_no},
|
||||
)
|
||||
status_data = status_res.get_json()
|
||||
|
||||
assert status_res.status_code == 200
|
||||
assert status_data["status"] == "ok"
|
||||
assert status_data["data"]["current_focus_task_no"] == focus_task_no
|
||||
assert [item["task_no"] for item in status_data["data"]["tasks"]] == task_refs
|
||||
|
||||
with app.app_context():
|
||||
rows = {
|
||||
task.task_no: task
|
||||
for task in ShippingTask.query.filter(ShippingTask.task_no.in_([focus_task_no, other_task_no])).all()
|
||||
}
|
||||
assert rows[focus_task_no].process_status == "created"
|
||||
assert rows[other_task_no].process_status == "created"
|
||||
|
||||
|
||||
def test_create_batch_defers_parse_without_structured(app, client):
|
||||
"""默认将 parse_notice 延后到 Dify,仅保存 raw_text。"""
|
||||
headers = _tool_headers(app)
|
||||
@@ -342,8 +383,8 @@ def test_auto_progress_inventory_trigger_failure_marks_step3(app):
|
||||
assert task.step_payload_json["current_step_progress"]["status"] == "needs_human"
|
||||
|
||||
|
||||
def test_workspace_task_detail_rechecks_timed_out_inventory_rpa(app, client, tmp_path):
|
||||
"""工作台查询遇到已超时 RPA 等待态时,应兜底复查并自动触发下一次库存导出。"""
|
||||
def test_workspace_task_detail_is_read_only_for_timed_out_inventory_rpa(app, client, tmp_path):
|
||||
"""工作台查询必须保持纯读;已超时 RPA 等待态也不能由 GET 触发补偿或事件落库。"""
|
||||
headers = _workspace_headers(app)
|
||||
app.config["SHIPPING_NOTICE_AUTO_PROGRESS_ENABLED"] = True
|
||||
app.config["SHIPPING_NOTICE_AUTO_RPA_INVENTORY_ENABLED"] = True
|
||||
@@ -394,11 +435,12 @@ def test_workspace_task_detail_rechecks_timed_out_inventory_rpa(app, client, tmp
|
||||
triggered = [event for event in events if event.event_type == "inventory_rpa_triggered"]
|
||||
failed = [event for event in events if event.event_type == "inventory_rpa_failed"]
|
||||
rechecked = [event for event in events if event.event_type == "inventory_rpa_wait_rechecked"]
|
||||
assert len(triggered) == 2
|
||||
assert len(failed) == 1
|
||||
assert len(rechecked) == 1
|
||||
assert triggered[-1].detail_json["attempt"] == 2
|
||||
assert task.step_payload_json["current_step_progress"]["current"] == 2
|
||||
assert len(triggered) == 1
|
||||
assert len(failed) == 0
|
||||
assert len(rechecked) == 0
|
||||
assert task.process_status == "waiting_inventory"
|
||||
assert task.pending_human_reason == "rpa_pending"
|
||||
assert not list((tmp_path / "inventory_triggers").glob("inventory_export_*.json"))
|
||||
|
||||
|
||||
def test_auto_progress_resolves_dub_inventory_source_into_rpa_trigger(app, tmp_path):
|
||||
|
||||
Reference in new issue
Block a user