Commit adc05cad66156e3d0be37fa7c890e2449480e45a
Committed by
Gitee
!1189 Simple设计器功能完善
Merge pull request !1189 from Lesan/feature/bpm-n
Showing
8 changed files
with
89 additions
and
57 deletions
yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmListenerMapType.java renamed to yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmListenerParamTypeEnum.java
| ... | ... | @@ -6,7 +6,6 @@ import lombok.Getter; |
| 6 | 6 | |
| 7 | 7 | import java.util.Arrays; |
| 8 | 8 | |
| 9 | -// TODO @lesan:BpmListenerParamTypeEnum | |
| 10 | 9 | /** |
| 11 | 10 | * BPM 任务监听器键值对类型 |
| 12 | 11 | * |
| ... | ... | @@ -14,7 +13,7 @@ import java.util.Arrays; |
| 14 | 13 | */ |
| 15 | 14 | @Getter |
| 16 | 15 | @AllArgsConstructor |
| 17 | -public enum BpmListenerMapType implements IntArrayValuable { | |
| 16 | +public enum BpmListenerParamTypeEnum implements IntArrayValuable { | |
| 18 | 17 | |
| 19 | 18 | FIXED_VALUE(1, "固定值"), |
| 20 | 19 | FROM_FORM(2, "表单"); |
| ... | ... | @@ -22,7 +21,7 @@ public enum BpmListenerMapType implements IntArrayValuable { |
| 22 | 21 | private final Integer type; |
| 23 | 22 | private final String name; |
| 24 | 23 | |
| 25 | - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmListenerMapType::getType).toArray(); | |
| 24 | + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmListenerParamTypeEnum::getType).toArray(); | |
| 26 | 25 | |
| 27 | 26 | @Override |
| 28 | 27 | public int[] array() { | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| ... | ... | @@ -60,6 +60,9 @@ public class BpmSimpleModelNodeVO { |
| 60 | 60 | @Schema(description = "操作按钮设置", example = "[]") |
| 61 | 61 | private List<OperationButtonSetting> buttonsSetting; // 用于审批节点 |
| 62 | 62 | |
| 63 | + @Schema(description = "是否需要签名", example = "false") | |
| 64 | + private Boolean signEnable; | |
| 65 | + | |
| 63 | 66 | /** |
| 64 | 67 | * 审批节点拒绝处理 |
| 65 | 68 | */ |
| ... | ... | @@ -113,13 +116,9 @@ public class BpmSimpleModelNodeVO { |
| 113 | 116 | */ |
| 114 | 117 | private ConditionGroups conditionGroups; // 仅用于条件节点 BpmSimpleModelNodeType.CONDITION_NODE |
| 115 | 118 | |
| 116 | - // TODO @lesan:route 改成 router 会不会好点。因为触发器、延迟器,都带了类似 r | |
| 117 | - | |
| 118 | - // TODO @lesan:routeGroups | |
| 119 | 119 | @Schema(description = "路由分支组", example = "[]") |
| 120 | - private List<RouteCondition> routeGroup; | |
| 120 | + private List<RouteCondition> routerGroups; | |
| 121 | 121 | |
| 122 | - // TODO @lesan:貌似没用??? | |
| 123 | 122 | @Schema(description = "默认分支 ID", example = "Flow_xxx") |
| 124 | 123 | private String defaultFlowId; // 仅用于路由分支节点 BpmSimpleModelNodeType.ROUTE_BRANCH_NODE |
| 125 | 124 | |
| ... | ... | @@ -136,20 +135,19 @@ public class BpmSimpleModelNodeVO { |
| 136 | 135 | private String path; |
| 137 | 136 | |
| 138 | 137 | @Schema(description = "请求头", example = "[]") |
| 139 | - private List<ListenerMap> header; | |
| 138 | + private List<ListenerParam> header; | |
| 140 | 139 | |
| 141 | 140 | @Schema(description = "请求体", example = "[]") |
| 142 | - private List<ListenerMap> body; | |
| 141 | + private List<ListenerParam> body; | |
| 143 | 142 | |
| 144 | 143 | // TODO @芋艿:这里后续要不要复用; |
| 145 | 144 | |
| 146 | - // TODO @lesan:ListenerParam 更合适哈。首先它是参数配置,然后形式是键值对 | |
| 147 | 145 | @Schema(description = "任务监听器键值对") |
| 148 | 146 | @Data |
| 149 | - public static class ListenerMap { | |
| 147 | + public static class ListenerParam { | |
| 150 | 148 | |
| 151 | 149 | @Schema(description = "值类型", example = "1") |
| 152 | - @InEnum(BpmListenerMapType.class) | |
| 150 | + @InEnum(BpmListenerParamTypeEnum.class) | |
| 153 | 151 | private Integer type; |
| 154 | 152 | |
| 155 | 153 | @Schema(description = "键", example = "xxx") |
| ... | ... | @@ -300,7 +298,6 @@ public class BpmSimpleModelNodeVO { |
| 300 | 298 | @NotEmpty(message = "节点 Id 不能为空") |
| 301 | 299 | private String nodeId; |
| 302 | 300 | |
| 303 | - // TODO @lesan:type、expression、groups; | |
| 304 | 301 | @Schema(description = "条件类型", example = "1") |
| 305 | 302 | @InEnum(BpmSimpleModeConditionType.class) |
| 306 | 303 | @NotNull(message = "条件类型不能为空") | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/task/vo/task/BpmTaskRespVO.java
| ... | ... | @@ -78,6 +78,9 @@ public class BpmTaskRespVO { |
| 78 | 78 | @Schema(description = "操作按钮设置值") |
| 79 | 79 | private Map<Integer, OperationButtonSetting> buttonsSetting; |
| 80 | 80 | |
| 81 | + @Schema(description = "是否需要签名") | |
| 82 | + private Boolean signEnable; | |
| 83 | + | |
| 81 | 84 | @Data |
| 82 | 85 | @Schema(description = "流程实例") |
| 83 | 86 | public static class ProcessInstance { | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnModelUtils.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.convert.Convert; | |
| 4 | 5 | import cn.hutool.core.map.MapUtil; |
| 5 | 6 | import cn.hutool.core.util.ArrayUtil; |
| 6 | 7 | import cn.hutool.core.util.ObjUtil; |
| ... | ... | @@ -115,25 +116,6 @@ public class BpmnModelUtils { |
| 115 | 116 | } |
| 116 | 117 | |
| 117 | 118 | /** |
| 118 | - * 给节点添加Simple设计器配置Json | |
| 119 | - * | |
| 120 | - * @param userTask 节点 | |
| 121 | - * @param node 节点对象 | |
| 122 | - */ | |
| 123 | - public static void addSimpleConfigInfo(FlowElement userTask, Object node) { | |
| 124 | - addExtensionElementJson(userTask, "config", node); | |
| 125 | - } | |
| 126 | - | |
| 127 | - /** | |
| 128 | - * 解析Simple设计器配置Json | |
| 129 | - * | |
| 130 | - * @param userTask 节点 | |
| 131 | - */ | |
| 132 | - public static BpmSimpleModelNodeVO parseSimpleConfigInfo(FlowElement userTask) { | |
| 133 | - return parseExtensionElementJson(userTask, "config", BpmSimpleModelNodeVO.class); | |
| 134 | - } | |
| 135 | - | |
| 136 | - /** | |
| 137 | 119 | * 给节点添加候选人元素 |
| 138 | 120 | * |
| 139 | 121 | * @param candidateStrategy 候选人策略 |
| ... | ... | @@ -386,6 +368,26 @@ public class BpmnModelUtils { |
| 386 | 368 | return Optional.ofNullable(extensionElement).map(ExtensionElement::getElementText).orElse(null); |
| 387 | 369 | } |
| 388 | 370 | |
| 371 | + public static void addSignEnable(Boolean signEnable, FlowElement userTask) { | |
| 372 | + if (ObjUtil.isNotNull(signEnable)) { | |
| 373 | + addExtensionElement(userTask, SIGN_ENABLE, signEnable.toString()); | |
| 374 | + } else { | |
| 375 | + addExtensionElement(userTask, SIGN_ENABLE, "false"); | |
| 376 | + } | |
| 377 | + } | |
| 378 | + | |
| 379 | + public static Boolean parseSignEnable(BpmnModel bpmnModel, String flowElementId) { | |
| 380 | + FlowElement flowElement = getFlowElementById(bpmnModel, flowElementId); | |
| 381 | + if (flowElement == null) { | |
| 382 | + return false; | |
| 383 | + } | |
| 384 | + List<ExtensionElement> extensionElements = flowElement.getExtensionElements().get(SIGN_ENABLE); | |
| 385 | + if (CollUtil.isEmpty(extensionElements)) { | |
| 386 | + return false; | |
| 387 | + } | |
| 388 | + return Convert.toBool(extensionElements.get(0).getElementText(), false); | |
| 389 | + } | |
| 390 | + | |
| 389 | 391 | // ========== BPM 简单查找相关的方法 ========== |
| 390 | 392 | |
| 391 | 393 | /** | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| ... | ... | @@ -5,6 +5,7 @@ import cn.hutool.core.lang.Assert; |
| 5 | 5 | import cn.hutool.core.map.MapUtil; |
| 6 | 6 | import cn.hutool.core.util.*; |
| 7 | 7 | import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils; |
| 8 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 8 | 9 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 9 | 10 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.ConditionGroups; |
| 10 | 11 | import cn.iocoder.yudao.module.bpm.enums.definition.*; |
| ... | ... | @@ -200,7 +201,7 @@ public class SimpleModelUtils { |
| 200 | 201 | // 3. 遍历分支节点 |
| 201 | 202 | if (nodeType == BpmSimpleModelNodeType.ROUTE_BRANCH_NODE) { |
| 202 | 203 | // 路由分支遍历 |
| 203 | - for (BpmSimpleModelNodeVO.RouteCondition route : node.getRouteGroup()) { | |
| 204 | + for (BpmSimpleModelNodeVO.RouteCondition route : node.getRouterGroups()) { | |
| 204 | 205 | SequenceFlow sequenceFlow = RouteBranchNodeConvert.buildSequenceFlow(node.getId(), route); |
| 205 | 206 | process.addFlowElement(sequenceFlow); |
| 206 | 207 | } |
| ... | ... | @@ -439,9 +440,8 @@ public class SimpleModelUtils { |
| 439 | 440 | } |
| 440 | 441 | // 设置监听器 |
| 441 | 442 | addUserTaskListener(node, userTask); |
| 442 | - // 设置 Simple 设计器节点配置 | |
| 443 | - // TODO @lesan:只设置到 flowableListener 里面,整个 node 太大了!因为很多都保存过啦。 | |
| 444 | - addSimpleConfigInfo(userTask, node); | |
| 443 | + // 添加是否需要签名 | |
| 444 | + addSignEnable(node.getSignEnable(), userTask); | |
| 445 | 445 | return userTask; |
| 446 | 446 | } |
| 447 | 447 | |
| ... | ... | @@ -453,6 +453,10 @@ public class SimpleModelUtils { |
| 453 | 453 | flowableListener.setEvent(TaskListener.EVENTNAME_CREATE); |
| 454 | 454 | flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); |
| 455 | 455 | flowableListener.setImplementation(DELEGATE_EXPRESSION); |
| 456 | + FieldExtension fieldExtension = new FieldExtension(); | |
| 457 | + fieldExtension.setFieldName("listenerConfig"); | |
| 458 | + fieldExtension.setStringValue(JsonUtils.toJsonString(node.getTaskCreateListener())); | |
| 459 | + flowableListener.getFieldExtensions().add(fieldExtension); | |
| 456 | 460 | flowableListeners.add(flowableListener); |
| 457 | 461 | } |
| 458 | 462 | if (node.getTaskAssignListener() != null |
| ... | ... | @@ -461,6 +465,10 @@ public class SimpleModelUtils { |
| 461 | 465 | flowableListener.setEvent(TaskListener.EVENTNAME_ASSIGNMENT); |
| 462 | 466 | flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); |
| 463 | 467 | flowableListener.setImplementation(DELEGATE_EXPRESSION); |
| 468 | + FieldExtension fieldExtension = new FieldExtension(); | |
| 469 | + fieldExtension.setFieldName("listenerConfig"); | |
| 470 | + fieldExtension.setStringValue(JsonUtils.toJsonString(node.getTaskAssignListener())); | |
| 471 | + flowableListener.getFieldExtensions().add(fieldExtension); | |
| 464 | 472 | flowableListeners.add(flowableListener); |
| 465 | 473 | } |
| 466 | 474 | if (node.getTaskCompleteListener() != null |
| ... | ... | @@ -469,6 +477,10 @@ public class SimpleModelUtils { |
| 469 | 477 | flowableListener.setEvent(TaskListener.EVENTNAME_COMPLETE); |
| 470 | 478 | flowableListener.setImplementationType(ImplementationType.IMPLEMENTATION_TYPE_DELEGATEEXPRESSION); |
| 471 | 479 | flowableListener.setImplementation(DELEGATE_EXPRESSION); |
| 480 | + FieldExtension fieldExtension = new FieldExtension(); | |
| 481 | + fieldExtension.setFieldName("listenerConfig"); | |
| 482 | + fieldExtension.setStringValue(JsonUtils.toJsonString(node.getTaskCompleteListener())); | |
| 483 | + flowableListener.getFieldExtensions().add(fieldExtension); | |
| 472 | 484 | flowableListeners.add(flowableListener); |
| 473 | 485 | } |
| 474 | 486 | if (CollUtil.isNotEmpty(flowableListeners)) { | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/BpmTaskServiceImpl.java
| ... | ... | @@ -64,6 +64,7 @@ import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionU |
| 64 | 64 | import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.*; |
| 65 | 65 | import static cn.iocoder.yudao.module.bpm.enums.ErrorCodeConstants.*; |
| 66 | 66 | import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnVariableConstants.PROCESS_INSTANCE_VARIABLE_RETURN_FLAG; |
| 67 | +import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSignEnable; | |
| 67 | 68 | |
| 68 | 69 | /** |
| 69 | 70 | * 流程任务实例 Service 实现类 |
| ... | ... | @@ -161,13 +162,17 @@ public class BpmTaskServiceImpl implements BpmTaskService { |
| 161 | 162 | BpmnModel bpmnModel = bpmProcessDefinitionService.getProcessDefinitionBpmnModel(todoTask.getProcessDefinitionId()); |
| 162 | 163 | Map<Integer, BpmTaskRespVO.OperationButtonSetting> buttonsSetting = BpmnModelUtils.parseButtonsSetting( |
| 163 | 164 | bpmnModel, todoTask.getTaskDefinitionKey()); |
| 165 | + Boolean signEnable = parseSignEnable(bpmnModel, todoTask.getTaskDefinitionKey()); | |
| 164 | 166 | |
| 165 | 167 | // 4. 任务表单 |
| 166 | 168 | BpmFormDO taskForm = null; |
| 167 | 169 | if (StrUtil.isNotBlank(todoTask.getFormKey())){ |
| 168 | 170 | taskForm = formService.getForm(NumberUtils.parseLong(todoTask.getFormKey())); |
| 169 | 171 | } |
| 170 | - return BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm); | |
| 172 | + | |
| 173 | + BpmTaskRespVO bpmTaskRespVO = BpmTaskConvert.INSTANCE.buildTodoTask(todoTask, childrenTasks, buttonsSetting, taskForm); | |
| 174 | + bpmTaskRespVO.setSignEnable(signEnable); | |
| 175 | + return bpmTaskRespVO; | |
| 171 | 176 | } |
| 172 | 177 | |
| 173 | 178 | @Override | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/listener/BpmUserTaskListener.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.service.task.listener; |
| 2 | 2 | |
| 3 | 3 | import cn.hutool.core.collection.CollUtil; |
| 4 | +import cn.hutool.core.lang.Assert; | |
| 4 | 5 | import cn.hutool.core.util.StrUtil; |
| 6 | +import cn.iocoder.yudao.framework.common.util.json.JsonUtils; | |
| 5 | 7 | import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO; |
| 6 | -import cn.iocoder.yudao.module.bpm.enums.definition.BpmListenerMapType; | |
| 8 | +import cn.iocoder.yudao.module.bpm.enums.definition.BpmListenerParamTypeEnum; | |
| 7 | 9 | import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; |
| 8 | 10 | import cn.iocoder.yudao.module.bpm.service.definition.BpmModelService; |
| 9 | 11 | import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; |
| 10 | 12 | import jakarta.annotation.Resource; |
| 11 | 13 | import lombok.extern.slf4j.Slf4j; |
| 12 | 14 | import org.flowable.bpmn.model.BpmnModel; |
| 13 | -import org.flowable.bpmn.model.FlowElement; | |
| 15 | +import org.flowable.bpmn.model.FieldExtension; | |
| 16 | +import org.flowable.bpmn.model.FlowableListener; | |
| 17 | +import org.flowable.bpmn.model.UserTask; | |
| 14 | 18 | import org.flowable.engine.delegate.TaskListener; |
| 15 | 19 | import org.flowable.engine.history.HistoricProcessInstance; |
| 16 | 20 | import org.flowable.task.service.delegate.DelegateTask; |
| ... | ... | @@ -26,7 +30,6 @@ import java.util.List; |
| 26 | 30 | import java.util.Map; |
| 27 | 31 | |
| 28 | 32 | import static cn.iocoder.yudao.framework.web.core.util.WebFrameworkUtils.HEADER_TENANT_ID; |
| 29 | -import static cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils.parseSimpleConfigInfo; | |
| 30 | 33 | |
| 31 | 34 | /** |
| 32 | 35 | * BPM 用户任务通用监听器 |
| ... | ... | @@ -53,9 +56,9 @@ public class BpmUserTaskListener implements TaskListener { |
| 53 | 56 | // 1. 获取所需基础信息 |
| 54 | 57 | HistoricProcessInstance processInstance = processInstanceService.getHistoricProcessInstance(delegateTask.getProcessInstanceId()); |
| 55 | 58 | BpmnModel bpmnModel = modelService.getBpmnModelByDefinitionId(delegateTask.getProcessDefinitionId()); |
| 56 | - FlowElement userTask = BpmnModelUtils.getFlowElementById(bpmnModel, delegateTask.getTaskDefinitionKey()); | |
| 57 | - BpmSimpleModelNodeVO node = parseSimpleConfigInfo(userTask); | |
| 58 | - BpmSimpleModelNodeVO.ListenerHandler listenerHandler = getListenerHandlerByEvent(delegateTask.getEventName(), node); | |
| 59 | + UserTask userTask = (UserTask) BpmnModelUtils.getFlowElementById(bpmnModel, delegateTask.getTaskDefinitionKey()); | |
| 60 | + BpmSimpleModelNodeVO.ListenerHandler listenerHandler = getListenerHandlerByEvent(delegateTask.getEventName(), | |
| 61 | + userTask.getTaskListeners()); | |
| 59 | 62 | |
| 60 | 63 | // 2. 获取请求头和请求体 |
| 61 | 64 | Map<String, Object> processVariables = processInstance.getProcessVariables(); |
| ... | ... | @@ -79,34 +82,40 @@ public class BpmUserTaskListener implements TaskListener { |
| 79 | 82 | HttpEntity<MultiValueMap<String, String>> requestEntity = new HttpEntity<>(body, headers); |
| 80 | 83 | ResponseEntity<String> responseEntity = restTemplate.exchange(listenerHandler.getPath(), HttpMethod.POST, |
| 81 | 84 | requestEntity, String.class); |
| 82 | - // TODO @lesan:日志打印,可以更全哈,例如说,请求参数、对应的 task id,哪个 listener | |
| 83 | - log.info("[notify][的响应结果({})]", responseEntity); | |
| 85 | + log.info("[notify][监听器:{},事件类型:{},请求头:{},请求体:{},响应结果:{}]", | |
| 86 | + DELEGATE_EXPRESSION, | |
| 87 | + delegateTask.getEventName(), | |
| 88 | + headers, | |
| 89 | + body, | |
| 90 | + responseEntity); | |
| 84 | 91 | // 4. 是否需要后续操作?TODO 芋艿:待定! |
| 85 | 92 | } |
| 86 | 93 | |
| 87 | - private void parseListenerMap(List<BpmSimpleModelNodeVO.ListenerHandler.ListenerMap> list, | |
| 94 | + private void parseListenerMap(List<BpmSimpleModelNodeVO.ListenerHandler.ListenerParam> list, | |
| 88 | 95 | Map<String, Object> processVariables, |
| 89 | 96 | MultiValueMap<String, String> to) { |
| 90 | 97 | if (CollUtil.isEmpty(list)) { |
| 91 | 98 | return; |
| 92 | 99 | } |
| 93 | 100 | list.forEach(item -> { |
| 94 | - if (item.getType().equals(BpmListenerMapType.FIXED_VALUE.getType())) { | |
| 101 | + if (item.getType().equals(BpmListenerParamTypeEnum.FIXED_VALUE.getType())) { | |
| 95 | 102 | to.add(item.getKey(), item.getValue()); |
| 96 | - } else if (item.getType().equals(BpmListenerMapType.FROM_FORM.getType())) { | |
| 103 | + } else if (item.getType().equals(BpmListenerParamTypeEnum.FROM_FORM.getType())) { | |
| 97 | 104 | to.add(item.getKey(), processVariables.get(item.getValue()).toString()); |
| 98 | 105 | } |
| 99 | 106 | }); |
| 100 | 107 | } |
| 101 | 108 | |
| 102 | - // TODO @lesan:改成 jdk8 写法哈。主要考虑好兼容! | |
| 103 | - private BpmSimpleModelNodeVO.ListenerHandler getListenerHandlerByEvent(String eventName, BpmSimpleModelNodeVO node) { | |
| 104 | - return switch (eventName) { | |
| 105 | - case TaskListener.EVENTNAME_CREATE -> node.getTaskCreateListener(); | |
| 106 | - case TaskListener.EVENTNAME_ASSIGNMENT -> node.getTaskAssignListener(); | |
| 107 | - case TaskListener.EVENTNAME_COMPLETE -> node.getTaskCompleteListener(); | |
| 108 | - default -> null; // TODO @lesan:这个抛出异常,可控一点 | |
| 109 | - }; | |
| 109 | + private BpmSimpleModelNodeVO.ListenerHandler getListenerHandlerByEvent(String eventName, List<FlowableListener> node) { | |
| 110 | + FlowableListener flowableListener = node.stream() | |
| 111 | + .filter(item -> item.getEvent().equals(eventName)) | |
| 112 | + .findFirst().orElse(null); | |
| 113 | + Assert.notNull(flowableListener, "监听器({})不能为空", flowableListener); | |
| 114 | + FieldExtension fieldExtension = flowableListener.getFieldExtensions().stream() | |
| 115 | + .filter(item -> item.getFieldName().equals("listenerConfig")) | |
| 116 | + .findFirst().orElse(null); | |
| 117 | + Assert.notNull(fieldExtension, "监听器扩展字段({})不能为空", fieldExtension); | |
| 118 | + return JsonUtils.parseObject(fieldExtension.getStringValue(), BpmSimpleModelNodeVO.ListenerHandler.class); | |
| 110 | 119 | } |
| 111 | 120 | |
| 112 | 121 | } |
| 113 | 122 | \ No newline at end of file | ... | ... |