use of org.activiti.engine.history.HistoricTaskInstanceQuery in project alfresco-repository by Alfresco.
the class ActivitiWorkflowEngine method createHistoricTaskQuery.
private HistoricTaskInstanceQuery createHistoricTaskQuery(WorkflowTaskQuery query) {
HistoricTaskInstanceQuery historicQuery = historyService.createHistoricTaskInstanceQuery().finished();
if (!activitiUtil.isMultiTenantWorkflowDeploymentEnabled()) {
// Filter by tenant domain
historicQuery.processVariableValueEquals(ActivitiConstants.VAR_TENANT_DOMAIN, TenantUtil.getCurrentDomain());
} else if (tenantService.isEnabled() && !TenantUtil.isCurrentDomainDefault() && !StringUtils.isEmpty(TenantUtil.getCurrentDomain())) {
// Process definition keys are prefixed with the tenant ID, in case MT is enabled and
// deployments are done in tenant-context
historicQuery.processDefinitionKeyLike("@" + TenantUtil.getCurrentDomain() + "@%");
}
if (query.getTaskId() != null) {
String taskId = createLocalId(query.getTaskId());
historicQuery.taskId(taskId);
}
if (query.getProcessId() != null) {
String processInstanceId = createLocalId(query.getProcessId());
historicQuery.processInstanceId(processInstanceId);
}
if (query.getTaskName() != null) {
historicQuery.taskDefinitionKey(query.getTaskName().toPrefixString());
}
if (query.getActorId() != null) {
historicQuery.taskAssignee(query.getActorId());
}
if (query.getProcessName() != null) {
String processName = getProcessNameMTSafe(query.getProcessName());
historicQuery.processDefinitionKey(processName);
}
if (query.getWorkflowDefinitionName() != null) {
String processName = factory.getProcessKey(query.getWorkflowDefinitionName());
historicQuery.processDefinitionKey(processName);
}
if (query.getTaskCustomProps() != null) {
addTaskPropertiesToQuery(query.getTaskCustomProps(), historicQuery);
}
if (query.getProcessCustomProps() != null) {
addProcessPropertiesToQuery(query.getProcessCustomProps(), historicQuery);
}
if (query.isActive() != null) {
if (query.isActive()) {
historicQuery.processUnfinished();
} else {
historicQuery.processFinished();
}
}
// Order query
if (query.getOrderBy() != null) {
orderQuery(historicQuery, query.getOrderBy());
}
return historicQuery;
}
use of org.activiti.engine.history.HistoricTaskInstanceQuery in project my_curd by qinyou.
the class MyCompleteTaskController method query.
// 表格数据
public void query() {
int pageNumber = getInt("page", 1);
int pageSize = getInt("rows", 30);
HistoricTaskInstanceQuery query = ActivitiUtils.getHistoryService().createHistoricTaskInstanceQuery().taskAssignee(WebUtils.getSessionUsername(this)).finished();
String instanceId = getPara("extra_instanceId");
if (StringUtils.notEmpty(instanceId)) {
query.processInstanceId(instanceId);
}
String taskName = getPara("extra_taskName");
if (StringUtils.notEmpty(taskName)) {
query.taskNameLike("%" + taskName + "%");
}
Long total = query.count();
List<Map<String, Object>> list = new ArrayList<>();
// 流程实例id 和 发起时间正相关,所以此处排序无问题
query.orderByProcessInstanceId().desc().orderByHistoricTaskInstanceEndTime().asc().listPage((pageNumber - 1) * pageSize, pageSize).forEach(task -> {
Map<String, Object> info = new HashMap<>();
// 任务id
info.put("id", task.getId());
// 任务开始时间
info.put("startTime", task.getStartTime());
// 任务完成时间
info.put("endTime", task.getEndTime());
// 任务名称
info.put("taskName", task.getName());
// 任务持续时长(毫秒)
info.put("duration", task.getDurationInMillis());
// 流程实例id
info.put("instanceId", task.getProcessInstanceId());
HistoricProcessInstance instance = ActivitiUtils.getHistoricProcessInstance(task.getProcessInstanceId(), false);
info.put("instanceName", instance.getName());
// 流程发起人
info.put("startUser", instance.getStartUserId());
list.add(info);
});
renderDatagrid(list, total.intValue());
}
Aggregations