!11 feat(shipping-notice): 实现滚动履约功能,优化发货通知流程与代码清理

Merge pull request !11 from 曹惠鹏/hugo-shipping-notice
This commit is contained in:
sophie authored and Gitee committed 2026-08-26 00:25:10 +00:00
commit 2ff9fdafe4
402 files changed
+23045 -20484

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());
}
@@ -77,6 +77,9 @@ export const getOrderDocumentProfileDetail = (profileId: number) =>
export const saveOrderDocumentProfileDraft = (profileId: number, payload: {
profile_code: string; display_name: string; schema_version_id: number;
definition: ShippingOrderDocumentProfile['definition']; change_note?: string;
/** 标注样本文档及其冻结视觉主表;二者必须与 definition.main_table_id 保持一致。 */
sample_document_id?: number;
sample_table_id?: string;
expected_lock_version: number; browser_session_id: string; lease_token: string; operation_id: string;
/** path_id → 服务端签发的拆分预览确认令牌;confirmed 规则必须携带 */
split_rule_confirmation_tokens?: Record<string, string>;
@@ -583,9 +586,12 @@ export const getOrderProfilePageTextCandidates = (profileId: number, documentId:
/** 读取当前受控样本中框选区域的坐标文本;仅用于画布生成文档匹配锚点。 */
export const readOrderProfilePreviewPageRegionText = (
profileId: number, documentId: number, pageNo: number, region: { x0: number; y0: number; x1: number; y1: number },
) => requestJson<{ document_id: number; page_no: number; text: string; source: string | null; status: 'needs_review' }>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/preview-pages/${pageNo}/region-text`, {
method: 'POST', body: JSON.stringify({ document_id: documentId, region }), ...jsonAuth(),
signal?: AbortSignal,
purpose?: 'reservation_id_region',
renderedImageBase64?: string | null,
) => requestJson<{ document_id: number; page_no: number; text: string; source: string | null; status: 'needs_review'; reservation_candidates?: Array<{ value: string; line_no: number | null; scope: 'header' | 'line'; raw_text: string; status: string }> }>(
`/api/admin/shipping-notice/order-document-profiles/${profileId}/preview-pages/${pageNo}/region-text`, {
method: 'POST', body: JSON.stringify({ document_id: documentId, region, ...(purpose ? { purpose } : {}), ...(renderedImageBase64 ? { rendered_image_base64: renderedImageBase64 } : {}) }), signal, ...jsonAuth(),
},
);