|
@@ -52,325 +52,325 @@ import java.util.*;
|
|
|
@AllArgsConstructor
|
|
|
public class FlowBusinessServiceImpl implements FlowBusinessService {
|
|
|
|
|
|
- private final TaskService taskService;
|
|
|
- private final HistoryService historyService;
|
|
|
+ private final TaskService taskService;
|
|
|
+ private final HistoryService historyService;
|
|
|
|
|
|
- @Override
|
|
|
- public IPage<BladeFlow> selectClaimPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
|
|
|
- String taskUser = TaskUtil.getTaskUser();
|
|
|
- String taskGroup = TaskUtil.getCandidateGroup();
|
|
|
- List<BladeFlow> flowList = new LinkedList<>();
|
|
|
+ @Override
|
|
|
+ public IPage<BladeFlow> selectClaimPage(IPage<BladeFlow> page, BladeFlow bladeFlow) {
|
|
|
+ String taskUser = TaskUtil.getTaskUser();
|
|
|
+ String taskGroup = TaskUtil.getCandidateGroup();
|
|
|
+ List<BladeFlow> flowList = new LinkedList<>();
|
|
|
|
|
|
- // 个人等待签收的任务
|
|
|
- TaskQuery claimUserQuery = taskService.createTaskQuery().taskCandidateUser(taskUser)
|
|
|
- .includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
- // 定制流程等待签收的任务
|
|
|
- TaskQuery claimRoleWithTenantIdQuery = taskService.createTaskQuery().taskTenantId(AuthUtil.getTenantId()).taskCandidateGroupIn(Func.toStrList(taskGroup))
|
|
|
- .includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
- // 通用流程等待签收的任务
|
|
|
- TaskQuery claimRoleWithoutTenantIdQuery = taskService.createTaskQuery().taskWithoutTenantId().taskCandidateGroupIn(Func.toStrList(taskGroup))
|
|
|
- .includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
+ // 个人等待签收的任务
|
|
|
+ TaskQuery claimUserQuery = taskService.createTaskQuery().taskCandidateUser(taskUser)
|
|
|
+ .includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
+ // 定制流程等待签收的任务
|
|
|
+ TaskQuery claimRoleWithTenantIdQuery = taskService.createTaskQuery().taskTenantId(AuthUtil.getTenantId()).taskCandidateGroupIn(Func.toStrList(taskGroup))
|
|
|
+ .includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
+ // 通用流程等待签收的任务
|
|
|
+ TaskQuery claimRoleWithoutTenantIdQuery = taskService.createTaskQuery().taskWithoutTenantId().taskCandidateGroupIn(Func.toStrList(taskGroup))
|
|
|
+ .includeProcessVariables().active().orderByTaskCreateTime().desc();
|
|
|
|
|
|
- // 构建列表数据
|
|
|
- buildFlowTaskList(page,bladeFlow, flowList, claimUserQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
- buildFlowTaskList(page,bladeFlow, flowList, claimRoleWithTenantIdQuery, FlowEngineConstant.STATUS_CLAIM);
|
|
|
- buildFlowTaskList(page,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();
|
|
|
- // 设置页数
|
|
|
- page.setSize(count);
|
|
|
- // 设置总数
|
|
|
- page.setTotal(count);
|
|
|
- // 设置数据
|
|
|
- page.setRecords(flowList);
|
|
|
- return page;
|
|
|
- }
|
|
|
+ // 计算总数
|
|
|
+ long count = claimUserQuery.count() + claimRoleWithTenantIdQuery.count() + claimRoleWithoutTenantIdQuery.count();
|
|
|
+ // 设置页数
|
|
|
+ page.setSize(count);
|
|
|
+ // 设置总数
|
|
|
+ page.setTotal(count);
|
|
|
+ // 设置数据
|
|
|
+ page.setRecords(flowList);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page,Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
- String taskUser = TaskUtil.getTaskUser();
|
|
|
- List<BladeFlow> flowList = new LinkedList<>();
|
|
|
+ @Override
|
|
|
+ public IPage<BladeFlow> selectTodoPage(IPage<BladeFlow> page, Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
+ String taskUser = TaskUtil.getTaskUser();
|
|
|
+ List<BladeFlow> flowList = new LinkedList<>();
|
|
|
|
|
|
- // 已签收的任务
|
|
|
- TaskQuery todoQuery;
|
|
|
- if(StringUtils.isEmpty(parallelProcessInstanceIds)){
|
|
|
- todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
|
|
- .includeProcessVariables();
|
|
|
+ // 已签收的任务
|
|
|
+ TaskQuery todoQuery;
|
|
|
+ if (StringUtils.isEmpty(parallelProcessInstanceIds)) {
|
|
|
+ todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
|
|
+ .includeProcessVariables();
|
|
|
// .orderByTaskCreateTime().desc();
|
|
|
- } else {
|
|
|
- todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
|
|
- .includeProcessVariables().processInstanceIdIn(Arrays.asList(parallelProcessInstanceIds.split(",").clone()));
|
|
|
+ } else {
|
|
|
+ todoQuery = taskService.createTaskQuery().taskAssignee(taskUser).active()
|
|
|
+ .includeProcessVariables().processInstanceIdIn(Arrays.asList(parallelProcessInstanceIds.split(",").clone()));
|
|
|
// .orderByTaskCreateTime().desc();
|
|
|
- }
|
|
|
- if(ordType == 1){
|
|
|
- todoQuery.orderByTaskCreateTime().desc();
|
|
|
- }else{
|
|
|
- todoQuery.orderByTaskCreateTime().asc();
|
|
|
- }
|
|
|
- // 构建列表数据
|
|
|
- buildFlowTaskList(page,bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
|
|
|
+ }
|
|
|
+ if (ordType == 1) {
|
|
|
+ todoQuery.orderByTaskCreateTime().desc();
|
|
|
+ } else {
|
|
|
+ todoQuery.orderByTaskCreateTime().asc();
|
|
|
+ }
|
|
|
+ // 构建列表数据
|
|
|
+ buildFlowTaskList(page, bladeFlow, flowList, todoQuery, FlowEngineConstant.STATUS_TODO);
|
|
|
|
|
|
- // 计算总数
|
|
|
- long count = todoQuery.count();
|
|
|
- // 设置页数
|
|
|
- page.setSize(count);
|
|
|
- // 设置总数
|
|
|
- page.setTotal(count);
|
|
|
- // 设置数据
|
|
|
- page.setRecords(flowList);
|
|
|
- return page;
|
|
|
- }
|
|
|
+ // 计算总数
|
|
|
+ long count = todoQuery.count();
|
|
|
+ // 设置页数
|
|
|
+ page.setSize(count);
|
|
|
+ // 设置总数
|
|
|
+ page.setTotal(count);
|
|
|
+ // 设置数据
|
|
|
+ page.setRecords(flowList);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public IPage<BladeFlow> selectSendPage(IPage<BladeFlow> page,Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
- String taskUser = TaskUtil.getTaskUser();
|
|
|
- List<BladeFlow> flowList = new LinkedList<>();
|
|
|
+ @Override
|
|
|
+ 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);
|
|
|
- } else {
|
|
|
- List<String> array = Arrays.asList(parallelProcessInstanceIds.split(","));
|
|
|
- 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());
|
|
|
- }
|
|
|
- if (bladeFlow.getProcessDefinitionName() != null) {
|
|
|
- historyQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
|
|
- }
|
|
|
- if (bladeFlow.getBeginDate() != null) {
|
|
|
- historyQuery.startedAfter(bladeFlow.getBeginDate());
|
|
|
- }
|
|
|
- if (bladeFlow.getEndDate() != null) {
|
|
|
- historyQuery.startedBefore(bladeFlow.getEndDate());
|
|
|
- }
|
|
|
+ HistoricProcessInstanceQuery historyQuery;
|
|
|
+ if (StringUtils.isEmpty(parallelProcessInstanceIds)) {
|
|
|
+ historyQuery = historyService.createHistoricProcessInstanceQuery().startedBy(taskUser);
|
|
|
+ } else {
|
|
|
+ List<String> array = Arrays.asList(parallelProcessInstanceIds.split(","));
|
|
|
+ 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());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getProcessDefinitionName() != null) {
|
|
|
+ historyQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getBeginDate() != null) {
|
|
|
+ historyQuery.startedAfter(bladeFlow.getBeginDate());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getEndDate() != null) {
|
|
|
+ historyQuery.startedBefore(bladeFlow.getEndDate());
|
|
|
+ }
|
|
|
|
|
|
- // 查询列表
|
|
|
- List<HistoricProcessInstance> historyList = historyQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize()));
|
|
|
+ // 查询列表
|
|
|
+ List<HistoricProcessInstance> historyList = historyQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize()));
|
|
|
|
|
|
- historyList.forEach(historicProcessInstance -> {
|
|
|
- BladeFlow flow = new BladeFlow();
|
|
|
- // historicProcessInstance
|
|
|
- flow.setCreateTime(historicProcessInstance.getStartTime());
|
|
|
- flow.setEndTime(historicProcessInstance.getEndTime());
|
|
|
- flow.setVariables(historicProcessInstance.getProcessVariables());
|
|
|
- String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
|
|
- if (businessKey.length > 1) {
|
|
|
- flow.setBusinessTable(businessKey[0]);
|
|
|
- flow.setBusinessId(businessKey[1]);
|
|
|
- }
|
|
|
- flow.setHistoryActivityName(historicProcessInstance.getName());
|
|
|
- flow.setProcessInstanceId(historicProcessInstance.getId());
|
|
|
- flow.setHistoryProcessInstanceId(historicProcessInstance.getId());
|
|
|
- // ProcessDefinition
|
|
|
- FlowProcess processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
|
|
|
- flow.setProcessDefinitionId(processDefinition.getId());
|
|
|
- flow.setProcessDefinitionName(processDefinition.getName());
|
|
|
- flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
|
|
- flow.setProcessDefinitionKey(processDefinition.getKey());
|
|
|
- flow.setCategory(processDefinition.getCategory());
|
|
|
- flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
|
|
- flow.setProcessInstanceId(historicProcessInstance.getId());
|
|
|
- // HistoricTaskInstance
|
|
|
- List<HistoricTaskInstance> historyTasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().list();
|
|
|
- if (Func.isNotEmpty(historyTasks)) {
|
|
|
- HistoricTaskInstance historyTask = historyTasks.iterator().next();
|
|
|
- flow.setTaskId(historyTask.getId());
|
|
|
- flow.setTaskName(historyTask.getName());
|
|
|
- flow.setTaskDefinitionKey(historyTask.getTaskDefinitionKey());
|
|
|
- }
|
|
|
- // Status
|
|
|
- if (historicProcessInstance.getEndActivityId() != null) {
|
|
|
- flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
|
|
|
- } else {
|
|
|
- flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
|
|
|
- }
|
|
|
- flow.setStatus(FlowEngineConstant.STATUS_FINISH);
|
|
|
- flowList.add(flow);
|
|
|
- });
|
|
|
+ historyList.forEach(historicProcessInstance -> {
|
|
|
+ BladeFlow flow = new BladeFlow();
|
|
|
+ // historicProcessInstance
|
|
|
+ flow.setCreateTime(historicProcessInstance.getStartTime());
|
|
|
+ flow.setEndTime(historicProcessInstance.getEndTime());
|
|
|
+ flow.setVariables(historicProcessInstance.getProcessVariables());
|
|
|
+ String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
|
|
+ if (businessKey.length > 1) {
|
|
|
+ flow.setBusinessTable(businessKey[0]);
|
|
|
+ flow.setBusinessId(businessKey[1]);
|
|
|
+ }
|
|
|
+ flow.setHistoryActivityName(historicProcessInstance.getName());
|
|
|
+ flow.setProcessInstanceId(historicProcessInstance.getId());
|
|
|
+ flow.setHistoryProcessInstanceId(historicProcessInstance.getId());
|
|
|
+ // ProcessDefinition
|
|
|
+ FlowProcess processDefinition = FlowCache.getProcessDefinition(historicProcessInstance.getProcessDefinitionId());
|
|
|
+ flow.setProcessDefinitionId(processDefinition.getId());
|
|
|
+ flow.setProcessDefinitionName(processDefinition.getName());
|
|
|
+ flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
|
|
+ flow.setProcessDefinitionKey(processDefinition.getKey());
|
|
|
+ flow.setCategory(processDefinition.getCategory());
|
|
|
+ flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
|
|
+ flow.setProcessInstanceId(historicProcessInstance.getId());
|
|
|
+ // HistoricTaskInstance
|
|
|
+ List<HistoricTaskInstance> historyTasks = historyService.createHistoricTaskInstanceQuery().processInstanceId(historicProcessInstance.getId()).orderByHistoricTaskInstanceEndTime().desc().list();
|
|
|
+ if (Func.isNotEmpty(historyTasks)) {
|
|
|
+ HistoricTaskInstance historyTask = historyTasks.iterator().next();
|
|
|
+ flow.setTaskId(historyTask.getId());
|
|
|
+ flow.setTaskName(historyTask.getName());
|
|
|
+ flow.setTaskDefinitionKey(historyTask.getTaskDefinitionKey());
|
|
|
+ }
|
|
|
+ // Status
|
|
|
+ if (historicProcessInstance.getEndActivityId() != null) {
|
|
|
+ flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
|
|
|
+ } else {
|
|
|
+ flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
|
|
|
+ }
|
|
|
+ flow.setStatus(FlowEngineConstant.STATUS_FINISH);
|
|
|
+ flowList.add(flow);
|
|
|
+ });
|
|
|
|
|
|
- // 计算总数
|
|
|
- long count = historyQuery.count();
|
|
|
- // 设置总数
|
|
|
- page.setTotal(count);
|
|
|
- page.setRecords(flowList);
|
|
|
- return page;
|
|
|
- }
|
|
|
+ // 计算总数
|
|
|
+ long count = historyQuery.count();
|
|
|
+ // 设置总数
|
|
|
+ page.setTotal(count);
|
|
|
+ page.setRecords(flowList);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public IPage<BladeFlow> selectDonePage(IPage<BladeFlow> page,Integer ordType, BladeFlow bladeFlow, String parallelProcessInstanceIds) {
|
|
|
- String taskUser = TaskUtil.getTaskUser();
|
|
|
- List<BladeFlow> flowList = new LinkedList<>();
|
|
|
+ @Override
|
|
|
+ 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();
|
|
|
- } else {
|
|
|
- doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
|
|
|
- .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()));
|
|
|
- }
|
|
|
- if (bladeFlow.getProcessDefinitionName() != null) {
|
|
|
- doneQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
|
|
- }
|
|
|
- if (bladeFlow.getBeginDate() != null) {
|
|
|
- doneQuery.taskCompletedAfter(bladeFlow.getBeginDate());
|
|
|
- }
|
|
|
- if (bladeFlow.getEndDate() != null) {
|
|
|
- doneQuery.taskCompletedBefore(bladeFlow.getEndDate());
|
|
|
- }
|
|
|
+ HistoricTaskInstanceQuery doneQuery;
|
|
|
+ if (StringUtils.isEmpty(parallelProcessInstanceIds)) {
|
|
|
+ doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
|
|
|
+ .includeProcessVariables();
|
|
|
+ } else {
|
|
|
+ doneQuery = historyService.createHistoricTaskInstanceQuery().taskAssignee(taskUser).finished()
|
|
|
+ .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()));
|
|
|
+ }
|
|
|
+ if (bladeFlow.getProcessDefinitionName() != null) {
|
|
|
+ doneQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getBeginDate() != null) {
|
|
|
+ doneQuery.taskCompletedAfter(bladeFlow.getBeginDate());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getEndDate() != null) {
|
|
|
+ doneQuery.taskCompletedBefore(bladeFlow.getEndDate());
|
|
|
+ }
|
|
|
|
|
|
- // 查询列表
|
|
|
- List<HistoricTaskInstance> doneList = doneQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize()));
|
|
|
- doneList.forEach(historicTaskInstance -> {
|
|
|
- BladeFlow flow = new BladeFlow();
|
|
|
- flow.setTaskId(historicTaskInstance.getId());
|
|
|
- flow.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey());
|
|
|
- flow.setTaskName(historicTaskInstance.getName());
|
|
|
- flow.setAssignee(historicTaskInstance.getAssignee());
|
|
|
- flow.setCreateTime(historicTaskInstance.getCreateTime());
|
|
|
- flow.setExecutionId(historicTaskInstance.getExecutionId());
|
|
|
- flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
|
|
|
- flow.setVariables(historicTaskInstance.getProcessVariables());
|
|
|
+ // 查询列表
|
|
|
+ List<HistoricTaskInstance> doneList = doneQuery.listPage(Func.toInt((page.getCurrent() - 1) * page.getSize()), Func.toInt(page.getSize()));
|
|
|
+ doneList.forEach(historicTaskInstance -> {
|
|
|
+ BladeFlow flow = new BladeFlow();
|
|
|
+ flow.setTaskId(historicTaskInstance.getId());
|
|
|
+ flow.setTaskDefinitionKey(historicTaskInstance.getTaskDefinitionKey());
|
|
|
+ flow.setTaskName(historicTaskInstance.getName());
|
|
|
+ flow.setAssignee(historicTaskInstance.getAssignee());
|
|
|
+ flow.setCreateTime(historicTaskInstance.getCreateTime());
|
|
|
+ flow.setExecutionId(historicTaskInstance.getExecutionId());
|
|
|
+ flow.setHistoryTaskEndTime(historicTaskInstance.getEndTime());
|
|
|
+ flow.setVariables(historicTaskInstance.getProcessVariables());
|
|
|
|
|
|
- FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
|
|
|
- flow.setProcessDefinitionId(processDefinition.getId());
|
|
|
- flow.setProcessDefinitionName(processDefinition.getName());
|
|
|
- flow.setProcessDefinitionKey(processDefinition.getKey());
|
|
|
- flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
|
|
- flow.setCategory(processDefinition.getCategory());
|
|
|
- flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
|
|
+ FlowProcess processDefinition = FlowCache.getProcessDefinition(historicTaskInstance.getProcessDefinitionId());
|
|
|
+ flow.setProcessDefinitionId(processDefinition.getId());
|
|
|
+ flow.setProcessDefinitionName(processDefinition.getName());
|
|
|
+ flow.setProcessDefinitionKey(processDefinition.getKey());
|
|
|
+ flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
|
|
+ flow.setCategory(processDefinition.getCategory());
|
|
|
+ flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
|
|
|
|
|
- flow.setProcessInstanceId(historicTaskInstance.getProcessInstanceId());
|
|
|
- flow.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId());
|
|
|
- HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance((historicTaskInstance.getProcessInstanceId()));
|
|
|
- if (Func.isNotEmpty(historicProcessInstance)) {
|
|
|
- String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
|
|
- flow.setBusinessTable(businessKey[0]);
|
|
|
- flow.setBusinessId(businessKey[1]);
|
|
|
- if (historicProcessInstance.getEndActivityId() != null) {
|
|
|
- flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
|
|
|
- } else {
|
|
|
- flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
|
|
|
- }
|
|
|
- }
|
|
|
- flow.setStatus(FlowEngineConstant.STATUS_FINISH);
|
|
|
- flowList.add(flow);
|
|
|
- });
|
|
|
- // 计算总数
|
|
|
- long count = doneQuery.count();
|
|
|
- // 设置总数
|
|
|
- page.setTotal(count);
|
|
|
- page.setRecords(flowList);
|
|
|
- return page;
|
|
|
- }
|
|
|
+ flow.setProcessInstanceId(historicTaskInstance.getProcessInstanceId());
|
|
|
+ flow.setHistoryProcessInstanceId(historicTaskInstance.getProcessInstanceId());
|
|
|
+ HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance((historicTaskInstance.getProcessInstanceId()));
|
|
|
+ if (Func.isNotEmpty(historicProcessInstance)) {
|
|
|
+ String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
|
|
+ flow.setBusinessTable(businessKey[0]);
|
|
|
+ flow.setBusinessId(businessKey[1]);
|
|
|
+ if (historicProcessInstance.getEndActivityId() != null) {
|
|
|
+ flow.setProcessIsFinished(FlowEngineConstant.STATUS_FINISHED);
|
|
|
+ } else {
|
|
|
+ flow.setProcessIsFinished(FlowEngineConstant.STATUS_UNFINISHED);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ flow.setStatus(FlowEngineConstant.STATUS_FINISH);
|
|
|
+ flowList.add(flow);
|
|
|
+ });
|
|
|
+ // 计算总数
|
|
|
+ long count = doneQuery.count();
|
|
|
+ // 设置总数
|
|
|
+ page.setTotal(count);
|
|
|
+ page.setRecords(flowList);
|
|
|
+ return page;
|
|
|
+ }
|
|
|
|
|
|
- @Override
|
|
|
- public boolean completeTask(BladeFlow flow) {
|
|
|
- String taskId = flow.getTaskId();
|
|
|
- String processInstanceId = flow.getProcessInstanceId();
|
|
|
- String comment = Func.toStr(flow.getComment(), ProcessConstant.PASS_COMMENT);
|
|
|
- // 增加评论
|
|
|
- if (StringUtil.isNoneBlank(processInstanceId, comment)) {
|
|
|
- taskService.addComment(taskId, processInstanceId, comment);
|
|
|
- }
|
|
|
- // 创建变量
|
|
|
- Map<String, Object> variables = flow.getVariables();
|
|
|
- if (variables == null) {
|
|
|
- variables = Kv.create();
|
|
|
- }
|
|
|
- variables.put(ProcessConstant.PASS_KEY, flow.isPass());
|
|
|
- //完成任务时,如果传入taskUser这个key,就是指定下一处理人
|
|
|
- variables.put("taskUser", flow.getTaskUser());
|
|
|
- // 完成任务
|
|
|
- taskService.complete(taskId, variables);
|
|
|
- return true;
|
|
|
- }
|
|
|
+ @Override
|
|
|
+ public boolean completeTask(BladeFlow flow) {
|
|
|
+ String taskId = flow.getTaskId();
|
|
|
+ String processInstanceId = flow.getProcessInstanceId();
|
|
|
+ String comment = Func.toStr(flow.getComment(), ProcessConstant.PASS_COMMENT);
|
|
|
+ // 增加评论
|
|
|
+ if (StringUtil.isNoneBlank(processInstanceId, comment)) {
|
|
|
+ taskService.addComment(taskId, processInstanceId, comment);
|
|
|
+ }
|
|
|
+ // 创建变量
|
|
|
+ Map<String, Object> variables = flow.getVariables();
|
|
|
+ if (variables == null) {
|
|
|
+ variables = Kv.create();
|
|
|
+ }
|
|
|
+ variables.put(ProcessConstant.PASS_KEY, flow.isPass());
|
|
|
+ //完成任务时,如果传入taskUser这个key,就是指定下一处理人
|
|
|
+ variables.put("taskUser", flow.getTaskUser());
|
|
|
+ // 完成任务
|
|
|
+ taskService.complete(taskId, variables);
|
|
|
+ return true;
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 构建流程
|
|
|
- *
|
|
|
- * @param bladeFlow 流程通用类
|
|
|
- * @param flowList 流程列表
|
|
|
- * @param taskQuery 任务查询类
|
|
|
- * @param 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()));
|
|
|
- }
|
|
|
- if (bladeFlow.getProcessDefinitionName() != null) {
|
|
|
- taskQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
|
|
- }
|
|
|
- if (bladeFlow.getBeginDate() != null) {
|
|
|
- taskQuery.taskCreatedAfter(bladeFlow.getBeginDate());
|
|
|
- }
|
|
|
- if (bladeFlow.getEndDate() != null) {
|
|
|
- taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
|
|
|
- }
|
|
|
- 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());
|
|
|
- flow.setTaskName(task.getName());
|
|
|
- flow.setAssignee(task.getAssignee());
|
|
|
- flow.setCreateTime(task.getCreateTime());
|
|
|
- flow.setClaimTime(task.getClaimTime());
|
|
|
- flow.setExecutionId(task.getExecutionId());
|
|
|
- flow.setVariables(task.getProcessVariables());
|
|
|
+ /**
|
|
|
+ * 构建流程
|
|
|
+ *
|
|
|
+ * @param bladeFlow 流程通用类
|
|
|
+ * @param flowList 流程列表
|
|
|
+ * @param taskQuery 任务查询类
|
|
|
+ * @param 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()));
|
|
|
+ }
|
|
|
+ if (bladeFlow.getProcessDefinitionName() != null) {
|
|
|
+ taskQuery.processDefinitionName(bladeFlow.getProcessDefinitionName());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getBeginDate() != null) {
|
|
|
+ taskQuery.taskCreatedAfter(bladeFlow.getBeginDate());
|
|
|
+ }
|
|
|
+ if (bladeFlow.getEndDate() != null) {
|
|
|
+ taskQuery.taskCreatedBefore(bladeFlow.getEndDate());
|
|
|
+ }
|
|
|
+ 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());
|
|
|
+ flow.setTaskName(task.getName());
|
|
|
+ flow.setAssignee(task.getAssignee());
|
|
|
+ flow.setCreateTime(task.getCreateTime());
|
|
|
+ flow.setClaimTime(task.getClaimTime());
|
|
|
+ flow.setExecutionId(task.getExecutionId());
|
|
|
+ flow.setVariables(task.getProcessVariables());
|
|
|
|
|
|
- HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(task.getProcessInstanceId());
|
|
|
- if (Func.isNotEmpty(historicProcessInstance)) {
|
|
|
- String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
|
|
- flow.setBusinessTable(businessKey[0]);
|
|
|
- flow.setBusinessId(businessKey[1]);
|
|
|
- }
|
|
|
+ HistoricProcessInstance historicProcessInstance = getHistoricProcessInstance(task.getProcessInstanceId());
|
|
|
+ if (Func.isNotEmpty(historicProcessInstance)) {
|
|
|
+ String[] businessKey = Func.toStrArray(StringPool.COLON, historicProcessInstance.getBusinessKey());
|
|
|
+ flow.setBusinessTable(businessKey[0]);
|
|
|
+ flow.setBusinessId(businessKey[1]);
|
|
|
+ }
|
|
|
|
|
|
- FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
|
|
|
- flow.setCategory(processDefinition.getCategory());
|
|
|
- flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
|
|
- flow.setProcessDefinitionId(processDefinition.getId());
|
|
|
- flow.setProcessDefinitionName(processDefinition.getName());
|
|
|
- flow.setProcessDefinitionKey(processDefinition.getKey());
|
|
|
- flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
|
|
- flow.setProcessInstanceId(task.getProcessInstanceId());
|
|
|
- flow.setStatus(status);
|
|
|
- flowList.add(flow);
|
|
|
- });
|
|
|
- }
|
|
|
+ FlowProcess processDefinition = FlowCache.getProcessDefinition(task.getProcessDefinitionId());
|
|
|
+ flow.setCategory(processDefinition.getCategory());
|
|
|
+ flow.setCategoryName(FlowCache.getCategoryName(processDefinition.getCategory()));
|
|
|
+ flow.setProcessDefinitionId(processDefinition.getId());
|
|
|
+ flow.setProcessDefinitionName(processDefinition.getName());
|
|
|
+ flow.setProcessDefinitionKey(processDefinition.getKey());
|
|
|
+ flow.setProcessDefinitionVersion(processDefinition.getVersion());
|
|
|
+ flow.setProcessInstanceId(task.getProcessInstanceId());
|
|
|
+ flow.setStatus(status);
|
|
|
+ flowList.add(flow);
|
|
|
+ });
|
|
|
+ }
|
|
|
|
|
|
- /**
|
|
|
- * 获取历史流程
|
|
|
- *
|
|
|
- * @param processInstanceId 流程实例id
|
|
|
- * @return HistoricProcessInstance
|
|
|
- */
|
|
|
- private HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) {
|
|
|
- return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
- }
|
|
|
+ /**
|
|
|
+ * 获取历史流程
|
|
|
+ *
|
|
|
+ * @param processInstanceId 流程实例id
|
|
|
+ * @return HistoricProcessInstance
|
|
|
+ */
|
|
|
+ private HistoricProcessInstance getHistoricProcessInstance(String processInstanceId) {
|
|
|
+ return historyService.createHistoricProcessInstanceQuery().processInstanceId(processInstanceId).singleResult();
|
|
|
+ }
|
|
|
|
|
|
}
|