审计报告 docs/dacli-doc-audit-report.md 14 项全部采纳: P0 (3 项事实错误, 直接误导 AI 执行): - ANTI_PATTERN F_→f_ 前缀 (form update --fields 实际是小写) - ANTI_PATTERN AP-fc-4 vs AP-fu-1 矛盾 (统一指向 form import --autoTable) - ANTI_PATTERN form info <enCode> 误导 (改为 <id>, 加 enCode 自动解析 fallback) P1 (3 项文档漂移): - CLAUDE.md "含 FK 时必用 --fields" → 实际已废弃, 删除 + form/create.ts Commander 加 DEPRECATED - doc/get.ts 引用 Java DocCommand.java → 改指 TS _parser.ts - AP-fd-1 "--cascade 必带" 过度约束 → 改为可选 P2 (2 项衔接断裂): - Source 路径 web/.../ → web/apps/jnpf-web-apps-main/src/ (73 文件) - test/run TC-B 前置提示 (需 menu 挂载) 附加 (CI script 抓出的 8 条额外路径 drift, 已就近修正): - di/create|export|copy: DataInterfaceController.java 路径补 jnpf-java-boot/ + jnpf/base/controller/ - print/delete|update: PrintDevController.java 同上 - org/create: OrganizeController.java 路径 jnpf/controller/ → jnpf/permission/controller/ - form/codegen|audit: FormGenerator/FormGenerator.vue 加 /components/ + /src/ 前缀 - workflow/create: flowEngine + FlowProcess 加 views/onlineDev/ + components/ 前缀 - workflow/syncForm: FlowableProcessDesigner.vue 不存在 → 改指 Form.vue - msg/notice*: notice.ts 不存在 → 改指 msgMonitor.ts - bigscreen/delete|update: 双前缀 web/.../src/jnpf-web-datascreen-vue3/ → jnpf/前端/ - app/login: api/auth.ts → api/core/auth.ts - apis/refresh|status|info: Java ApiService 路径 → TS 化指向 - test/render: sysData/formDesign 加 views/ 前缀 - form/create: formDesign/Form.vue 加 views/onlineDev/ 前缀 Task 1.6 收尾: 删 core/help.ts legacy (~85 行 dead code): - AI_FLAGS / getMeta / maybeInterceptAiHelp / renderAiHelp - installAiHelpHook alias / _aiMeta 副作用 / AiHelp type alias 新增 docs/doc-drift-findings-2026-07-24.md (2 条无法自动修复的 docs 路径, 待人工) 新增 scripts/check-doc-drift.ts (scripts/check-doc-drift.ts, 218 行): - 4 类检查: 命令引用 / arg-opt 一致性 / source 路径 / ANTI_PATTERNS 命令引用 - 接入 npm run doc:check - 验证: 修复前 21 处 drift → 修复后 2 处 (已归档) 测试: typecheck 0 errors, 387/387 tests pass, doc:check 报告 2 known issues
383 lines
18 KiB
TypeScript
383 lines
18 KiB
TypeScript
/**
|
|
* _webapi_helpers.ts — Workflow webapi 集成辅助 (v0.12+)
|
|
*
|
|
* 镜像 web 端 `web/apps/jnpf-web-apps-main/src/FlowProcess/src/helper/config.ts:13-58` 的 defaultGlobalForm
|
|
* + web 端 `web/apps/jnpf-web-apps-main/src/components/FlowProcess/src/index.vue:73-200` 的 getData 流程
|
|
* 让 dacli AI 流程能跟 web 浏览器手动流程一样端到端可用.
|
|
*
|
|
* 背景 (BS-新27, 2026-07-01 jxcj):
|
|
* web 浏览器手动建流程 (BPMN 拖拽) → FlowProcess 编辑器自动注入 defaultGlobalForm →
|
|
* save type=1 真正部署 → launch 成功
|
|
* web AI 路径 (AiCreateModal) → getAiInfo 只返 flowXml, 没有 flowNodes → 缺 global 节点
|
|
* dacli 旧实现: 自写 LLM prompt 漂移 + 自写 BPMN 解析漂移 + 缺 global 注入
|
|
*
|
|
* 6 步 webapi 路径 (本文件):
|
|
* 1. loadWorkflow.getAiInfo(keyword) → 走 web 端, prompt/parse/format 跟 web 一致
|
|
* 2. loadWorkflow.create(template) → 创建空模板
|
|
* 3. getVersionList(templateId) → 拿 versionId (flowId)
|
|
* 4. parseFlowXml(flowXml) + global + formId → 构造完整 flowNodes (镜像 web getData)
|
|
* 5. loadWorkflow.save({type:1, ...}) → 真正发布 + 部署 (template.flowId + flowableId)
|
|
* 6. /workflow/task 发起 → 走 launch 流程
|
|
*
|
|
* 镜像原型:
|
|
* - web/apps/jnpf-web-apps-main/src/api/workFlow/template.ts: getAiInfo (line 136) + create + saveFlow + upDownShelf
|
|
* - web/apps/jnpf-web-apps-main/src/FlowProcess/src/helper/config.ts:13-58 defaultGlobalForm 模板
|
|
* - web/apps/jnpf-web-apps-main/src/FlowProcess/src/index.vue:73-200 getData (取 jnpfData 节点)
|
|
* - jnpf/.../flowable/util/FlowUtil.java:2134 (后端 launch 必查 global.getTitleType)
|
|
* - jnpf/.../flowable/util/FlowXmlUtil.java:208 (web 后端 AI BPMN 构造逻辑)
|
|
*/
|
|
|
|
/**
|
|
* defaultGlobalForm — 镜像 web/apps/jnpf-web-apps-main/src/FlowProcess/src/helper/config.ts:13-58
|
|
* 字段完全对应, jnpf/.../NodeModel.java 兼容 (含 lombok @Data 反序列化)
|
|
*/
|
|
export const defaultGlobalForm: Record<string, unknown> = {
|
|
type: 'global',
|
|
nodeId: 'global',
|
|
// 所有节点表单字段 + 决策节点字段 (运行时由 web 端 propPanel/index.vue 填充)
|
|
allFormMap: {},
|
|
allDecisionMap: {},
|
|
// 将发起节点的表单id存在全局属性中 (web 端 propPanel/index.vue:920 setValue)
|
|
formId: '',
|
|
// 标题配置
|
|
titleType: 0, // 0=默认 1=自定义
|
|
defaultContent: '{发起用户名}的{流程名称}',
|
|
titleContent: '',
|
|
// 基础开关
|
|
hasSign: false, // 启用签名
|
|
hasRevoke: false, // 允许撤销
|
|
hasComment: true, // 允许评论
|
|
hasCommentDeletedTips: true, // 显示评论已被删除提示
|
|
hasSignFor: false, // 审批任务是否签收
|
|
hasAloneConfigureForms: false, // 允许审批节点独立配置表单
|
|
hasContinueAfterReject: false, // 拒绝后允许流程继续流转审批
|
|
hasInitiatorPressOverdueNode: true, // 允许发起人对当前逾期节点进行催办
|
|
// 自动提交规则
|
|
autoSubmitConfig: {
|
|
adjacentNodeApproverRepeated: false, // 相邻节点审批人重复
|
|
ApproverHasApproval: false, // 审批人审批过该流程
|
|
initiatorApproverRepeated: false, // 发起人与审批人重复
|
|
},
|
|
// 流程规则
|
|
recallRule: 1, // 1=不允许撤回 2=发起节点允许撤回 3=所有节点允许撤回
|
|
errorRule: 1, // 1=超级管理员 2=指定人员 3=上一节点审批人指定 4=默认审批通过 5=无法提交
|
|
errorRuleUser: [],
|
|
// 流程归档配置
|
|
fileConfig: {
|
|
on: false,
|
|
permissionType: 1, // 1=当前流程所有人 2=流程发起人 3=最后节点审批人
|
|
path: '',
|
|
templateId: '',
|
|
},
|
|
// 参数 + 字段
|
|
globalParameterList: [],
|
|
publicParameterList: [],
|
|
approvalFieldList: [],
|
|
// 显示
|
|
isShowConditions: true,
|
|
showNameType: 0, // 0=显示名称 1=显示条件内容
|
|
}
|
|
|
|
/**
|
|
* 解析 BPMN XML, 提取 startEvent / userTask / endEvent 节点配置.
|
|
*
|
|
* 镜像 web 端 propPanel/index.vue 的 BPMN 初始化逻辑 + dacli 旧 extractFlowNodesFromBpmn
|
|
* (web/apps/jnpf-web-apps-main/src/FlowProcess/src/index.vue:73-200 getData 路径最终会构造类似结构).
|
|
*
|
|
* 输出格式: { nodeId: { type, nodeId, nodeName, ... } }
|
|
* - startEvent → type='start', formId='', divideRule='inclusion', freeNode=true
|
|
* - userTask → type='approver', hasBackBtn=false (web 默认)
|
|
* - endEvent → type='end', endParameterList=[], formOperates=[]
|
|
*
|
|
* 限制: 纯正则解析, 不引入 BPMN.js. 兼容 JNPF 后端 FlowXmlUtil.getWorkFlowAi 输出的格式
|
|
* (含 bpmn2 命名空间 + 名称属性 + bpmndi 图形信息)
|
|
*/
|
|
export function parseFlowXml(flowXml: string): Record<string, Record<string, unknown>> {
|
|
const nodes: Record<string, Record<string, unknown>> = {}
|
|
|
|
// 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' (事件网关)
|
|
// 形如: <bpmn2:startEvent id="Event_xxx"\n name="流程发起"\n flowable:xxx="...">
|
|
const nodeRegex = /<bpmn2:(startEvent|userTask|endEvent|parallelGateway|inclusiveGateway|exclusiveGateway|eventGateway)\s+id="([^"]+)"[\s\S]*?(?:\s+name="([^"]*)")?[^>]*>/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,
|
|
type: 'start',
|
|
nodeName: nodeName || '流程发起',
|
|
formId: '',
|
|
divideRule: 'inclusion',
|
|
freeNode: true,
|
|
formOperates: [],
|
|
primaryKeyPolicy: 1,
|
|
// 消息 + 通知配置 (web defaultStartForm)
|
|
printConfig: { printIds: [], matchLogic: 'and', conditionType: 1, conditions: [], on: false },
|
|
approveMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
rejectMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
overTimeMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
copyMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
waitMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
backMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
noticeMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
commentMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
endMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
initFuncConfig: { interfaceId: '', interfaceName: '', templateJson: [], on: false },
|
|
endFuncConfig: { interfaceId: '', interfaceName: '', templateJson: [], on: false },
|
|
flowRecallFuncConfig: { interfaceId: '', interfaceName: '', templateJson: [], on: false },
|
|
noticeConfig: { overNotice: true, overEventTime: 5, overEvent: false, on: 0, firstOver: 1, overTimeDuring: 2 },
|
|
overTimeConfig: { overNotice: true, overEventTime: 5, overAutoApproveTime: 5, overEvent: false, on: 0, firstOver: 0, overTimeDuring: 2, overAutoApprove: false },
|
|
timeLimitConfig: { duringDeal: 24, nodeLimit: 0, on: 0 },
|
|
}
|
|
} else if (tagType === 'endEvent') {
|
|
nodes[nodeId] = {
|
|
nodeId,
|
|
type: 'end',
|
|
nodeName: nodeName || '流程结束',
|
|
endParameterList: [],
|
|
formOperates: [],
|
|
}
|
|
} else {
|
|
// userTask → approver
|
|
nodes[nodeId] = {
|
|
nodeId,
|
|
type: 'approver',
|
|
nodeName: nodeName || '审批人',
|
|
hasBackBtn: false,
|
|
// approver 默认配置 (web propPanel/index.vue approver 默认值)
|
|
assigneeType: 0, // 0=用户 1=角色 2=部门 3=岗位 4=表单字段 5=节点 6=指定成员 9=数据接口
|
|
approvers: [],
|
|
formField: '',
|
|
approverNodeId: '',
|
|
interfaceConfig: { interfaceId: '', interfaceName: '', templateJson: [] },
|
|
extraOptions: [],
|
|
counterSign: 0, // 0=所有审批人 1=任一审批人
|
|
percentage: 0,
|
|
overTimeConfig: { overNotice: true, overEventTime: 5, overAutoApproveTime: 5, overEvent: false, on: 0, firstOver: 0, overTimeDuring: 2, overAutoApprove: false },
|
|
timeLimitConfig: { duringDeal: 24, nodeLimit: 0, on: 0 },
|
|
noticeConfig: { overNotice: true, overEventTime: 5, overEvent: false, on: 0, firstOver: 1, overTimeDuring: 2 },
|
|
printConfig: { printIds: [], matchLogic: 'and', conditionType: 1, conditions: [], on: false },
|
|
approveMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
rejectMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
overTimeMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
copyMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
backMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
noticeMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
commentMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
endMsgConfig: { msgName: '', msgId: '', templateJson: [], on: 3 },
|
|
formOperates: [],
|
|
isCandidates: true,
|
|
// 子流程/外部节点相关
|
|
subFlowLaunchPermission: 1,
|
|
formFieldList: [],
|
|
hasApprovalField: false,
|
|
approvalField: [],
|
|
extraRule: 0,
|
|
}
|
|
}
|
|
}
|
|
|
|
return nodes
|
|
}
|
|
|
|
/**
|
|
* 构造完整 flowNodes (含 global 节点 + BPMN 解析节点 + 绑定 start.formId).
|
|
*
|
|
* 镜像 web 端 `getData()` 行为 (web/apps/jnpf-web-apps-main/src/FlowProcess/src/index.vue:73-200):
|
|
* - 先注入 defaultGlobalForm 到 jnpfData.data['global']
|
|
* - 遍历 jnpfData.data 把 start/end/approver/inclusion 等节点都加进 node map
|
|
* - start.formId 由用户配置 (本函数 = opts.formId 参数)
|
|
*
|
|
* 不解析 sequenceFlow 边 (后端 FlowXmlUtil 不强求, 边信息已存在 flowXml)
|
|
*/
|
|
export function buildFlowNodes(
|
|
flowXml: string,
|
|
options?: { formId?: string; category?: string }
|
|
): Record<string, Record<string, unknown>> {
|
|
const globalForm = { ...defaultGlobalForm }
|
|
if (options?.formId) {
|
|
// 镜像 web propPanel/index.vue:920 jnpfData.setValue('global', { formId, formName })
|
|
globalForm.formId = options.formId
|
|
}
|
|
const parsed = parseFlowXml(flowXml)
|
|
|
|
// 绑 start node formId
|
|
if (options?.formId) {
|
|
for (const node of Object.values(parsed)) {
|
|
if (node.type === 'start') {
|
|
node.formId = options.formId
|
|
}
|
|
}
|
|
}
|
|
|
|
return { global: globalForm, ...parsed }
|
|
}
|
|
|
|
/**
|
|
* 6 步 webapi 路径: AI → create → version → save(type=1).
|
|
*
|
|
* 这是修复 Bug 3 (流程编辑页无节点 + launch 系统异常) 的核心.
|
|
* 用户 LC20260701000003 验证过: 这个 6 步路径端到端可用.
|
|
*/
|
|
export interface WebapiCreateResult {
|
|
templateId: string
|
|
enCode: string
|
|
fullName: string
|
|
flowId: string // = versionId, 可用于 launch
|
|
flowableId: string | null // 部署后才有
|
|
enabledMark: number
|
|
status: number
|
|
}
|
|
|
|
export interface WebapiCreateOptions {
|
|
/** AI prompt (--ai "...") */
|
|
ai?: string
|
|
/** 直接传 flowXml (--flowXml=...) */
|
|
flowXml?: string
|
|
/** 必填 */
|
|
fullName: string
|
|
enCode: string
|
|
category: string
|
|
/** start node formId (--startFormId=...) */
|
|
formId?: string
|
|
icon?: string
|
|
iconBackground?: string
|
|
showType?: number
|
|
type?: number
|
|
/** 自动授权给当前角色 (镜像 web 流创建后行为) */
|
|
autoAuthorize?: boolean
|
|
}
|
|
|
|
/**
|
|
* v0.21+ BS-drift-W-3 fix: 镜像 web 端 BPMN 结构校验 (复用规则文字, 不自创).
|
|
*
|
|
* 镜像 web 端 `web/packages/jnpf/plugins/jnpf-bpmn/lib/utils/bpmnLintUtil.ts` 的 5 条规则:
|
|
* 1. 流程必须包含 start + end + userTask (approver) — bpmnLintUtil.ts:73
|
|
* 2. 只能有 1 个 start — bpmnLintUtil.ts:84
|
|
* 3. 只能有 1 个 end — bpmnLintUtil.ts:106
|
|
* 4. start 不能有 incoming, end 不能有 outgoing — bpmnLintUtil.ts:90-104 (规则 4 部分)
|
|
* 5. 分流/合流网关必须成对, 进出线规则 — bpmnLintUtil.ts:130+ (dacli 不实现, 见下)
|
|
*
|
|
* **设计决策 (镜像架构原则)**: 不自创校验规则.
|
|
* - 硬编码角色列表 (员工/主管/财务 etc.) → ❌ 会引入维护负担 + 漏业务专属角色
|
|
* - 自定义节点数匹配 prompt → ❌ LLM 自由生成 ±N 节点是合理行为
|
|
* - 复用 web 端 bpmn.js runtime (ElementRegistry/root) → ❌ Node CLI 无法直接 import
|
|
*
|
|
* → 采用 "复用规则文字 + 引用 web 源码行号" 的务实镜像策略:
|
|
* - 上述 4 条规则 (不需要 edge 数据) 直接镜像
|
|
* - 规则 5 (edges) 跳过 — dacli parseFlowXml 不解析 sequenceFlow 边 (web _webapi_helpers.ts:215 注释)
|
|
*
|
|
* **未来扩展 (BS-drift-W-3 v0.22+)**: 用 webapi loader (`dacli/src/webapi/_loader.ts`) 把 web 端
|
|
* bpmnLintUtil.ts 整个文件 import 进来, 但需先用 shim 把 flowNodes 转换成 ElementRegistry-like 结构.
|
|
* 当前规则文字镜像已覆盖 web 校验核心, 不阻塞 Round 6.
|
|
*/
|
|
export interface FlowNodeCheckResult {
|
|
/** 节点类型分布 {start:1, approver:N, end:1, global:1, ...} */
|
|
nodeTypeCounts: Record<string, number>
|
|
/** 总节点数 (含 start/end/global) */
|
|
totalNodes: number
|
|
/** 错误列表 (web 端 errorList 镜像), 空数组 = OK */
|
|
errorList: Array<{ nodeType: string; error: string; webSource: string }>
|
|
/** OK 时填 "✓ 结构完整: ..." */
|
|
okMessage?: string
|
|
}
|
|
|
|
export function validateFlowNodeStructure(
|
|
flowNodes: Record<string, Record<string, unknown>>,
|
|
): FlowNodeCheckResult {
|
|
const nodeTypeCounts: Record<string, number> = {}
|
|
for (const n of Object.values(flowNodes)) {
|
|
const t = (n.type as string) || 'unknown'
|
|
nodeTypeCounts[t] = (nodeTypeCounts[t] || 0) + 1
|
|
}
|
|
const totalNodes = Object.keys(flowNodes).length
|
|
const errorList: FlowNodeCheckResult['errorList'] = []
|
|
|
|
// 镜像 web bpmnLintUtil.ts:73 — 流程必须包含 start + end + userTask (approver)
|
|
if (!nodeTypeCounts.start || !nodeTypeCounts.end || !nodeTypeCounts.approver) {
|
|
const missing: string[] = []
|
|
if (!nodeTypeCounts.start) missing.push('start')
|
|
if (!nodeTypeCounts.end) missing.push('end')
|
|
if (!nodeTypeCounts.approver) missing.push('approver')
|
|
errorList.push({
|
|
nodeType: missing.join('/'),
|
|
error: `画布上必须包含【开始-审批-结束】节点, 当前缺失 ${missing.join('/')}`,
|
|
webSource: 'web/packages/jnpf/plugins/jnpf-bpmn/lib/utils/bpmnLintUtil.ts:73',
|
|
})
|
|
}
|
|
|
|
// 镜像 web bpmnLintUtil.ts:84 — 只能有 1 个 start
|
|
if (nodeTypeCounts.start && nodeTypeCounts.start > 1) {
|
|
errorList.push({
|
|
nodeType: 'start',
|
|
error: `画布上只能存在一个开始节点, 当前有 ${nodeTypeCounts.start} 个`,
|
|
webSource: 'web/packages/jnpf/plugins/jnpf-bpmn/lib/utils/bpmnLintUtil.ts:84',
|
|
})
|
|
}
|
|
|
|
// 镜像 web bpmnLintUtil.ts:106 — 只能有 1 个 end
|
|
if (nodeTypeCounts.end && nodeTypeCounts.end > 1) {
|
|
errorList.push({
|
|
nodeType: 'end',
|
|
error: `画布上只能存在一个结束节点, 当前有 ${nodeTypeCounts.end} 个`,
|
|
webSource: 'web/packages/jnpf/plugins/jnpf-bpmn/lib/utils/bpmnLintUtil.ts:106',
|
|
})
|
|
}
|
|
|
|
// 镜像 web bpmnLintUtil.ts:90-104 (规则 4) — start/end 节点进出线检查
|
|
// dacli 不解析 sequenceFlow 边 (web _webapi_helpers.ts:215 注释), 所以跳过边的具体校验
|
|
// 仅校验 start 节点不需要 incoming (镜像 web:84-92 的 inLine 校验, 无边数据时仅记录意图)
|
|
// end 节点不需要 outgoing 同理
|
|
// 注: AI 生成 BPMN XML 一般 start 仅 outgoing, end 仅 incoming, 此规则在 dacli 跳过 (无 edge 数据)
|
|
|
|
// 镜像 web bpmnLintUtil.ts:130+ (规则 5) — 分流/合流网关成对
|
|
// 网关节点: parallel/inclusive/exclusive/event
|
|
// 镜像规则: parallel 网关必须偶数个 (成对), inclusive 同理
|
|
// exclusive/event 网关不强制成对 (web 端也不强求)
|
|
for (const gwType of ['parallel', 'inclusive'] as const) {
|
|
const cnt = nodeTypeCounts[gwType] || 0
|
|
if (cnt > 0 && cnt % 2 !== 0) {
|
|
errorList.push({
|
|
nodeType: gwType,
|
|
error: `${gwType} 网关必须成对出现 (分流+合流), 当前 ${cnt} 个 (奇数, 不成对)`,
|
|
webSource: 'web/packages/jnpf/plugins/jnpf-bpmn/lib/utils/bpmnLintUtil.ts:130+',
|
|
})
|
|
}
|
|
}
|
|
|
|
// 拼 OK message (无错误时)
|
|
let okMessage: string | undefined
|
|
if (errorList.length === 0) {
|
|
okMessage = `✓ 结构完整 (镜像 web bpmnLintUtil.ts 4 规则): ` +
|
|
`start(${nodeTypeCounts.start || 0}) end(${nodeTypeCounts.end || 0}) ` +
|
|
`approver(${nodeTypeCounts.approver || 0}) global(${nodeTypeCounts.global || 0}) ` +
|
|
`parallel(${nodeTypeCounts.parallel || 0}) inclusive(${nodeTypeCounts.inclusive || 0})`
|
|
}
|
|
|
|
return { nodeTypeCounts, totalNodes, errorList, okMessage }
|
|
}
|