其他
肝了一夜,撸了一个请假工作流模块
点击▲关注 “爪哇笔记” 给公众号标星置顶
更多精彩 第一时间直达
前言
开肝
@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);
}
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);
}
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);
}