|
@@ -23,6 +23,7 @@ import org.flowable.engine.HistoryService;
|
|
|
import org.flowable.engine.TaskService;
|
|
|
import org.flowable.engine.history.HistoricProcessInstance;
|
|
|
import org.flowable.engine.history.HistoricProcessInstanceQuery;
|
|
|
+import org.flowable.task.api.Task;
|
|
|
import org.flowable.task.api.TaskQuery;
|
|
|
import org.flowable.task.api.history.HistoricTaskInstance;
|
|
|
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
|
|
@@ -71,9 +72,9 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
.includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
|
|
|
// 构建列表数据
|
|
|
- buildFlowTaskList(bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
- buildFlowTaskList(bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
- buildFlowTaskList(bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
+ buildFlowTaskList(page,bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
+ buildFlowTaskList(page,bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
+ buildFlowTaskList(page,bladeFlow, flowList, claimRoleWithoutTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
|
|
|
// 计算总数
|
|
|
long count = claimUserQuery.count() + claimRoleWithTenantIdQuery.count() + claimRoleWithoutTenantIdQuery.count();
|
|
@@ -87,7 +88,7 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
+ public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page,Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
String taskUser = TaskUtil.getTaskUser();
|
|
|
List<BladeFlow> flowList = new LinkedList<>();
|
|
|
|
|
@@ -95,14 +96,20 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
TaskQuery todoQuery;
|
|
|
if(StringUtils.isEmpty(parallelProcessInstanceIds)){
|
|
|
todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
|
|
- .includeProcessVariables().orderByTaskCreateTime().desc();
|
|
|
+ .includeProcessVariables();
|
|
|
+// .orderByTaskCreateTime().desc();
|
|
|
} else {
|
|
|
todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
|
|
- .includeProcessVariables().processInstanceIdIn(Arrays.asList(parallelProcessInstanceIds.split(",").clone())).orderByTaskCreateTime().desc();
|
|
|
+ .includeProcessVariables().processInstanceIdIn(Arrays.asList(parallelProcessInstanceIds.split(",").clone()));
|
|
|
+// .orderByTaskCreateTime().desc();
|
|
|
+ }
|
|
|
+ if(ordType == 1){
|
|
|
+ todoQuery.orderByTaskCreateTime().desc();
|
|
|
+ }else{
|
|
|
+ todoQuery.orderByTaskCreateTime().asc();
|
|
|
}
|
|
|
-
|
|
|
// 构建列表数据
|
|
|
- buildFlowTaskList(bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
|
|
|
+ buildFlowTaskList(page,bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
|
|
|
|
|
|
// 计算总数
|
|
|
long count = todoQuery.count();
|
|
@@ -116,18 +123,22 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
+ public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page,Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
String taskUser = TaskUtil.getTaskUser();
|
|
|
List<BladeFlow> flowList = new LinkedList<>();
|
|
|
|
|
|
HistoricProcessInstanceQuery historyQuery;
|
|
|
if(StringUtils.isEmpty(parallelProcessInstanceIds)){
|
|
|
- historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).orderByProcessInstanceStartTime().desc();
|
|
|
+ historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser);
|
|
|
} else {
|
|
|
List<String> array = Arrays.asList(parallelProcessInstanceIds.split(","));
|
|
|
- historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).processInstanceIds(new HashSet<>(array)).orderByProcessInstanceStartTime().desc();
|
|
|
+ historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser).processInstanceIds(new HashSet<>(array));
|
|
|
+ }
|
|
|
+ if(ordType == 1){
|
|
|
+ historyQuery.orderByProcessInstanceStartTime().desc();
|
|
|
+ }else{
|
|
|
+ historyQuery.orderByProcessInstanceStartTime().asc();
|
|
|
}
|
|
|
-
|
|
|
if (bladeFlow.getCategory() != null) {
|
|
|
historyQuery.processDefinitionCategory(bladeFlow.getCategory());
|
|
|
}
|
|
@@ -194,19 +205,23 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
- public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
+ public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page,Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
String taskUser = TaskUtil.getTaskUser();
|
|
|
List<BladeFlow> flowList = new LinkedList<>();
|
|
|
|
|
|
HistoricTaskInstanceQuery doneQuery;
|
|
|
if(StringUtils.isEmpty(parallelProcessInstanceIds)){
|
|
|
doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
|
|
|
- .includeProcessVariables().orderByHistoricTaskInstanceEndTime().desc();
|
|
|
+ .includeProcessVariables();
|
|
|
} else {
|
|
|
doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
|
|
|
- .includeProcessVariables().processInstanceIdIn(Arrays.asList(parallelProcessInstanceIds.split(","))).orderByHistoricTaskInstanceEndTime().desc();
|
|
|
+ .includeProcessVariables().processInstanceIdIn(Arrays.asList(parallelProcessInstanceIds.split(",")));
|
|
|
+ }
|
|
|
+ if(ordType == 1){
|
|
|
+ doneQuery.orderByHistoricTaskInstanceEndTime().desc();
|
|
|
+ }else{
|
|
|
+ doneQuery.orderByHistoricTaskInstanceEndTime().asc();
|
|
|
}
|
|
|
-
|
|
|
if (bladeFlow.getCategory() != null) {
|
|
|
doneQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
|
|
|
}
|
|
@@ -295,7 +310,7 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
* @param taskQuery 任务查询类
|
|
|
* @param status 状态
|
|
|
*/
|
|
|
- private void buildFlowTaskList(BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) {
|
|
|
+ private void buildFlowTaskList(IPage<BladeFlow> page,BladeFlow bladeFlow, List<BladeFlow> flowList, TaskQuery taskQuery, String status) {
|
|
|
if (bladeFlow.getCategory() != null) {
|
|
|
taskQuery.processCategoryIn(Func.toStrList(bladeFlow.getCategory()));
|
|
|
}
|
|
@@ -308,7 +323,16 @@ public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
if (bladeFlow.getEndDate() != null) {
|
|
|
taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
|
|
|
}
|
|
|
- taskQuery.list().forEach(task -> {
|
|
|
+ List<Task> list;
|
|
|
+ //代办任务列表分页失效,在这里加上分页取数
|
|
|
+ if(status.equals(FlowEngineConstant.STATUS_TODO)){
|
|
|
+ int l = (int) ((page.getCurrent()-1) * page.getSize());
|
|
|
+ int l1 = (int) page.getSize();
|
|
|
+ list = taskQuery.listPage(l,l1);
|
|
|
+ }else{
|
|
|
+ list = taskQuery.list();
|
|
|
+ }
|
|
|
+ list.forEach(task -> {
|
|
|
BladeFlow flow = new BladeFlow();
|
|
|
flow.setTaskId(task.getId());
|
|
|
flow.setTaskDefinitionKey(task.getTaskDefinitionKey());
|