feat(shipping-notice): 新增通用解析能力,优化性能并清理遗留废弃代码
This commit is contained in:
1 parent
935bf26fa6
commit
7cfd5d167e
230 files changed
+9337
-10989
No files matched your search
@@ -1,131 +0,0 @@
|
||||
/**
|
||||
* features/admin/api/shipping-legacy-stp-jobs.api.ts
|
||||
* 用途:Phase 5-1 —— 管理员历史 STP Job(928/929 面板)HTTP API 客户端。
|
||||
* 依赖:requestJson / getAuthHeaders(shared/api/client & shared/utils/auth)。
|
||||
* 逻辑:GET list / GET detail;后端 URL 为 /api/admin/shipping-notice/legacy-stp-jobs。
|
||||
*/
|
||||
import { getAuthHeaders } from '@/shared/utils/auth';
|
||||
import { requestJson } from '@/shared/api/client';
|
||||
import type { PaginatedResult } from '@/shared/types/pagination.types';
|
||||
|
||||
const auth = () => ({ headers: getAuthHeaders() });
|
||||
|
||||
export type LegacyStpJobRow = {
|
||||
job_id: number;
|
||||
domain: string;
|
||||
job_type: string;
|
||||
status: 'failed' | 'dead' | string;
|
||||
business_ref: string | null;
|
||||
reference_key: string | null;
|
||||
case_no: string | null;
|
||||
priority: number;
|
||||
attempts: number;
|
||||
max_attempts: number;
|
||||
message: string | null;
|
||||
error_message: string | null;
|
||||
error_code: string | null;
|
||||
blocking_reason: string | null;
|
||||
retryable: boolean | null;
|
||||
next_action: string | string[] | null;
|
||||
retry_of_job_id: number | null;
|
||||
created_by_id: number | null;
|
||||
result_json_masked: Record<string, unknown> | null;
|
||||
payload_json_masked: Record<string, unknown> | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
started_at: string | null;
|
||||
finished_at: string | null;
|
||||
};
|
||||
|
||||
export type LegacyStpJobCaseBacklink = {
|
||||
case_id: number;
|
||||
case_no: string;
|
||||
status: string;
|
||||
candidate_id: number | null;
|
||||
confirmed_task_id: number | null;
|
||||
document_id: number | null;
|
||||
owner_user_id: number | null;
|
||||
created_at: string | null;
|
||||
updated_at: string | null;
|
||||
};
|
||||
|
||||
export type LegacyStpJobReplayPlan = {
|
||||
supported: boolean;
|
||||
recommended_user_action: 'force_create' | 'create_revision' | string;
|
||||
needs_replay_mode: boolean;
|
||||
reconcile_and_progress_endpoint: string | null;
|
||||
};
|
||||
|
||||
export type LegacyStpJobDetailPayload = {
|
||||
job: LegacyStpJobRow;
|
||||
case: LegacyStpJobCaseBacklink | null;
|
||||
replay_plan: LegacyStpJobReplayPlan;
|
||||
};
|
||||
|
||||
export type LegacyStpJobListFilters = {
|
||||
status?: '' | 'failed' | 'dead';
|
||||
job_type?: string;
|
||||
q?: string;
|
||||
case_no?: string;
|
||||
error_code?: string;
|
||||
blocking_reason?: string;
|
||||
created_from?: string;
|
||||
created_to?: string;
|
||||
sort?: string;
|
||||
};
|
||||
|
||||
const EMPTY_FILTERS: Required<LegacyStpJobListFilters> = {
|
||||
status: '',
|
||||
job_type: '',
|
||||
q: '',
|
||||
case_no: '',
|
||||
error_code: '',
|
||||
blocking_reason: '',
|
||||
created_from: '',
|
||||
created_to: '',
|
||||
sort: '-created_at',
|
||||
};
|
||||
|
||||
export const DEFAULT_LEGACY_STP_JOB_FILTERS = EMPTY_FILTERS;
|
||||
|
||||
export const LEGACY_STP_JOB_STATUS_OPTIONS = ['failed', 'dead'] as const;
|
||||
|
||||
function normalizeDateTimeFilter(value?: string): string {
|
||||
const raw = String(value || '').trim();
|
||||
if (!raw) return '';
|
||||
const date = new Date(raw);
|
||||
if (Number.isNaN(date.getTime())) return raw;
|
||||
return date.toISOString();
|
||||
}
|
||||
|
||||
function buildListSearchParams(filters: LegacyStpJobListFilters, page: number, pageSize: number): URLSearchParams {
|
||||
const params = new URLSearchParams({
|
||||
page: String(page),
|
||||
page_size: String(pageSize),
|
||||
});
|
||||
if (filters.status) params.set('status', filters.status);
|
||||
if (filters.job_type) params.set('job_type', filters.job_type);
|
||||
if (filters.q) params.set('q', filters.q);
|
||||
if (filters.case_no) params.set('case_no', filters.case_no);
|
||||
if (filters.error_code) params.set('error_code', filters.error_code);
|
||||
if (filters.blocking_reason) params.set('blocking_reason', filters.blocking_reason);
|
||||
if (filters.created_from) params.set('created_from', normalizeDateTimeFilter(filters.created_from));
|
||||
if (filters.created_to) params.set('created_to', normalizeDateTimeFilter(filters.created_to));
|
||||
if (filters.sort) params.set('sort', filters.sort);
|
||||
return params;
|
||||
}
|
||||
|
||||
export function listAdminLegacyStpJobs(
|
||||
page = 1,
|
||||
pageSize = 25,
|
||||
filters: LegacyStpJobListFilters = {},
|
||||
): Promise<PaginatedResult<LegacyStpJobRow> & {
|
||||
filters: { domain: string; job_types: string[]; statuses: string[] };
|
||||
}> {
|
||||
const params = buildListSearchParams(filters, page, pageSize);
|
||||
return requestJson(`/api/admin/shipping-notice/legacy-stp-jobs?${params}`, auth());
|
||||
}
|
||||
|
||||
export function getAdminLegacyStpJob(jobId: number): Promise<LegacyStpJobDetailPayload> {
|
||||
return requestJson(`/api/admin/shipping-notice/legacy-stp-jobs/${encodeURIComponent(String(jobId))}`, auth());
|
||||
}
|
||||
Reference in new issue
Block a user