From 6c69eeba094c1da3a0ee973563eaa8cacdbb14e7 Mon Sep 17 00:00:00 2001 From: jason <2667446@qq.com> Date: Sun, 11 Aug 2024 22:07:11 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BB=BF=E9=92=89=E9=92=89=E6=B5=81=E7=A8=8B?= =?UTF-8?q?=E8=AE=BE=E8=AE=A1-=20code=20review=20=E9=83=A8=E5=88=86?= =?UTF-8?q?=E4=BF=AE=E6=94=B9?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- ...ava => BpmUserTaskTimeoutHandlerType.java} | 11 ++- .../vo/model/simple/BpmSimpleModelNodeVO.java | 4 +- .../core/enums/BpmnModelConstants.java | 19 ---- .../core/listener/BpmTaskEventListener.java | 1 - .../listener/BpmTimerFiredEventListener.java | 10 +-- .../SimpleModelUserTaskConfig.java | 90 ------------------- .../flowable/core/util/BpmnFormUtils.java | 73 --------------- .../flowable/core/util/SimpleModelUtils.java | 2 +- 8 files changed, 13 insertions(+), 197 deletions(-) rename yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/{BpmUserTaskTimeoutActionEnum.java => BpmUserTaskTimeoutHandlerType.java} (65%) delete mode 100644 yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/simplemodel/SimpleModelUserTaskConfig.java delete mode 100644 yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnFormUtils.java diff --git a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskTimeoutActionEnum.java b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskTimeoutHandlerType.java similarity index 65% rename from yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskTimeoutActionEnum.java rename to yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskTimeoutHandlerType.java index 50f265221..d1c32158e 100644 --- a/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskTimeoutActionEnum.java +++ b/yudao-module-bpm/yudao-module-bpm-api/src/main/java/cn/iocoder/yudao/module/bpm/enums/definition/BpmUserTaskTimeoutHandlerType.java @@ -7,15 +7,14 @@ import lombok.Getter; import java.util.Arrays; -// TODO @jason:BpmUserTaskTimeoutHandlerTypeEnum 会不会更匹配哈 /** - * 用户任务超时处理执行动作枚举 + * 用户任务超时处理类型枚举 * * @author jason */ @Getter @AllArgsConstructor -public enum BpmUserTaskTimeoutActionEnum implements IntArrayValuable { +public enum BpmUserTaskTimeoutHandlerType implements IntArrayValuable { REMINDER(1,"自动提醒"), APPROVE(2, "自动同意"), @@ -24,10 +23,10 @@ public enum BpmUserTaskTimeoutActionEnum implements IntArrayValuable { private final Integer action; private final String name; - public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmUserTaskTimeoutActionEnum::getAction).toArray(); + public static final int[] ARRAYS = Arrays.stream(values()).mapToInt(BpmUserTaskTimeoutHandlerType::getAction).toArray(); - public static BpmUserTaskTimeoutActionEnum actionOf(Integer action) { - return ArrayUtil.firstMatch(item -> item.getAction().equals(action), values()); + public static BpmUserTaskTimeoutHandlerType typeOf(Integer type) { + return ArrayUtil.firstMatch(item -> item.getAction().equals(type), values()); } @Override diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java index fa216bb3f..ecc59ba2c 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/controller/admin/definition/vo/model/simple/BpmSimpleModelNodeVO.java @@ -4,7 +4,7 @@ import cn.iocoder.yudao.framework.common.validation.InEnum; import cn.iocoder.yudao.module.bpm.enums.definition.BpmApproveMethodEnum; import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType; import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskRejectHandlerType; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutActionEnum; +import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutHandlerType; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum; import com.fasterxml.jackson.annotation.JsonIgnore; import com.fasterxml.jackson.annotation.JsonInclude; @@ -104,7 +104,7 @@ public class BpmSimpleModelNodeVO { private Boolean enable; @Schema(description = "任务超时未处理的行为", example = "1") - @InEnum(BpmUserTaskTimeoutActionEnum.class) + @InEnum(BpmUserTaskTimeoutHandlerType.class) private Integer action; @Schema(description = "超时时间", example = "PT6H") diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java index 2c9902a00..aa3878a2c 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/enums/BpmnModelConstants.java @@ -1,12 +1,5 @@ package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums; -import com.google.common.collect.ImmutableSet; -import org.flowable.bpmn.model.EndEvent; -import org.flowable.bpmn.model.FlowNode; -import org.flowable.bpmn.model.UserTask; - -import java.util.Set; - /** * BPMN XML 常量信息 * @@ -89,16 +82,4 @@ public interface BpmnModelConstants { */ String BUTTON_SETTING_ELEMENT_ENABLE_ATTRIBUTE = "enable"; - // TODO @jason:这个是不是可以删除啦 - /** - * BPMN End Event 节点 Id, 用于后端生成 End Event 节点 - */ - String END_EVENT_ID = "EndEvent_1"; - - // TODO @jason:这个是不是可以删除啦 - /** - * 支持转仿钉钉设计模型的 Bpmn 节点 - */ - Set> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class); - } diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java index a2af341b3..645d4e03f 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTaskEventListener.java @@ -58,7 +58,6 @@ public class BpmTaskEventListener extends AbstractFlowableEngineEventListener { @Override protected void activityCancelled(FlowableActivityCancelledEvent event) { - // TODO @jason:如果用户主动取消,可能需要考虑这个 List activityList = activityService.getHistoricActivityListByExecutionId(event.getExecutionId()); if (CollUtil.isEmpty(activityList)) { log.error("[activityCancelled][使用 executionId({}) 查找不到对应的活动实例]", event.getExecutionId()); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTimerFiredEventListener.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTimerFiredEventListener.java index 9f2c40d21..f52e999ec 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTimerFiredEventListener.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/listener/BpmTimerFiredEventListener.java @@ -5,7 +5,7 @@ import cn.iocoder.yudao.framework.tenant.core.context.TenantContextHolder; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskApproveReqVO; import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRejectReqVO; import cn.iocoder.yudao.module.bpm.enums.definition.BpmBoundaryEventType; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutActionEnum; +import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutHandlerType; import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants; import cn.iocoder.yudao.module.bpm.framework.flowable.core.mq.message.task.TodoTaskReminderMessage; import cn.iocoder.yudao.module.bpm.framework.flowable.core.mq.producer.task.TodoTaskReminderProducer; @@ -78,20 +78,20 @@ public class BpmTimerFiredEventListener extends AbstractFlowableEngineEventListe } private void userTaskTimeoutHandler(String processInstanceId, String taskDefKey, Integer timeoutAction) { - BpmUserTaskTimeoutActionEnum userTaskTimeoutAction = BpmUserTaskTimeoutActionEnum.actionOf(timeoutAction); + BpmUserTaskTimeoutHandlerType userTaskTimeoutAction = BpmUserTaskTimeoutHandlerType.typeOf(timeoutAction); if (userTaskTimeoutAction != null) { // 查询超时未处理的任务 TODO 加签的情况会不会有问题 ??? List taskList = bpmTaskService.getRunningTaskListByProcessInstanceId(processInstanceId, true, null, taskDefKey); taskList.forEach(task -> { // 自动提醒 - if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.REMINDER) { + if (userTaskTimeoutAction == BpmUserTaskTimeoutHandlerType.REMINDER) { TodoTaskReminderMessage message = new TodoTaskReminderMessage().setTenantId(Long.parseLong(task.getTenantId())) .setUserId(Long.parseLong(task.getAssignee())).setTaskName(task.getName()); todoTaskReminderProducer.sendReminderMessage(message); } // 自动同意 - if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.APPROVE) { + if (userTaskTimeoutAction == BpmUserTaskTimeoutHandlerType.APPROVE) { // TODO @芋艿 这个上下文如何清除呢? 任务通过后, BpmProcessInstanceEventListener 会有回调 TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId())); TenantContextHolder.setIgnore(false); @@ -100,7 +100,7 @@ public class BpmTimerFiredEventListener extends AbstractFlowableEngineEventListe bpmTaskService.approveTask(Long.parseLong(task.getAssignee()), req); } // 自动拒绝 - if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.REJECT) { + if (userTaskTimeoutAction == BpmUserTaskTimeoutHandlerType.REJECT) { // TODO @芋艿 这个上下文如何清除呢? 任务拒绝后, BpmProcessInstanceEventListener 会有回调 TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId())); TenantContextHolder.setIgnore(false); diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/simplemodel/SimpleModelUserTaskConfig.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/simplemodel/SimpleModelUserTaskConfig.java deleted file mode 100644 index ec9ad8e9c..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/simplemodel/SimpleModelUserTaskConfig.java +++ /dev/null @@ -1,90 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.simplemodel; - -import cn.iocoder.yudao.module.bpm.enums.definition.BpmApproveMethodEnum; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskRejectHandlerType; -import lombok.Data; - -import java.util.List; -import java.util.Map; - -// TODO @jason:这个貌似没用到,是不是可以删除啦 -/** - * 仿钉钉流程设计器审批节点配置 Model - * - * @author jason - */ -@Data -public class SimpleModelUserTaskConfig { - - /** - * 候选人策略 - */ - private Integer candidateStrategy; - /** - * 候选人参数 - */ - private String candidateParam; - - /** - * 字段权限 - */ - private List> fieldsPermission; - - /** - * 审批方式 {@link BpmApproveMethodEnum } - */ - private Integer approveMethod; - /** - * 通过比例 当审批方式为 多人会签(按通过比例) 需设置 - */ - private Integer approveRatio; - - /** - * 超时处理 - */ - private TimeoutHandler timeoutHandler; - - /** - * 用户任务拒绝处理 - */ - private RejectHandler rejectHandler; - - @Data - public static class TimeoutHandler { - - /** - * 是否开启超时处理 - */ - private Boolean enable; - - /** - * 超时执行的动作 - */ - private Integer action; - - /** - * 超时时间设置 - */ - private String timeDuration; - - /** - * 如果执行动作是自动提醒, 最大提醒次数 - */ - private Integer maxRemindCount; - } - - @Data - public static class RejectHandler { - - /** - * 用户任务拒绝处理类型 {@link BpmUserTaskRejectHandlerType} - */ - private Integer type; - - /** - * 用户任务拒绝后驳回的节点 Id - */ - private String returnNodeId; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnFormUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnFormUtils.java deleted file mode 100644 index e8f8345f7..000000000 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/BpmnFormUtils.java +++ /dev/null @@ -1,73 +0,0 @@ -package cn.iocoder.yudao.module.bpm.framework.flowable.core.util; - -import cn.hutool.core.collection.CollUtil; -import cn.hutool.core.lang.Assert; -import cn.hutool.core.map.MapUtil; -import cn.hutool.core.util.ObjUtil; -import cn.hutool.core.util.StrUtil; -import cn.iocoder.yudao.framework.common.util.json.JsonUtils; -import cn.iocoder.yudao.module.bpm.enums.definition.BpmFieldPermissionEnum; -import com.fasterxml.jackson.core.type.TypeReference; - -import java.util.ArrayList; -import java.util.List; -import java.util.Map; - -import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE; - -// TODO @芋艿:这块去研究下! -/** - * Bpmn 流程表单相关工具方法 - * - * @author jason - */ -public class BpmnFormUtils { - - private static final String CREATE_FORM_DISPLAY_ATTRIBUTE = "display"; - private static final String CREATE_FORM_DISABLED_ATTRIBUTE = "disabled"; - - // TODO @jason:这个方法,还要哇? - /** - * 修改 form-create 表单组件字段权限规则: 包括可编辑、只读、隐藏规则 - * - * @param fields 字段规则 - * @param fieldsPermission 字段权限 - * @return 修改权限后的字段规则 - */ - public static List changeCreateFormFiledPermissionRule(List fields, Map fieldsPermission) { - if ( CollUtil.isEmpty(fields) || MapUtil.isEmpty(fieldsPermission)) { - return fields; - } - List afterChangedFields = new ArrayList<>(fields.size()); - fields.forEach( f-> { - Map fieldMap = JsonUtils.parseObject(f, new TypeReference<>() {}); - String field = ObjUtil.defaultIfNull(fieldMap.get(FORM_FIELD_PERMISSION_ELEMENT_FIELD_ATTRIBUTE), Object::toString, ""); - if (StrUtil.isEmpty(field) || !fieldsPermission.containsKey(field)) { - afterChangedFields.add(f); - return; - } - BpmFieldPermissionEnum fieldPermission = BpmFieldPermissionEnum.valueOf(fieldsPermission.get(field)); - Assert.notNull(fieldPermission, "字段权限不匹配"); - if (BpmFieldPermissionEnum.NONE == fieldPermission) { - fieldMap.put(CREATE_FORM_DISPLAY_ATTRIBUTE, Boolean.FALSE); - } else if (BpmFieldPermissionEnum.WRITE == fieldPermission){ - Map props = MapUtil.get(fieldMap, "props", new cn.hutool.core.lang.TypeReference<>() {}); - if (props == null) { - props = MapUtil.newHashMap(); - fieldMap.put("props", props); - } - props.put(CREATE_FORM_DISABLED_ATTRIBUTE, Boolean.FALSE); - } else if (BpmFieldPermissionEnum.READ == fieldPermission) { - Map props = MapUtil.get(fieldMap, "props", new cn.hutool.core.lang.TypeReference<>() {}); - if (props == null) { - props = MapUtil.newHashMap(); - fieldMap.put("props", props); - } - props.put(CREATE_FORM_DISABLED_ATTRIBUTE, Boolean.TRUE); - } - afterChangedFields.add(JsonUtils.toJsonString(fieldMap)); - }); - return afterChangedFields; - } - -} diff --git a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java index 0727ad3b8..59d095d85 100644 --- a/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java +++ b/yudao-module-bpm/yudao-module-bpm-biz/src/main/java/cn/iocoder/yudao/module/bpm/framework/flowable/core/util/SimpleModelUtils.java @@ -27,7 +27,7 @@ import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.s import static cn.iocoder.yudao.module.bpm.controller.admin.definition.vo.model.simple.BpmSimpleModelNodeVO.TimeoutHandler; import static cn.iocoder.yudao.module.bpm.enums.definition.BpmBoundaryEventType.USER_TASK_TIMEOUT; import static cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType.*; -import static cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutActionEnum.REMINDER; +import static cn.iocoder.yudao.module.bpm.enums.definition.BpmUserTaskTimeoutHandlerType.REMINDER; import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmnModelConstants.*; import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.*; import static org.flowable.bpmn.constants.BpmnXMLConstants.*;