|
@@ -1,5 +1,6 @@
|
|
|
-package cn.iocoder.yudao.framework.flowable.core.util;
|
|
|
+package cn.iocoder.yudao.module.bpm.framework.flowable.core.util;
|
|
|
|
|
|
+import cn.iocoder.yudao.module.bpm.framework.flowable.core.enums.BpmConstants;
|
|
|
import org.flowable.common.engine.api.delegate.Expression;
|
|
|
import org.flowable.common.engine.api.variable.VariableContainer;
|
|
|
import org.flowable.common.engine.impl.el.ExpressionManager;
|
|
@@ -32,11 +33,23 @@ public class FlowableUtils {
|
|
|
|
|
|
// ========== Execution 相关的工具方法 ==========
|
|
|
|
|
|
- public static String formatCollectionVariable(String activityId) {
|
|
|
+ /**
|
|
|
+ * 格式化多实例(并签、或签)的 collectionVariable 变量(多实例对应的多审批人列表)
|
|
|
+ *
|
|
|
+ * @param activityId 活动编号
|
|
|
+ * @return collectionVariable 变量
|
|
|
+ */
|
|
|
+ public static String formatExecutionCollectionVariable(String activityId) {
|
|
|
return activityId + "_assignees";
|
|
|
}
|
|
|
|
|
|
- public static String formatCollectionElementVariable(String activityId) {
|
|
|
+ /**
|
|
|
+ * 格式化多实例(并签、或签)的 collectionElementVariable 变量(当前实例对应的一个审批人)
|
|
|
+ *
|
|
|
+ * @param activityId 活动编号
|
|
|
+ * @return collectionElementVariable 变量
|
|
|
+ */
|
|
|
+ public static String formatExecutionCollectionElementVariable(String activityId) {
|
|
|
return activityId + "_assignee";
|
|
|
}
|
|
|
|
|
@@ -50,43 +63,86 @@ public class FlowableUtils {
|
|
|
return getProcessInstanceStatus(processInstance.getProcessVariables());
|
|
|
}
|
|
|
|
|
|
- // TODO 芋艿:需要再搞搞
|
|
|
+ /**
|
|
|
+ * 获得流程实例的状态
|
|
|
+ *
|
|
|
+ * @param processVariables 流程实例的 variables
|
|
|
+ * @return 状态
|
|
|
+ */
|
|
|
private static Integer getProcessInstanceStatus(Map<String, Object> processVariables) {
|
|
|
- return (Integer) processVariables.get("PROCESS_STATUS");
|
|
|
+ return (Integer) processVariables.get(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获得流程实例的表单
|
|
|
+ *
|
|
|
+ * @param processInstance 流程实例
|
|
|
+ * @return 表单
|
|
|
+ */
|
|
|
public static Map<String, Object> getProcessInstanceFormVariable(ProcessInstance processInstance) {
|
|
|
Map<String, Object> formVariables = new HashMap<>(processInstance.getProcessVariables());
|
|
|
filterProcessInstanceFormVariable(formVariables);
|
|
|
return formVariables;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 过滤流程实例的表单
|
|
|
+ *
|
|
|
+ * 为什么要过滤?目前使用 processVariables 存储所有流程实例的拓展字段,需要过滤掉一部分的系统字段,从而实现表单的展示
|
|
|
+ *
|
|
|
+ * @param processVariables 流程实例的 variables
|
|
|
+ * @return 过滤后的表单
|
|
|
+ */
|
|
|
public static Map<String, Object> filterProcessInstanceFormVariable(Map<String, Object> processVariables) {
|
|
|
- processVariables.remove("PROCESS_STATUS");
|
|
|
+ processVariables.remove(BpmConstants.PROCESS_INSTANCE_VARIABLE_STATUS);
|
|
|
return processVariables;
|
|
|
}
|
|
|
|
|
|
// ========== Task 相关的工具方法 ==========
|
|
|
|
|
|
- // TODO 芋艿:需要再搞搞
|
|
|
-
|
|
|
+ /**
|
|
|
+ * 获得任务的状态
|
|
|
+ *
|
|
|
+ * @param task 任务
|
|
|
+ * @return 状态
|
|
|
+ */
|
|
|
public static Integer getTaskStatus(TaskInfo task) {
|
|
|
- return (Integer) task.getTaskLocalVariables().get("TASK_STATUS");
|
|
|
+ return (Integer) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_STATUS);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获得任务的审批原因
|
|
|
+ *
|
|
|
+ * @param task 任务
|
|
|
+ * @return 审批原因
|
|
|
+ */
|
|
|
public static String getTaskReason(TaskInfo task) {
|
|
|
- return (String) task.getTaskLocalVariables().get("TASK_REASON");
|
|
|
+ return (String) task.getTaskLocalVariables().get(BpmConstants.TASK_VARIABLE_REASON);
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 获得任务的表单
|
|
|
+ *
|
|
|
+ * @param task 任务
|
|
|
+ * @return 表单
|
|
|
+ */
|
|
|
public static Map<String, Object> getTaskFormVariable(TaskInfo task) {
|
|
|
Map<String, Object> formVariables = new HashMap<>(task.getTaskLocalVariables());
|
|
|
filterTaskFormVariable(formVariables);
|
|
|
return formVariables;
|
|
|
}
|
|
|
|
|
|
+ /**
|
|
|
+ * 过滤任务的表单
|
|
|
+ *
|
|
|
+ * 为什么要过滤?目前使用 taskLocalVariables 存储所有任务的拓展字段,需要过滤掉一部分的系统字段,从而实现表单的展示
|
|
|
+ *
|
|
|
+ * @param taskLocalVariables 任务的 taskLocalVariables
|
|
|
+ * @return 过滤后的表单
|
|
|
+ */
|
|
|
public static Map<String, Object> filterTaskFormVariable(Map<String, Object> taskLocalVariables) {
|
|
|
- taskLocalVariables.remove("TASK_STATUS");
|
|
|
- taskLocalVariables.remove("TASK_REASON");
|
|
|
+ taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_STATUS);
|
|
|
+ taskLocalVariables.remove(BpmConstants.TASK_VARIABLE_REASON);
|
|
|
return taskLocalVariables;
|
|
|
}
|
|
|
|