Commit 7cf55c5300bdf026ad042525b14eded6fa04a3bc
1 parent
e5aede62
fix: 添加节点类型以区分不同节点
Showing
4 changed files
with
30 additions
and
2 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java
| @@ -129,4 +129,9 @@ public interface BpmnModelConstants { | @@ -129,4 +129,9 @@ public interface BpmnModelConstants { | ||
| 129 | */ | 129 | */ |
| 130 | String REASON_REQUIRE = "reasonRequire"; | 130 | String REASON_REQUIRE = "reasonRequire"; |
| 131 | 131 | ||
| 132 | + /** | ||
| 133 | + * 节点类型 | ||
| 134 | + */ | ||
| 135 | + String NODE_TYPE = "nodeType"; | ||
| 136 | + | ||
| 132 | } | 137 | } |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
| @@ -410,6 +410,26 @@ public class BpmnModelUtils { | @@ -410,6 +410,26 @@ public class BpmnModelUtils { | ||
| 410 | return parseExtensionElement(flowElement, TRIGGER_PARAM); | 410 | return parseExtensionElement(flowElement, TRIGGER_PARAM); |
| 411 | } | 411 | } |
| 412 | 412 | ||
| 413 | + /** | ||
| 414 | + * 给节点添加节点类型 | ||
| 415 | + * | ||
| 416 | + * @param nodeType 节点类型 | ||
| 417 | + * @param flowElement 节点 | ||
| 418 | + */ | ||
| 419 | + public static void addNodeType(Integer nodeType, FlowElement flowElement) { | ||
| 420 | + addExtensionElement(flowElement, BpmnModelConstants.NODE_TYPE, nodeType); | ||
| 421 | + } | ||
| 422 | + | ||
| 423 | + /** | ||
| 424 | + * 解析节点类型 | ||
| 425 | + * | ||
| 426 | + * @param flowElement 节点 | ||
| 427 | + * @return 节点类型 | ||
| 428 | + */ | ||
| 429 | + public static Integer parseNodeType(FlowElement flowElement) { | ||
| 430 | + return NumberUtils.parseInt(parseExtensionElement(flowElement, BpmnModelConstants.NODE_TYPE)); | ||
| 431 | + } | ||
| 432 | + | ||
| 413 | // ========== BPM 简单查找相关的方法 ========== | 433 | // ========== BPM 简单查找相关的方法 ========== |
| 414 | 434 | ||
| 415 | /** | 435 | /** |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| @@ -445,6 +445,8 @@ public class SimpleModelUtils { | @@ -445,6 +445,8 @@ public class SimpleModelUtils { | ||
| 445 | addSignEnable(node.getSignEnable(), userTask); | 445 | addSignEnable(node.getSignEnable(), userTask); |
| 446 | // 审批意见 | 446 | // 审批意见 |
| 447 | addReasonRequire(node.getReasonRequire(), userTask); | 447 | addReasonRequire(node.getReasonRequire(), userTask); |
| 448 | + // 节点类型 | ||
| 449 | + addNodeType(node.getType(), userTask); | ||
| 448 | return userTask; | 450 | return userTask; |
| 449 | } | 451 | } |
| 450 | 452 |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmProcessInstanceServiceImpl.java
| @@ -67,6 +67,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | @@ -67,6 +67,7 @@ import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils. | ||
| 67 | import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode; | 67 | import static cn.iocoder.yudao.module.bpm.controller.admin.task.vo.instance.BpmApprovalDetailRespVO.ActivityNode; |
| 68 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; | 68 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; |
| 69 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID; | 69 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.START_USER_NODE_ID; |
| 70 | +import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseNodeType; | ||
| 70 | import static java.util.Arrays.asList; | 71 | import static java.util.Arrays.asList; |
| 71 | import static java.util.Collections.singletonList; | 72 | import static java.util.Collections.singletonList; |
| 72 | import static org.flowable.bpmn.constants.BpmnXMLConstants.*; | 73 | import static org.flowable.bpmn.constants.BpmnXMLConstants.*; |
| @@ -325,7 +326,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -325,7 +326,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 325 | ActivityNode activityNode = new ActivityNode().setId(task.getTaskDefinitionKey()).setName(task.getName()) | 326 | ActivityNode activityNode = new ActivityNode().setId(task.getTaskDefinitionKey()).setName(task.getName()) |
| 326 | .setNodeType(START_USER_NODE_ID.equals(task.getTaskDefinitionKey()) | 327 | .setNodeType(START_USER_NODE_ID.equals(task.getTaskDefinitionKey()) |
| 327 | ? BpmSimpleModelNodeTypeEnum.START_USER_NODE.getType() | 328 | ? BpmSimpleModelNodeTypeEnum.START_USER_NODE.getType() |
| 328 | - : BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType()) | 329 | + : parseNodeType(flowNode)) |
| 329 | .setStatus(FlowableUtils.getTaskStatus(task)) | 330 | .setStatus(FlowableUtils.getTaskStatus(task)) |
| 330 | .setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(flowNode)) | 331 | .setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(flowNode)) |
| 331 | .setStartTime(DateUtils.of(task.getCreateTime())).setEndTime(DateUtils.of(task.getEndTime())) | 332 | .setStartTime(DateUtils.of(task.getCreateTime())).setEndTime(DateUtils.of(task.getEndTime())) |
| @@ -402,7 +403,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | @@ -402,7 +403,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService | ||
| 402 | HistoricActivityInstance firstActivity = CollUtil.getFirst(taskActivities); // 取第一个任务,会签/或签的任务,开始时间相同 | 403 | HistoricActivityInstance firstActivity = CollUtil.getFirst(taskActivities); // 取第一个任务,会签/或签的任务,开始时间相同 |
| 403 | ActivityNode activityNode = new ActivityNode().setId(firstActivity.getActivityId()) | 404 | ActivityNode activityNode = new ActivityNode().setId(firstActivity.getActivityId()) |
| 404 | .setName(firstActivity.getActivityName()) | 405 | .setName(firstActivity.getActivityName()) |
| 405 | - .setNodeType(BpmSimpleModelNodeTypeEnum.APPROVE_NODE.getType()) | 406 | + .setNodeType(parseNodeType(flowNode)) |
| 406 | .setStatus(BpmTaskStatusEnum.RUNNING.getStatus()) | 407 | .setStatus(BpmTaskStatusEnum.RUNNING.getStatus()) |
| 407 | .setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(flowNode)) | 408 | .setCandidateStrategy(BpmnModelUtils.parseCandidateStrategy(flowNode)) |
| 408 | .setStartTime(DateUtils.of(CollUtil.getFirst(taskActivities).getStartTime())) | 409 | .setStartTime(DateUtils.of(CollUtil.getFirst(taskActivities).getStartTime())) |