feat(shipping): 新增货代发货批量自动处理与任务重试功能
本次提交完整实现货代发货通知的自动化批量处理能力: 1. 新增发货单票后台任务类型与专用worker队列,实现任务持久化调度 2. 实现发货批次后台编排器,支持上传后自动逐票推进解析、匹配、导出全流程 3. 新增单票重试、批次待处理重试的API与前端操作界面 4. 补充全量多语言翻译,新增重试、任务列表、状态展示相关文案 5. 优化上传交互逻辑,改为后台自动处理任务,无需手动触发解析指令 6. 修复文件检核工具无数据预检逻辑,避免创建空检核批次 7. 调整发货工作流细节,优化Excel生成幂等性与任务状态同步 8. 更新环境配置与API文档,修正货代工具接口地址端口
This commit is contained in:
1 parent
70e8f700ff
commit
08360a4142
40 files changed
+2515
-371
No files matched your search
@@ -389,6 +389,81 @@ def test_file_check_tool_start_records_chat_log_bind_context(app, client, monkey
|
||||
assert resolve_run_id_for_chat_log(session_id='bind-on-start', query='执行 RoHS 检核') == run_id
|
||||
|
||||
|
||||
def test_file_check_tool_no_data_does_not_create_run_or_bind_context(app, client, monkeypatch):
|
||||
with app.app_context():
|
||||
app.config['INTEGRATION_API_KEY'] = 'secret'
|
||||
admin = _mk_admin()
|
||||
db.session.commit()
|
||||
task = _mk_check_task(admin.id)
|
||||
task_id = task.id
|
||||
before_count = ScheduleRun.query.filter_by(schedule_task_id=task_id).count()
|
||||
|
||||
monkeypatch.setattr('app.api.file_check_tools._precheck_no_data', lambda _task: {
|
||||
'ok': False,
|
||||
'error_code': 'no_data_to_check',
|
||||
'message': '目前没有资料需要检核',
|
||||
'task': {'task_id': _task.id, 'task_name': _task.name},
|
||||
})
|
||||
|
||||
res = client.post(
|
||||
'/api/file-check/tools/tasks/run',
|
||||
headers={'X-Integration-Key': 'secret', 'Content-Type': 'application/json'},
|
||||
json={
|
||||
'task_id': task_id,
|
||||
'hxops_session_id': 'no-data-session',
|
||||
'hxops_turn_id': 'no-data-turn',
|
||||
'user_message': '立即执行检核',
|
||||
},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
data = res.get_json()
|
||||
assert data['ok'] is False
|
||||
assert data['error_code'] == 'no_data_to_check'
|
||||
assert 'run' not in data
|
||||
|
||||
with app.app_context():
|
||||
after_count = ScheduleRun.query.filter_by(schedule_task_id=task_id).count()
|
||||
assert after_count == before_count
|
||||
from app.services.file_check_tools.chat_log_run_binding import resolve_run_id_for_chat_log
|
||||
|
||||
assert resolve_run_id_for_chat_log(turn_id='no-data-turn') is None
|
||||
assert resolve_run_id_for_chat_log(session_id='no-data-session', query='立即执行检核') is None
|
||||
|
||||
|
||||
def test_file_check_tool_no_data_keeps_existing_running_conflict_priority(app, client, monkeypatch):
|
||||
with app.app_context():
|
||||
app.config['INTEGRATION_API_KEY'] = 'secret'
|
||||
admin = _mk_admin()
|
||||
db.session.commit()
|
||||
task = _mk_check_task(admin.id)
|
||||
run = ScheduleRun(
|
||||
run_no='RUN-ROHS-NO-DATA-CONFLICT',
|
||||
schedule_task_id=task.id,
|
||||
status='running',
|
||||
trigger_type='manual',
|
||||
)
|
||||
db.session.add(run)
|
||||
db.session.commit()
|
||||
task_id = task.id
|
||||
|
||||
monkeypatch.setattr('app.api.file_check_tools._precheck_no_data', lambda _task: {
|
||||
'ok': False,
|
||||
'error_code': 'no_data_to_check',
|
||||
'message': '目前没有资料需要检核',
|
||||
'task': {'task_id': _task.id, 'task_name': _task.name},
|
||||
})
|
||||
|
||||
res = client.post(
|
||||
'/api/file-check/tools/tasks/run',
|
||||
headers={'X-Integration-Key': 'secret', 'Content-Type': 'application/json'},
|
||||
json={'task_id': task_id},
|
||||
)
|
||||
assert res.status_code == 200
|
||||
data = res.get_json()
|
||||
assert data['error_code'] == 'check_running'
|
||||
assert data.get('run', {}).get('run_id')
|
||||
|
||||
|
||||
def test_file_check_tool_requires_task_id(app, client):
|
||||
with app.app_context():
|
||||
app.config['INTEGRATION_API_KEY'] = 'secret'
|
||||
|
||||
Reference in new issue
Block a user