Commit d36c0dce7cf24514dd7484f7b9e1a05afd5e2ff8
1 parent
51859afa
fix:【BPM 工作流】BPMN 场景下,多次提醒可能丢失 elementId 的问题
Showing
1 changed file
with
18 additions
and
0 deletions
yudao-module-bpm/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java
| ... | ... | @@ -3,6 +3,7 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.listener; |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | 4 | import cn.hutool.core.util.ObjectUtil; |
| 5 | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | +import cn.hutool.json.JSONObject; | |
| 6 | 7 | import cn.iocoder.yudao.framework.common.util.number.NumberUtils; |
| 7 | 8 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmBoundaryEventTypeEnum; |
| 8 | 9 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; |
| ... | ... | @@ -98,6 +99,23 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { |
| 98 | 99 | String processDefinitionId = event.getProcessDefinitionId(); |
| 99 | 100 | BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(processDefinitionId); |
| 100 | 101 | Job entity = (Job) event.getEntity(); |
| 102 | + // 特殊 from https://t.zsxq.com/h6oWr :当 elementId 为空时,尝试从 JobHandlerConfiguration 中解析 JSON 获取 | |
| 103 | + String elementId = entity.getElementId(); | |
| 104 | + if (elementId == null && entity.getJobHandlerConfiguration() != null) { | |
| 105 | + try { | |
| 106 | + String handlerConfig = entity.getJobHandlerConfiguration(); | |
| 107 | + if (handlerConfig.startsWith("{") && handlerConfig.contains("activityId")) { | |
| 108 | + elementId = new JSONObject(handlerConfig).getStr("activityId"); | |
| 109 | + } | |
| 110 | + } catch (Exception e) { | |
| 111 | + log.error("[timerFired][解析 entity({}) 失败]", entity, e); | |
| 112 | + return; | |
| 113 | + } | |
| 114 | + } | |
| 115 | + if (elementId == null) { | |
| 116 | + log.error("[timerFired][解析 entity({}) elementId 为空,跳过处理]", entity); | |
| 117 | + return; | |
| 118 | + } | |
| 101 | 119 | FlowElement element = BpmnModelUtils.getFlowElementById(bpmnModel, entity.getElementId()); |
| 102 | 120 | if (!(element instanceof BoundaryEvent)) { |
| 103 | 121 | return; | ... | ... |