mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-26 17:21:53 +08:00
bpm 我的流程,增加 task 的展示
This commit is contained in:
parent
14a7d637b3
commit
1ab15dd1f9
@ -5,7 +5,7 @@ tenant-id: 1
|
|||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
{
|
{
|
||||||
"processDefinitionId": "leave:7:20ada39c-6c95-11ec-88b1-cacd34981f8e",
|
"processDefinitionId": "gateway_test:2:00e52d8e-701b-11ec-aca9-a2380e71991a",
|
||||||
"variables": {
|
"variables": {
|
||||||
"a": 1,
|
"a": 1,
|
||||||
"b": "2"
|
"b": "2"
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
import cn.iocoder.yudao.framework.common.pojo.CommonResult;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
@ -5,6 +5,7 @@ import io.swagger.annotations.ApiModelProperty;
|
|||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@ApiModel("流程实例的分页 Item Response VO")
|
@ApiModel("流程实例的分页 Item Response VO")
|
||||||
@Data
|
@Data
|
||||||
@ -34,6 +35,21 @@ public class BpmProcessInstancePageItemRespVO {
|
|||||||
@ApiModelProperty(value = "结束时间", required = true)
|
@ApiModelProperty(value = "结束时间", required = true)
|
||||||
private Date endTime;
|
private Date endTime;
|
||||||
|
|
||||||
// TODO 芋艿:tasks
|
/**
|
||||||
|
* 当前任务
|
||||||
|
*/
|
||||||
|
private List<Task> tasks;
|
||||||
|
|
||||||
|
@ApiModel("流程任务")
|
||||||
|
@Data
|
||||||
|
public static class Task {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程任务的编号", required = true, example = "1024")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "任务名称", required = true, example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
|
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import lombok.Data;
|
import lombok.Data;
|
||||||
import lombok.ToString;
|
import lombok.ToString;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
@ -1,4 +1,4 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo;
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
import io.swagger.annotations.ApiModel;
|
import io.swagger.annotations.ApiModel;
|
||||||
import lombok.Data;
|
import lombok.Data;
|
@ -5,12 +5,15 @@ import cn.iocoder.yudao.adminserver.modules.bpm.dal.dataobject.task.BpmProcessIn
|
|||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import org.activiti.engine.repository.ProcessDefinition;
|
import org.activiti.engine.repository.ProcessDefinition;
|
||||||
import org.activiti.engine.runtime.ProcessInstance;
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
|
import org.activiti.engine.task.Task;
|
||||||
import org.mapstruct.Mapper;
|
import org.mapstruct.Mapper;
|
||||||
import org.mapstruct.Mapping;
|
import org.mapstruct.Mapping;
|
||||||
import org.mapstruct.Mappings;
|
import org.mapstruct.Mappings;
|
||||||
import org.mapstruct.factory.Mappers;
|
import org.mapstruct.factory.Mappers;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.function.Consumer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程实例 Convert
|
* 流程实例 Convert
|
||||||
@ -32,10 +35,17 @@ public interface BpmProcessInstanceConvert {
|
|||||||
})
|
})
|
||||||
BpmProcessInstanceExtDO convert(ProcessInstance instance, ProcessDefinition definition);
|
BpmProcessInstanceExtDO convert(ProcessInstance instance, ProcessDefinition definition);
|
||||||
|
|
||||||
PageResult<BpmProcessInstancePageItemRespVO> convertPage(PageResult<BpmProcessInstanceExtDO> page);
|
default PageResult<BpmProcessInstancePageItemRespVO> convertPage(PageResult<BpmProcessInstanceExtDO> page,
|
||||||
|
Map<String, List<Task>> taskMap) {
|
||||||
|
List<BpmProcessInstancePageItemRespVO> list = convertList(page.getList());
|
||||||
|
list.forEach(respVO -> respVO.setTasks(convertList2(taskMap.get(respVO.getId()))));
|
||||||
|
return new PageResult<>(list, page.getTotal());
|
||||||
|
}
|
||||||
|
|
||||||
List<BpmProcessInstancePageItemRespVO> convertList(List<BpmProcessInstanceExtDO> list);
|
List<BpmProcessInstancePageItemRespVO> convertList(List<BpmProcessInstanceExtDO> list);
|
||||||
|
|
||||||
|
List<BpmProcessInstancePageItemRespVO.Task> convertList2(List<Task> tasks);
|
||||||
|
|
||||||
@Mapping(source = "processInstanceId", target = "id")
|
@Mapping(source = "processInstanceId", target = "id")
|
||||||
BpmProcessInstancePageItemRespVO convert(BpmProcessInstanceExtDO bean);
|
BpmProcessInstancePageItemRespVO convert(BpmProcessInstanceExtDO bean);
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
|
package cn.iocoder.yudao.adminserver.modules.bpm.convert.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.TaskStepVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TaskStepVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.TodoTaskRespVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TodoTaskRespVO;
|
||||||
import org.activiti.api.task.model.Task;
|
import org.activiti.api.task.model.Task;
|
||||||
import org.activiti.engine.history.HistoricActivityInstance;
|
import org.activiti.engine.history.HistoricActivityInstance;
|
||||||
import org.activiti.engine.repository.ProcessDefinition;
|
import org.activiti.engine.repository.ProcessDefinition;
|
||||||
|
@ -1,15 +1,41 @@
|
|||||||
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
|
package cn.iocoder.yudao.adminserver.modules.bpm.service.task;
|
||||||
|
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
|
import org.activiti.engine.task.Task;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 工作流用户任务服务接口
|
* 工作任务 Service 接口
|
||||||
|
*
|
||||||
|
* @author jason
|
||||||
|
* @author 芋道源码
|
||||||
*/
|
*/
|
||||||
public interface BpmTaskService {
|
public interface BpmTaskService {
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得流程任务列表
|
||||||
|
*
|
||||||
|
* @param processInstanceIds 流程实例的编号数组
|
||||||
|
* @return 流程任务列表
|
||||||
|
*/
|
||||||
|
List<Task> getTasksByProcessInstanceIds(List<String> processInstanceIds);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得流程任务 Map
|
||||||
|
*
|
||||||
|
* @param processInstanceIds 流程实例的编号数组
|
||||||
|
* @return 流程任务 Map
|
||||||
|
*/
|
||||||
|
default Map<String, List<Task>> getTaskMapByProcessInstanceIds(List<String> processInstanceIds) {
|
||||||
|
return CollectionUtils.convertMultiMap(getTasksByProcessInstanceIds(processInstanceIds),
|
||||||
|
Task::getProcessInstanceId);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取当前用户的待办任务, 分页
|
* 获取当前用户的待办任务, 分页
|
||||||
|
@ -12,9 +12,11 @@ import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceRes
|
|||||||
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum;
|
import cn.iocoder.yudao.adminserver.modules.bpm.enums.task.BpmProcessInstanceStatusEnum;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.definition.BpmProcessDefinitionService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmProcessInstanceService;
|
||||||
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||||
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
import cn.iocoder.yudao.adminserver.modules.system.service.user.SysUserService;
|
||||||
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
import cn.iocoder.yudao.coreservice.modules.system.dal.dataobject.user.SysUserDO;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.activiti.engine.HistoryService;
|
import org.activiti.engine.HistoryService;
|
||||||
import org.activiti.engine.RuntimeService;
|
import org.activiti.engine.RuntimeService;
|
||||||
@ -34,6 +36,7 @@ import java.util.Map;
|
|||||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_IS_SUSPENDED;
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_IS_SUSPENDED;
|
||||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_NOT_EXISTS;
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_DEFINITION_NOT_EXISTS;
|
||||||
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
import static cn.iocoder.yudao.framework.common.exception.util.ServiceExceptionUtil.exception;
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.collection.CollectionUtils.convertList;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 流程实例 Service 实现类
|
* 流程实例 Service 实现类
|
||||||
@ -55,7 +58,7 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||||||
@Resource
|
@Resource
|
||||||
private RuntimeService runtimeService;
|
private RuntimeService runtimeService;
|
||||||
@Resource
|
@Resource
|
||||||
private TaskService taskService;
|
private BpmTaskService taskService;
|
||||||
@Resource
|
@Resource
|
||||||
private HistoryService historyService;
|
private HistoryService historyService;
|
||||||
|
|
||||||
@ -88,17 +91,17 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||||||
createProcessInstanceExt(instance, definition);
|
createProcessInstanceExt(instance, definition);
|
||||||
|
|
||||||
// 添加初始的评论 TODO 芋艿:在思考下
|
// 添加初始的评论 TODO 芋艿:在思考下
|
||||||
Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult();
|
// Task task = taskService.createTaskQuery().processInstanceId(instance.getId()).singleResult();
|
||||||
if (task != null) {
|
// if (task != null) {
|
||||||
SysUserDO user = userService.getUser(userId);
|
// SysUserDO user = userService.getUser(userId);
|
||||||
Assert.notNull(user, "用户({})不存在", userId);
|
// Assert.notNull(user, "用户({})不存在", userId);
|
||||||
String type = "normal";
|
// String type = "normal";
|
||||||
taskService.addComment(task.getId(), instance.getProcessInstanceId(), type,
|
// taskService.addComment(task.getId(), instance.getProcessInstanceId(), type,
|
||||||
String.format("%s 发起流程申请", user.getNickname()));
|
// String.format("%s 发起流程申请", user.getNickname()));
|
||||||
// TODO 芋艿:应该不用下面两个步骤
|
// // TODO 芋艿:应该不用下面两个步骤
|
||||||
// taskService.setAssignee(task.getId(), String.valueOf(userId));
|
//// taskService.setAssignee(task.getId(), String.valueOf(userId));
|
||||||
// taskService.complete(task.getId(), variables);
|
//// taskService.complete(task.getId(), variables);
|
||||||
}
|
// }
|
||||||
return instance.getId();
|
return instance.getId();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -123,24 +126,12 @@ public class BpmProcessInstanceServiceImpl implements BpmProcessInstanceService
|
|||||||
if (CollUtil.isEmpty(pageResult.getList())) {
|
if (CollUtil.isEmpty(pageResult.getList())) {
|
||||||
return new PageResult<>(pageResult.getTotal());
|
return new PageResult<>(pageResult.getTotal());
|
||||||
}
|
}
|
||||||
// TODO 芋艿:tasks
|
|
||||||
|
// 获得流程 Task Map
|
||||||
|
List<String> processInstanceIds = convertList(pageResult.getList(), BpmProcessInstanceExtDO::getProcessInstanceId);
|
||||||
|
Map<String, List<Task>> taskMap = taskService.getTaskMapByProcessInstanceIds(processInstanceIds);
|
||||||
// 转换返回
|
// 转换返回
|
||||||
return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult);
|
return BpmProcessInstanceConvert.INSTANCE.convertPage(pageResult, taskMap);
|
||||||
}
|
|
||||||
|
|
||||||
public void getMyProcessInstancePage(Long userId) {
|
|
||||||
// id title 所属流程 当前审批环节 状态 结果 创建时间 提交申请时间 【标题、状态】「ActBusiness」
|
|
||||||
// id title 流程类别 流程版本 提交时间 流程状态 耗时 当前节点 办理 【标题、提交时间】「HistoricProcessInstanceQuery」
|
|
||||||
|
|
||||||
// id name 所属流程 流程类别 创建时间 状态 当前审批环节 【标题、流程、时间、状态、结果】
|
|
||||||
|
|
||||||
runtimeService.createProcessInstanceQuery().list();
|
|
||||||
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
|
||||||
.startedBy(String.valueOf(userId)) // 发起人是自己
|
|
||||||
.orderByProcessInstanceStartTime().desc(); // 按照发起时间倒序
|
|
||||||
List<HistoricProcessInstance> list = historicProcessInstanceQuery.list();
|
|
||||||
System.out.println("test");
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -2,16 +2,13 @@ package cn.iocoder.yudao.adminserver.modules.bpm.service.task.impl;
|
|||||||
|
|
||||||
import cn.hutool.core.collection.CollUtil;
|
import cn.hutool.core.collection.CollUtil;
|
||||||
import cn.hutool.core.io.IoUtil;
|
import cn.hutool.core.io.IoUtil;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.workflow.vo.*;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.*;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.TaskConvert;
|
import cn.iocoder.yudao.adminserver.modules.bpm.convert.task.TaskConvert;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
import cn.iocoder.yudao.adminserver.modules.bpm.service.task.BpmTaskService;
|
||||||
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
import cn.iocoder.yudao.framework.common.pojo.PageResult;
|
||||||
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
import cn.iocoder.yudao.framework.security.core.util.SecurityFrameworkUtils;
|
||||||
import lombok.extern.slf4j.Slf4j;
|
import lombok.extern.slf4j.Slf4j;
|
||||||
import org.activiti.api.runtime.shared.query.Page;
|
|
||||||
import org.activiti.api.runtime.shared.query.Pageable;
|
|
||||||
import org.activiti.api.task.model.Task;
|
|
||||||
import org.activiti.api.task.model.builders.ClaimTaskPayloadBuilder;
|
import org.activiti.api.task.model.builders.ClaimTaskPayloadBuilder;
|
||||||
import org.activiti.api.task.model.builders.TaskPayloadBuilder;
|
import org.activiti.api.task.model.builders.TaskPayloadBuilder;
|
||||||
import org.activiti.api.task.runtime.TaskRuntime;
|
import org.activiti.api.task.runtime.TaskRuntime;
|
||||||
@ -22,11 +19,13 @@ import org.activiti.bpmn.model.SequenceFlow;
|
|||||||
import org.activiti.engine.HistoryService;
|
import org.activiti.engine.HistoryService;
|
||||||
import org.activiti.engine.RepositoryService;
|
import org.activiti.engine.RepositoryService;
|
||||||
import org.activiti.engine.RuntimeService;
|
import org.activiti.engine.RuntimeService;
|
||||||
|
import org.activiti.engine.TaskService;
|
||||||
import org.activiti.engine.history.HistoricActivityInstance;
|
import org.activiti.engine.history.HistoricActivityInstance;
|
||||||
import org.activiti.engine.history.HistoricProcessInstance;
|
import org.activiti.engine.history.HistoricProcessInstance;
|
||||||
import org.activiti.engine.repository.ProcessDefinition;
|
import org.activiti.engine.repository.ProcessDefinition;
|
||||||
import org.activiti.engine.runtime.ProcessInstance;
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
import org.activiti.engine.task.Comment;
|
import org.activiti.engine.task.Comment;
|
||||||
|
import org.activiti.engine.task.Task;
|
||||||
import org.activiti.image.ProcessDiagramGenerator;
|
import org.activiti.image.ProcessDiagramGenerator;
|
||||||
import org.springframework.stereotype.Service;
|
import org.springframework.stereotype.Service;
|
||||||
import org.springframework.transaction.annotation.Transactional;
|
import org.springframework.transaction.annotation.Transactional;
|
||||||
@ -35,11 +34,7 @@ import org.springframework.util.ObjectUtils;
|
|||||||
import javax.annotation.Resource;
|
import javax.annotation.Resource;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.util.ArrayList;
|
import java.util.*;
|
||||||
import java.util.List;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Optional;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.HIGHLIGHT_IMG_ERROR;
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.HIGHLIGHT_IMG_ERROR;
|
||||||
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS;
|
import static cn.iocoder.yudao.adminserver.modules.bpm.enums.BpmErrorCodeConstants.PROCESS_INSTANCE_NOT_EXISTS;
|
||||||
@ -51,34 +46,39 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private TaskRuntime taskRuntime;
|
private TaskRuntime taskRuntime;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private org.activiti.engine.TaskService activitiTaskService;
|
private TaskService taskService;
|
||||||
|
|
||||||
@Resource
|
|
||||||
private HistoryService historyService;
|
|
||||||
|
|
||||||
@Resource
|
|
||||||
private RepositoryService repositoryService;
|
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private RuntimeService runtimeService;
|
private RuntimeService runtimeService;
|
||||||
|
@Resource
|
||||||
|
private HistoryService historyService;
|
||||||
|
@Resource
|
||||||
|
private RepositoryService repositoryService;
|
||||||
|
|
||||||
@Resource
|
@Resource
|
||||||
private ProcessDiagramGenerator processDiagramGenerator;
|
private ProcessDiagramGenerator processDiagramGenerator;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public List<Task> getTasksByProcessInstanceIds(List<String> processInstanceIds) {
|
||||||
|
if (CollUtil.isEmpty(processInstanceIds)) {
|
||||||
|
return Collections.emptyList();
|
||||||
|
}
|
||||||
|
return taskService.createTaskQuery().processInstanceIdIn(processInstanceIds).list();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PageResult<TodoTaskRespVO> getTodoTaskPage(TodoTaskPageReqVO pageReqVO) {
|
public PageResult<TodoTaskRespVO> getTodoTaskPage(TodoTaskPageReqVO pageReqVO) {
|
||||||
// TODO @jason:封装一个方法,用于转换成 activiti 的分页对象
|
// TODO @jason:封装一个方法,用于转换成 activiti 的分页对象
|
||||||
final Pageable pageable = Pageable.of((pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize(), pageReqVO.getPageSize());
|
// final Pageable pageable = Pageable.of((pageReqVO.getPageNo() - 1) * pageReqVO.getPageSize(), pageReqVO.getPageSize());
|
||||||
Page<Task> pageTasks = taskRuntime.tasks(pageable);
|
// Page<Task> pageTasks = taskRuntime.tasks(pageable);
|
||||||
int totalItems = pageTasks.getTotalItems();
|
// int totalItems = pageTasks.getTotalItems();
|
||||||
List<Task> tasks = pageTasks.getContent();
|
// List<Task> tasks = pageTasks.getContent();
|
||||||
final List<TodoTaskRespVO> respVOList = tasks.stream().map(task -> {
|
// final List<TodoTaskRespVO> respVOList = tasks.stream().map(task -> {
|
||||||
ProcessDefinition definition = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
|
// ProcessDefinition definition = repositoryService.getProcessDefinition(task.getProcessDefinitionId());
|
||||||
return TaskConvert.INSTANCE.convert(task, definition);
|
// return TaskConvert.INSTANCE.convert(task, definition);
|
||||||
}).collect(Collectors.toList());
|
// }).collect(Collectors.toList());
|
||||||
return new PageResult<>(respVOList, (long)totalItems);
|
// return new PageResult<>(respVOList, (long)totalItems);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -95,27 +95,27 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void completeTask(TaskReqVO taskReq) {
|
public void completeTask(TaskReqVO taskReq) {
|
||||||
final Task task = taskRuntime.task(taskReq.getTaskId());
|
// final Task task = taskRuntime.task(taskReq.getTaskId());
|
||||||
|
//
|
||||||
activitiTaskService.addComment(taskReq.getTaskId(), task.getProcessInstanceId(), taskReq.getComment());
|
// taskService.addComment(taskReq.getTaskId(), task.getProcessInstanceId(), taskReq.getComment());
|
||||||
|
//
|
||||||
taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskReq.getTaskId())
|
// taskRuntime.complete(TaskPayloadBuilder.complete().withTaskId(taskReq.getTaskId())
|
||||||
.withVariables(taskReq.getVariables())
|
// .withVariables(taskReq.getVariables())
|
||||||
.build());
|
// .build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery) {
|
public TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery) {
|
||||||
TaskHandleVO handleVO = new TaskHandleVO();
|
// TaskHandleVO handleVO = new TaskHandleVO();
|
||||||
final Task task = taskRuntime.task(taskQuery.getTaskId());
|
// final Task task = taskRuntime.task(taskQuery.getTaskId());
|
||||||
List<TaskStepVO> steps = getTaskSteps(task.getProcessInstanceId());
|
// List<TaskStepVO> steps = getTaskSteps(task.getProcessInstanceId());
|
||||||
handleVO.setHistoryTask(steps);
|
// handleVO.setHistoryTask(steps);
|
||||||
return handleVO;
|
// return handleVO;
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private List<TaskStepVO> getTaskSteps(String processInstanceId) {
|
private List<TaskStepVO> getTaskSteps(String processInstanceId) {
|
||||||
// 获得已完成的活动
|
// 获得已完成的活动
|
||||||
List<HistoricActivityInstance> finished = historyService.createHistoricActivityInstanceQuery()
|
List<HistoricActivityInstance> finished = historyService.createHistoricActivityInstanceQuery()
|
||||||
@ -129,7 +129,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
TaskStepVO stepVO = TaskConvert.INSTANCE.convert(instance);
|
TaskStepVO stepVO = TaskConvert.INSTANCE.convert(instance);
|
||||||
stepVO.setStatus(1); // TODO @jason:1 这个 magic number 要枚举起来。
|
stepVO.setStatus(1); // TODO @jason:1 这个 magic number 要枚举起来。
|
||||||
// TODO @jason:可以考虑把 comments 读取后,在统一调用 convert 拼接。另外 Comment 是废弃的类,有没其它可以使用的哈?
|
// TODO @jason:可以考虑把 comments 读取后,在统一调用 convert 拼接。另外 Comment 是废弃的类,有没其它可以使用的哈?
|
||||||
List<Comment> comments = activitiTaskService.getTaskComments(instance.getTaskId());
|
List<Comment> comments = taskService.getTaskComments(instance.getTaskId());
|
||||||
if (!CollUtil.isEmpty(comments)) {
|
if (!CollUtil.isEmpty(comments)) {
|
||||||
stepVO.setComment(Optional.ofNullable(comments.get(0)).map(Comment::getFullMessage).orElse(""));
|
stepVO.setComment(Optional.ofNullable(comments.get(0)).map(Comment::getFullMessage).orElse(""));
|
||||||
}
|
}
|
||||||
@ -160,8 +160,9 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TodoTaskRespVO getTaskFormKey(TaskQueryReqVO taskQuery) {
|
public TodoTaskRespVO getTaskFormKey(TaskQueryReqVO taskQuery) {
|
||||||
final Task task = taskRuntime.task(taskQuery.getTaskId());
|
// final Task task = taskRuntime.task(taskQuery.getTaskId());
|
||||||
return TaskConvert.INSTANCE.convert(task);
|
// return TaskConvert.INSTANCE.convert(task);
|
||||||
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -54,7 +54,13 @@
|
|||||||
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
|
<span>{{ getDictDataLabel(DICT_TYPE.BPM_MODEL_CATEGORY, scope.row.category) }}</span>
|
||||||
</template>
|
</template>
|
||||||
</el-table-column>
|
</el-table-column>
|
||||||
<el-table-column label="当前审批任务" align="center" prop="tasks" /> <!-- TODO 芋艿:待完善 -->
|
<el-table-column label="当前审批任务" align="center" prop="tasks">
|
||||||
|
<template slot-scope="scope">
|
||||||
|
<el-button v-for="task in scope.row.tasks" type="text" @click="handleFormDetail(task.id)">
|
||||||
|
<span>{{ task.name }}</span>
|
||||||
|
</el-button>
|
||||||
|
</template>
|
||||||
|
</el-table-column>
|
||||||
<el-table-column label="状态" align="center" prop="status">
|
<el-table-column label="状态" align="center" prop="status">
|
||||||
<template slot-scope="scope">
|
<template slot-scope="scope">
|
||||||
<span>
|
<span>
|
||||||
|
Loading…
Reference in New Issue
Block a user