mirror of
https://gitee.com/huangge1199_admin/vue-pro.git
synced 2024-11-30 03:01:53 +08:00
实现 bpm 已办任务的后端接口
This commit is contained in:
parent
77f06e79c4
commit
2017b03169
@ -2,3 +2,8 @@
|
|||||||
GET {{baseUrl}}/bpm/task/todo-page
|
GET {{baseUrl}}/bpm/task/todo-page
|
||||||
tenant-id: 1
|
tenant-id: 1
|
||||||
Authorization: Bearer {{token}}
|
Authorization: Bearer {{token}}
|
||||||
|
|
||||||
|
### 请求 /bpm/task/done-page 接口 => 成功
|
||||||
|
GET {{baseUrl}}/bpm/task/done-page
|
||||||
|
tenant-id: 1
|
||||||
|
Authorization: Bearer {{token}}
|
||||||
|
@ -31,11 +31,17 @@ public class BpmTaskController {
|
|||||||
// TODO 芋艿:权限、validation;
|
// TODO 芋艿:权限、validation;
|
||||||
|
|
||||||
@GetMapping("todo-page")
|
@GetMapping("todo-page")
|
||||||
@ApiOperation("获取 TODO 待办任务分页")
|
@ApiOperation("获取 Todo 待办任务分页")
|
||||||
public CommonResult<PageResult<BpmTaskTodoPageItemRespVO>> getTodoTaskPage(@Valid BpmTaskTodoPageReqVO pageVO) {
|
public CommonResult<PageResult<BpmTaskTodoPageItemRespVO>> getTodoTaskPage(@Valid BpmTaskTodoPageReqVO pageVO) {
|
||||||
return success(taskService.getTodoTaskPage(getLoginUserId(), pageVO));
|
return success(taskService.getTodoTaskPage(getLoginUserId(), pageVO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@GetMapping("done-page")
|
||||||
|
@ApiOperation("获取 Done 已办任务分页")
|
||||||
|
public CommonResult<PageResult<BpmTaskDonePageItemRespVO>> getTodoTaskPage(@Valid BpmTaskDonePageReqVO pageVO) {
|
||||||
|
return success(taskService.getDoneTaskPage(getLoginUserId(), pageVO));
|
||||||
|
}
|
||||||
|
|
||||||
@PostMapping("/task-steps")
|
@PostMapping("/task-steps")
|
||||||
public CommonResult<TaskHandleVO> getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) {
|
public CommonResult<TaskHandleVO> getTaskSteps(@RequestBody TaskQueryReqVO taskQuery) {
|
||||||
return success(taskService.getTaskSteps(taskQuery));
|
return success(taskService.getTaskSteps(taskQuery));
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
@ApiModel("流程任务的 Done 已完成的分页项 Response VO")
|
||||||
|
@Data
|
||||||
|
public class BpmTaskDonePageItemRespVO {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "任务编号", required = true, example = "1024")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "任务名字", required = true, example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "接收时间", required = true)
|
||||||
|
private Date claimTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "创建时间", required = true)
|
||||||
|
private Date createTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束时间", required = true)
|
||||||
|
private Date endTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "持续时间", required = true, example = "1000")
|
||||||
|
private Long durationInMillis;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 所属流程实例
|
||||||
|
*/
|
||||||
|
private ProcessInstance processInstance;
|
||||||
|
|
||||||
|
@Data
|
||||||
|
@ApiModel("流程实例")
|
||||||
|
public static class ProcessInstance {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程实例编号", required = true, example = "1024")
|
||||||
|
private String id;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程实例名称", required = true, example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发起人的用户编号", required = true, example = "1024")
|
||||||
|
private Long startUserId;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "发起人的用户昵称", required = true, example = "芋艿")
|
||||||
|
private String startUserNickname;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程定义的编号", required = true, example = "2048")
|
||||||
|
private String processDefinitionId;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
// 任务编号、流程名称、任务节点、流程发起人、接收时间、审批时间、耗时【名称、开始时间】「流程记录、撤回」
|
||||||
|
// 任务编号、任务名称、所属流程、委托代办人、流程发起人、优先级、审批操作、审批意见、耗时、创建时间【名称、开始时间】「申请详情」
|
||||||
|
|
||||||
|
// 任务编号、任务名称、流程名称、流程发起人、接收时间、审批时间、耗时【名称、接收时间】「详情」TODO 撤回
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,32 @@
|
|||||||
|
package cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task;
|
||||||
|
|
||||||
|
import cn.iocoder.yudao.framework.common.pojo.PageParam;
|
||||||
|
import io.swagger.annotations.ApiModel;
|
||||||
|
import io.swagger.annotations.ApiModelProperty;
|
||||||
|
import lombok.Data;
|
||||||
|
import lombok.EqualsAndHashCode;
|
||||||
|
import lombok.ToString;
|
||||||
|
import org.springframework.format.annotation.DateTimeFormat;
|
||||||
|
|
||||||
|
import java.util.Date;
|
||||||
|
|
||||||
|
import static cn.iocoder.yudao.framework.common.util.date.DateUtils.FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND;
|
||||||
|
|
||||||
|
@ApiModel("流程任务的 Done 已办的分页 Request VO")
|
||||||
|
@Data
|
||||||
|
@EqualsAndHashCode(callSuper = true)
|
||||||
|
@ToString(callSuper = true)
|
||||||
|
public class BpmTaskDonePageReqVO extends PageParam {
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "流程任务名", example = "芋道")
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "开始的创建收间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private Date beginCreateTime;
|
||||||
|
|
||||||
|
@ApiModelProperty(value = "结束的创建时间")
|
||||||
|
@DateTimeFormat(pattern = FORMAT_YEAR_MONTH_DAY_HOUR_MINUTE_SECOND)
|
||||||
|
private Date endCreateTime;
|
||||||
|
|
||||||
|
}
|
@ -6,7 +6,7 @@ import lombok.Data;
|
|||||||
|
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
|
||||||
@ApiModel(value = "流程任务的 Running 进行中的分页项 Response VO", description = "待办任务")
|
@ApiModel("流程任务的 Running 进行中的分页项 Response VO")
|
||||||
@Data
|
@Data
|
||||||
public class BpmTaskTodoPageItemRespVO {
|
public class BpmTaskTodoPageItemRespVO {
|
||||||
|
|
||||||
@ -51,8 +51,4 @@ public class BpmTaskTodoPageItemRespVO {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 任务编号、任务名称、任务节点、流程版本、流程发起人、接收时间【名称、开始时间】「处理」
|
|
||||||
// 任务编号、任务名称、所属流程、委托代办人、流程发起人、优先级、状态、创建时间【名称、开始时间】「申请详情、通过、驳回、转办、历史」
|
|
||||||
|
|
||||||
// 任务编号、任务名称、流程名称、流程发起人、接收时间、状态【名称、接收时间】【处理、委托】
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,12 @@
|
|||||||
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.task.vo.task.BpmTaskDonePageItemRespVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskTodoPageItemRespVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.BpmTaskTodoPageItemRespVO;
|
||||||
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TaskStepVO;
|
import cn.iocoder.yudao.adminserver.modules.bpm.controller.task.vo.task.TaskStepVO;
|
||||||
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.util.collection.CollectionUtils;
|
import cn.iocoder.yudao.framework.common.util.collection.CollectionUtils;
|
||||||
import org.activiti.engine.history.HistoricActivityInstance;
|
import org.activiti.engine.history.HistoricActivityInstance;
|
||||||
|
import org.activiti.engine.history.HistoricTaskInstance;
|
||||||
import org.activiti.engine.impl.persistence.entity.SuspensionState;
|
import org.activiti.engine.impl.persistence.entity.SuspensionState;
|
||||||
import org.activiti.engine.runtime.ProcessInstance;
|
import org.activiti.engine.runtime.ProcessInstance;
|
||||||
import org.activiti.engine.task.Task;
|
import org.activiti.engine.task.Task;
|
||||||
@ -61,4 +63,28 @@ public interface BpmTaskConvert {
|
|||||||
SuspensionState.ACTIVE.getStateCode();
|
SuspensionState.ACTIVE.getStateCode();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
default List<BpmTaskDonePageItemRespVO> convertList2(List<HistoricTaskInstance> tasks,
|
||||||
|
Map<String, ProcessInstance> processInstanceMap,
|
||||||
|
Map<Long, SysUserDO> userMap) {
|
||||||
|
return CollectionUtils.convertList(tasks, task -> {
|
||||||
|
ProcessInstance processInstance = processInstanceMap.get(task.getProcessInstanceId());
|
||||||
|
return convert(task, processInstance, userMap.get(Long.valueOf(processInstance.getStartUserId())));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
@Mappings({
|
||||||
|
@Mapping(source = "task.id", target = "id"),
|
||||||
|
@Mapping(source = "task.name", target = "name"),
|
||||||
|
@Mapping(source = "task.claimTime", target = "claimTime"),
|
||||||
|
@Mapping(source = "task.createTime", target = "createTime"),
|
||||||
|
@Mapping(source = "task.endTime", target = "endTime"),
|
||||||
|
@Mapping(source = "task.durationInMillis", target = "durationInMillis"),
|
||||||
|
@Mapping(source = "processInstance.id", target = "processInstance.id"),
|
||||||
|
@Mapping(source = "processInstance.name", target = "processInstance.name"),
|
||||||
|
@Mapping(source = "processInstance.startUserId", target = "processInstance.startUserId"),
|
||||||
|
@Mapping(source = "processInstance.processDefinitionId", target = "processInstance.processDefinitionId"),
|
||||||
|
@Mapping(source = "user.nickname", target = "processInstance.startUserNickname")
|
||||||
|
})
|
||||||
|
BpmTaskDonePageItemRespVO convert(HistoricTaskInstance task, ProcessInstance processInstance, SysUserDO user);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -44,7 +44,7 @@ public interface BpmTaskService {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获得流程任务分页
|
* 获得待办的流程任务分页
|
||||||
*
|
*
|
||||||
* @param userId 用户编号
|
* @param userId 用户编号
|
||||||
* @param pageReqVO 分页请求
|
* @param pageReqVO 分页请求
|
||||||
@ -52,6 +52,15 @@ public interface BpmTaskService {
|
|||||||
*/
|
*/
|
||||||
PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO);
|
PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageReqVO);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获得已办的流程任务分页
|
||||||
|
*
|
||||||
|
* @param userId 用户编号
|
||||||
|
* @param pageReqVO 分页请求
|
||||||
|
* @return 流程任务分页
|
||||||
|
*/
|
||||||
|
PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageReqVO);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 将流程任务分配给指定用户
|
* 将流程任务分配给指定用户
|
||||||
*
|
*
|
||||||
|
@ -23,6 +23,8 @@ import org.activiti.engine.RuntimeService;
|
|||||||
import org.activiti.engine.TaskService;
|
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.history.HistoricTaskInstance;
|
||||||
|
import org.activiti.engine.history.HistoricTaskInstanceQuery;
|
||||||
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;
|
||||||
@ -83,7 +85,8 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {
|
public PageResult<BpmTaskTodoPageItemRespVO> getTodoTaskPage(Long userId, BpmTaskTodoPageReqVO pageVO) {
|
||||||
// 查询待办任务
|
// 查询待办任务
|
||||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||||
.taskAssignee(String.valueOf(userId));
|
.taskAssignee(String.valueOf(userId)) // 分配给自己
|
||||||
|
.orderByTaskCreateTime().desc(); // 创建时间倒序
|
||||||
if (StrUtil.isNotBlank(pageVO.getName())) {
|
if (StrUtil.isNotBlank(pageVO.getName())) {
|
||||||
taskQuery.taskNameLike("%" + pageVO.getName() + "%");
|
taskQuery.taskNameLike("%" + pageVO.getName() + "%");
|
||||||
}
|
}
|
||||||
@ -94,8 +97,7 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
taskQuery.taskCreatedBefore(pageVO.getEndCreateTime());
|
taskQuery.taskCreatedBefore(pageVO.getEndCreateTime());
|
||||||
}
|
}
|
||||||
// 执行查询
|
// 执行查询
|
||||||
List<Task> tasks = taskQuery.orderByTaskCreateTime().desc() // 创建时间倒序
|
List<Task> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
||||||
.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
|
||||||
if (CollUtil.isEmpty(tasks)) {
|
if (CollUtil.isEmpty(tasks)) {
|
||||||
return PageResult.empty(taskQuery.count());
|
return PageResult.empty(taskQuery.count());
|
||||||
}
|
}
|
||||||
@ -103,7 +105,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
// 获得 ProcessInstance Map
|
// 获得 ProcessInstance Map
|
||||||
Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(
|
Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(
|
||||||
convertSet(tasks, Task::getProcessInstanceId));
|
convertSet(tasks, Task::getProcessInstanceId));
|
||||||
|
|
||||||
// 获得 User Map
|
// 获得 User Map
|
||||||
Map<Long, SysUserDO> userMap = userService.getUserMap(
|
Map<Long, SysUserDO> userMap = userService.getUserMap(
|
||||||
convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
|
convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
|
||||||
@ -112,6 +113,39 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
taskQuery.count());
|
taskQuery.count());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageVO) {
|
||||||
|
// 查询已办任务
|
||||||
|
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery()
|
||||||
|
.finished() // 已完成
|
||||||
|
.taskAssignee(String.valueOf(userId)) // 分配给自己
|
||||||
|
.orderByHistoricTaskInstanceEndTime().desc(); // 审批时间倒序
|
||||||
|
if (StrUtil.isNotBlank(pageVO.getName())) {
|
||||||
|
taskQuery.taskNameLike("%" + pageVO.getName() + "%");
|
||||||
|
}
|
||||||
|
if (pageVO.getBeginCreateTime() != null) {
|
||||||
|
taskQuery.taskCreatedAfter(pageVO.getBeginCreateTime());
|
||||||
|
}
|
||||||
|
if (pageVO.getEndCreateTime() != null) {
|
||||||
|
taskQuery.taskCreatedBefore(pageVO.getEndCreateTime());
|
||||||
|
}
|
||||||
|
// 执行查询
|
||||||
|
List<HistoricTaskInstance> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
|
||||||
|
if (CollUtil.isEmpty(tasks)) {
|
||||||
|
return PageResult.empty(taskQuery.count());
|
||||||
|
}
|
||||||
|
|
||||||
|
// 获得 ProcessInstance Map
|
||||||
|
Map<String, ProcessInstance> processInstanceMap = processInstanceService.getProcessInstanceMap(
|
||||||
|
convertSet(tasks, HistoricTaskInstance::getProcessInstanceId));
|
||||||
|
// 获得 User Map
|
||||||
|
Map<Long, SysUserDO> userMap = userService.getUserMap(
|
||||||
|
convertSet(processInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
|
||||||
|
// 拼接结果
|
||||||
|
return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, processInstanceMap, userMap),
|
||||||
|
taskQuery.count());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void updateTaskAssign(String id, Long userId) {
|
public void updateTaskAssign(String id, Long userId) {
|
||||||
taskService.setAssignee(id, String.valueOf(userId));
|
taskService.setAssignee(id, String.valueOf(userId));
|
||||||
@ -122,11 +156,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// 任务编号、流程名称、任务节点、流程发起人、接收时间、审批时间、耗时【名称、开始时间】「流程记录、撤回」
|
|
||||||
// 任务编号、任务名称、所属流程、委托代办人、流程发起人、优先级、审批操作、审批意见、耗时、创建时间【名称、开始时间】「申请详情」
|
|
||||||
|
|
||||||
// 任务编号、任务名称、流程名称、流程发起人、接收时间、审批时间、耗时【名称、接收时间】「详情」TODO 撤回
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@Transactional
|
@Transactional
|
||||||
public void completeTask(TaskReqVO taskReq) {
|
public void completeTask(TaskReqVO taskReq) {
|
||||||
@ -139,8 +168,6 @@ public class BpmTaskServiceImpl implements BpmTaskService {
|
|||||||
// .build());
|
// .build());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery) {
|
public TaskHandleVO getTaskSteps(TaskQueryReqVO taskQuery) {
|
||||||
// TaskHandleVO handleVO = new TaskHandleVO();
|
// TaskHandleVO handleVO = new TaskHandleVO();
|
||||||
|
Loading…
Reference in New Issue
Block a user