feat(shipping-notice): 新增发货通知自动上传功能与候选资格评估

- 在环境配置中新增 SHIPPING_NOTICE_AUTO_UPLOAD_ENABLED 选项,默认关闭,需显式开启以支持自动上传。
- 引入新的 pytest.ini 文件,增加测试标记以支持自动化测试。
- 删除不再使用的 seed_shipping_notice_agents.py 文件,简化代码库。
- 更新相关 API,增强发货通知与候选资格评估功能,支持多种筛选条件。
- 增强文档与代码注释,反映新的业务逻辑与功能要求。
This commit is contained in:
hugo committed 2026-08-02 19:26:35 +08:00
1 parent cef3d5b26a
commit 3a9fbac2fc
226 files changed
+25010 -2098

No files matched your search

@@ -1,11 +1,11 @@
/**
* features/admin/api/shipping-audit.api.ts
* 用途:货代统一审计查询/详情/关联链/哈希校验/导出 HTTP 客户端。
* 依赖:shared/api/client、getAuthHeaders。
* 依赖:shared/api/client(requestJson / requestBlob)、getAuthHeaders。
* 逻辑:由 ShippingAuditCenterPage / ShippingAuditEventDetailDrawer 调用;
* 导出走 blob 下载;敏感详情由后端按 audit_sensitive_read 裁剪。
* 导出走 requestBlob;失败为 BusinessError;敏感详情由后端按 audit_sensitive_read 裁剪。
*/
import { requestJson } from '@/shared/api/client';
import { requestBlob, requestJson } from '@/shared/api/client';
import { getAuthHeaders } from '@/shared/utils/auth';
export type ShippingAuditEventSummary = {
@@ -56,11 +56,20 @@ export type ShippingAuditEventDetail = ShippingAuditEventSummary & {
export type ShippingAuditFilters = {
event_type?: string;
/**
* 事件分组:review_workbench / chat_workbench / process_gate /
* candidate_qualification / workflow_node。
*/
event_type_group?: string;
actor_type?: string;
/** 操作者用户 ID;与后端 audit_query_service.actor_id 对齐 */
actor_id?: string;
run_no?: string;
task_no?: string;
/** Candidate 编号;匹配 aggregate_id */
candidate_no?: string;
/** Process Gate / 节点码;匹配 aggregate_id 后缀 */
gate_code?: string;
document_id?: string;
operation_id?: string;
request_id?: string;
@@ -69,6 +78,8 @@ export type ShippingAuditFilters = {
workflow_item_id?: string;
review_case_no?: string;
owner_user_id?: string;
/** 稳定业务原因码;与后端 audit_query_service.reason_code 对齐 */
reason_code?: string;
result?: string;
created_from?: string;
created_to?: string;
@@ -154,12 +165,13 @@ export function verifyShippingAuditHashChain(body: {
/**
* 受控导出审计 CSV/JSON,并触发浏览器下载。
* 核心逻辑:经 requestBlob 统一鉴权与 BusinessError;成功后触发本地下载。
*/
export async function exportShippingAuditEvents(
filters: ShippingAuditFilters = {},
format: 'csv' | 'json' = 'csv',
): Promise<void> {
const response = await fetch('/api/admin/shipping-notice/audit-events/export', {
const { blob, filename } = await requestBlob('/api/admin/shipping-notice/audit-events/export', {
method: 'POST',
headers: {
...getAuthHeaders(),
@@ -167,15 +179,10 @@ export async function exportShippingAuditEvents(
},
body: JSON.stringify({ ...filters, format, limit: 2000 }),
});
if (!response.ok) throw new Error(`HTTP ${response.status}`);
const blob = await response.blob();
const disposition = response.headers.get('Content-Disposition') || '';
const filename = disposition.match(/filename="?([^";]+)"?/i)?.[1]
|| `shipping-audit.${format}`;
const objectUrl = URL.createObjectURL(blob);
const anchor = document.createElement('a');
anchor.href = objectUrl;
anchor.download = filename;
anchor.download = filename || `shipping-audit.${format}`;
anchor.click();
URL.revokeObjectURL(objectUrl);
}
@@ -296,7 +296,7 @@ export const runOrderProfileInstantCheck = (profileId: number, payload: {
/** 在绑定 annotation/training 样本上试运行;接口不会接受或回显盲测真值。 */
export const runOrderProfileCurrentSample = (profileId: number, payload: {
sample_binding_id?: number; browser_session_id: string; lease_token: string; operation_id: string;
sample_binding_id: number; browser_session_id: string; lease_token: string; operation_id: string;
}) => requestJson<import('@/features/admin/types/shipping-order-document-profile.types').OrderProfileValidationRun>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/validation-runs/current-sample`,
{ method: 'POST', body: JSON.stringify(payload), ...jsonAuth() },