点击▲关注 “爪哇笔记” 给公众号标星置顶
更多精彩 第一时间直达
前言
应广大网友墙裂呼吁,撸主点灯野战撸了一个简单的工作流模块,的确是简单了那么一丢丢,但是不影响体验,后面会慢慢优化,直到大家足够满意。
开肝
话不多说,先上图。
我的休假:
@Override
@Transactional(rollbackFor = Exception.class)
public Result myList(BpmLeave leave) {
Long userId = ShiroUtils.getUserId();
PageBean<BpmLeave> data = new PageBean<>();
long count = historyService.createHistoricProcessInstanceQuery()
.processDefinitionKey("leave").startedBy(userId.toString())
.count();
if (count > 0) {
Integer pageSize = leave.getPageSize();
Integer firstResult = (leave.getPageNo()) * pageSize;
List<HistoricProcessInstance> list = historyService.createHistoricProcessInstanceQuery()
.processDefinitionKey("leave").startedBy(userId.toString())
.listPage(firstResult, pageSize);
List<BpmLeave> listLeave = new ArrayList<>();
list.forEach(instance->{
String nativeSql = "SELECT * FROM bpm_leave WHERE process_instance_id=?";
BpmLeave entity = dynamicQuery.nativeQuerySingleResult(BpmLeave.class,nativeSql,new Object[]{instance.getId()});
entity.setStatus(instance.getEndTime()==null?"进行中":"已完成");
listLeave.add(entity);
});
data = new PageBean(listLeave, count);
}
return Result.ok(data);
}
待办任务:
@Override
public Result toDoList(BpmLeave leave) {
Long userId = ShiroUtils.getUserId();
PageBean<BpmLeave> data = new PageBean<>();
long count = taskService.createTaskQuery()
.taskCandidateOrAssigned(userId.toString()).count();
if(count>0){
Integer pageSize = leave.getPageSize();
Integer firstResult = (leave.getPageNo()) * pageSize;
List<Task> tasks = taskService.createTaskQuery()
.taskCandidateOrAssigned(userId.toString())
.listPage(firstResult,pageSize);
List<BpmLeave> listLeave = new ArrayList<>();
tasks.forEach(task->{
String processInstanceId = task.getProcessInstanceId();
String nativeSql = "SELECT * FROM bpm_leave WHERE process_instance_id=?";
BpmLeave entity = dynamicQuery.nativeQuerySingleResult(BpmLeave.class,nativeSql,new Object[]{processInstanceId});
entity.setTaskId(task.getId());
listLeave.add(entity);
});
data = new PageBean(listLeave, count);
}
return Result.ok(data);
}
已办任务:
@Override
public Result toDoList(BpmLeave leave) {
Long userId = ShiroUtils.getUserId();
PageBean<BpmLeave> data = new PageBean<>();
long count = taskService.createTaskQuery()
.taskCandidateOrAssigned(userId.toString()).count();
if(count>0){
Integer pageSize = leave.getPageSize();
Integer firstResult = (leave.getPageNo()) * pageSize;
List<Task> tasks = taskService.createTaskQuery()
.taskCandidateOrAssigned(userId.toString())
.listPage(firstResult,pageSize);
List<BpmLeave> listLeave = new ArrayList<>();
tasks.forEach(task->{
String processInstanceId = task.getProcessInstanceId();
String nativeSql = "SELECT * FROM bpm_leave WHERE process_instance_id=?";
BpmLeave entity = dynamicQuery.nativeQuerySingleResult(BpmLeave.class,nativeSql,new Object[]{processInstanceId});
entity.setTaskId(task.getId());
listLeave.add(entity);
});
data = new PageBean(listLeave, count);
}
return Result.ok(data);
}
小结
流程做的有点仓促,无论怎样,先开源给各位小伙伴,需要请666点赞再看,如果觉得不错可以分享给身边的朋友,你们的支持是我更新最大的动力。
获取方式
1. 识别下方二维码
2. 后台回复「666」即可获取