Commit f5050807e1f9b6a0284af024f7cc8a9678434547
1 parent
a23b0480
【功能优化】 优化更新流程表单数据触发器
Showing
3 changed files
with
12 additions
and
37 deletions
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java
| ... | ... | @@ -346,9 +346,9 @@ public class BpmSimpleModelNodeVO { |
| 346 | 346 | private HttpRequestTriggerSetting httpRequestSetting; |
| 347 | 347 | |
| 348 | 348 | /** |
| 349 | - * 更新流程表单触发器设置 | |
| 349 | + * 流程表单触发器设置 | |
| 350 | 350 | */ |
| 351 | - private UpdateNormalFormTriggerSetting updateNormalFormSetting; | |
| 351 | + private NormalFormTriggerSetting normalFormSetting; | |
| 352 | 352 | |
| 353 | 353 | @Schema(description = "http 请求触发器设置", example = "{}") |
| 354 | 354 | @Data |
| ... | ... | @@ -378,23 +378,11 @@ public class BpmSimpleModelNodeVO { |
| 378 | 378 | private List<KeyValue<String, String>> response; |
| 379 | 379 | } |
| 380 | 380 | |
| 381 | - @Schema(description = "更新流程表单触发器设置", example = "{}") | |
| 381 | + @Schema(description = "流程表单触发器设置", example = "{}") | |
| 382 | 382 | @Data |
| 383 | - public static class UpdateNormalFormTriggerSetting { | |
| 383 | + public static class NormalFormTriggerSetting { | |
| 384 | 384 | |
| 385 | - @Schema(description = "条件类型", example = "1") | |
| 386 | - @InEnum(BpmSimpleModeConditionTypeEnum.class) | |
| 387 | - @NotNull(message = "条件类型不能为空") | |
| 388 | - private Integer conditionType; | |
| 389 | - | |
| 390 | - @Schema(description = "条件表达式", example = "${day>3}") | |
| 391 | - private String conditionExpression; | |
| 392 | - | |
| 393 | - @Schema(description = "条件组", example = "{}") | |
| 394 | - private ConditionGroups conditionGroups; | |
| 395 | - | |
| 396 | - @Schema(description = "更新的表单字段", example = "userName") | |
| 397 | - @NotEmpty(message = "更新的表单字段不能为空") | |
| 385 | + @Schema(description = "修改的表单字段", example = "userName") | |
| 398 | 386 | private Map<String, Object> updateFormFields; |
| 399 | 387 | } |
| 400 | 388 | } | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java
| ... | ... | @@ -628,8 +628,6 @@ public class SimpleModelUtils { |
| 628 | 628 | String conditionExpression = buildConditionExpression(node.getConditionSetting()); |
| 629 | 629 | return buildBpmnSequenceFlow(sourceId, targetId, node.getId(), node.getName(), conditionExpression); |
| 630 | 630 | } |
| 631 | - | |
| 632 | - | |
| 633 | 631 | } |
| 634 | 632 | |
| 635 | 633 | /** |
| ... | ... | @@ -726,8 +724,8 @@ public class SimpleModelUtils { |
| 726 | 724 | if (node.getTriggerSetting().getHttpRequestSetting() != null) { |
| 727 | 725 | addExtensionElementJson(serviceTask, TRIGGER_PARAM, node.getTriggerSetting().getHttpRequestSetting()); |
| 728 | 726 | } |
| 729 | - if (node.getTriggerSetting().getUpdateNormalFormSetting() != null) { | |
| 730 | - addExtensionElementJson(serviceTask, TRIGGER_PARAM, node.getTriggerSetting().getUpdateNormalFormSetting()); | |
| 727 | + if (node.getTriggerSetting().getNormalFormSetting() != null) { | |
| 728 | + addExtensionElementJson(serviceTask, TRIGGER_PARAM, node.getTriggerSetting().getNormalFormSetting()); | |
| 731 | 729 | } |
| 732 | 730 | } |
| 733 | 731 | return serviceTask; | ... | ... |
yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/service/task/trigger/BpmUpdateNormalFormTrigger.java
| 1 | 1 | package cn.iocoder.yudao.module.bpm.service.task.trigger; |
| 2 | 2 | |
| 3 | +import cn.hutool.core.collection.CollUtil; | |
| 3 | 4 | import cn.iocoder.yudao.framework.common.util.json.JsonUtils; |
| 4 | -import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.TriggerSetting.UpdateNormalFormTriggerSetting; | |
| 5 | +import cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.TriggerSetting.NormalFormTriggerSetting; | |
| 5 | 6 | import cn.iocoder.yudao.module.bpm.enums.definition.BpmTriggerTypeEnum; |
| 6 | -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.BpmnModelUtils; | |
| 7 | -import cn.iocoder.yudao.module.bpm.framework.flowable.core.util.SimpleModelUtils; | |
| 8 | 7 | import cn.iocoder.yudao.module.bpm.service.task.BpmProcessInstanceService; |
| 9 | 8 | import jakarta.annotation.Resource; |
| 10 | 9 | import lombok.extern.slf4j.Slf4j; |
| 11 | -import org.flowable.engine.runtime.ProcessInstance; | |
| 12 | 10 | import org.springframework.stereotype.Component; |
| 13 | 11 | |
| 14 | -import java.util.Map; | |
| 15 | - | |
| 16 | - | |
| 17 | 12 | /** |
| 18 | 13 | * BPM 更新流程表单触发器 |
| 19 | 14 | * |
| ... | ... | @@ -34,19 +29,13 @@ public class BpmUpdateNormalFormTrigger implements BpmTrigger { |
| 34 | 29 | @Override |
| 35 | 30 | public void execute(String processInstanceId, String param) { |
| 36 | 31 | // 1. 解析更新流程表单配置 |
| 37 | - UpdateNormalFormTriggerSetting setting = JsonUtils.parseObject(param, UpdateNormalFormTriggerSetting.class); | |
| 32 | + NormalFormTriggerSetting setting = JsonUtils.parseObject(param, NormalFormTriggerSetting.class); | |
| 38 | 33 | if (setting == null) { |
| 39 | 34 | log.error("[execute][流程({}) 更新流程表单触发器配置为空]", processInstanceId); |
| 40 | 35 | return; |
| 41 | 36 | } |
| 42 | - // 2.获取流程变量 | |
| 43 | - ProcessInstance processInstance = processInstanceService.getProcessInstance(processInstanceId); | |
| 44 | - Map<String, Object> processVariables = processInstance.getProcessVariables(); | |
| 45 | - String expression = SimpleModelUtils.buildConditionExpression(setting.getConditionType(), setting.getConditionExpression(), | |
| 46 | - setting.getConditionGroups()); | |
| 47 | - | |
| 48 | - // 3.满足条件,更新流程表单 | |
| 49 | - if(BpmnModelUtils.evalConditionExpress(processVariables, expression)) { | |
| 37 | + // 2.更新流程变量 | |
| 38 | + if (CollUtil.isNotEmpty(setting.getUpdateFormFields())) { | |
| 50 | 39 | processInstanceService.updateProcessInstanceVariables(processInstanceId, setting.getUpdateFormFields()); |
| 51 | 40 | } |
| 52 | 41 | } | ... | ... |