Archived
三面拆分⑮:图只留 v4 —— 拔自动重排修回节点身份,按钮改边号+标签
用户在编辑器里手调了几何(整体右下移 10px,三条定价来路并入 x170 合流下行道, 议价回边沿左缘绕行),存出 v2–v4;令「图只留 V4 版本」。落库前查出一处大 bug: **编辑器每次改动都按几何拓扑自动重排活动编号**(renumberAll 挂 commandStack)。 卡点时代回跳不是真边、图无环,重排恰好稳定;上轮回跳成真边后图有环, 破环顺序把在座节点的 id 转圈重派 —— v4 里成本定价 id 变 A6、审批变 A4、议价变 A5 (code 显示无恙,身份已漂)。id 是节点身份:在途按它钉定义、映射按它寻址、 异常按它定位,不许因挪布局而漂移。 处置: - **拔除自动重排**:编号落子时铸定(mintNodeId 取下一空号),此后恒定; orderActivityIds / swapIdTokens 死代码删除 - **修复 v4**:id permute 回对齐编号(A4=定价 A5=审批 A6=议价),语义按种子重建 (审批 reject 声明与 reopen 标记在漂移中已损,一并复原),几何原样保留用户手调 - **外科手术**:删 v1–v3,v4 成唯一生效版;种子几何回灌 v4 手调版, 重种实证幂等(「已在库,内容未变 —— 不存新版」) - **拣选条按钮:边号 + 标签**(E4 直接定价),不再显示边方向;方向在属性卡标题里看 八例端到端真库全绿,五闸退出码全过。 Co-Authored-By: Claude Fable 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01KeDBx2PHLavbURXB8LJJ7m
This commit is contained in:
@@ -5,8 +5,8 @@
|
||||
* 无条件边作默认兜底);汇合 = 多入边异或。活动契约不带负责人岗位 —— 分派归运营。
|
||||
* 10 节点 14 边(E1–E14);审批点 A5 的两个去向就是它自己的两条条件出边(verdict 由引擎注入)。
|
||||
*
|
||||
* 几何:顺序流一律画成**真边**(卡点画法已废除,2026-07-28 第三轮),零交叉:
|
||||
* 直达与回跳各占一条车道,长线避框走 —— 见 diagram 里逐段注记。
|
||||
* 几何:顺序流一律画成**真边**(卡点画法已废除);现行几何取自设计者手调的 v4 ——
|
||||
* 三条定价来路并入 x170 合流下行道、议价回边沿左缘绕行,见 diagram 里逐段注记。
|
||||
*/
|
||||
import { processPackageSchema, triggerConfigSchema } from '@contracts';
|
||||
import type { ProcessPackage } from '@contracts';
|
||||
@@ -215,101 +215,123 @@ export const MVP_PACKAGE: ProcessPackage = processPackageSchema.parse({
|
||||
],
|
||||
variables: [],
|
||||
/*
|
||||
* 手绘几何存证 —— 呈现以它为真相。顺序流全是真边,零交叉:
|
||||
* 顶车道 y30:E3 直接寻源(A1 北口 → A3 北口,跨过 A2)
|
||||
* 带 0(y60–100) start → A1 → A2 → A3
|
||||
* E4 直接定价:A1 南口 x130 直落 A4 北口(x130 在所有横车道的左端之外)
|
||||
* 车道 y190:E6 选型后定价(A2 南口 x310 落下,西行,x160 进 A4 北口)
|
||||
* 车道 y230:E7 供应商底价表(A3 东探 x610 下行,西扫,x200 进 A4 北口)
|
||||
* 带 1(y310–350) A4 → A5 → A6 → end_won;E8/E10 在 A4–A5 缝隙里一上一下对开
|
||||
* 车道 y380:E12 有异议(A6 南口 x500 落下,西扫,x160 上顶 A4 南口)
|
||||
* E13 拒绝/超时:A6 南口 x520 下行右拐进 A7;带 2(y410+) A7 → end_arch
|
||||
* 手绘几何存证 —— 呈现以它为真相。本几何取自设计者手调的 v4(2026-07-28,
|
||||
* id 经修复对齐编号;整体较初版右下移 10px),顺序流全是真边:
|
||||
* 顶车道 y40:E3 直接寻源(A1 北口 → A3 北口,跨过 A2)
|
||||
* 带 0(y70–110) start → A1 → A2 → A3
|
||||
* 合流下行道 x170:E4 直落、E6(y210 西行)、E7(y240 西行)三条定价来路
|
||||
* 并入同一条下行道,共同扎进 A4 北口 —— 视觉即「三路汇于定价」
|
||||
* 带 1(y320–360) A4 → A5 → A6 → end_won;E8 提审 / E9 通过走缝隙 y340
|
||||
* E10 不通过:带下 y410 折返,上顶 A4 南口
|
||||
* E12 有异议:与 E13 共干(x530 下行至 y440),再沿左缘 x80 上行,进 A4 西口
|
||||
* E13 拒绝/超时:共干后右行进 A7;带 2(y420+) A7 → end_arch
|
||||
*/
|
||||
diagram: {
|
||||
manual: true,
|
||||
rows: [],
|
||||
anchors: [],
|
||||
nodes: [
|
||||
{ id: 'start', kind: 'start', label: '客户RFQ询价', x: 30, y: 70, lx: 44, ly: 104 },
|
||||
{ id: 'A1', kind: 'activity', label: '客户RFQ受理', code: 'A1', x: 110, y: 60 },
|
||||
{ id: 'A2', kind: 'activity', label: '替代选型', code: 'A2', x: 290, y: 60 },
|
||||
{ id: 'A3', kind: 'activity', label: '寻源询价', code: 'A3', x: 470, y: 60 },
|
||||
{ id: 'A4', kind: 'activity', label: '成本定价', code: 'A4', x: 110, y: 310 },
|
||||
{ id: 'A5', kind: 'activity', label: '定价审批', code: 'A5', owner: 'PM', flavor: 'approval', x: 290, y: 310 },
|
||||
{ id: 'A6', kind: 'activity', label: '报价议价', code: 'A6', x: 470, y: 310 },
|
||||
{ id: 'A7', kind: 'activity', label: '情报归档', code: 'A7', x: 630, y: 410 },
|
||||
{ id: 'end_won', kind: 'end', label: '转订单履约', x: 630, y: 320, lx: 640, ly: 352 },
|
||||
{ id: 'end_arch', kind: 'end-bad', label: '归档闭环', x: 790, y: 420, lx: 800, ly: 452 },
|
||||
{ id: 'start', kind: 'start', label: '客户RFQ询价', x: 40, y: 80, lx: 54, ly: 112 },
|
||||
{ id: 'A1', kind: 'activity', label: '客户RFQ受理', code: 'A1', x: 120, y: 70 },
|
||||
{ id: 'A2', kind: 'activity', label: '替代选型', code: 'A2', x: 300, y: 70 },
|
||||
{ id: 'A3', kind: 'activity', label: '寻源询价', code: 'A3', x: 480, y: 70 },
|
||||
{ id: 'A4', kind: 'activity', label: '成本定价', code: 'A4', x: 120, y: 320 },
|
||||
{ id: 'A5', kind: 'activity', label: '定价审批', code: 'A5', owner: 'PM', flavor: 'approval', x: 300, y: 320 },
|
||||
{ id: 'A6', kind: 'activity', label: '报价议价', code: 'A6', x: 480, y: 320 },
|
||||
{ id: 'A7', kind: 'activity', label: '情报归档', code: 'A7', x: 640, y: 420 },
|
||||
{ id: 'end_won', kind: 'end', label: '转订单履约', x: 640, y: 330, lx: 650, ly: 360 },
|
||||
{ id: 'end_arch', kind: 'end-bad', label: '归档闭环', x: 800, y: 430, lx: 810, ly: 460 },
|
||||
],
|
||||
edges: [
|
||||
{ from: 'start', to: 'A1', points: [{ x: 50, y: 80 }, { x: 110, y: 80 }] },
|
||||
{ from: 'A1', to: 'A2', label: '需要选型', points: [{ x: 210, y: 80 }, { x: 290, y: 80 }] },
|
||||
// E3 顶车道:跨过 A2 直达 A3 北口
|
||||
{ from: 'start', to: 'A1', points: [{ x: 60, y: 90 }, { x: 120, y: 90 }] },
|
||||
{ from: 'A1', to: 'A2', label: '需要选型', lx: 260, ly: 78, points: [{ x: 220, y: 90 }, { x: 300, y: 90 }] },
|
||||
{
|
||||
from: 'A1',
|
||||
to: 'A3',
|
||||
label: '直接寻源',
|
||||
lx: 350,
|
||||
ly: 28,
|
||||
points: [
|
||||
{ x: 160, y: 60 },
|
||||
{ x: 160, y: 30 },
|
||||
{ x: 520, y: 30 },
|
||||
{ x: 520, y: 60 },
|
||||
{ x: 170, y: 70 },
|
||||
{ x: 170, y: 40 },
|
||||
{ x: 530, y: 40 },
|
||||
{ x: 530, y: 70 },
|
||||
],
|
||||
},
|
||||
// E4 直落:x130 在 E6(x160 起)与 E7(x200 起)两条横车道左端之外,零交叉
|
||||
{ from: 'A1', to: 'A4', label: '直接定价', lx: 88, ly: 200, points: [{ x: 130, y: 100 }, { x: 130, y: 310 }] },
|
||||
{ from: 'A2', to: 'A3', label: '仍需寻源', points: [{ x: 390, y: 80 }, { x: 470, y: 80 }] },
|
||||
// E6 车道 y190:A2 南口下行、西行、进 A4 北口
|
||||
{ from: 'A1', to: 'A4', label: '直接定价', lx: 200, ly: 140, points: [{ x: 170, y: 110 }, { x: 170, y: 320 }] },
|
||||
{ from: 'A2', to: 'A3', label: '仍需寻源', lx: 440, ly: 78, points: [{ x: 400, y: 90 }, { x: 480, y: 90 }] },
|
||||
{
|
||||
from: 'A2',
|
||||
to: 'A4',
|
||||
label: '选型后定价',
|
||||
lx: 235,
|
||||
ly: 182,
|
||||
lx: 260,
|
||||
ly: 200,
|
||||
points: [
|
||||
{ x: 310, y: 100 },
|
||||
{ x: 310, y: 190 },
|
||||
{ x: 160, y: 190 },
|
||||
{ x: 160, y: 310 },
|
||||
{ x: 350, y: 110 },
|
||||
{ x: 350, y: 210 },
|
||||
{ x: 170, y: 210 },
|
||||
{ x: 170, y: 320 },
|
||||
],
|
||||
},
|
||||
// E7 车道 y230:A3 东探绕行(x610),在 E6 之下、A5 上行线之上零交叉扫回
|
||||
{
|
||||
from: 'A3',
|
||||
to: 'A4',
|
||||
label: '供应商底价表',
|
||||
lx: 420,
|
||||
ly: 222,
|
||||
lx: 480,
|
||||
ly: 230,
|
||||
points: [
|
||||
{ x: 570, y: 80 },
|
||||
{ x: 610, y: 80 },
|
||||
{ x: 610, y: 230 },
|
||||
{ x: 200, y: 230 },
|
||||
{ x: 200, y: 310 },
|
||||
{ x: 530, y: 110 },
|
||||
{ x: 530, y: 240 },
|
||||
{ x: 170, y: 240 },
|
||||
{ x: 170, y: 320 },
|
||||
],
|
||||
},
|
||||
// E8/E10:A4–A5 缝隙里一上一下对开(y320 提审,y340 退回)
|
||||
{ from: 'A4', to: 'A5', label: '报价草案提审', lx: 250, ly: 312, points: [{ x: 210, y: 320 }, { x: 290, y: 320 }] },
|
||||
{ from: 'A5', to: 'A6', label: '通过', tone: 'ok', points: [{ x: 390, y: 330 }, { x: 470, y: 330 }] },
|
||||
{ from: 'A5', to: 'A4', label: '不通过', tone: 'bad', lx: 250, ly: 352, points: [{ x: 290, y: 340 }, { x: 210, y: 340 }] },
|
||||
{ from: 'A6', to: 'end_won', label: '成交', tone: 'ok', points: [{ x: 570, y: 330 }, { x: 630, y: 330 }] },
|
||||
// E12 车道 y380:A6 南口西扫,上顶 A4 南口
|
||||
{ from: 'A4', to: 'A5', label: '报价草案提审', lx: 260, ly: 328, points: [{ x: 220, y: 340 }, { x: 300, y: 340 }] },
|
||||
{ from: 'A5', to: 'A6', label: '通过', tone: 'ok', lx: 440, ly: 328, points: [{ x: 400, y: 340 }, { x: 480, y: 340 }] },
|
||||
{
|
||||
from: 'A5',
|
||||
to: 'A4',
|
||||
label: '不通过',
|
||||
tone: 'bad',
|
||||
lx: 250,
|
||||
ly: 400,
|
||||
points: [
|
||||
{ x: 350, y: 360 },
|
||||
{ x: 350, y: 410 },
|
||||
{ x: 170, y: 410 },
|
||||
{ x: 170, y: 360 },
|
||||
],
|
||||
},
|
||||
{ from: 'A6', to: 'end_won', label: '成交', tone: 'ok', lx: 610, ly: 328, points: [{ x: 580, y: 340 }, { x: 640, y: 340 }] },
|
||||
{
|
||||
from: 'A6',
|
||||
to: 'A4',
|
||||
label: '有异议',
|
||||
tone: 'bad',
|
||||
lx: 330,
|
||||
ly: 372,
|
||||
lx: 350,
|
||||
ly: 428,
|
||||
points: [
|
||||
{ x: 500, y: 350 },
|
||||
{ x: 500, y: 380 },
|
||||
{ x: 160, y: 380 },
|
||||
{ x: 160, y: 350 },
|
||||
{ x: 530, y: 360 },
|
||||
{ x: 530, y: 440 },
|
||||
{ x: 80, y: 440 },
|
||||
{ x: 80, y: 340 },
|
||||
{ x: 120, y: 340 },
|
||||
],
|
||||
},
|
||||
{ from: 'A6', to: 'A7', label: '拒绝/超时', tone: 'bad', lx: 560, ly: 405, points: [{ x: 520, y: 350 }, { x: 520, y: 430 }, { x: 630, y: 430 }] },
|
||||
{ from: 'A7', to: 'end_arch', label: '归档闭环', points: [{ x: 730, y: 430 }, { x: 790, y: 430 }] },
|
||||
{
|
||||
from: 'A6',
|
||||
to: 'A7',
|
||||
label: '拒绝/超时',
|
||||
tone: 'bad',
|
||||
lx: 580,
|
||||
ly: 430,
|
||||
points: [
|
||||
{ x: 530, y: 360 },
|
||||
{ x: 530, y: 440 },
|
||||
{ x: 640, y: 440 },
|
||||
],
|
||||
},
|
||||
{ from: 'A7', to: 'end_arch', label: '归档闭环', lx: 770, ly: 428, points: [{ x: 740, y: 440 }, { x: 800, y: 440 }] },
|
||||
],
|
||||
},
|
||||
});
|
||||
|
||||
@@ -939,7 +939,7 @@ function FlowLab({
|
||||
onClick={() => { setSelEdge(selEdge === i ? null : i); setSel(null); }}
|
||||
>
|
||||
<b className="g-mono">{e.code ?? `边${i + 1}`}</b>
|
||||
{e.from}→{e.to}
|
||||
{e.label ?? ''}
|
||||
</button>
|
||||
))}
|
||||
</div>
|
||||
|
||||
@@ -38,7 +38,7 @@ import {
|
||||
type FlowNodeKind,
|
||||
type FlowTone,
|
||||
} from "./flow-layout.ts";
|
||||
import { cleanPoints, mintNodeId, orderActivityIds, seedManualGraph, snap, swapIdTokens, type OrderNode } from "./manual-flow.ts";
|
||||
import { cleanPoints, mintNodeId, seedManualGraph, snap } from "./manual-flow.ts";
|
||||
import { arrowHeadPoints, CAPTION_STYLE, FLOW_MONO, paintNode, svgEl, TONE_COLOR } from "./flow-node-paint.ts";
|
||||
|
||||
/**
|
||||
@@ -809,51 +809,14 @@ export function createFlowEditor(initial: FlowGraph | null | undefined, options:
|
||||
}
|
||||
}
|
||||
|
||||
const renumberAll = () => {
|
||||
const shapes = elementRegistry
|
||||
.getAll()
|
||||
.filter((el: Any) => el.parent && !el.waypoints && !el.labelTarget && el.businessObject?.id);
|
||||
const nodes: OrderNode[] = shapes.map((el: Any) => ({
|
||||
id: el.businessObject.id,
|
||||
kind: el.businessObject.kind,
|
||||
x: el.x + el.width / 2,
|
||||
y: el.y + el.height / 2,
|
||||
}));
|
||||
const edges = elementRegistry
|
||||
.getAll()
|
||||
.filter((el: Any) => el.waypoints && el.parent && el.source?.businessObject?.id && el.target?.businessObject?.id)
|
||||
.map((el: Any) => ({ from: el.source.businessObject.id, to: el.target.businessObject.id }));
|
||||
const mapping = orderActivityIds(nodes, edges);
|
||||
if (mapping.size === 0) return;
|
||||
const changed: Any[] = [];
|
||||
for (const el of shapes) {
|
||||
const bo = el.businessObject as FlowNode;
|
||||
let touched = false;
|
||||
if (mapping.has(bo.id)) {
|
||||
bo.id = mapping.get(bo.id)!;
|
||||
touched = true;
|
||||
}
|
||||
if (bo.to && mapping.has(bo.to)) {
|
||||
bo.to = mapping.get(bo.to)!;
|
||||
touched = true;
|
||||
}
|
||||
if (bo.basis) {
|
||||
const swapped = swapIdTokens(bo.basis, mapping);
|
||||
if (swapped !== bo.basis) {
|
||||
bo.basis = swapped;
|
||||
touched = true;
|
||||
}
|
||||
}
|
||||
if (touched) {
|
||||
changed.push(el);
|
||||
const label = labelOf(el);
|
||||
if (label) changed.push(label);
|
||||
}
|
||||
}
|
||||
if (changed.length) eventBus.fire("elements.changed", { elements: changed });
|
||||
};
|
||||
renumberAll();
|
||||
eventBus.on("commandStack.changed", renumberAll);
|
||||
/*
|
||||
* **不自动重排编号**(2026-07-28 第四轮拔除)。
|
||||
* 旧机制「几何即排序把手」在卡点时代成立 —— 回跳画成牌子,图无环,拓扑重排稳定;
|
||||
* 回跳成真边后图**有环**,破环顺序会把在座节点的 id 转圈重派(实测:成本定价
|
||||
* A4→A6、审批 A4、议价 A5),而 id 是**节点身份**:在途工作流按它钉定义、
|
||||
* 边映射按它寻址、异常按它定位 —— 身份不许因挪动布局而漂移。
|
||||
* 编号在落子时铸定(mintNodeId 取下一个空号),此后恒定;想换号,删了重画。
|
||||
*/
|
||||
|
||||
const serialize = (): { graph: FlowGraph; idMap: Record<string, string> } => {
|
||||
// 画布是无限域(可有负坐标)——先求整体包围,统一平移到非负(保相对几何/正交),再吸附珊格。
|
||||
|
||||
@@ -133,84 +133,7 @@ const ID_PREFIX: Partial<Record<FlowNodeKind, string>> = {
|
||||
|
||||
/* ---- 活动自动顺序编号:沿流向拓扑序,几何 (y,x) 决胜 ---- */
|
||||
|
||||
export interface OrderNode {
|
||||
id: string;
|
||||
kind: FlowNodeKind;
|
||||
/** 节点中心(决胜用)。 */
|
||||
x: number;
|
||||
y: number;
|
||||
}
|
||||
|
||||
/**
|
||||
* 计算活动的规范编号 A1..An:从入度 0 的节点(起始)沿连线做拓扑遍历,
|
||||
* 同时就绪者按 (y,x) 取先(上面的先、左边的先)——汇合点等所有来路编号完才轮到,
|
||||
* 所以网关分支链先占号、汇后主线随后,与剧本世界的编号纪律同构;
|
||||
* 几何即排序把手:想换号,挪节点。环用 (剩余入度,y,x) 最小者破;
|
||||
* 不可达的活动排在最后。只返回**有变化**的 旧id→新id 映射。
|
||||
*/
|
||||
export function orderActivityIds(nodes: OrderNode[], edges: Array<{ from: string; to: string }>): Map<string, string> {
|
||||
const byId = new Map(nodes.map((n) => [n.id, n]));
|
||||
const indeg = new Map<string, number>(nodes.map((n) => [n.id, 0]));
|
||||
const out = new Map<string, string[]>();
|
||||
for (const e of edges) {
|
||||
if (!byId.has(e.from) || !byId.has(e.to) || e.from === e.to) continue;
|
||||
out.set(e.from, [...(out.get(e.from) ?? []), e.to]);
|
||||
indeg.set(e.to, (indeg.get(e.to) ?? 0) + 1);
|
||||
}
|
||||
const geo = (id: string): [number, number] => {
|
||||
const n = byId.get(id)!;
|
||||
return [n.y, n.x];
|
||||
};
|
||||
const byGeo = (a: string, b: string) => geo(a)[0] - geo(b)[0] || geo(a)[1] - geo(b)[1];
|
||||
|
||||
const visited = new Set<string>();
|
||||
const ready = new Set<string>(nodes.filter((n) => (indeg.get(n.id) ?? 0) === 0).map((n) => n.id));
|
||||
const mapping = new Map<string, string>();
|
||||
let seq = 0;
|
||||
|
||||
const visit = (id: string) => {
|
||||
visited.add(id);
|
||||
ready.delete(id);
|
||||
const node = byId.get(id)!;
|
||||
if (node.kind === "activity") mapping.set(id, `A${++seq}`);
|
||||
for (const t of out.get(id) ?? []) {
|
||||
indeg.set(t, (indeg.get(t) ?? 1) - 1);
|
||||
if ((indeg.get(t) ?? 0) <= 0 && !visited.has(t)) ready.add(t);
|
||||
}
|
||||
};
|
||||
|
||||
while (visited.size < nodes.length) {
|
||||
const candidates = [...ready].filter((id) => !visited.has(id));
|
||||
if (candidates.length > 0) {
|
||||
visit(candidates.sort(byGeo)[0]!);
|
||||
} else {
|
||||
// 环/汇合死锁:挑未访问中 (剩余入度, y, x) 最小者破环。
|
||||
const rest = nodes.filter((n) => !visited.has(n.id)).map((n) => n.id);
|
||||
rest.sort((a, b) => (indeg.get(a) ?? 0) - (indeg.get(b) ?? 0) || byGeo(a, b));
|
||||
visit(rest[0]!);
|
||||
}
|
||||
}
|
||||
|
||||
for (const [oldId, newId] of [...mapping]) {
|
||||
if (oldId === newId) mapping.delete(oldId);
|
||||
}
|
||||
return mapping;
|
||||
}
|
||||
|
||||
/** 文本里的 id 引用按映射换号:占位符两段式(防级联),长 id 先换(防 A10 被 A1 误伤)。 */
|
||||
export function swapIdTokens(text: string, mapping: ReadonlyMap<string, string>): string {
|
||||
const pairs = [...mapping.entries()].filter(([from, to]) => from !== to).sort((a, b) => b[0].length - a[0].length);
|
||||
let outText = text;
|
||||
pairs.forEach(([from], i) => {
|
||||
outText = outText.split(from).join(`⟦${i}⟧`);
|
||||
});
|
||||
pairs.forEach(([, to], i) => {
|
||||
outText = outText.split(`⟦${i}⟧`).join(to);
|
||||
});
|
||||
return outText;
|
||||
}
|
||||
|
||||
/** 铸新编号:前缀取未用最小号;起/止先用 S/E,再 S2/E2…;避开 reserved(下钻 operations 键)。 */
|
||||
export function mintNodeId(kind: FlowNodeKind, graph: FlowGraph, reserved: ReadonlySet<string>): string {
|
||||
const used = new Set([...graph.nodes.map((n) => n.id), ...reserved]);
|
||||
if (kind === "start" || kind === "end") {
|
||||
|
||||
Reference in New Issue
Block a user