use of org.flowable.task.api.history.HistoricTaskInstanceQuery in project petals-se-flowable by petalslink.
the class Assert method assertUserTaskEnded.
/**
* Assertion to check that a user task was completed by the given user.
*
* @param processInstanceId
* The process instance identifier
* @param taskDefinitionKey
* The process definition key
* @param user
* The task has been completed by the given user
* @param historyService
* The Flowable's history service used to request the Flowable engine about historic process instances.
*/
public static void assertUserTaskEnded(final String processInstanceId, final String taskDefinitionKey, final String user, final HistoryService historyService) {
final HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery();
final HistoricTaskInstance nextTask = taskQuery.processInstanceId(processInstanceId).taskDefinitionKey(taskDefinitionKey).singleResult();
assertNotNull(nextTask);
assertEquals(user, nextTask.getAssignee());
}
use of org.flowable.task.api.history.HistoricTaskInstanceQuery in project plumdo-work by wengwh.
the class TaskDoneResource method getTasks.
@GetMapping(value = "/tasks/done", name = "已办任务查询")
public PageResponse getTasks(@RequestParam Map<String, String> requestParams) {
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
if (ObjectUtils.isNotEmpty(requestParams.get("processInstanceId"))) {
query.processInstanceId(requestParams.get("processInstanceId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processInstanceBusinessKey"))) {
query.processInstanceBusinessKeyLike(ObjectUtils.convertToLike(requestParams.get("processInstanceBusinessKey")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processDefinitionKey"))) {
query.processDefinitionKeyLike(ObjectUtils.convertToLike(requestParams.get("processDefinitionKey")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processDefinitionId"))) {
query.processDefinitionId(requestParams.get("processDefinitionId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processDefinitionName"))) {
query.processDefinitionNameLike(ObjectUtils.convertToLike(requestParams.get("processDefinitionName")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCreatedBefore"))) {
query.taskCreatedBefore(ObjectUtils.convertToDatetime(requestParams.get("taskCreatedBefore")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCreatedAfter"))) {
query.taskCreatedAfter(ObjectUtils.convertToDatetime(requestParams.get("taskCreatedAfter")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCompletedBefore"))) {
query.taskCompletedBefore(ObjectUtils.convertToDatetime(requestParams.get("taskCompletedBefore")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCompletedAfter"))) {
query.taskCompletedAfter(ObjectUtils.convertToDatetime(requestParams.get("taskCompletedAfter")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processFinished"))) {
boolean isProcessFinished = ObjectUtils.convertToBoolean(requestParams.get("processFinished"));
if (isProcessFinished) {
query.processFinished();
} else {
query.processUnfinished();
}
}
if (ObjectUtils.isNotEmpty(requestParams.get("tenantId"))) {
query.taskTenantId(requestParams.get("tenantId"));
}
query.finished().or().taskAssignee(Authentication.getUserId()).taskOwner(Authentication.getUserId()).endOr();
return new TaskPaginateList(restResponseFactory).paginateList(getPageable(requestParams), query, allowedSortProperties);
}
use of org.flowable.task.api.history.HistoricTaskInstanceQuery in project plumdo-work by wengwh.
the class TaskResource method getTasks.
@GetMapping(value = "/tasks", name = "任务查询")
public PageResponse getTasks(@RequestParam Map<String, String> requestParams) {
HistoricTaskInstanceQuery query = historyService.createHistoricTaskInstanceQuery();
if (ObjectUtils.isNotEmpty(requestParams.get("taskId"))) {
query.taskId(requestParams.get("taskId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processInstanceId"))) {
query.processInstanceId(requestParams.get("processInstanceId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processInstanceBusinessKey"))) {
query.processInstanceBusinessKeyLike(ObjectUtils.convertToLike(requestParams.get("processInstanceBusinessKey")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processDefinitionKey"))) {
query.processDefinitionKeyLike(ObjectUtils.convertToLike(requestParams.get("processDefinitionKey")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processDefinitionId"))) {
query.processDefinitionId(requestParams.get("processDefinitionId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("processDefinitionName"))) {
query.processDefinitionNameLike(ObjectUtils.convertToLike(requestParams.get("processDefinitionName")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("executionId"))) {
query.executionId(requestParams.get("executionId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskName"))) {
query.taskNameLike(ObjectUtils.convertToLike(requestParams.get("taskName")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskDescription"))) {
query.taskDescriptionLike(ObjectUtils.convertToLike(requestParams.get("taskDescription")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskDefinitionKey"))) {
query.taskDefinitionKeyLike(ObjectUtils.convertToLike(requestParams.get("taskDefinitionKey")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskAssignee"))) {
query.taskAssignee(requestParams.get("taskAssignee"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskOwner"))) {
query.taskOwner(requestParams.get("taskOwner"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskInvolvedUser"))) {
query.taskInvolvedUser(requestParams.get("taskInvolvedUser"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskPriority"))) {
query.taskPriority(ObjectUtils.convertToInteger(requestParams.get("taskPriority")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("finished"))) {
boolean isFinished = ObjectUtils.convertToBoolean(requestParams.get("finished"));
if (isFinished) {
query.finished();
} else {
query.unfinished();
}
}
if (ObjectUtils.isNotEmpty(requestParams.get("processFinished"))) {
boolean isProcessFinished = ObjectUtils.convertToBoolean(requestParams.get("processFinished"));
if (isProcessFinished) {
query.processFinished();
} else {
query.processUnfinished();
}
}
if (ObjectUtils.isNotEmpty(requestParams.get("parentTaskId"))) {
query.taskParentTaskId(requestParams.get("parentTaskId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("dueDateAfter"))) {
query.taskDueAfter(ObjectUtils.convertToDatetime(requestParams.get("dueDateAfter")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("dueDateBefore"))) {
query.taskDueBefore(ObjectUtils.convertToDatetime(requestParams.get("dueDateBefore")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCreatedBefore"))) {
query.taskCreatedBefore(ObjectUtils.convertToDatetime(requestParams.get("taskCreatedBefore")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCreatedAfter"))) {
query.taskCreatedAfter(ObjectUtils.convertToDatetime(requestParams.get("taskCreatedAfter")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCompletedBefore"))) {
query.taskCompletedBefore(ObjectUtils.convertToDatetime(requestParams.get("taskCompletedBefore")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCompletedAfter"))) {
query.taskCompletedAfter(ObjectUtils.convertToDatetime(requestParams.get("taskCompletedAfter")));
}
if (ObjectUtils.isNotEmpty(requestParams.get("tenantId"))) {
query.taskTenantId(requestParams.get("tenantId"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCandidateUser"))) {
query.taskCandidateUser(requestParams.get("taskCandidateUser"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCandidateGroup"))) {
query.taskCandidateGroup(requestParams.get("taskCandidateGroup"));
}
if (ObjectUtils.isNotEmpty(requestParams.get("taskCandidateGroups"))) {
String[] candidateGroups = requestParams.get("taskCandidateGroups").split(",");
query.taskCandidateGroupIn(Arrays.asList(candidateGroups));
}
return new TaskPaginateList(restResponseFactory).paginateList(getPageable(requestParams), query, allowedSortProperties);
}
use of org.flowable.task.api.history.HistoricTaskInstanceQuery in project ruoyi-vue-pro by YunaiV.
the class BpmTaskServiceImpl method getDoneTaskPage.
@Override
public PageResult<BpmTaskDonePageItemRespVO> getDoneTaskPage(Long userId, BpmTaskDonePageReqVO pageVO) {
// 查询已办任务
HistoricTaskInstanceQuery taskQuery = historyService.createHistoricTaskInstanceQuery().finished().taskAssignee(// 分配给自己
String.valueOf(userId)).orderByHistoricTaskInstanceEndTime().desc();
if (StrUtil.isNotBlank(pageVO.getName())) {
taskQuery.taskNameLike("%" + pageVO.getName() + "%");
}
if (pageVO.getBeginCreateTime() != null) {
taskQuery.taskCreatedAfter(pageVO.getBeginCreateTime());
}
if (pageVO.getEndCreateTime() != null) {
taskQuery.taskCreatedBefore(pageVO.getEndCreateTime());
}
// 执行查询
List<HistoricTaskInstance> tasks = taskQuery.listPage(PageUtils.getStart(pageVO), pageVO.getPageSize());
if (CollUtil.isEmpty(tasks)) {
return PageResult.empty(taskQuery.count());
}
// 获得 TaskExtDO Map
List<BpmTaskExtDO> bpmTaskExtDOs = taskExtMapper.selectListByTaskIds(convertSet(tasks, HistoricTaskInstance::getId));
Map<String, BpmTaskExtDO> bpmTaskExtDOMap = convertMap(bpmTaskExtDOs, BpmTaskExtDO::getTaskId);
// 获得 ProcessInstance Map
Map<String, HistoricProcessInstance> historicProcessInstanceMap = processInstanceService.getHistoricProcessInstanceMap(convertSet(tasks, HistoricTaskInstance::getProcessInstanceId));
// 获得 User Map
Map<Long, AdminUserRespDTO> userMap = adminUserApi.getUserMap(convertSet(historicProcessInstanceMap.values(), instance -> Long.valueOf(instance.getStartUserId())));
// 拼接结果
return new PageResult<>(BpmTaskConvert.INSTANCE.convertList2(tasks, bpmTaskExtDOMap, historicProcessInstanceMap, userMap), taskQuery.count());
}
use of org.flowable.task.api.history.HistoricTaskInstanceQuery in project RuoYi-Flowable-Plus by KonBAI-Q.
the class WfTaskServiceImpl method finishedList.
/**
* 已办任务列表
*
* @return
*/
@Override
public TableDataInfo<WfTaskVo> finishedList(PageQuery pageQuery) {
Page<WfTaskVo> page = new Page<>();
Long userId = LoginHelper.getUserId();
HistoricTaskInstanceQuery taskInstanceQuery = historyService.createHistoricTaskInstanceQuery().includeProcessVariables().finished().taskAssignee(userId.toString()).orderByHistoricTaskInstanceEndTime().desc();
int offset = pageQuery.getPageSize() * (pageQuery.getPageNum() - 1);
List<HistoricTaskInstance> historicTaskInstanceList = taskInstanceQuery.listPage(offset, pageQuery.getPageSize());
List<WfTaskVo> hisTaskList = Lists.newArrayList();
for (HistoricTaskInstance histTask : historicTaskInstanceList) {
WfTaskVo flowTask = new WfTaskVo();
// 当前流程信息
flowTask.setTaskId(histTask.getId());
// 审批人员信息
flowTask.setCreateTime(histTask.getCreateTime());
flowTask.setFinishTime(histTask.getEndTime());
flowTask.setDuration(getDate(histTask.getDurationInMillis()));
flowTask.setProcDefId(histTask.getProcessDefinitionId());
flowTask.setTaskDefKey(histTask.getTaskDefinitionKey());
flowTask.setTaskName(histTask.getName());
// 流程定义信息
ProcessDefinition pd = repositoryService.createProcessDefinitionQuery().processDefinitionId(histTask.getProcessDefinitionId()).singleResult();
flowTask.setDeployId(pd.getDeploymentId());
flowTask.setProcDefName(pd.getName());
flowTask.setProcDefVersion(pd.getVersion());
flowTask.setProcInsId(histTask.getProcessInstanceId());
flowTask.setHisProcInsId(histTask.getProcessInstanceId());
// 流程发起人信息
HistoricProcessInstance historicProcessInstance = historyService.createHistoricProcessInstanceQuery().processInstanceId(histTask.getProcessInstanceId()).singleResult();
SysUser startUser = sysUserService.selectUserById(Long.parseLong(historicProcessInstance.getStartUserId()));
flowTask.setStartUserId(startUser.getNickName());
flowTask.setStartUserName(startUser.getNickName());
flowTask.setStartDeptName(startUser.getDept().getDeptName());
hisTaskList.add(flowTask);
}
page.setTotal(taskInstanceQuery.count());
page.setRecords(hisTaskList);
// result.put("finished",true);
return TableDataInfo.build(page);
}
Aggregations