feat(REQ-4418) - 调整部分外部设置、调整审批人时的接口参数属性校验逻辑
This commit is contained in:
parent
0526c6d18e
commit
efb57e02da
@ -22,6 +22,7 @@ public enum OtherRespCode implements IModuleRespCode {
|
||||
ASYNC_JOB_EXECUTION_ERROR("007", "获取指定实例 ID【{}】的锁失败"),
|
||||
ILLEGAL_PARAM_ERROR("008", "非法的参数:【{}】"),
|
||||
MESSAGE_IM_EVENT_BUILD_ERROR("009", "不能使用 createEvent 函数创建`IM 消息`的事件, 请调用 createIMEvent 函数"),
|
||||
ASSIGNEE_NODE_ID_NOT_EXISTS("010", "审批人 nodeId 不存在, 请检查参数是否正确")
|
||||
;
|
||||
|
||||
private final String code;
|
||||
|
||||
@ -141,6 +141,9 @@ public final class BpmnMetaParserHelper {
|
||||
}
|
||||
|
||||
public static Optional<Integer> getCategoryVersion(Process process) {
|
||||
if(Objects.isNull(process)) {
|
||||
return Optional.of(0);
|
||||
}
|
||||
String categoryVersion = process.getAttributeValue(null, FLOW_CATEGORY_VERSION);
|
||||
if (StringUtils.hasText(categoryVersion)) {
|
||||
try {
|
||||
|
||||
@ -6,6 +6,7 @@ import cn.axzo.workflow.core.common.utils.SpringContextUtils;
|
||||
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
|
||||
import cn.axzo.workflow.core.service.CategoryService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.HistoryService;
|
||||
import org.flowable.engine.ManagementService;
|
||||
@ -14,6 +15,7 @@ import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.job.api.Job;
|
||||
import org.flowable.job.service.impl.persistence.entity.TimerJobEntity;
|
||||
import org.flowable.task.api.Task;
|
||||
@ -32,6 +34,7 @@ import static cn.axzo.workflow.common.code.BpmnTaskRespCode.ACTIVITY_BIZ_SET_ASS
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.ACTIVITY_CANT_SET_ASSIGNEE;
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.PROCESS_CANT_SET_ASSIGNEE;
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.PROCESS_SET_ASSIGNEE_PARAM_ERROR;
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.BPM_MODEL_CATEGORY;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.HIDDEN_ASSIGNEE_ID;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
|
||||
@ -40,6 +43,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERA
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.DELETED;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.PROCESSING;
|
||||
import static cn.axzo.workflow.common.enums.WorkspaceType.PROJECT;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTaskAssignerCount;
|
||||
|
||||
/**
|
||||
@ -80,6 +84,11 @@ public class CustomBizSpecifyAssigneeToTaskCmd extends AbstractCommand<Boolean>
|
||||
* @param assigners
|
||||
*/
|
||||
public static void validate(RuntimeService runtimeService, String executionId, Task task, List<BpmnTaskDelegateAssigner> assigners) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(task.getProcessDefinitionId());
|
||||
boolean present = assigners.stream().anyMatch(assigner -> !StringUtils.hasText(assigner.getNodeId()));
|
||||
if (present && getCategoryVersion(bpmnModel.getMainProcess()).orElse(0) > 0) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
validTask(task, executionId);
|
||||
//校验审批人数量是否超过限制
|
||||
validTaskAssignerCount(runtimeService, (TaskEntity) task, assigners);
|
||||
|
||||
@ -1,13 +1,16 @@
|
||||
package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskCountersignDTO;
|
||||
import cn.axzo.workflow.core.engine.job.AsyncCountersignUserTaskJobHandler;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.job.service.JobService;
|
||||
import org.flowable.job.service.impl.persistence.entity.JobEntity;
|
||||
import org.flowable.task.api.Task;
|
||||
@ -17,6 +20,8 @@ import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTask;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTaskAssignerCount;
|
||||
|
||||
@ -44,6 +49,8 @@ public class CustomCountersignUserTaskAsyncCmd extends AbstractCommand<Void> imp
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
Task task = taskService.createTaskQuery().taskId(dto.getTaskId()).singleResult();
|
||||
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
|
||||
validTask(historicTaskInstance, (TaskEntity) task, dto.getOriginAssigner(), null);
|
||||
|
||||
// validTaskAssignerDuplicated(commandContext, (TaskEntity) task, dto.getTargetAssignerList());
|
||||
@ -75,4 +82,12 @@ public class CustomCountersignUserTaskAsyncCmd extends AbstractCommand<Void> imp
|
||||
jobService.scheduleAsyncJob(job);
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
boolean present = dto.getTargetAssignerList().stream().anyMatch(assigner -> !org.springframework.util.StringUtils.hasText(assigner.getNodeId()));
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && present) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.enums.BpmnCountersignTypeEnum;
|
||||
import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.AttachmentDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
|
||||
@ -9,11 +10,13 @@ import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.TaskInfo;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
@ -29,9 +32,11 @@ import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COUNTERSIGN_ASSIGNER_SHOW_NUMBER;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.COUNTERSIGN;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.completeVirtualTask;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.createVirtualTask;
|
||||
@ -95,6 +100,8 @@ public class CustomCountersignUserTaskCmd extends AbstractCommand<Void> implemen
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(originTaskId).singleResult();
|
||||
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
|
||||
validTask(historicTaskInstance, task, originTaskAssignee, null);
|
||||
|
||||
validTaskAssignerCount(processEngineConfiguration.getRuntimeService(), task, targetTaskAssigneeList);
|
||||
@ -180,4 +187,12 @@ public class CustomCountersignUserTaskCmd extends AbstractCommand<Void> implemen
|
||||
completeVirtualTask(commandContext, virtualTask);
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
boolean present = targetTaskAssigneeList.stream().anyMatch(assigner -> !org.springframework.util.StringUtils.hasText(assigner.getNodeId()));
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && present) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -7,6 +7,7 @@ import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
|
||||
import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.cfg.IdGenerator;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
@ -15,10 +16,12 @@ import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.history.HistoricProcessInstance;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.service.impl.persistence.entity.HistoricTaskInstanceEntity;
|
||||
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import org.springframework.util.CollectionUtils;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Date;
|
||||
@ -27,6 +30,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.HIDDEN_ASSIGNEE_ID;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.NO_ASSIGNEE;
|
||||
@ -36,6 +40,7 @@ import static cn.axzo.workflow.common.code.BpmnTaskRespCode.DUMMY_TASK_CANT_CREA
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.DUMMY_TASK_CANT_REPEAT_CREATE;
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.DUMMY_TASK_CREATED_ERROR;
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.DUMMY_TASK_CREATED_NOT_SUPPORT;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static org.flowable.task.api.Task.DEFAULT_PRIORITY;
|
||||
|
||||
/**
|
||||
@ -125,6 +130,7 @@ public class CustomCreateDummyTaskCmd extends AbstractCommand<String> implements
|
||||
taskService.saveTask(task);
|
||||
|
||||
if (Objects.nonNull(operator)) {
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
CommandContextUtil.getEntityCache().findInCache(HistoricTaskInstanceEntity.class).stream()
|
||||
.filter(i -> Objects.equals(i.getId(), task.getId())).findAny()
|
||||
.ifPresent(i -> i.setAssignee(operator.buildAssigneeId()));
|
||||
@ -154,4 +160,11 @@ public class CustomCreateDummyTaskCmd extends AbstractCommand<String> implements
|
||||
}
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && !StringUtils.hasText(operator.getNodeId())) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,14 +1,17 @@
|
||||
package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskResetApproversDTO;
|
||||
import cn.axzo.workflow.core.engine.job.AsyncResetApproversUserTaskJobHandler;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.job.service.JobService;
|
||||
import org.flowable.job.service.impl.persistence.entity.JobEntity;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
@ -17,6 +20,8 @@ import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
|
||||
import java.io.Serializable;
|
||||
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTask;
|
||||
|
||||
/**
|
||||
@ -51,6 +56,8 @@ public class CustomResetTaskApproversAsyncCmd extends AbstractCommand<Void> impl
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(dto.getTaskId()).singleResult();
|
||||
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
|
||||
validTask(historicTaskInstance, task, dto.getOriginAssigner(), null);
|
||||
|
||||
startAsync(processEngineConfiguration, task);
|
||||
@ -78,4 +85,12 @@ public class CustomResetTaskApproversAsyncCmd extends AbstractCommand<Void> impl
|
||||
jobService.scheduleAsyncJob(job);
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
boolean present = dto.getTargetAssignerList().stream().anyMatch(assigner -> !org.springframework.util.StringUtils.hasText(assigner.getNodeId()));
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && present) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
package cn.axzo.workflow.core.engine.cmd;
|
||||
|
||||
import cn.axzo.workflow.common.exception.WorkflowEngineException;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.AttachmentDTO;
|
||||
import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper;
|
||||
@ -7,12 +8,14 @@ import cn.axzo.workflow.core.service.ExtAxHiTaskInstService;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
||||
@ -24,6 +27,7 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_ADVICE;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
|
||||
@ -33,6 +37,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_ASSIGNEE_SKIP_
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TASK_COMPLETE_OPERATION_TYPE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.UPGRADED;
|
||||
import static cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner.buildDummyAssigner;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.addComment;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTask;
|
||||
@ -83,7 +88,7 @@ public class CustomResetTaskApproversCmd extends AbstractCommand<Void> implement
|
||||
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(originTaskId).singleResult();
|
||||
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
validTask(historicTaskInstance, task, originTaskAssignee, null);
|
||||
|
||||
resolveOriginTask(commandContext, taskService, task);
|
||||
@ -151,4 +156,12 @@ public class CustomResetTaskApproversCmd extends AbstractCommand<Void> implement
|
||||
taskService.saveTask(task);
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
boolean present = targetTaskAssigneeList.stream().anyMatch(assigner -> !org.springframework.util.StringUtils.hasText(assigner.getNodeId()));
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && present) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -5,10 +5,13 @@ import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskTransferDTO;
|
||||
import cn.axzo.workflow.core.engine.job.AsyncTransferUserTaskJobHandler;
|
||||
import cn.hutool.json.JSONUtil;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.job.service.JobService;
|
||||
import org.flowable.job.service.impl.persistence.entity.JobEntity;
|
||||
import org.flowable.task.api.Task;
|
||||
@ -19,6 +22,8 @@ import org.flowable.task.service.impl.persistence.entity.TaskEntity;
|
||||
import java.io.Serializable;
|
||||
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.TRANSFER_TO_SELF;
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.validTask;
|
||||
|
||||
/**
|
||||
@ -48,8 +53,11 @@ public class CustomTransferUserTaskAsyncCmd extends AbstractCommand<Void> implem
|
||||
ProcessEngineConfigurationImpl processEngineConfiguration = CommandContextUtil.getProcessEngineConfiguration(commandContext);
|
||||
HistoricTaskInstanceQuery taskQuery = processEngineConfiguration.getHistoryService().createHistoricTaskInstanceQuery();
|
||||
HistoricTaskInstance historicTaskInstance = taskQuery.taskId(dto.getTaskId()).singleResult();
|
||||
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
Task task = taskService.createTaskQuery().taskId(dto.getTaskId()).singleResult();
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
|
||||
validTask(historicTaskInstance, (TaskEntity) task, dto.getOriginAssigner(), null);
|
||||
startAsync(processEngineConfiguration, task);
|
||||
return null;
|
||||
@ -76,4 +84,12 @@ public class CustomTransferUserTaskAsyncCmd extends AbstractCommand<Void> implem
|
||||
jobService.scheduleAsyncJob(job);
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && StringUtils.isNotBlank(dto.getTargetAssigner().getNodeId())) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@ -7,12 +7,14 @@ import cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner;
|
||||
import com.alibaba.fastjson.JSON;
|
||||
import com.google.common.collect.Lists;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
import org.flowable.bpmn.model.BpmnModel;
|
||||
import org.flowable.common.engine.impl.identity.Authentication;
|
||||
import org.flowable.common.engine.impl.interceptor.CommandContext;
|
||||
import org.flowable.engine.RuntimeService;
|
||||
import org.flowable.engine.TaskService;
|
||||
import org.flowable.engine.impl.cfg.ProcessEngineConfigurationImpl;
|
||||
import org.flowable.engine.impl.util.CommandContextUtil;
|
||||
import org.flowable.engine.impl.util.ProcessDefinitionUtil;
|
||||
import org.flowable.task.api.Task;
|
||||
import org.flowable.task.api.history.HistoricTaskInstance;
|
||||
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
||||
@ -28,6 +30,7 @@ import java.util.Map;
|
||||
import java.util.Objects;
|
||||
|
||||
import static cn.axzo.workflow.common.code.BpmnTaskRespCode.TRANSFER_TO_SELF;
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_ADVICE;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.COMMENT_TYPE_OPERATION_DESC;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.INTERNAL_ACTIVITY_RELATION_ASSIGNEE_LIST_INFO_SNAPSHOT;
|
||||
@ -37,6 +40,7 @@ import static cn.axzo.workflow.common.constant.BpmnConstants.TRANSFER_TO;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.TRANSFER_TO_ADVICE;
|
||||
import static cn.axzo.workflow.common.enums.BpmnProcessInstanceResultEnum.TRANSFER;
|
||||
import static cn.axzo.workflow.common.model.request.bpmn.task.BpmnTaskDelegateAssigner.buildDummyAssigner;
|
||||
import static cn.axzo.workflow.core.common.utils.BpmnMetaParserHelper.getCategoryVersion;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.addComment;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.addMultiTask;
|
||||
import static cn.axzo.workflow.core.engine.cmd.helper.CustomTaskHelper.batchAddAttachment;
|
||||
@ -97,6 +101,8 @@ public class CustomTransferUserTaskCmd extends AbstractCommand<Void> implements
|
||||
TaskService taskService = processEngineConfiguration.getTaskService();
|
||||
TaskEntity task = (TaskEntity) taskService.createTaskQuery().taskId(originTaskId).singleResult();
|
||||
|
||||
validTargetAssigneeNodeId(task.getProcessDefinitionId());
|
||||
|
||||
validTask(historicTaskInstance, task, originTaskAssignee, null);
|
||||
|
||||
|
||||
@ -123,6 +129,14 @@ public class CustomTransferUserTaskCmd extends AbstractCommand<Void> implements
|
||||
return null;
|
||||
}
|
||||
|
||||
private void validTargetAssigneeNodeId(String processDefinitionId) {
|
||||
BpmnModel bpmnModel = ProcessDefinitionUtil.getBpmnModel(processDefinitionId);
|
||||
Integer categoryVersion = getCategoryVersion(bpmnModel.getMainProcess()).orElse(0);
|
||||
if (categoryVersion > 0 && StringUtils.isNotBlank(targetTaskAssignee.getNodeId())) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
|
||||
private void resolveOriginTask(CommandContext commandContext, TaskService taskService, TaskEntity task) {
|
||||
BpmnTaskDelegateAssigner assigner = buildDummyAssigner("transfer", TASK_ASSIGNEE_SKIP_FLAT, "dummyApprover");
|
||||
task.setAssignee(assigner.buildAssigneeId());
|
||||
|
||||
@ -163,6 +163,7 @@ import static cn.axzo.workflow.common.code.BpmnProcessDefinitionRespCode.PROCESS
|
||||
import static cn.axzo.workflow.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_IS_INVALID;
|
||||
import static cn.axzo.workflow.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_IS_SUSPENDED;
|
||||
import static cn.axzo.workflow.common.code.BpmnProcessDefinitionRespCode.PROCESS_DEFINITION_KEY_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.code.OtherRespCode.ASSIGNEE_NODE_ID_NOT_EXISTS;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.AND_SIGN_EXPRESSION;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.BIZ_ORG_RELATION;
|
||||
import static cn.axzo.workflow.common.constant.BpmnConstants.BPMN_FILE_SUFFIX;
|
||||
@ -476,9 +477,12 @@ public class BpmnProcessInstanceServiceImpl implements BpmnProcessInstanceServic
|
||||
}
|
||||
//新版入参 nodeId 校验
|
||||
if (categoryItemVO.isPresent() && categoryItemVO.get().getWorkspaceTypeCode().equals(String.valueOf(PROJECT.getCode())) && categoryItemVO.get().getVersion() > 0) {
|
||||
if(Objects.isNull(dto.getCooperationOrg().getNodeId())) {
|
||||
if (Objects.isNull(dto.getCooperationOrg().getNodeId())) {
|
||||
throw new WorkflowEngineException(PROCESS_INSTANCE_CREATE_PARAM_ERROR);
|
||||
}
|
||||
if (!StringUtils.hasText(dto.getInitiator().getNodeId())) {
|
||||
throw new WorkflowEngineException(ASSIGNEE_NODE_ID_NOT_EXISTS);
|
||||
}
|
||||
}
|
||||
categoryItemVO.ifPresent(itemVO -> {
|
||||
dto.getVariables().put(INTERNAL_PROCESS_WORKSPACE_TYPE, WorkspaceType.getType(Integer.valueOf(itemVO.getWorkspaceTypeCode())).getCode());
|
||||
|
||||
Loading…
Reference in New Issue
Block a user