fix: 待办任务只查询当前用户所属任务
parent
59935dd2f2
commit
8c393c4f44
|
|
@ -2,6 +2,7 @@ package com.ruoyi.flowable.controller;
|
|||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.flowable.domain.dto.FlowTaskDto;
|
||||
import com.ruoyi.flowable.domain.vo.FlowQueryVo;
|
||||
import com.ruoyi.flowable.domain.vo.FlowTaskVo;
|
||||
import com.ruoyi.flowable.service.IFlowTaskService;
|
||||
import io.swagger.annotations.Api;
|
||||
|
|
@ -35,9 +36,8 @@ public class FlowTaskController {
|
|||
|
||||
@ApiOperation(value = "我发起的流程", response = FlowTaskDto.class)
|
||||
@GetMapping(value = "/myProcess")
|
||||
public AjaxResult myProcess(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
|
||||
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
|
||||
return flowTaskService.myProcess(pageNum, pageSize);
|
||||
public AjaxResult myProcess(FlowQueryVo queryVo) {
|
||||
return flowTaskService.myProcess(queryVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "取消申请", response = FlowTaskDto.class)
|
||||
|
|
@ -54,16 +54,14 @@ public class FlowTaskController {
|
|||
|
||||
@ApiOperation(value = "获取待办列表", response = FlowTaskDto.class)
|
||||
@GetMapping(value = "/todoList")
|
||||
public AjaxResult todoList(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
|
||||
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
|
||||
return flowTaskService.todoList(pageNum, pageSize);
|
||||
public AjaxResult todoList(FlowQueryVo queryVo) {
|
||||
return flowTaskService.todoList(queryVo);
|
||||
}
|
||||
|
||||
@ApiOperation(value = "获取已办任务", response = FlowTaskDto.class)
|
||||
@GetMapping(value = "/finishedList")
|
||||
public AjaxResult finishedList(@ApiParam(value = "当前页码", required = true) @RequestParam Integer pageNum,
|
||||
@ApiParam(value = "每页条数", required = true) @RequestParam Integer pageSize) {
|
||||
return flowTaskService.finishedList(pageNum, pageSize);
|
||||
public AjaxResult finishedList(FlowQueryVo queryVo) {
|
||||
return flowTaskService.finishedList(queryVo);
|
||||
}
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,36 @@
|
|||
package com.ruoyi.flowable.domain.vo;
|
||||
|
||||
import io.swagger.annotations.ApiModel;
|
||||
import io.swagger.annotations.ApiModelProperty;
|
||||
import lombok.Data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
/**
|
||||
* <p>流程任务<p>
|
||||
*
|
||||
* @author XuanXuan
|
||||
* @date 2021-04-03
|
||||
*/
|
||||
@Data
|
||||
@ApiModel("工作流任务相关--请求参数")
|
||||
public class FlowQueryVo {
|
||||
|
||||
@ApiModelProperty("流程名称")
|
||||
private String name;
|
||||
|
||||
@ApiModelProperty("开始时间")
|
||||
private String startTime;
|
||||
|
||||
@ApiModelProperty("结束时间")
|
||||
private String endTime;
|
||||
|
||||
@ApiModelProperty("当前页码")
|
||||
private Integer pageNum;
|
||||
|
||||
@ApiModelProperty("每页条数")
|
||||
private Integer pageSize;
|
||||
|
||||
|
||||
}
|
||||
|
|
@ -1,6 +1,7 @@
|
|||
package com.ruoyi.flowable.service;
|
||||
|
||||
import com.ruoyi.common.core.domain.AjaxResult;
|
||||
import com.ruoyi.flowable.domain.vo.FlowQueryVo;
|
||||
import com.ruoyi.flowable.domain.vo.FlowTaskVo;
|
||||
import org.flowable.task.api.Task;
|
||||
|
||||
|
|
@ -81,11 +82,10 @@ public interface IFlowTaskService {
|
|||
|
||||
/**
|
||||
* 我发起的流程
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @param queryVo 请求参数
|
||||
* @return
|
||||
*/
|
||||
AjaxResult myProcess(Integer pageNum, Integer pageSize);
|
||||
AjaxResult myProcess(FlowQueryVo queryVo);
|
||||
|
||||
/**
|
||||
* 取消申请
|
||||
|
|
@ -105,21 +105,19 @@ public interface IFlowTaskService {
|
|||
/**
|
||||
* 代办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @param queryVo 请求参数
|
||||
* @return
|
||||
*/
|
||||
AjaxResult todoList(Integer pageNum, Integer pageSize);
|
||||
AjaxResult todoList(FlowQueryVo queryVo);
|
||||
|
||||
|
||||
/**
|
||||
* 已办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @param queryVo 请求参数
|
||||
* @return
|
||||
*/
|
||||
AjaxResult finishedList(Integer pageNum, Integer pageSize);
|
||||
AjaxResult finishedList(FlowQueryVo queryVo);
|
||||
|
||||
/**
|
||||
* 流程历史流转记录
|
||||
|
|
|
|||
|
|
@ -18,6 +18,7 @@ import com.ruoyi.flowable.domain.dto.FlowCommentDto;
|
|||
import com.ruoyi.flowable.domain.dto.FlowNextDto;
|
||||
import com.ruoyi.flowable.domain.dto.FlowTaskDto;
|
||||
import com.ruoyi.flowable.domain.dto.FlowViewerDto;
|
||||
import com.ruoyi.flowable.domain.vo.FlowQueryVo;
|
||||
import com.ruoyi.flowable.domain.vo.FlowTaskVo;
|
||||
import com.ruoyi.flowable.factory.FlowServiceFactory;
|
||||
import com.ruoyi.flowable.flow.CustomProcessDiagramGenerator;
|
||||
|
|
@ -459,19 +460,18 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
/**
|
||||
* 我发起的流程
|
||||
*
|
||||
* @param pageNum
|
||||
* @param pageSize
|
||||
* @param queryVo 请求参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult myProcess(Integer pageNum, Integer pageSize) {
|
||||
public AjaxResult myProcess(FlowQueryVo queryVo) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
||||
HistoricProcessInstanceQuery historicProcessInstanceQuery = historyService.createHistoricProcessInstanceQuery()
|
||||
.startedBy(userId.toString())
|
||||
.orderByProcessInstanceStartTime()
|
||||
.desc();
|
||||
List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage(pageSize * (pageNum - 1), pageSize);
|
||||
List<HistoricProcessInstance> historicProcessInstances = historicProcessInstanceQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
|
||||
page.setTotal(historicProcessInstanceQuery.count());
|
||||
List<FlowTaskDto> flowList = new ArrayList<>();
|
||||
for (HistoricProcessInstance hisIns : historicProcessInstances) {
|
||||
|
|
@ -616,23 +616,27 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
/**
|
||||
* 代办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @param queryVo 请求参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult todoList(Integer pageNum, Integer pageSize) {
|
||||
public AjaxResult todoList(FlowQueryVo queryVo) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
// 只查看自己的数据
|
||||
SysUser sysUser = SecurityUtils.getLoginUser().getUser();
|
||||
Long userId = sysUser.getUserId();
|
||||
TaskQuery taskQuery = taskService.createTaskQuery()
|
||||
.active()
|
||||
.includeProcessVariables()
|
||||
.taskCandidateOrAssigned(userId.toString())
|
||||
.taskCandidateGroupIn(sysUser.getRoles().stream().map(role -> role.getRoleId().toString()).collect(Collectors.toList()))
|
||||
.taskCandidateOrAssigned(sysUser.getUserId().toString())
|
||||
.orderByTaskCreateTime().desc();
|
||||
|
||||
// TODO 传入名称查询不到数据?
|
||||
// if (StringUtils.isNotBlank(queryVo.getName())){
|
||||
// taskQuery.processDefinitionNameLike(queryVo.getName());
|
||||
// }
|
||||
page.setTotal(taskQuery.count());
|
||||
List<Task> taskList = taskQuery.listPage(pageSize * (pageNum - 1), pageSize);
|
||||
List<Task> taskList = taskQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
|
||||
List<FlowTaskDto> flowList = new ArrayList<>();
|
||||
for (Task task : taskList) {
|
||||
FlowTaskDto flowTask = new FlowTaskDto();
|
||||
|
|
@ -671,12 +675,11 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
/**
|
||||
* 已办任务列表
|
||||
*
|
||||
* @param pageNum 当前页码
|
||||
* @param pageSize 每页条数
|
||||
* @param queryVo 请求参数
|
||||
* @return
|
||||
*/
|
||||
@Override
|
||||
public AjaxResult finishedList(Integer pageNum, Integer pageSize) {
|
||||
public AjaxResult finishedList(FlowQueryVo queryVo) {
|
||||
Page<FlowTaskDto> page = new Page<>();
|
||||
Long userId = SecurityUtils.getLoginUser().getUser().getUserId();
|
||||
HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery()
|
||||
|
|
@ -685,7 +688,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
.taskAssignee(userId.toString())
|
||||
.orderByHistoricTaskInstanceEndTime()
|
||||
.desc();
|
||||
List<HistoricTaskInstance> historicTaskInstanceList = taskInstanceQuery.listPage(pageSize * (pageNum - 1), pageSize);
|
||||
List<HistoricTaskInstance> historicTaskInstanceList = taskInstanceQuery.listPage(queryVo.getPageSize() * (queryVo.getPageNum() - 1), queryVo.getPageSize());
|
||||
List<FlowTaskDto> hisTaskList = new ArrayList<>();
|
||||
for (HistoricTaskInstance histTask : historicTaskInstanceList) {
|
||||
FlowTaskDto flowTask = new FlowTaskDto();
|
||||
|
|
@ -721,9 +724,6 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
}
|
||||
page.setTotal(taskInstanceQuery.count());
|
||||
page.setRecords(hisTaskList);
|
||||
// Map<String, Object> result = new HashMap<>();
|
||||
// result.put("result",page);
|
||||
// result.put("finished",true);
|
||||
return AjaxResult.success(page);
|
||||
}
|
||||
|
||||
|
|
@ -1091,7 +1091,7 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
@Override
|
||||
public AjaxResult flowTaskForm(String taskId) throws Exception {
|
||||
JSONObject result = new JSONObject();
|
||||
result.put("formKeyExist",false);
|
||||
result.put("formKeyExist", false);
|
||||
Task task = taskService.createTaskQuery().taskId(taskId).singleResult();
|
||||
BpmnModel bpmnModel = repositoryService.getBpmnModel(task.getProcessDefinitionId());
|
||||
FlowElement flowElement = bpmnModel.getFlowElement(task.getTaskDefinitionKey());
|
||||
|
|
@ -1122,15 +1122,15 @@ public class FlowTaskServiceImpl extends FlowServiceFactory implements IFlowTask
|
|||
oldVariables.put("fields", oldFields);
|
||||
oldVariables.put("disabled", false);
|
||||
oldVariables.put("formBtns", true);
|
||||
result.put("formData",oldVariables);
|
||||
result.put("formKeyExist",true);
|
||||
result.put("formData", oldVariables);
|
||||
result.put("formKeyExist", true);
|
||||
return AjaxResult.success("", result);
|
||||
} else {
|
||||
result.put("formData",parameters.get("variables"));
|
||||
result.put("formData", parameters.get("variables"));
|
||||
return AjaxResult.success("", result);
|
||||
}
|
||||
} else {
|
||||
result.put("formData",parameters.get("variables"));
|
||||
result.put("formData", parameters.get("variables"));
|
||||
return AjaxResult.success("", result);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -0,0 +1,23 @@
|
|||
//package com.ruoyi.framework.config;
|
||||
//
|
||||
//import com.p6spy.engine.spy.appender.MessageFormattingStrategy;
|
||||
//import com.ruoyi.common.utils.DateUtils;
|
||||
//import org.apache.commons.lang3.StringUtils;
|
||||
//
|
||||
//import java.util.Date;
|
||||
//
|
||||
///**
|
||||
// * 自定义 p6spy sql输出格式
|
||||
// *
|
||||
// */
|
||||
//public class P6spySqlFormatConfig implements MessageFormattingStrategy {
|
||||
//
|
||||
// /**
|
||||
// * 过滤掉定时任务的 SQL
|
||||
// */
|
||||
// @Override
|
||||
// public String formatMessage(int connectionId, String now, long elapsed, String category, String prepared, String sql, String url) {
|
||||
// return StringUtils.isNotBlank(sql) ? DateUtils.parseDateToStr("yyyy-MM-dd HH:mm:ss", new Date())
|
||||
// + " | 耗时 " + elapsed + " ms | SQL 语句:" + StringUtils.LF + sql.replaceAll("[\\s]+", StringUtils.SPACE) + ";" : "";
|
||||
// }
|
||||
//}
|
||||
Loading…
Reference in New Issue