|
@@ -99,15 +99,16 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
|
|
|
// 生成流程id
|
|
|
- final long flowId = IdWorker.getId();
|
|
|
-
|
|
|
- // 初始化模板参数
|
|
|
+ long flowId = IdWorker.getId();
|
|
|
Map<String, Object> templateMap = flowDelegate.initTemplateMap(dto.getData(), dto.getData());
|
|
|
- FlowThreadLocalUtil.setTemplateData(templateMap);
|
|
|
- FlowThreadLocalUtil.setStartData(dto.getData());
|
|
|
- FlowThreadLocalUtil.setCurrentData(dto.getData());
|
|
|
- FlowThreadLocalUtil.setFlowId(flowId);
|
|
|
- FlowThreadLocalUtil.setHandleTypeEnum(HandleTypeEnum.SKIP_TO_NEXT);
|
|
|
+
|
|
|
+ FlowThreadLocalUtil flowThreadLocal = FlowThreadLocalUtil.create();
|
|
|
+ flowThreadLocal.setTemplateData(templateMap);
|
|
|
+ flowThreadLocal.setStartData(dto.getData());
|
|
|
+ flowThreadLocal.setCurrentData(dto.getData());
|
|
|
+ flowThreadLocal.setFlowId(flowId);
|
|
|
+ flowThreadLocal.setHandleTypeEnum(HandleTypeEnum.SKIP_TO_NEXT);
|
|
|
+ flowThreadLocal.setCurrentNodeTypeEnum(NodeTypeEnum.START);
|
|
|
|
|
|
// 寻找下一节点
|
|
|
FlowDefinitionNode nextUserNode = getNextUserNode(startNode, flowDefinitionNodeList);
|
|
@@ -123,7 +124,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
// 如果下一节点处理用户只有1人,赋值用户id
|
|
|
if (handleUser.getSuccess()) {
|
|
|
flowExample.setHandleUserId(handleUser.getUserId());
|
|
|
- FlowThreadLocalUtil.setNextHandleUserId(handleUser.getUserId());
|
|
|
+ flowThreadLocal.setNextHandleUserId(handleUser.getUserId());
|
|
|
}
|
|
|
// 如果下一节点处理用户有多人,则返回用户列表让用户选择下一节点处理人id
|
|
|
else {
|
|
@@ -131,11 +132,11 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
// 流程进行中
|
|
|
flowExample.setStatus(FlowStatusEnum.IN_PROGRESS.getKey());
|
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
+ flowThreadLocal.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
} else {
|
|
|
// 流程已通过
|
|
|
flowExample.setStatus(FlowStatusEnum.PASS.getKey());
|
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(FlowStatusEnum.PASS);
|
|
|
+ flowThreadLocal.setFlowStatusEnum(FlowStatusEnum.PASS);
|
|
|
}
|
|
|
|
|
|
// 执行开始流程方法
|
|
@@ -162,7 +163,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
if (NodeTypeEnum.END.equals(nextNodeType)) {
|
|
|
|
|
|
// 赋值业务id到租户线程
|
|
|
- FlowThreadLocalUtil.setBusinessId(businessId);
|
|
|
+ flowThreadLocal.setBusinessId(businessId);
|
|
|
|
|
|
// 执行结束方法
|
|
|
invokeEndMethod(nextUserNode, flowDelegate);
|
|
@@ -205,20 +206,21 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
public FlowResult jump(JumpDto dto) {
|
|
|
|
|
|
FlowJumpContext context = new FlowJumpContext(dto);
|
|
|
+ FlowThreadLocalUtil flowThreadLocal = FlowThreadLocalUtil.create();
|
|
|
|
|
|
// 发起流程参数
|
|
|
JSONObject startData = JSONObject.parseObject(context.getFlowExample().getStartData());
|
|
|
Map<String, Object> templateMap = context.getFlowDelegate().initTemplateMap(dto.getData(), startData);
|
|
|
- FlowThreadLocalUtil.setTemplateData(templateMap);
|
|
|
- FlowThreadLocalUtil.setStartData(startData);
|
|
|
- FlowThreadLocalUtil.setCurrentData(dto.getData());
|
|
|
- FlowThreadLocalUtil.setFlowId(dto.getFlowId());
|
|
|
- FlowThreadLocalUtil.setBusinessId(context.getFlowExample().getBusinessId());
|
|
|
+ flowThreadLocal.setTemplateData(templateMap);
|
|
|
+ flowThreadLocal.setStartData(startData);
|
|
|
+ flowThreadLocal.setCurrentData(dto.getData());
|
|
|
+ flowThreadLocal.setFlowId(dto.getFlowId());
|
|
|
+ flowThreadLocal.setBusinessId(context.getFlowExample().getBusinessId());
|
|
|
|
|
|
FlowResult flowResult;
|
|
|
|
|
|
// 流程处理逻辑
|
|
|
- switch (context.getHandleTypeEnum()) {
|
|
|
+ switch (context.getHandleType()) {
|
|
|
|
|
|
// 跳转下一节点
|
|
|
case SKIP_TO_NEXT:
|
|
@@ -250,9 +252,10 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
return flowResult;
|
|
|
}
|
|
|
|
|
|
- FlowThreadLocalUtil.setFlowStatusEnum(context.getFlowStatusEnum());
|
|
|
- FlowThreadLocalUtil.setHandleTypeEnum(context.getHandleTypeEnum());
|
|
|
- FlowThreadLocalUtil.setNextHandleUserId(context.getJumpHandleUserId());
|
|
|
+ flowThreadLocal.setFlowStatusEnum(context.getFlowStatus());
|
|
|
+ flowThreadLocal.setHandleTypeEnum(context.getHandleType());
|
|
|
+ flowThreadLocal.setNextHandleUserId(context.getJumpHandleUserId());
|
|
|
+ flowThreadLocal.setCurrentNodeTypeEnum(context.getCurrentNodeType());
|
|
|
|
|
|
// 执行节点方法
|
|
|
executiveNodeMethod(context);
|
|
@@ -293,7 +296,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
// 如果下一节点为结束节点
|
|
|
if (NodeTypeEnum.END.equals(NodeTypeEnum.getEnum(jumpNode.getNodeType()))) {
|
|
|
// 流程已通过
|
|
|
- context.setFlowStatusEnum(FlowStatusEnum.PASS);
|
|
|
+ context.setFlowStatus(FlowStatusEnum.PASS);
|
|
|
// 流程结束,则流程节点审批人不存在
|
|
|
context.setJumpHandleUserId(null);
|
|
|
return new FlowResult(true);
|
|
@@ -302,7 +305,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
// 寻找节点审批人
|
|
|
FlowResult flowResult = getHandleUser(jumpNode, context.getJumpHandleUserId());
|
|
|
// 流程进行中
|
|
|
- context.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
+ context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
// 赋值流程节点审批人
|
|
|
context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
|
|
@@ -315,7 +318,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private FlowResult reject(FlowJumpContext context) {
|
|
|
|
|
|
// 流程已驳回
|
|
|
- context.setFlowStatusEnum(FlowStatusEnum.REJECT);
|
|
|
+ context.setFlowStatus(FlowStatusEnum.REJECT);
|
|
|
// 流程结束,则流程节点审批人不存在
|
|
|
context.setJumpHandleUserId(null);
|
|
|
|
|
@@ -341,7 +344,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
// 如果流程回退到开始节点
|
|
|
if (NodeTypeEnum.START.getKey().equals(jumpNode.getNodeType())) {
|
|
|
// 流程未发起
|
|
|
- context.setFlowStatusEnum(FlowStatusEnum.READY_START);
|
|
|
+ context.setFlowStatus(FlowStatusEnum.READY_START);
|
|
|
// 流程节点处理人为流程发起人
|
|
|
context.setJumpHandleUserId(context.getFlowExample().getCreateUser());
|
|
|
return new FlowResult(true);
|
|
@@ -349,7 +352,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
|
|
|
FlowResult flowResult = getHandleUser(jumpNode, context.getJumpHandleUserId());
|
|
|
// 流程进行中
|
|
|
- context.setFlowStatusEnum(FlowStatusEnum.IN_PROGRESS);
|
|
|
+ context.setFlowStatus(FlowStatusEnum.IN_PROGRESS);
|
|
|
// 赋值流程节点审批人
|
|
|
context.setJumpHandleUserId(flowResult.getUserId());
|
|
|
|
|
@@ -362,7 +365,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private FlowResult returnToSubmitter(FlowJumpContext context) {
|
|
|
|
|
|
// 流程未发起
|
|
|
- context.setFlowStatusEnum(FlowStatusEnum.READY_START);
|
|
|
+ context.setFlowStatus(FlowStatusEnum.READY_START);
|
|
|
// 赋值发起人为节点审批人
|
|
|
context.setJumpHandleUserId(context.getFlowExample().getCreateUser());
|
|
|
|
|
@@ -388,7 +391,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
FlowDelegate flowDelegate = context.getFlowDelegate();
|
|
|
|
|
|
// 流程状态
|
|
|
- FlowStatusEnum flowStatusEnum = context.getFlowStatusEnum();
|
|
|
+ FlowStatusEnum flowStatus = context.getFlowStatus();
|
|
|
|
|
|
// 自定义方法不为空,走自定义方法
|
|
|
if (StrUtil.isNotBlank(handlingMethod)) {
|
|
@@ -411,10 +414,10 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
FlowExample flowExample = context.getFlowExample();
|
|
|
Long flowId = flowExample.getId();
|
|
|
Long businessId = flowExample.getBusinessId();
|
|
|
-
|
|
|
+ NodeTypeEnum currentNodeType = context.getCurrentNodeType();
|
|
|
JSONObject data = context.getJumpDto().getData();
|
|
|
|
|
|
- flowDelegate.defaultMethod(flowId, businessId, flowStatusEnum, data);
|
|
|
+ flowDelegate.defaultMethod(flowId, businessId, currentNodeType, flowStatus, data);
|
|
|
} catch (Exception e) {
|
|
|
|
|
|
log.error("跳转节点方法异常", e);
|
|
@@ -423,7 +426,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
}
|
|
|
|
|
|
// 结束节点
|
|
|
- if (FlowStatusEnum.PASS.equals(flowStatusEnum)) {
|
|
|
+ if (FlowStatusEnum.PASS.equals(flowStatus)) {
|
|
|
invokeEndMethod(context.getJumpNode(), flowDelegate);
|
|
|
}
|
|
|
|
|
@@ -485,7 +488,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
// 更新流程实例
|
|
|
flowExample.setDefinitionNodeId(jumpNode.getId());
|
|
|
flowExample.setHandleUserId(context.getJumpHandleUserId());
|
|
|
- flowExample.setStatus(context.getFlowStatusEnum().getKey());
|
|
|
+ flowExample.setStatus(context.getFlowStatus().getKey());
|
|
|
flowExample.setStartData(null);
|
|
|
boolean updateFlag = flowExampleService.updateById(flowExample);
|
|
|
if (!updateFlag) {
|
|
@@ -504,7 +507,7 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
flowExampleDetailList.add(nodeExampleDetail);
|
|
|
|
|
|
// 如果流程已结束
|
|
|
- if (FlowStatusEnum.PASS.equals(context.getFlowStatusEnum())) {
|
|
|
+ if (FlowStatusEnum.PASS.equals(context.getFlowStatus())) {
|
|
|
FlowExampleDetail endExampleDetail = new FlowExampleDetail();
|
|
|
endExampleDetail.setFlowExampleId(flowExample.getId());
|
|
|
endExampleDetail.setFlowDefinitionNodeId(jumpNode.getId());
|
|
@@ -718,8 +721,8 @@ public class FlowProcessServiceImpl implements FlowProcessService {
|
|
|
private void pushJumpMessage(FlowJumpContext context) {
|
|
|
|
|
|
FlowExample flowExample = context.getFlowExample();
|
|
|
- HandleTypeEnum handleTypeEnum = context.getHandleTypeEnum();
|
|
|
- FlowStatusEnum flowStatusEnum = context.getFlowStatusEnum();
|
|
|
+ HandleTypeEnum handleTypeEnum = context.getHandleType();
|
|
|
+ FlowStatusEnum flowStatusEnum = context.getFlowStatus();
|
|
|
FlowDefinitionNode jumpNode = context.getJumpNode();
|
|
|
FlowDefinitionNode currentNode = context.getCurrentNode();
|
|
|
Long jumpHandleUserId = context.getJumpHandleUserId();
|