From cac0a4cd169857c7eaad80b5fff1c989d0981bd0 Mon Sep 17 00:00:00 2001
From: 疯狂的狮子Li <15040126243@163.com>
Date: 星期四, 29 八月 2024 14:12:07 +0800
Subject: [PATCH] update 优化 RegexUtils#extractFromString 方法未匹配返回null不返回默认值问题
---
ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/QueryUtils.java | 35 +++++++++++++++++++++++++++++++++++
1 files changed, 35 insertions(+), 0 deletions(-)
diff --git a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/QueryUtils.java b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/QueryUtils.java
index 850315f..df928dc 100644
--- a/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/QueryUtils.java
+++ b/ruoyi-modules/ruoyi-workflow/src/main/java/org/dromara/workflow/utils/QueryUtils.java
@@ -1,16 +1,20 @@
package org.dromara.workflow.utils;
+import cn.hutool.core.bean.BeanUtil;
import lombok.AccessLevel;
import lombok.NoArgsConstructor;
import org.dromara.common.core.utils.SpringUtils;
import org.dromara.common.tenant.helper.TenantHelper;
+import org.dromara.workflow.domain.vo.TaskVo;
import org.flowable.engine.ProcessEngine;
import org.flowable.engine.history.HistoricActivityInstanceQuery;
import org.flowable.engine.history.HistoricProcessInstanceQuery;
import org.flowable.engine.repository.DeploymentQuery;
import org.flowable.engine.repository.ModelQuery;
import org.flowable.engine.repository.ProcessDefinitionQuery;
+import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.runtime.ProcessInstanceQuery;
+import org.flowable.task.api.Task;
import org.flowable.task.api.TaskQuery;
import org.flowable.task.api.history.HistoricTaskInstanceQuery;
@@ -72,6 +76,10 @@
return hisTaskInstanceQuery().processInstanceId(processInstanceId);
}
+ public static HistoricTaskInstanceQuery hisTaskBusinessKeyQuery(String businessKey) {
+ return hisTaskInstanceQuery().processInstanceBusinessKey(businessKey);
+ }
+
public static ProcessInstanceQuery instanceQuery() {
ProcessInstanceQuery query = PROCESS_ENGINE.getRuntimeService().createProcessInstanceQuery();
if (TenantHelper.isEnable()) {
@@ -82,6 +90,10 @@
public static ProcessInstanceQuery instanceQuery(String processInstanceId) {
return instanceQuery().processInstanceId(processInstanceId);
+ }
+
+ public static ProcessInstanceQuery businessKeyQuery(String businessKey) {
+ return instanceQuery().processInstanceBusinessKey(businessKey);
}
public static ProcessInstanceQuery instanceQuery(Set<String> processInstanceIds) {
@@ -98,6 +110,10 @@
public static HistoricProcessInstanceQuery hisInstanceQuery(String processInstanceId) {
return hisInstanceQuery().processInstanceId(processInstanceId);
+ }
+
+ public static HistoricProcessInstanceQuery hisBusinessKeyQuery(String businessKey) {
+ return hisInstanceQuery().processInstanceBusinessKey(businessKey);
}
public static HistoricProcessInstanceQuery hisInstanceQuery(Set<String> processInstanceIds) {
@@ -131,4 +147,23 @@
public static TaskQuery taskQuery(Collection<String> processInstanceIds) {
return taskQuery().processInstanceIdIn(processInstanceIds);
}
+
+ /**
+ * 鎸夌収浠诲姟id鏌ヨ褰撳墠浠诲姟
+ *
+ * @param taskId 浠诲姟id
+ */
+ public static TaskVo getTask(String taskId) {
+ Task task = PROCESS_ENGINE.getTaskService().createTaskQuery().taskId(taskId).singleResult();
+ if (task == null) {
+ return null;
+ }
+ ProcessInstance processInstance = QueryUtils.instanceQuery(task.getProcessInstanceId()).singleResult();
+ TaskVo taskVo = BeanUtil.toBean(task, TaskVo.class);
+ taskVo.setBusinessKey(processInstance.getBusinessKey());
+ taskVo.setMultiInstance(WorkflowUtils.isMultiInstance(task.getProcessDefinitionId(), task.getTaskDefinitionKey()) != null);
+ String businessStatus = WorkflowUtils.getBusinessStatus(taskVo.getBusinessKey());
+ taskVo.setBusinessStatus(businessStatus);
+ return taskVo;
+ }
}
--
Gitblit v1.9.3