mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2025-01-19 03:30:06 +08:00
Merge remote-tracking branch 'origin/feature/bpm' into feature/bpm
This commit is contained in:
commit
ae7dbd3c53
@ -7,15 +7,14 @@ import lombok.Getter;
|
|||||||
|
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
|
|
||||||
// TODO @jason:BpmUserTaskTimeoutHandlerTypeEnum 会不会更匹配哈
|
|
||||||
/**
|
/**
|
||||||
* 用户任务超时处理执行动作枚举
|
* 用户任务超时处理类型枚举
|
||||||
*
|
*
|
||||||
* @author jason
|
* @author jason
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
@AllArgsConstructor
|
@AllArgsConstructor
|
||||||
public enum BpmUserTaskTimeoutActionEnum implements IntArrayValuable {
|
public enum BpmUserTaskTimeoutHandlerType implements IntArrayValuable {
|
||||||
|
|
||||||
REMINDER(1,"自动提醒"),
|
REMINDER(1,"自动提醒"),
|
||||||
APPROVE(2, "自动同意"),
|
APPROVE(2, "自动同意"),
|
||||||
@ -24,10 +23,10 @@ public enum BpmUserTaskTimeoutActionEnum implements IntArrayValuable {
|
|||||||
private final Integer action;
|
private final Integer action;
|
||||||
private final String name;
|
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) {
|
public static BpmUserTaskTimeoutHandlerType typeOf(Integer type) {
|
||||||
return ArrayUtil.firstMatch(item -> item.getAction().equals(action), values());
|
return ArrayUtil.firstMatch(item -> item.getAction().equals(type), values());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
@ -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.BpmApproveMethodEnum;
|
||||||
import cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType;
|
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.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 cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmTaskCandidateStrategyEnum;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonInclude;
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
||||||
@ -104,7 +104,7 @@ public class BpmSimpleModelNodeVO {
|
|||||||
private Boolean enable;
|
private Boolean enable;
|
||||||
|
|
||||||
@Schema(description = "任务超时未处理的行为", example = "1")
|
@Schema(description = "任务超时未处理的行为", example = "1")
|
||||||
@InEnum(BpmUserTaskTimeoutActionEnum.class)
|
@InEnum(BpmUserTaskTimeoutHandlerType.class)
|
||||||
private Integer action;
|
private Integer action;
|
||||||
|
|
||||||
@Schema(description = "超时时间", example = "PT6H")
|
@Schema(description = "超时时间", example = "PT6H")
|
||||||
|
@ -1,12 +1,5 @@
|
|||||||
package cn.iocoder.yudao.module.bpm.framework.flowable.core.enums;
|
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 常量信息
|
* BPMN XML 常量信息
|
||||||
*
|
*
|
||||||
@ -89,16 +82,4 @@ public interface BpmnModelConstants {
|
|||||||
*/
|
*/
|
||||||
String BUTTON_SETTING_ELEMENT_ENABLE_ATTRIBUTE = "enable";
|
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<Class<? extends FlowNode>> SUPPORT_CONVERT_SIMPLE_FlOW_NODES = ImmutableSet.of(UserTask.class, EndEvent.class);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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.BpmTaskApproveReqVO;
|
||||||
import cn.iocoder.yudao.module.bpm.controller.admin.task.vo.task.BpmTaskRejectReqVO;
|
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.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.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.message.task.TodoTaskReminderMessage;
|
||||||
import cn.iocoder.yudao.module.bpm.framework.flowable.core.mq.producer.task.TodoTaskReminderProducer;
|
import cn.iocoder.yudao.module.bpm.framework.flowable.core.mq.producer.task.TodoTaskReminderProducer;
|
||||||
@ -77,19 +77,19 @@ public class BpmTimerFiredEventListener extends AbstractFlowableEngineEventListe
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void userTaskTimeoutHandler(String processInstanceId, String taskDefKey, Integer timeoutAction) {
|
private void userTaskTimeoutHandler(String processInstanceId, String taskDefKey, Integer timeoutAction) {
|
||||||
BpmUserTaskTimeoutActionEnum userTaskTimeoutAction = BpmUserTaskTimeoutActionEnum.actionOf(timeoutAction);
|
BpmUserTaskTimeoutHandlerType userTaskTimeoutAction = BpmUserTaskTimeoutHandlerType.typeOf(timeoutAction);
|
||||||
if (userTaskTimeoutAction != null) {
|
if (userTaskTimeoutAction != null) {
|
||||||
// 查询超时未处理的任务 TODO 加签的情况会不会有问题 ???
|
// 查询超时未处理的任务 TODO 加签的情况会不会有问题 ???
|
||||||
List<Task> taskList = bpmTaskService.getRunningTaskListByProcessInstanceId(processInstanceId, true, taskDefKey);
|
List<Task> taskList = bpmTaskService.getRunningTaskListByProcessInstanceId(processInstanceId, true, taskDefKey);
|
||||||
taskList.forEach(task -> {
|
taskList.forEach(task -> {
|
||||||
// 自动提醒
|
// 自动提醒
|
||||||
if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.REMINDER) {
|
if (userTaskTimeoutAction == BpmUserTaskTimeoutHandlerType.REMINDER) {
|
||||||
TodoTaskReminderMessage message = new TodoTaskReminderMessage().setTenantId(Long.parseLong(task.getTenantId()))
|
TodoTaskReminderMessage message = new TodoTaskReminderMessage().setTenantId(Long.parseLong(task.getTenantId()))
|
||||||
.setUserId(Long.parseLong(task.getAssignee())).setTaskName(task.getName());
|
.setUserId(Long.parseLong(task.getAssignee())).setTaskName(task.getName());
|
||||||
todoTaskReminderProducer.sendReminderMessage(message);
|
todoTaskReminderProducer.sendReminderMessage(message);
|
||||||
}
|
}
|
||||||
// 自动同意
|
// 自动同意
|
||||||
if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.APPROVE) {
|
if (userTaskTimeoutAction == BpmUserTaskTimeoutHandlerType.APPROVE) {
|
||||||
// TODO @芋艿 这个上下文如何清除呢? 任务通过后, BpmProcessInstanceEventListener 会有回调
|
// TODO @芋艿 这个上下文如何清除呢? 任务通过后, BpmProcessInstanceEventListener 会有回调
|
||||||
TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId()));
|
TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId()));
|
||||||
TenantContextHolder.setIgnore(false);
|
TenantContextHolder.setIgnore(false);
|
||||||
@ -98,7 +98,7 @@ public class BpmTimerFiredEventListener extends AbstractFlowableEngineEventListe
|
|||||||
bpmTaskService.approveTask(Long.parseLong(task.getAssignee()), req);
|
bpmTaskService.approveTask(Long.parseLong(task.getAssignee()), req);
|
||||||
}
|
}
|
||||||
// 自动拒绝
|
// 自动拒绝
|
||||||
if (userTaskTimeoutAction == BpmUserTaskTimeoutActionEnum.REJECT) {
|
if (userTaskTimeoutAction == BpmUserTaskTimeoutHandlerType.REJECT) {
|
||||||
// TODO @芋艿 这个上下文如何清除呢? 任务拒绝后, BpmProcessInstanceEventListener 会有回调
|
// TODO @芋艿 这个上下文如何清除呢? 任务拒绝后, BpmProcessInstanceEventListener 会有回调
|
||||||
TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId()));
|
TenantContextHolder.setTenantId(Long.parseLong(task.getTenantId()));
|
||||||
TenantContextHolder.setIgnore(false);
|
TenantContextHolder.setIgnore(false);
|
||||||
|
@ -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<Map<String,String>> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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<String> changeCreateFormFiledPermissionRule(List<String> fields, Map<String,Integer> fieldsPermission) {
|
|
||||||
if ( CollUtil.isEmpty(fields) || MapUtil.isEmpty(fieldsPermission)) {
|
|
||||||
return fields;
|
|
||||||
}
|
|
||||||
List<String> afterChangedFields = new ArrayList<>(fields.size());
|
|
||||||
fields.forEach( f-> {
|
|
||||||
Map<String, Object> 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<String, Object> 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<String, Object> 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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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.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.BpmBoundaryEventType.USER_TASK_TIMEOUT;
|
||||||
import static cn.iocoder.yudao.module.bpm.enums.definition.BpmSimpleModelNodeType.*;
|
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.BpmnModelConstants.*;
|
||||||
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.*;
|
import static cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.SimpleModelConstants.*;
|
||||||
import static org.flowable.bpmn.constants.BpmnXMLConstants.*;
|
import static org.flowable.bpmn.constants.BpmnXMLConstants.*;
|
||||||
|
Loading…
Reference in New Issue
Block a user