feat(shipping-notice): 完善订单模板解析与库存 RPA 调度流程
- 新增行字段补充合并与订单模板匹配能力 - 优化运行时解析策略、签名校验及资料验证 - 完善库存 RPA 归档、收尾与 Worker 启动流程 - 补充前后端测试、多语言文案及功能文档
This commit is contained in:
1 parent
8f2f568f92
commit
dabf140e41
45 files changed
+2007
-151
No files matched your search
+1
-1
@@ -294,7 +294,7 @@ export function useScheduleAdminRuns(
|
||||
const a = document.createElement('a');
|
||||
a.href = url;
|
||||
const disposition = res.headers.get('content-disposition');
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || 'inventory-rpa-raw.zip';
|
||||
a.download = disposition?.match(/filename\*?=(?:UTF-8'')?["']?([^;"'\n]+)/)?.[1] || '库存RPA-库存.zip';
|
||||
document.body.appendChild(a);
|
||||
a.click();
|
||||
document.body.removeChild(a);
|
||||
|
||||
+81
-9
@@ -1115,6 +1115,19 @@ const nextOrderFieldSequence = (targetPageNo: number): number => {
|
||||
const beginFormEdit = () => {
|
||||
pendingFormEdit = snapshot();
|
||||
};
|
||||
/**
|
||||
* 将选中物理行标记为主明细或 LN 补料号补充表(如 COO)。
|
||||
* 核心逻辑:写入 tableRegionRole 后走同一 finishFormEdit,保存时按角色拆成两个 table_regions。
|
||||
*/
|
||||
const onSelectedLineTableRegionRoleChange = (event: Event): void => {
|
||||
const target = selectedRegion.value;
|
||||
if (!target || target.kind !== 'line') return;
|
||||
const value = (event.target as HTMLSelectElement).value;
|
||||
target.tableRegionRole = value === 'line_field_supplement'
|
||||
? 'line_field_supplement'
|
||||
: 'business_lines';
|
||||
finishFormEdit();
|
||||
};
|
||||
/**
|
||||
* 记录字段改绑前的共同视觉身份。
|
||||
*
|
||||
@@ -1549,12 +1562,51 @@ const definition = () => {
|
||||
.map((item) => item.pageNo),
|
||||
)]
|
||||
.sort((left, right) => left - right)
|
||||
.map((regionPageNo) => {
|
||||
.flatMap((regionPageNo) => {
|
||||
const regionSettings = ensureTableRegionSetting(regionPageNo);
|
||||
const pageItems = normalizedRegions.filter(
|
||||
(item) => item.pageNo === regionPageNo,
|
||||
);
|
||||
const lineRegions = pageItems.filter((item) => item.kind === "line");
|
||||
const roles: Array<'business_lines' | 'line_field_supplement'> = [
|
||||
'business_lines',
|
||||
'line_field_supplement',
|
||||
];
|
||||
return roles.flatMap((regionRole) => {
|
||||
const lineRegions = pageItems.filter(
|
||||
(item) =>
|
||||
item.kind === "line"
|
||||
&& (item.tableRegionRole || 'business_lines') === regionRole,
|
||||
);
|
||||
const supplementLineRegions = pageItems.filter(
|
||||
(item) =>
|
||||
item.kind === "line"
|
||||
&& (item.tableRegionRole || 'business_lines') === 'line_field_supplement',
|
||||
);
|
||||
/** 表头中心点是否落在补充表明细行并集内(含少量纵向余量)。 */
|
||||
const headerOverlapsSupplement = (header: typeof pageItems[number]): boolean => {
|
||||
if (!supplementLineRegions.length) return false;
|
||||
const cy = (header.region.y0 + header.region.y1) / 2;
|
||||
const cx = (header.region.x0 + header.region.x1) / 2;
|
||||
return supplementLineRegions.some((line) => {
|
||||
const pad = Math.max(0.01, (line.region.y1 - line.region.y0) * 0.5);
|
||||
return (
|
||||
cx >= line.region.x0
|
||||
&& cx <= line.region.x1
|
||||
&& cy >= line.region.y0 - pad
|
||||
&& cy <= line.region.y1 + pad
|
||||
);
|
||||
});
|
||||
};
|
||||
// 表头只挂在业务明细区;补充表(COO)不携带 header_layouts。
|
||||
// 落在补充行附近的表头不得并入 business,否则会污染版面签名 header_tokens。
|
||||
const pageHeaderItems = regionRole === 'business_lines'
|
||||
? pageItems.filter(
|
||||
(item) => item.kind === "header_field" && !headerOverlapsSupplement(item),
|
||||
)
|
||||
: [];
|
||||
if (!lineRegions.length && !pageHeaderItems.length) {
|
||||
return [];
|
||||
}
|
||||
const groupedLineFields = groupUniqueOrderProfileLineFields(
|
||||
pageItems,
|
||||
lineRegions.map((item) => item.id),
|
||||
@@ -1579,14 +1631,14 @@ const definition = () => {
|
||||
lineFields.value.map((field) => field.field_code),
|
||||
);
|
||||
};
|
||||
const headerLayouts = pageItems
|
||||
.filter((item) => item.kind === "header_field" && item.parentId)
|
||||
const headerLayouts = pageHeaderItems
|
||||
.filter((item) => item.parentId)
|
||||
.reduce<string[]>((layoutIds, item) => {
|
||||
if (!layoutIds.includes(item.parentId!)) layoutIds.push(item.parentId!);
|
||||
return layoutIds;
|
||||
}, [])
|
||||
.map((layoutId) => {
|
||||
const fields = pageItems.filter(
|
||||
const fields = pageHeaderItems.filter(
|
||||
(item) =>
|
||||
item.kind === "header_field" && item.parentId === layoutId,
|
||||
);
|
||||
@@ -1608,7 +1660,7 @@ const definition = () => {
|
||||
});
|
||||
const layoutRegions = [
|
||||
...lineRegions,
|
||||
...pageItems.filter((item) => item.kind === "header_field"),
|
||||
...pageHeaderItems,
|
||||
];
|
||||
const tableRegion = layoutRegions.length
|
||||
? {
|
||||
@@ -1624,12 +1676,15 @@ const definition = () => {
|
||||
? fieldRegionsFor(firstLineRegion.id).map((item) => item.field_code)
|
||||
: [],
|
||||
);
|
||||
return {
|
||||
region_id: `main_lines_page_${regionPageNo}`,
|
||||
return [{
|
||||
region_id: regionRole === 'line_field_supplement'
|
||||
? `line_supplement_page_${regionPageNo}`
|
||||
: `main_lines_page_${regionPageNo}`,
|
||||
// 仅为旧 schema 提供兼容形状;运行时会自动选择适用页范围。
|
||||
page_scope: 'exact_page' as const,
|
||||
page_no: regionPageNo,
|
||||
region: tableRegion,
|
||||
region_role: regionRole,
|
||||
line_start_field_code: resolveLineStartFieldCode(mainLineFieldCodes),
|
||||
// 仅为旧 schema 提供兼容形状;运行时固定/自适应策略并行评估。
|
||||
row_reconstruction_mode: 'fixed_subrows' as const,
|
||||
@@ -1661,6 +1716,7 @@ const definition = () => {
|
||||
(item) =>
|
||||
(item.kind === "field" || item.kind === "header_field") &&
|
||||
item.parentId &&
|
||||
lineRegions.some((line) => line.id === item.parentId) &&
|
||||
(!item.fieldCode ||
|
||||
(item.kind === "header_field" && !coordinateFieldScope(item.fieldCode)) ||
|
||||
(item.kind === "field" && !boundLineFieldRegionIds.has(item.id))),
|
||||
@@ -1671,7 +1727,8 @@ const definition = () => {
|
||||
label: item.label,
|
||||
region: item.region,
|
||||
})),
|
||||
};
|
||||
}];
|
||||
});
|
||||
});
|
||||
const visualDefinition: OrderCoordinateProfileDefinition = {
|
||||
// 主表身份由创建向导冻结;编辑器保存时随定义原样携带,不能退化为只存 sample.table_id。
|
||||
@@ -2727,6 +2784,7 @@ const restoreRegions = (profile: ShippingOrderDocumentProfile) => {
|
||||
label: item.layout_id,
|
||||
region: item.region,
|
||||
pageNo: regionPageNo,
|
||||
tableRegionRole: table.region_role || 'business_lines',
|
||||
})),
|
||||
...table.line_layouts.flatMap((line) =>
|
||||
line.field_regions.map((item, index) => ({
|
||||
@@ -3443,6 +3501,20 @@ onBeforeUnmount(() => {
|
||||
{{ line.label }}
|
||||
</option>
|
||||
</select></label
|
||||
><label v-if="selectedRegion.kind === 'line'"
|
||||
>{{ t('admin.shippingOrderProfiles.workbench.tableRegionRole')
|
||||
}}<select
|
||||
:value="selectedRegion.tableRegionRole || 'business_lines'"
|
||||
class="select-field"
|
||||
:disabled="compactEditor || saveState === 'readonly'"
|
||||
@focus="beginFormEdit"
|
||||
@change="onSelectedLineTableRegionRoleChange"
|
||||
>
|
||||
<option value="business_lines">{{ t('admin.shippingOrderProfiles.workbench.tableRegionRoles.business_lines') }}</option>
|
||||
<option value="line_field_supplement">{{ t('admin.shippingOrderProfiles.workbench.tableRegionRoles.line_field_supplement') }}</option>
|
||||
</select>
|
||||
<small>{{ t('admin.shippingOrderProfiles.workbench.tableRegionRoleHint') }}</small>
|
||||
</label
|
||||
><label v-if="['header_field', 'field', 'order_field'].includes(selectedRegion.kind)"
|
||||
>{{ t("admin.shippingOrderProfiles.workbench.schemaField")
|
||||
}}<select
|
||||
|
||||
@@ -11,6 +11,8 @@ export type OrderProfileExtractorKey = 'direct' | 'temp_internal_parts' | 'quant
|
||||
export type OrderProfileEvidenceLevel = 'coordinate' | 'ocr_coordinate';
|
||||
export type OrderProfileAllowedSource = 'pdf_coordinate' | 'ocr_coordinate';
|
||||
export type OrderProfileRowReconstructionMode = 'fixed_subrows' | 'adaptive_record_columns';
|
||||
/** 主明细命中源 vs 同文档按 LN 补料号的补充表(如 COO)。 */
|
||||
export type OrderProfileTableRegionRole = 'business_lines' | 'line_field_supplement';
|
||||
export type OrderProfileChangeSource = 'wizard_created' | 'manual_save' | 'autosave' | 'restore' | 'sample_changed';
|
||||
export type OrderProfileLeaseState = 'active' | 'expired' | 'released' | 'taken_over';
|
||||
export type OrderProfileValidationRunType = 'instant_check' | 'current_sample' | 'blind_test' | 'scenario_coverage' | 'schema_compatibility' | 'layout_signature' | 'cross_template_overlap' | 'xfa_structure_signature';
|
||||
@@ -72,7 +74,26 @@ export interface OrderProfileOrderFieldLayout { layout_id: string; field_id: str
|
||||
export interface OrderProfileDraftUnboundOrderFieldLayout { layout_id: string; label: string; page_scope: 'first_page' | 'all_pages' | 'exact_page'; page_no?: number | null; anchor?: OrderProfileAnchorRule | null; value_region?: OrderProfileAnchorRelativeRegion | null; absolute_value_region?: OrderProfileRelativeRegion | null; fallback_value_region?: OrderProfileRelativeRegion | null; value_mode: 'single_line' | 'multi_line' | 'right_of_anchor' | 'below_anchor'; stop_anchors: OrderProfileAnchorRule[]; minimum_evidence_level: OrderProfileEvidenceLevel; }
|
||||
export interface OrderProfileHeaderLayout { layout_id: string; region: OrderProfileRelativeRegion; field_regions: OrderProfileFieldRegion[]; }
|
||||
export interface OrderProfileLineLayout { layout_id: string; row_offset: number; role: 'main' | 'continuation'; region: OrderProfileRelativeRegion; field_regions: OrderProfileFieldRegion[]; new_line_anchor?: OrderProfileAnchorRule | null; continuation_conditions: OrderProfileAnchorRule[]; required_fields: string[]; allowed_empty_fields: string[]; }
|
||||
export interface OrderProfileTableRegion { region_id: string; page_scope: 'first_page' | 'all_pages' | 'continuation_pages' | 'exact_page'; page_no?: number | null; region: OrderProfileRelativeRegion; /** 逻辑明细起行锚点;默认 customer_po_line_no;line_no 为可识别内部项次亦可绑定。 */ line_start_field_code?: string; /** 默认固定子行;仅显式启用时允许在同一逻辑明细内跨视觉行按列重建。 */ row_reconstruction_mode?: OrderProfileRowReconstructionMode; /** 管理员确认的视觉行结构来源;审计用途,不是字段正式值源。 */ visual_evidence_source?: 'pdf_coordinate' | 'ocr_coordinate' | 'opencv_geometry' | 'acroform_widget_geometry' | null; header_layouts: OrderProfileHeaderLayout[]; line_layouts: OrderProfileLineLayout[]; continuation_rule: { allow_cross_page: boolean; required_anchor_ids: string[] }; termination_rules: Array<{ rule_id: string; anchor: OrderProfileAnchorRule }>; exclusion_regions: OrderProfileRelativeRegion[]; draft_unbound_field_regions?: Array<{ region_id: string; parent_layout_id: string; label: string; region: OrderProfileRelativeRegion }>; }
|
||||
export interface OrderProfileTableRegion {
|
||||
region_id: string;
|
||||
page_scope: 'first_page' | 'all_pages' | 'continuation_pages' | 'exact_page';
|
||||
page_no?: number | null;
|
||||
region: OrderProfileRelativeRegion;
|
||||
/** 主明细命中源(默认)或同文档 LN 补料号补充表。 */
|
||||
region_role?: OrderProfileTableRegionRole;
|
||||
/** 逻辑明细起行锚点;默认 customer_po_line_no;line_no 为可识别内部项次亦可绑定。 */
|
||||
line_start_field_code?: string;
|
||||
/** 默认固定子行;仅显式启用时允许在同一逻辑明细内跨视觉行按列重建。 */
|
||||
row_reconstruction_mode?: OrderProfileRowReconstructionMode;
|
||||
/** 管理员确认的视觉行结构来源;审计用途,不是字段正式值源。 */
|
||||
visual_evidence_source?: 'pdf_coordinate' | 'ocr_coordinate' | 'opencv_geometry' | 'acroform_widget_geometry' | null;
|
||||
header_layouts: OrderProfileHeaderLayout[];
|
||||
line_layouts: OrderProfileLineLayout[];
|
||||
continuation_rule: { allow_cross_page: boolean; required_anchor_ids: string[] };
|
||||
termination_rules: Array<{ rule_id: string; anchor: OrderProfileAnchorRule }>;
|
||||
exclusion_regions: OrderProfileRelativeRegion[];
|
||||
draft_unbound_field_regions?: Array<{ region_id: string; parent_layout_id: string; label: string; region: OrderProfileRelativeRegion }>;
|
||||
}
|
||||
export interface OrderProfileDocumentMatch { document_type: 'purchase_order'; page_pattern: 'one_or_more'; required_anchors: OrderProfileDocumentMatchAnchor[]; optional_anchors: OrderProfileDocumentMatchAnchor[]; minimum_score: number; minimum_margin: number; }
|
||||
|
||||
/**
|
||||
@@ -968,6 +989,8 @@ export interface OrderProfileCanvasRegion {
|
||||
stopAnchorText?: string | null;
|
||||
/** 标记所属文档页;画布切页时仅渲染当前页的区域。 */
|
||||
pageNo: number;
|
||||
/** 物理行所属表区角色;补充表(如 COO)保存为 line_field_supplement。 */
|
||||
tableRegionRole?: OrderProfileTableRegionRole;
|
||||
/** datasets adapter 可附加的视觉证据确认状态,不影响共同画布区域种类。 */
|
||||
visualBindingStatus?: XfaVisualBindingStatus;
|
||||
/** 工作台待确认候选的临时视觉标记;不会进入 Profile 保存 payload。 */
|
||||
|
||||
+27
-1
@@ -18,7 +18,9 @@ const i18n = createI18n({
|
||||
title: '文档模板匹配', subtitle: '摘要', selected: '命中模板', noSelected: '未选定模板',
|
||||
expandCandidates: '查看候选模板({count})', collapseCandidates: '收起候选模板',
|
||||
routeType: '路由类型', executionMode: '执行模式',
|
||||
extractionBlocked: '模板已命中,但字段提取仍被安全门禁阻断', extractionBlockedReason: '阻断原因:{reasons}',
|
||||
extractionBlocked: '模板已命中,但字段提取仍被安全门禁阻断',
|
||||
extractionBlockedNoMatch: '模板未唯一命中,字段提取被阻断',
|
||||
extractionBlockedReason: '阻断原因:{reasons}',
|
||||
coordinateModel: {
|
||||
anchorFrame: '锚点坐标框架', status: '变换状态', translateX: '横向平移',
|
||||
translateY: '纵向平移', reasonCodes: '原因码',
|
||||
@@ -122,6 +124,30 @@ describe('ReviewProfileMatchPanel', () => {
|
||||
// 关键断言:唯一模板命中不等于字段已提取,必须明确暴露下游阻断原因。
|
||||
expect(wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text())
|
||||
.toContain('PARSE_STRATEGY_ROW_MODE_AMBIGUOUS');
|
||||
expect(wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text())
|
||||
.toContain('模板已命中');
|
||||
});
|
||||
|
||||
it('未选定模板时阻断文案不得再写模板已命中', () => {
|
||||
const wrapper = mount(ReviewProfileMatchPanel, {
|
||||
props: {
|
||||
profileMatch: {
|
||||
available: true,
|
||||
visibility: 'admin',
|
||||
status: 'evidence_insufficient',
|
||||
needs_review: true,
|
||||
selected_profile: null,
|
||||
candidates: [],
|
||||
fallback_reason_codes: ['coordinate_evidence_unavailable'],
|
||||
},
|
||||
},
|
||||
global: { plugins: [i18n] },
|
||||
});
|
||||
|
||||
const blocked = wrapper.get('[data-testid="review-profile-match-extraction-blocked"]').text();
|
||||
expect(blocked).toContain('模板未唯一命中');
|
||||
expect(blocked).not.toContain('模板已命中');
|
||||
expect(blocked).toContain('coordinate_evidence_unavailable');
|
||||
});
|
||||
|
||||
it('管理员技术详情展示锚点框架平移和稳定原因码,不展示原始正文或完整坐标', async () => {
|
||||
|
||||
@@ -43,10 +43,20 @@ const selectedCoordinateTransform = computed(() => {
|
||||
const coordinateTransformReasonCodes = computed(() => (
|
||||
selectedCoordinateTransform.value?.reason_codes || []
|
||||
));
|
||||
/** 唯一命中仅证明版式身份;下游字段/明细恢复若受门禁阻断,必须在同卡明确说明。 */
|
||||
/** 唯一命中仅证明版式身份;下游字段/明细恢复若受门禁阻断,必须在同卡明确说明。
|
||||
* 未选定模板时不得再写「模板已命中」,避免与上方「未选定模板」矛盾。 */
|
||||
const extractionBlockReasons = computed(() => (
|
||||
(props.profileMatch?.fallback_reason_codes || []).filter((code) => String(code).trim())
|
||||
));
|
||||
const hasSelectedProfile = computed(() => Boolean(
|
||||
String(props.profileMatch?.selected_profile?.profile_code || '').trim()
|
||||
|| String(props.profileMatch?.selected_profile?.display_name || '').trim(),
|
||||
));
|
||||
const extractionBlockedTitle = computed(() => (
|
||||
hasSelectedProfile.value
|
||||
? t('chat.shippingOrderReview.profileMatch.extractionBlocked')
|
||||
: t('chat.shippingOrderReview.profileMatch.extractionBlockedNoMatch')
|
||||
));
|
||||
|
||||
watch(
|
||||
() => `${props.profileMatch?.status || ''}:${props.profileMatch?.selected_profile?.profile_code || ''}:${candidateCount.value}`,
|
||||
@@ -117,7 +127,7 @@ const selectedLabel = computed(() => {
|
||||
class="mt-3 rounded-lg border border-amber-200 bg-amber-50 px-2.5 py-2 text-xs text-amber-900 dark:border-amber-900 dark:bg-amber-950/30 dark:text-amber-100"
|
||||
data-testid="review-profile-match-extraction-blocked"
|
||||
>
|
||||
<p class="font-medium">{{ t('chat.shippingOrderReview.profileMatch.extractionBlocked') }}</p>
|
||||
<p class="font-medium">{{ extractionBlockedTitle }}</p>
|
||||
<p class="mt-1 text-amber-800 dark:text-amber-200">
|
||||
{{ t('chat.shippingOrderReview.profileMatch.extractionBlockedReason', { reasons: extractionBlockReasons.join(', ') }) }}
|
||||
</p>
|
||||
|
||||
Reference in new issue
Block a user