From cfd1fa9211e48309879b304c65bdc1f62bfbd97e Mon Sep 17 00:00:00 2001 From: ssw Date: Thu, 2 Jul 2026 12:20:42 +0800 Subject: [PATCH] =?UTF-8?q?P1-6=20=E4=BF=AE=E5=A4=8D:=20workflow=20parseFl?= =?UTF-8?q?owXml=20=E8=B7=A8=E8=A1=8C=E5=8C=B9=E9=85=8D=20+=204=20?= =?UTF-8?q?=E7=A7=8D=20gateway=20=E8=8A=82=E7=82=B9=20(2026-07-02)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit FINDING-F3: parseFlowXml 解析不完整 - 单行正则 \s+ 不匹配跨行 id 属性 → JNPF FlowXmlUtil 输出带换行缩进时漏解析 - 不匹配 parallelGateway/inclusiveGateway/exclusiveGateway/eventGateway - 复杂流程 (含条件分支) 网关节点全丢, launch 条件路由失效 修复: - 正则改 [\s\S]*? 跨行匹配 - 加 4 种 gateway 节点 (parallel/inclusive/exclusive/event) - 类型映射: parallelGateway → type='parallel', inclusiveGateway → 'inclusive', etc. testspace 验证 (3 单元测试): - Test 1 单行 BPMN: 3 nodes (start + task + end) ✓ - Test 2 跨行 BPMN: 2 nodes (旧版 0) ✓ - Test 3 含网关: 6 nodes (旧版 4, 漏 g1/g2) ✓ - 网关类型映射: exclusive/parallel 正确 ✓ 审计: dacli/docs/cmd-review/v0.14-rollout-audit-2026-07-02.md §4.1 F3 --- src/commands/workflow/_webapi_helpers.ts | 30 +++++++++++++++++++++--- 1 file changed, 27 insertions(+), 3 deletions(-) diff --git a/src/commands/workflow/_webapi_helpers.ts b/src/commands/workflow/_webapi_helpers.ts index e7ca83b..01dda33 100644 --- a/src/commands/workflow/_webapi_helpers.ts +++ b/src/commands/workflow/_webapi_helpers.ts @@ -95,12 +95,36 @@ export const defaultGlobalForm: Record = { export function parseFlowXml(flowXml: string): Record> { const nodes: Record> = {} - // 匹配 bpmn2:startEvent / userTask / endEvent 节点 - // 形如: - const nodeRegex = /]*>/g + // v0.15+ (P1-6): 跨行匹配 + 加 4 种 gateway 节点 + // 旧版 [\s\S]*? 改 [\s\S]* (单行) → 跨行也匹配 (JNPF FlowXmlUtil 输出 BPMN 经常带换行缩进) + // 旧版仅 startEvent|userTask|endEvent → 加 parallelGateway/inclusiveGateway/exclusiveGateway/eventGateway + // 网关节点类型: 'gateway' (web FlowXmlUtil 不细分, 后端 save 时 flowable 启动器按 type 区分) + // parallelGateway → type='parallel' (并行, 全部通过) + // inclusiveGateway → type='inclusive' (包容, 至少一个) + // exclusiveGateway → type='exclusive' (排他, 唯一一个) + // eventGateway → type='event' (事件网关) + // 形如: + const nodeRegex = /]*>/g let match: RegExpExecArray | null while ((match = nodeRegex.exec(flowXml)) !== null) { const [, tagType, nodeId, nodeName = ''] = match + // 网关节点特殊处理 (P1-6) + if (tagType === 'parallelGateway') { + nodes[nodeId] = { nodeId, type: 'parallel', nodeName: nodeName || '并行网关' } + continue + } + if (tagType === 'inclusiveGateway') { + nodes[nodeId] = { nodeId, type: 'inclusive', nodeName: nodeName || '包容网关' } + continue + } + if (tagType === 'exclusiveGateway') { + nodes[nodeId] = { nodeId, type: 'exclusive', nodeName: nodeName || '排他网关' } + continue + } + if (tagType === 'eventGateway') { + nodes[nodeId] = { nodeId, type: 'event', nodeName: nodeName || '事件网关' } + continue + } if (tagType === 'startEvent') { nodes[nodeId] = { nodeId,