feat(shipping_notice): 新增货代订单全流程业务模块及配套基建
本次提交新增货代订单处理全流程的完整业务能力、数据库迁移与测试用例: 1. 统一追加式审计事件体系,支持全链路不可篡改的业务追溯 2. 货代任务撤销、版本替代管控逻辑,规范已上传订单的合规版本更替 3. 订单抽取路由审计、模板自动冻结资格、路由计数等核心业务基建 4. EML订单补充表解析契约与合并逻辑,完善订单补全能力 5. Chatflow只读能力令牌校验机制,保障工具调用安全 6. 人工复核证据校验服务,规范人工审核的证据留存 所有变更均配套完整的单元测试与迁移契约测试,支持受控回退
This commit is contained in:
1 parent
90f77634d6
commit
1f3ecb87b7
128 files changed
+3635
-2074
No files matched your search
@@ -1,7 +1,7 @@
|
||||
/**
|
||||
* features/chat/shipping/useShippingNoticeIntakes.ts
|
||||
* 用途:发货通知选择即上传、创建 intake 与批量状态轮询编排。
|
||||
* 依赖:file-assets.api、shipping.api、shipping.types、shippingNoticeAttachmentIntegrity。
|
||||
* 依赖:file-assets.api、shipping.api、shipping.types、shippingNoticeAttachmentIntegrity、后端布局状态汇总。
|
||||
* 逻辑:useChatShipping / useChatAttachments 在货代 Agent 下委托本 composable 管理预解析附件;
|
||||
* 完整性判定委托 shippingNoticeAttachmentIntegrity(与后端契约对齐);会话刷新仅恢复未提交的处理中或解析失败附件。
|
||||
*/
|
||||
@@ -51,34 +51,55 @@ export function shouldRestoreShippingNoticeIntake(
|
||||
parseStatus: string | null | undefined,
|
||||
orderExtractionStatus?: string | null,
|
||||
candidateCount = 0,
|
||||
layoutStatus?: ShippingNoticePendingAttachment['layoutStatus'],
|
||||
): boolean {
|
||||
const status = String(parseStatus || '').trim().toLowerCase();
|
||||
const extractionStatus = String(orderExtractionStatus || '').trim().toLowerCase();
|
||||
return ACTIVE_PARSE.has(status)
|
||||
|| status === 'parse_failed'
|
||||
|| layoutStatus === 'processing'
|
||||
|| extractionStatus === 'failed'
|
||||
|| (extractionStatus === 'partially_completed' && candidateCount > 0);
|
||||
}
|
||||
|
||||
/** 判断 Intake 是否仍需轮询上传预处理或订单抽取状态。 */
|
||||
export function shouldPollShippingNoticeIntake(
|
||||
item: Pick<ShippingNoticePendingAttachment, 'parseStatus' | 'orderExtractionStatus'>,
|
||||
item: Pick<ShippingNoticePendingAttachment, 'parseStatus' | 'orderExtractionStatus' | 'layoutStatus'>,
|
||||
): boolean {
|
||||
return !TERMINAL_PARSE.has(item.parseStatus)
|
||||
|| ACTIVE_ORDER_EXTRACTION.has(String(item.orderExtractionStatus || '').trim().toLowerCase());
|
||||
|| ACTIVE_ORDER_EXTRACTION.has(String(item.orderExtractionStatus || '').trim().toLowerCase())
|
||||
|| item.layoutStatus === 'processing';
|
||||
}
|
||||
|
||||
/** 判断附件是否仍可作为新一轮完整订单抽取的输入。 */
|
||||
export function isOrderExtractionEligibleIntake(
|
||||
item: Pick<ShippingNoticePendingAttachment, 'intakeNo' | 'parseStatus' | 'parseSummary' | 'orderExtractionStatus'>,
|
||||
item: Pick<ShippingNoticePendingAttachment, 'intakeNo' | 'parseStatus' | 'parseSummary' | 'orderExtractionStatus' | 'layoutStatus'>,
|
||||
): boolean {
|
||||
const extractionStatus = String(item.orderExtractionStatus || 'not_started').trim().toLowerCase();
|
||||
return item.parseStatus === 'parsed'
|
||||
&& Boolean(item.intakeNo)
|
||||
&& (extractionStatus === 'not_started' || extractionStatus === 'failed')
|
||||
&& item.layoutStatus !== 'processing'
|
||||
&& !isShippingNoticeAttachmentParseIncomplete(item.parseSummary);
|
||||
}
|
||||
|
||||
/** 把后端布局汇总投影为附件卡片使用的最小状态,旧响应缺字段时保持兼容。 */
|
||||
function mapServerLayout(remote: ShippingNoticeIntakeResponse): Pick<ShippingNoticePendingAttachment, 'layoutStatus' | 'layoutSummary'> {
|
||||
const summary = remote.layout_summary;
|
||||
return {
|
||||
layoutStatus: remote.layout_status || summary?.status,
|
||||
layoutSummary: summary ? {
|
||||
total: Number(summary.total || 0),
|
||||
queued: Number(summary.queued || 0),
|
||||
running: Number(summary.running || 0),
|
||||
ready: Number(summary.ready || 0),
|
||||
needs_review: Number(summary.needs_review || 0),
|
||||
failed: Number(summary.failed || 0),
|
||||
unsupported: Number(summary.unsupported || 0),
|
||||
} : undefined,
|
||||
};
|
||||
}
|
||||
|
||||
/** 保留刚点击发送的本地 extracting,直到服务端进入真实抽取状态或返回终态。 */
|
||||
export function resolveShippingOrderExtractionStatus(localStatus?: string, remoteStatus?: string | null): string | undefined {
|
||||
const local = String(localStatus || '').trim().toLowerCase();
|
||||
@@ -239,6 +260,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
|| ACTIVE_PARSE.has(item.parseStatus)
|
||||
|| item.parseStatus === 'queued'
|
||||
|| item.parseStatus === 'parsing'
|
||||
|| item.layoutStatus === 'processing'
|
||||
|| ACTIVE_ORDER_EXTRACTION.has(String(item.orderExtractionStatus || '').trim().toLowerCase()),
|
||||
),
|
||||
);
|
||||
@@ -339,6 +361,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
remote.order_extraction_status,
|
||||
),
|
||||
parseSummary: (remote.parse_summary || undefined) as ShippingNoticeParseSummary | undefined,
|
||||
...mapServerLayout(remote),
|
||||
errorCode: remote.order_extraction_error_code || remote.error_code || undefined,
|
||||
errorMessage: remote.order_extraction_error_message || remote.error_message || undefined,
|
||||
expiresAt: remote.expires_at || undefined,
|
||||
@@ -369,6 +392,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
parseStatus: mapServerParseStatus(intake.parse_status),
|
||||
orderExtractionStatus: intake.order_extraction_status || undefined,
|
||||
parseSummary: (intake.parse_summary || undefined) as ShippingNoticeParseSummary | undefined,
|
||||
...mapServerLayout(intake),
|
||||
errorCode: intake.order_extraction_error_code || intake.error_code || undefined,
|
||||
errorMessage: intake.order_extraction_error_message || intake.error_message || undefined,
|
||||
expiresAt: intake.expires_at || undefined,
|
||||
@@ -421,6 +445,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
patchAttachment(id, {
|
||||
parseStatus: mapServerParseStatus(intake.parse_status),
|
||||
parseSummary: (intake.parse_summary || undefined) as ShippingNoticeParseSummary | undefined,
|
||||
...mapServerLayout(intake),
|
||||
errorCode: intake.error_code || undefined,
|
||||
errorMessage: intake.error_message || undefined,
|
||||
});
|
||||
@@ -472,6 +497,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
item.parse_status,
|
||||
item.order_extraction_status,
|
||||
item.candidates?.length || 0,
|
||||
item.layout_status,
|
||||
))
|
||||
.map((item) => ({
|
||||
id: `restored_${item.intake_no}`,
|
||||
@@ -486,6 +512,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
originalFilename: item.original_filename || item.intake_no,
|
||||
fileSize: Number(item.file_size || 0),
|
||||
parseSummary: (item.parse_summary || undefined) as ShippingNoticeParseSummary | undefined,
|
||||
...mapServerLayout(item),
|
||||
errorCode: item.order_extraction_error_code || item.error_code || undefined,
|
||||
errorMessage: item.order_extraction_error_message || item.error_message || undefined,
|
||||
expiresAt: item.expires_at || undefined,
|
||||
@@ -515,6 +542,7 @@ export function useShippingNoticeIntakes(options: UseShippingNoticeIntakesOption
|
||||
);
|
||||
patchAttachment(target.id, {
|
||||
parseStatus: mapServerParseStatus(intake.parse_status),
|
||||
...mapServerLayout(intake),
|
||||
...mapServerDuplicate(intake),
|
||||
});
|
||||
};
|
||||
|
||||
Reference in new issue
Block a user