增加工作流发起时间和comment到变量中

This commit is contained in:
guoshengxiong 2024-08-23 10:06:56 +08:00
parent 8242b3e2a5
commit 3ce4ef018e

View File

@ -6,7 +6,6 @@ import cn.hutool.core.util.ArrayUtil;
import cn.hutool.core.util.NumberUtil; import cn.hutool.core.util.NumberUtil;
import com.wflow.bean.do_.UserDeptDo; import com.wflow.bean.do_.UserDeptDo;
import com.wflow.service.OrgRepositoryService; import com.wflow.service.OrgRepositoryService;
import com.wflow.workflow.bean.dto.ProcessInstanceOwnerDto;
import com.wflow.workflow.bean.process.HttpDefinition; import com.wflow.workflow.bean.process.HttpDefinition;
import com.wflow.workflow.bean.process.OrgUser; import com.wflow.workflow.bean.process.OrgUser;
import com.wflow.workflow.bean.process.props.ConditionProps; import com.wflow.workflow.bean.process.props.ConditionProps;
@ -25,6 +24,8 @@ import org.flowable.engine.TaskService;
import org.flowable.engine.delegate.DelegateExecution; import org.flowable.engine.delegate.DelegateExecution;
import org.flowable.engine.impl.persistence.entity.ExecutionEntity; import org.flowable.engine.impl.persistence.entity.ExecutionEntity;
import org.flowable.engine.repository.ProcessDefinition; import org.flowable.engine.repository.ProcessDefinition;
import org.flowable.engine.runtime.ProcessInstance;
import org.flowable.engine.task.Comment;
import org.flowable.task.api.history.HistoricTaskInstance; import org.flowable.task.api.history.HistoricTaskInstance;
import org.springframework.beans.factory.annotation.Autowired; import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component; import org.springframework.stereotype.Component;
@ -114,7 +115,7 @@ public class UELTools {
//读取当前节点内3个变量: 已完成的任务数任务总数未处理的任务数 //读取当前节点内3个变量: 已完成的任务数任务总数未处理的任务数
Number nrOfCompletedInstances = execution.getVariable("nrOfCompletedInstances", Number.class); Number nrOfCompletedInstances = execution.getVariable("nrOfCompletedInstances", Number.class);
Number nrOfActiveInstances = execution.getVariable("nrOfActiveInstances", Number.class); Number nrOfActiveInstances = execution.getVariable("nrOfActiveInstances", Number.class);
if (Objects.isNull(nrOfCompletedInstances)){ if (Objects.isNull(nrOfCompletedInstances)) {
nrOfCompletedInstances = historyService.createHistoricTaskInstanceQuery() nrOfCompletedInstances = historyService.createHistoricTaskInstanceQuery()
.processInstanceId(execution.getProcessInstanceId()) .processInstanceId(execution.getProcessInstanceId())
.taskDefinitionKey(execution.getActivityId()) .taskDefinitionKey(execution.getActivityId())
@ -125,11 +126,11 @@ public class UELTools {
return nrOfCompletedInstances.longValue() >= 0; return nrOfCompletedInstances.longValue() >= 0;
case "AND": case "AND":
case "NEXT": case "NEXT":
if (Objects.nonNull(nrOfActiveInstances)){ if (Objects.nonNull(nrOfActiveInstances)) {
return nrOfActiveInstances.longValue() == 0; return nrOfActiveInstances.longValue() == 0;
}else { } else {
Number nrOfInstances = execution.getVariable("nrOfInstances", Number.class); Number nrOfInstances = execution.getVariable("nrOfInstances", Number.class);
if (Objects.nonNull(nrOfInstances)){ if (Objects.nonNull(nrOfInstances)) {
return nrOfCompletedInstances.equals(nrOfInstances); return nrOfCompletedInstances.equals(nrOfInstances);
} else { } else {
//nrOfInstances和 nrOfActiveInstances 变量都不存在 //nrOfInstances和 nrOfActiveInstances 变量都不存在
@ -365,6 +366,8 @@ public class UELTools {
} }
} }
ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(defId).singleResult(); ProcessDefinition definition = repositoryService.createProcessDefinitionQuery().processDefinitionId(defId).singleResult();
ProcessInstance processInstance = runtimeService.createProcessInstanceQuery().processInstanceId(instanceId).singleResult();
List<Comment> processInstanceComments = taskService.getProcessInstanceComments(instanceId);
variables.put("formName", definition.getName()); variables.put("formName", definition.getName());
variables.put("instanceId", instanceId); variables.put("instanceId", instanceId);
//获取流程发起人信息 //获取流程发起人信息
@ -380,6 +383,8 @@ public class UELTools {
variables.put("owner.deptName", userDeptDo.getDeptName()); variables.put("owner.deptName", userDeptDo.getDeptName());
variables.put("tenantId", TenantContextHolder.getTenantId()); variables.put("tenantId", TenantContextHolder.getTenantId());
variables.put("op.user", opUserIds); variables.put("op.user", opUserIds);
variables.put("startTime", processInstance.getStartTime());
variables.put("fullMessages", processInstanceComments.stream().map(comment -> comment.getFullMessage()).collect(Collectors.toList()));
return variables; return variables;
} }