|
@@ -1,6 +1,7 @@
|
|
|
package com.fjhx.flow.core;
|
|
|
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
+import com.fjhx.flow.enums.FlowStatusEnum;
|
|
|
import com.fjhx.flow.enums.HandleTypeEnum;
|
|
|
import org.springframework.core.NamedThreadLocal;
|
|
|
|
|
@@ -8,66 +9,148 @@ import java.util.Map;
|
|
|
|
|
|
public class FlowThreadLocalUtil {
|
|
|
|
|
|
- private static final ThreadLocal<FlowThreadLocalData> FLOW_HOLDER = new NamedThreadLocal<>("hx-flow");
|
|
|
-
|
|
|
+ private static final ThreadLocal<FlowThreadLocalUtil> FLOW_HOLDER = new NamedThreadLocal<>("hx-flow");
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程id
|
|
|
+ */
|
|
|
+ private Long flowId;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 业务id
|
|
|
+ */
|
|
|
+ private Long businessId;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 当前节点提交参数
|
|
|
+ */
|
|
|
+ private JSONObject currentData;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 发起流程提交参数
|
|
|
+ */
|
|
|
+ private JSONObject startData;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 模板配置参数
|
|
|
+ */
|
|
|
+ private Map<String, Object> templateData;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程处理类型
|
|
|
+ */
|
|
|
+ private HandleTypeEnum handleTypeEnum;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 流程状态
|
|
|
+ */
|
|
|
+ private FlowStatusEnum flowStatusEnum;
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 下个节点审批用户id
|
|
|
+ */
|
|
|
+ private Long nextHandleUserId;
|
|
|
+
|
|
|
+ // ===================================================
|
|
|
+ // 流程id
|
|
|
+ // ===================================================
|
|
|
public static Long getFlowId() {
|
|
|
- return getData().getFlowId();
|
|
|
+ return getData().flowId;
|
|
|
}
|
|
|
+
|
|
|
public static void setFlowId(Long flowId) {
|
|
|
- getData().setFlowId(flowId);
|
|
|
+ getData().flowId = flowId;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // ===================================================
|
|
|
+ // 业务id
|
|
|
+ // ===================================================
|
|
|
public static Long getBusinessId() {
|
|
|
- return getData().getBusinessId();
|
|
|
+ return getData().businessId;
|
|
|
}
|
|
|
+
|
|
|
public static void setBusinessId(Long businessId) {
|
|
|
- getData().setBusinessId(businessId);
|
|
|
+ getData().businessId = businessId;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // ===================================================
|
|
|
+ // 当前节点提交参数
|
|
|
+ // ===================================================
|
|
|
public static JSONObject getCurrentData() {
|
|
|
- return getData().getCurrentData();
|
|
|
+ return getData().currentData;
|
|
|
}
|
|
|
+
|
|
|
public static <T> T getCurrentData(Class<T> cls) {
|
|
|
- return getData().getCurrentData().toJavaObject(cls);
|
|
|
+ return getData().currentData.toJavaObject(cls);
|
|
|
}
|
|
|
+
|
|
|
public static void setCurrentData(JSONObject currentData) {
|
|
|
- getData().setCurrentData(currentData);
|
|
|
+ getData().currentData = currentData;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // ===================================================
|
|
|
+ // 发起流程提交参数
|
|
|
+ // ===================================================
|
|
|
public static JSONObject getStartData() {
|
|
|
- return getData().getStartData();
|
|
|
+ return getData().startData;
|
|
|
}
|
|
|
+
|
|
|
public static <T> T getStartData(Class<T> cls) {
|
|
|
- return getData().getStartData().toJavaObject(cls);
|
|
|
+ return getData().startData.toJavaObject(cls);
|
|
|
}
|
|
|
+
|
|
|
public static void setStartData(JSONObject startData) {
|
|
|
- getData().setStartData(startData);
|
|
|
+ getData().startData = startData;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // ===================================================
|
|
|
+ // 模板配置参数
|
|
|
+ // ===================================================
|
|
|
public static Map<String, Object> getTemplateData() {
|
|
|
- return getData().getTemplateData();
|
|
|
+ return getData().templateData;
|
|
|
}
|
|
|
+
|
|
|
public static void setTemplateData(Map<String, Object> templateData) {
|
|
|
- getData().setTemplateData(templateData);
|
|
|
+ getData().templateData = templateData;
|
|
|
}
|
|
|
|
|
|
-
|
|
|
+ // ===================================================
|
|
|
+ // 流程处理类型
|
|
|
+ // ===================================================
|
|
|
public static HandleTypeEnum getHandleTypeEnum() {
|
|
|
- return getData().getHandleTypeEnum();
|
|
|
+ return getData().handleTypeEnum;
|
|
|
}
|
|
|
+
|
|
|
public static void setHandleTypeEnum(HandleTypeEnum handleTypeEnum) {
|
|
|
- getData().setHandleTypeEnum(handleTypeEnum);
|
|
|
+ getData().handleTypeEnum = handleTypeEnum;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ===================================================
|
|
|
+ // 流程状态
|
|
|
+ // ===================================================
|
|
|
+ public static FlowStatusEnum getFlowStatusEnum() {
|
|
|
+ return getData().flowStatusEnum;
|
|
|
}
|
|
|
|
|
|
+ public static void setFlowStatusEnum(FlowStatusEnum flowStatusEnum) {
|
|
|
+ getData().flowStatusEnum = flowStatusEnum;
|
|
|
+ }
|
|
|
+
|
|
|
+ // ===================================================
|
|
|
+ // 下个节点审批用户id
|
|
|
+ // ===================================================
|
|
|
+ public static Long getNextHandleUserId() {
|
|
|
+ return getData().nextHandleUserId;
|
|
|
+ }
|
|
|
+
|
|
|
+ public static void setNextHandleUserId(Long nextHandleUserId) {
|
|
|
+ getData().nextHandleUserId = nextHandleUserId;
|
|
|
+ }
|
|
|
|
|
|
- private static FlowThreadLocalData getData() {
|
|
|
- FlowThreadLocalData flowThreadLocalData = FLOW_HOLDER.get();
|
|
|
+ private static FlowThreadLocalUtil getData() {
|
|
|
+ FlowThreadLocalUtil flowThreadLocalData = FLOW_HOLDER.get();
|
|
|
if (flowThreadLocalData == null) {
|
|
|
- flowThreadLocalData = new FlowThreadLocalData();
|
|
|
+ flowThreadLocalData = new FlowThreadLocalUtil();
|
|
|
FLOW_HOLDER.set(flowThreadLocalData);
|
|
|
}
|
|
|
return flowThreadLocalData;
|