|
|
|
|
@ -9,8 +9,10 @@ import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
|
|
|
|
|
import lombok.RequiredArgsConstructor;
|
|
|
|
|
import org.dromara.common.core.domain.dto.RoleDTO;
|
|
|
|
|
import org.dromara.common.core.domain.dto.UserDTO;
|
|
|
|
|
import org.dromara.common.core.domain.event.ProcessTaskEvent;
|
|
|
|
|
import org.dromara.common.core.exception.ServiceException;
|
|
|
|
|
import org.dromara.common.core.service.UserService;
|
|
|
|
|
import org.dromara.common.core.utils.ServletUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StreamUtils;
|
|
|
|
|
import org.dromara.common.core.utils.StringUtils;
|
|
|
|
|
import org.dromara.common.mybatis.core.page.PageQuery;
|
|
|
|
|
@ -25,9 +27,7 @@ import org.dromara.workflow.domain.WfTaskBackNode;
|
|
|
|
|
import org.dromara.workflow.domain.bo.*;
|
|
|
|
|
import org.dromara.workflow.domain.vo.*;
|
|
|
|
|
import org.dromara.workflow.flowable.cmd.*;
|
|
|
|
|
import org.dromara.workflow.flowable.strategy.FlowEventStrategy;
|
|
|
|
|
import org.dromara.workflow.flowable.strategy.FlowProcessEventHandler;
|
|
|
|
|
import org.dromara.workflow.flowable.strategy.FlowTaskEventHandler;
|
|
|
|
|
import org.dromara.workflow.flowable.handler.FlowProcessEventHandler;
|
|
|
|
|
import org.dromara.workflow.mapper.ActHiTaskinstMapper;
|
|
|
|
|
import org.dromara.workflow.mapper.ActTaskMapper;
|
|
|
|
|
import org.dromara.workflow.service.IActTaskService;
|
|
|
|
|
@ -75,13 +75,13 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|
|
|
|
private final HistoryService historyService;
|
|
|
|
|
private final IdentityService identityService;
|
|
|
|
|
private final ManagementService managementService;
|
|
|
|
|
private final FlowEventStrategy flowEventStrategy;
|
|
|
|
|
private final ActTaskMapper actTaskMapper;
|
|
|
|
|
private final IWfTaskBackNodeService wfTaskBackNodeService;
|
|
|
|
|
private final ActHiTaskinstMapper actHiTaskinstMapper;
|
|
|
|
|
private final IWfNodeConfigService wfNodeConfigService;
|
|
|
|
|
private final IWfDefinitionConfigService wfDefinitionConfigService;
|
|
|
|
|
private final UserService userService;
|
|
|
|
|
private final FlowProcessEventHandler flowProcessEventHandler;
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
* 启动任务
|
|
|
|
|
@ -179,19 +179,15 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|
|
|
|
//附件上传
|
|
|
|
|
AttachmentCmd attachmentCmd = new AttachmentCmd(completeTaskBo.getFileId(), task.getId(), task.getProcessInstanceId());
|
|
|
|
|
managementService.executeCommand(attachmentCmd);
|
|
|
|
|
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
|
|
|
|
|
String businessStatus = WorkflowUtils.getBusinessStatus(processInstance.getBusinessKey());
|
|
|
|
|
//流程提交监听
|
|
|
|
|
if (BusinessStatusEnum.DRAFT.getStatus().equals(businessStatus) || BusinessStatusEnum.BACK.getStatus().equals(businessStatus) || BusinessStatusEnum.CANCEL.getStatus().equals(businessStatus)) {
|
|
|
|
|
if (processHandler != null) {
|
|
|
|
|
processHandler.handleProcess(processInstance.getBusinessKey(), businessStatus, true);
|
|
|
|
|
}
|
|
|
|
|
flowProcessEventHandler.processHandler(processInstance.getProcessDefinitionKey(), processInstance.getBusinessKey(), businessStatus, true);
|
|
|
|
|
}
|
|
|
|
|
runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.WAITING.getStatus());
|
|
|
|
|
String key = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey();
|
|
|
|
|
FlowTaskEventHandler taskHandler = flowEventStrategy.getTaskHandler(key);
|
|
|
|
|
if (taskHandler != null) {
|
|
|
|
|
taskHandler.handleTask(task.getId(), processInstance.getBusinessKey());
|
|
|
|
|
}
|
|
|
|
|
//办理监听
|
|
|
|
|
String keyNode = processInstance.getProcessDefinitionKey() + "_" + task.getTaskDefinitionKey();
|
|
|
|
|
flowProcessEventHandler.processTaskHandler(keyNode, task.getId(), processInstance.getBusinessKey());
|
|
|
|
|
//办理意见
|
|
|
|
|
taskService.addComment(completeTaskBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), StringUtils.isBlank(completeTaskBo.getMessage()) ? "同意" : completeTaskBo.getMessage());
|
|
|
|
|
//办理任务
|
|
|
|
|
@ -207,9 +203,8 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|
|
|
|
if (pi == null) {
|
|
|
|
|
UpdateBusinessStatusCmd updateBusinessStatusCmd = new UpdateBusinessStatusCmd(task.getProcessInstanceId(), BusinessStatusEnum.FINISH.getStatus());
|
|
|
|
|
managementService.executeCommand(updateBusinessStatusCmd);
|
|
|
|
|
if (processHandler != null) {
|
|
|
|
|
processHandler.handleProcess(processInstance.getBusinessKey(), BusinessStatusEnum.FINISH.getStatus(), false);
|
|
|
|
|
}
|
|
|
|
|
flowProcessEventHandler.processHandler(processInstance.getProcessDefinitionKey(), processInstance.getBusinessKey(),
|
|
|
|
|
BusinessStatusEnum.FINISH.getStatus(), false);
|
|
|
|
|
} else {
|
|
|
|
|
List<Task> list = QueryUtils.taskQuery(task.getProcessInstanceId()).list();
|
|
|
|
|
for (Task t : list) {
|
|
|
|
|
@ -520,10 +515,9 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|
|
|
|
runtimeService.updateBusinessStatus(task.getProcessInstanceId(), BusinessStatusEnum.TERMINATION.getStatus());
|
|
|
|
|
runtimeService.deleteProcessInstance(task.getProcessInstanceId(), StrUtil.EMPTY);
|
|
|
|
|
}
|
|
|
|
|
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(historicProcessInstance.getProcessDefinitionKey());
|
|
|
|
|
if (processHandler != null) {
|
|
|
|
|
processHandler.handleProcess(historicProcessInstance.getBusinessKey(), BusinessStatusEnum.TERMINATION.getStatus(), false);
|
|
|
|
|
}
|
|
|
|
|
//流程终止监听
|
|
|
|
|
flowProcessEventHandler.processHandler(historicProcessInstance.getProcessDefinitionKey(),
|
|
|
|
|
historicProcessInstance.getBusinessKey(), BusinessStatusEnum.TERMINATION.getStatus(), false);
|
|
|
|
|
return true;
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new ServiceException(e.getMessage());
|
|
|
|
|
@ -721,10 +715,8 @@ public class ActTaskServiceImpl implements IActTaskService {
|
|
|
|
|
WfTaskBackNode wfTaskBackNode = wfTaskBackNodeService.getListByInstanceIdAndNodeId(task.getProcessInstanceId(), backProcessBo.getTargetActivityId());
|
|
|
|
|
if (ObjectUtil.isNotNull(wfTaskBackNode) && wfTaskBackNode.getOrderNo() == 0) {
|
|
|
|
|
runtimeService.updateBusinessStatus(processInstanceId, BusinessStatusEnum.BACK.getStatus());
|
|
|
|
|
FlowProcessEventHandler processHandler = flowEventStrategy.getProcessHandler(processInstance.getProcessDefinitionKey());
|
|
|
|
|
if (processHandler != null) {
|
|
|
|
|
processHandler.handleProcess(processInstance.getBusinessKey(), BusinessStatusEnum.BACK.getStatus(), false);
|
|
|
|
|
}
|
|
|
|
|
flowProcessEventHandler.processHandler(processInstance.getProcessDefinitionKey(),
|
|
|
|
|
processInstance.getBusinessKey(), BusinessStatusEnum.BACK.getStatus(), false);
|
|
|
|
|
}
|
|
|
|
|
//删除驳回后的流程节点
|
|
|
|
|
wfTaskBackNodeService.deleteBackTaskNode(processInstanceId, backProcessBo.getTargetActivityId());
|
|
|
|
|
|