package com.ruoyi.workflow.service.impl;
import cn.hutool.core.collection.CollUtil;
import cn.hutool.core.collection.CollectionUtil;
import cn.hutool.core.util.ObjectUtil;
import cn.hutool.core.util.StrUtil;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.ruoyi.common.core.domain.PageQuery;
import com.ruoyi.common.core.domain.entity.SysUser;
import com.ruoyi.common.core.page.TableDataInfo;
import com.ruoyi.common.exception.ServiceException;
import com.ruoyi.common.helper.LoginHelper;
import com.ruoyi.common.utils.StringUtils;
import com.ruoyi.workflow.common.constant.FlowConstant;
import com.ruoyi.workflow.common.enums.BusinessStatusEnum;
import com.ruoyi.workflow.common.enums.TaskStatusEnum;
import com.ruoyi.workflow.domain.ActBusinessStatus;
import com.ruoyi.workflow.domain.ActNodeAssignee;
import com.ruoyi.workflow.domain.ActTaskNode;
import com.ruoyi.workflow.domain.bo.*;
import com.ruoyi.workflow.domain.vo.*;
import com.ruoyi.workflow.flowable.cmd.*;
import com.ruoyi.workflow.listener.AbstractExecuteProcessHandler;
import com.ruoyi.workflow.listener.AbstractExecuteTaskHandler;
import com.ruoyi.workflow.mapper.ActTaskMapper;
import com.ruoyi.workflow.service.*;
import com.ruoyi.workflow.utils.CompleteTaskUtils;
import com.ruoyi.workflow.utils.WorkflowUtils;
import lombok.RequiredArgsConstructor;
import org.flowable.bpmn.model.BpmnModel;
import org.flowable.bpmn.model.FlowElement;
import org.flowable.engine.*;
import org.flowable.engine.impl.bpmn.behavior.ParallelMultiInstanceBehavior;
import org.flowable.engine.impl.bpmn.behavior.SequentialMultiInstanceBehavior;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.impl.persistence.entity.ExecutionEntityImpl;
import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.task.Attachment;
import org.flowable.identitylink.api.history.HistoricIdentityLink;
import org.flowable.task.api.Task;
import org.flowable.task.api.history.HistoricTaskInstance;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
import org.flowable.task.service.impl.persistence.entity.TaskEntity;
import org.flowable.variable.api.persistence.entity.VariableInstance;
import org.springframework.beans.BeanUtils;
import org.springframework.scheduling.annotation.Async;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import java.util.*;
import java.util.stream.Collectors;
import static com.ruoyi.common.helper.LoginHelper.getUserId;
/**
* @description: 任务业务层
* @author: gssong
* @date: 2021/10/17 14:57
*/
@Service
@RequiredArgsConstructor
public class ActTaskServiceImpl implements IActTaskService {
private final IWorkflowUserService iWorkflowUserService;
private final IActBusinessStatusService iActBusinessStatusService;
private final IActTaskNodeService iActTaskNodeService;
private final IActNodeAssigneeService iActNodeAssigneeService;
private final IActBusinessRuleService iActBusinessRuleService;
private final ManagementService managementService;
private final ActTaskMapper actTaskMapper;
private final IActProcessDefSettingService iActProcessDefSettingService;
private final IActProcessInstanceService iActProcessInstanceService;
private final TaskService taskService;
private final RuntimeService runtimeService;
private final RepositoryService repositoryService;
private final HistoryService historyService;
/**
* @description: 办理任务
* @param: taskCompleteBo
* @return: boolean
* @author: gssong
* @date: 2021/10/21
*/
@Override
@Transactional(rollbackFor = Exception.class)
public boolean completeTask(TaskCompleteBo taskCompleteBo) {
// 1.查询任务
Task task = taskService.createTaskQuery().taskId(taskCompleteBo.getTaskId()).taskAssignee(String.valueOf(LoginHelper.getUserId())).singleResult();
if (ObjectUtil.isEmpty(task)) {
throw new ServiceException(FlowConstant.MESSAGE_CURRENT_TASK_IS_NULL);
}
if (task.isSuspended()) {
throw new ServiceException(FlowConstant.MESSAGE_SUSPENDED);
}
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(task.getProcessInstanceId()).singleResult();
try {
//办理委托任务
if (ObjectUtil.isNotEmpty(task.getDelegationState()) && FlowConstant.PENDING.equals(task.getDelegationState().name())) {
taskService.resolveTask(taskCompleteBo.getTaskId());
TaskEntity newTask = WorkflowUtils.createNewTask(task, true);
taskService.addComment(newTask.getId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), taskCompleteBo.getMessage());
taskService.complete(newTask.getId());
return true;
}
//附件上传
AttachmentCmd attachmentCmd = new AttachmentCmd(taskCompleteBo.getFileId(), task.getId(), task.getProcessInstanceId());
managementService.executeCommand(attachmentCmd);
//流程定义设置
ActProcessDefSettingVo setting = iActProcessDefSettingService.getProcessDefSettingByDefId(task.getProcessDefinitionId());
if (setting != null && !setting.getDefaultProcess()) {
return CompleteTaskUtils.execute(taskCompleteBo);
}
// 2. 判断下一节点是否是会签 如果是会签 将选择的人员放到会签变量
List<ActNodeAssignee> actNodeAssignees = iActNodeAssigneeService.getInfoByProcessDefinitionId(task.getProcessDefinitionId());
for (ActNodeAssignee actNodeAssignee : actNodeAssignees) {
String column = actNodeAssignee.getMultipleColumn();
String assigneeId = actNodeAssignee.getAssigneeId();
if (actNodeAssignee.getMultiple() && actNodeAssignee.getIsShow()) {
List<Long> userIdList = taskCompleteBo.getAssignees(actNodeAssignee.getMultipleColumn());
if (CollectionUtil.isNotEmpty(userIdList)) {
taskService.setVariable(task.getId(), column, userIdList);
}
}
//判断是否有会签并且不需要弹窗选人的节点
if (Boolean.TRUE.equals(actNodeAssignee.getMultiple() && Boolean.FALSE.equals(actNodeAssignee.getIsShow())) && (StringUtils.isBlank(column) || StringUtils.isBlank(assigneeId))) {
throw new ServiceException("请检查【" + processInstance.getProcessDefinitionKey() + "】配置 ");
}
if (Boolean.TRUE.equals(actNodeAssignee.getMultiple()) && Boolean.FALSE.equals(actNodeAssignee.getIsShow())) {
WorkflowUtils.settingAssignee(task, actNodeAssignee, actNodeAssignee.getMultiple());
}
}
// 3. 指定任务审批意见
taskService.addComment(taskCompleteBo.getTaskId(), task.getProcessInstanceId(), TaskStatusEnum.PASS.getStatus(), taskCompleteBo.getMessage());
// 设置变量
if (CollectionUtil.isNotEmpty(taskCompleteBo.getVariables())) {
taskService.setVariables(taskCompleteBo.getTaskId(), taskCompleteBo.getVariables());
}
ActNodeAssignee actNodeAssignee = actNodeAssignees.stream().filter(e -> e.getNodeId().equals(task.getTaskDefinitionKey())).findFirst().orElse(null);
if (ObjectUtil.isNull(actNodeAssignee)) {
throw new ServiceException("请检查【" + task.getName() + "】节点配置");
}
//办理任务
new AbstractExecuteTaskHandler()
没有合适的资源?快使用搜索试试~ 我知道了~
温馨提示
本项目为基于RuoYi-Vue-Plus集成Flowable工作流的定制化设计源码,包含1254个文件,涵盖625个Java文件、160个Vue文件、144个JavaScript文件、91个SVG文件、66个XML文件、23个SQL文件以及其他类型文件。该工作流支持RBAC动态权限、数据权限、多种工作流操作,如自由驳回、委托、转办、提交、会签、加签、减签、抄送等,并具备并行网关、分支网关等高级功能。项目定期同步RuoYi-Vue-Plus更新,鼓励通过Star支持,以激励作者持续开发。
资源推荐
资源详情
资源评论
收起资源包目录
基于RuoYi-Vue-Plus的Flowable工作流设计源码 (1252个子文件)
ry.bat 2KB
package.bat 165B
run-web.bat 118B
build.bat 109B
nginx.conf 4KB
redis.conf 662B
bootstrap.min.css 119KB
AdminLTE.min.css 104KB
ionicons.min.css 50KB
_all-skins.min.css 41KB
font-awesome.min.css 30KB
layer.css 14KB
codemirror.css 8KB
daterangepicker.css 8KB
dataTables.bootstrap.min.css 4KB
pace-theme-flash.css 2KB
blue.css 2KB
show-hint.css 623B
.env.development 696B
Dockerfile 647B
Dockerfile 359B
Dockerfile 270B
.editorconfig 514B
.editorconfig 340B
fontawesome-webfont.eot 162KB
ionicons.eot 118KB
glyphicons-halflings-regular.eot 20KB
.eslintignore 298B
jobinfo.index.ftl 30KB
common.macro.ftl 10KB
jobgroup.index.ftl 9KB
user.index.ftl 9KB
joblog.index.ftl 8KB
jobcode.index.ftl 8KB
index.ftl 6KB
joblog.detail.ftl 2KB
login.ftl 2KB
help.ftl 1KB
common.exception.ftl 747B
401.gif 160KB
loading-0.gif 6KB
loading-2.gif 2KB
loading-1.gif 701B
.gitignore 649B
.gitignore 256B
ie.html 23KB
index.html 5KB
favicon.ico 8KB
favicon.ico 4KB
ActTaskServiceImpl.java 68KB
CronExpression.java 60KB
CustomDefaultProcessDiagramGenerator.java 57KB
WorkflowUtils.java 57KB
ActProcessInstanceServiceImpl.java 51KB
ActProcessDefinitionServiceImpl.java 23KB
XxlJobServiceImpl.java 21KB
SysLoginService.java 20KB
GenTableServiceImpl.java 18KB
MailUtils.java 18KB
ExcelDownHandler.java 18KB
WorkflowUserServiceImpl.java 17KB
ExcelUtil.java 17KB
SysUserServiceImpl.java 16KB
SysRoleServiceImpl.java 16KB
JobScheduleHelper.java 16KB
ActModelServiceImpl.java 15KB
ActNodeAssigneeServiceImpl.java 15KB
VelocityUtils.java 15KB
CompleteTaskUtils.java 15KB
SysMenuServiceImpl.java 14KB
XxlJobDynamicScheduler.java 14KB
ProcessRunningPathUtils.java 14KB
RedisUtils.java 13KB
OssClient.java 13KB
ActTaskController.java 11KB
SysDictTypeServiceImpl.java 11KB
XxlJobTrigger.java 11KB
OpenApiHandler.java 10KB
SysDeptServiceImpl.java 10KB
EncryptUtils.java 10KB
SysUserController.java 10KB
JobLogController.java 9KB
StringUtils.java 9KB
StreamUtils.java 9KB
JobRegistryHelper.java 9KB
JobGroupController.java 9KB
ActProcessDefSettingServiceImpl.java 9KB
CommonTaskWaitingVo.java 8KB
GenUtils.java 8KB
ActGatewayConditionServiceImpl.java 8KB
SysOssServiceImpl.java 8KB
SampleService.java 8KB
GlobalExceptionHandler.java 8KB
ExportExcelServiceImpl.java 8KB
ActProcessInstanceController.java 8KB
CommonTaskFinishVo.java 8KB
SysConfigServiceImpl.java 8KB
PlusDataPermissionHandler.java 8KB
SysRoleController.java 8KB
LogAspect.java 8KB
共 1252 条
- 1
- 2
- 3
- 4
- 5
- 6
- 13
资源评论
lsx202406
- 粉丝: 2799
- 资源: 5661
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
最新资源
资源上传下载、课程学习等过程中有任何疑问或建议,欢迎提出宝贵意见哦~我们会及时处理!
点击此处反馈
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功