|
|
@@ -1,5 +1,6 @@
|
|
|
package com.fs.company.service.impl.call.node;
|
|
|
|
|
|
+import cn.hutool.core.collection.CollectionUtil;
|
|
|
import com.alibaba.fastjson.JSONObject;
|
|
|
import com.fs.common.constant.Constants;
|
|
|
import com.fs.common.core.redis.RedisCacheT;
|
|
|
@@ -65,10 +66,14 @@ public class AiQwAddWxTaskNode extends AbstractWorkflowNode {
|
|
|
boolean addSuccess = wxClient != null && Integer.valueOf(1).equals(wxClient.getIsAdd());
|
|
|
//回调加微成功
|
|
|
if (addSuccess) {
|
|
|
- List<CompanyWorkflowEdge> cList = edges.stream().filter(a ->
|
|
|
- StringUtils.isNotBlank(a.getConditionExpr()) && JSONObject.parseArray(a.getConditionExpr(), AiCallWorkflowConditionVo.class).get(0).isAdd())
|
|
|
- .collect(Collectors.toList());
|
|
|
- if(!cList.isEmpty() && nodeKey.equals(exec.getCurrentNodeKey())){
|
|
|
+ List<CompanyWorkflowEdge> cList = edges.stream().filter(a -> {
|
|
|
+ if (StringUtils.isBlank(a.getConditionExpr())) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ List<AiCallWorkflowConditionVo> list = JSONObject.parseArray(a.getConditionExpr(), AiCallWorkflowConditionVo.class);
|
|
|
+ return list != null && !list.isEmpty() && list.get(0).isAdd();
|
|
|
+ }).collect(Collectors.toList());
|
|
|
+ if (!cList.isEmpty() && nodeKey.equals(exec.getCurrentNodeKey())) {
|
|
|
super.runNextNode(context, cList.get(0));
|
|
|
}
|
|
|
}
|
|
|
@@ -78,7 +83,8 @@ public class AiQwAddWxTaskNode extends AbstractWorkflowNode {
|
|
|
.collect(Collectors.toList());
|
|
|
// 加微失败,根据条件判断走哪条边
|
|
|
CompanyWorkflowEdge edge = cList.get(0);
|
|
|
- AiCallWorkflowConditionVo condition = JSONObject.parseObject(edge.getConditionExpr(), AiCallWorkflowConditionVo.class);
|
|
|
+ List<AiCallWorkflowConditionVo> conditions = JSONObject.parseArray(edge.getConditionExpr(), AiCallWorkflowConditionVo.class);
|
|
|
+ AiCallWorkflowConditionVo condition = conditions.get(0);
|
|
|
// 匹配失败条件
|
|
|
if (!condition.isAdd()) {
|
|
|
log.info("加微失败,执行失败分支 - workflowInstanceId: {}", context.getWorkflowInstanceId());
|
|
|
@@ -104,8 +110,8 @@ public class AiQwAddWxTaskNode extends AbstractWorkflowNode {
|
|
|
return ExecutionResult.failure().nextNodeKey(null).build();
|
|
|
}
|
|
|
try {
|
|
|
- super.asyncWorkflowForBlockingNode(context.getWorkflowInstanceId(), context.getCurrentNodeKey(), context, ExecutionStatusEnum.PAUSED);
|
|
|
- return ExecutionResult.paused()
|
|
|
+ super.asyncWorkflowForBlockingNode(context.getWorkflowInstanceId(), context.getCurrentNodeKey(), context, ExecutionStatusEnum.WAITING);
|
|
|
+ return ExecutionResult.waiting()
|
|
|
.outputData(context.getVariables())
|
|
|
.nextNodeKey("").build();
|
|
|
} catch (Exception e) {
|
|
|
@@ -184,49 +190,49 @@ public class AiQwAddWxTaskNode extends AbstractWorkflowNode {
|
|
|
* getRedisCacheKey
|
|
|
*
|
|
|
*/
|
|
|
- public static String getDelayAddWxKeyPrefix(Long time) {
|
|
|
+ public static String getDelayAddWxKeyPrefix(Integer cidGroupNo,Long time) {
|
|
|
Date nowDay;
|
|
|
if (null != time) {
|
|
|
nowDay = new Date(time);
|
|
|
}else{
|
|
|
nowDay = new Date();
|
|
|
}
|
|
|
- return String.format(DELAY_QW_ADD_WX_KEY, nowDay.getHours(), nowDay.getMinutes());
|
|
|
+ return String.format(DELAY_QW_ADD_WX_KEY,cidGroupNo, nowDay.getHours(), nowDay.getMinutes());
|
|
|
}
|
|
|
|
|
|
/**
|
|
|
* 完成加微动作
|
|
|
*
|
|
|
*/
|
|
|
-// public void doneQwAddWx(String workflowInstanceId) {
|
|
|
-// ExecutionContext context = createExecutionContext(workflowInstanceId, nodeKey);
|
|
|
-// context.setVariable("lastNodeKey", nodeKey);
|
|
|
-// //启动定时节点倒计时
|
|
|
-// CompanyAiWorkflowExec exec = companyAiWorkflowExecMapper.selectByWorkflowInstanceId(context.getWorkflowInstanceId());
|
|
|
-// if (!exec.getCurrentNodeKey().equals(nodeKey)) {
|
|
|
-// //当前节点已流转
|
|
|
-// log.error("当前节点已流转 ,目标:{},实际:{}", nodeKey, exec.getCurrentNodeKey());
|
|
|
-// return;
|
|
|
-// }
|
|
|
-// //更新加微日志执行状态
|
|
|
-// super.updateLogStatusIfExist(context, ExecutionStatusEnum.PAUSED, ExecutionStatusEnum.WAITING);
|
|
|
-// super.asyncWorkflowForBlockingNode(context.getWorkflowInstanceId(), nodeKey, context, ExecutionStatusEnum.WAITING);
|
|
|
-// List<CompanyWorkflowEdge> edges = companyWorkflowEdgeMapper.selectListByWorkflowIdAndNodeKey(exec.getWorkflowId(), nodeKey);
|
|
|
-// edges.forEach(edge -> {
|
|
|
-// List<AiCallWorkflowConditionVo> conditions = JSONObject.parseArray(edge.getConditionExpr(), AiCallWorkflowConditionVo.class);
|
|
|
-// if (null == conditions || conditions.isEmpty()) {
|
|
|
-// super.runNextNode(context, edge);
|
|
|
-// } else {
|
|
|
-// AiCallWorkflowConditionVo condition = conditions.get(0);
|
|
|
-// //节点包含延时条件
|
|
|
-// if (null != condition.getAddTime() && !condition.isAdd()) {
|
|
|
-// long l = System.currentTimeMillis() + condition.getAddTime() * 60 * 1000;
|
|
|
-// String redisKey = getDelayAddWxKeyPrefix(l) + workflowInstanceId;
|
|
|
-// ExecutionContext nextContext = context.clone();
|
|
|
-// nextContext.setCurrentNodeKey(edge.getTargetNodeKey());
|
|
|
-// super.redisCache.setCacheObject(redisKey, nextContext);
|
|
|
-// }
|
|
|
-// }
|
|
|
-// });
|
|
|
-// }
|
|
|
+ public void doneQwAddWx(String workflowInstanceId) {
|
|
|
+ ExecutionContext context = createExecutionContext(workflowInstanceId, nodeKey);
|
|
|
+ context.setVariable("lastNodeKey", nodeKey);
|
|
|
+ //启动定时节点倒计时
|
|
|
+ CompanyAiWorkflowExec exec = companyAiWorkflowExecMapper.selectByWorkflowInstanceId(context.getWorkflowInstanceId());
|
|
|
+ if (!exec.getCurrentNodeKey().equals(nodeKey)) {
|
|
|
+ //当前节点已流转
|
|
|
+ log.error("当前节点已流转 ,目标:{},实际:{}", nodeKey, exec.getCurrentNodeKey());
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ //更新加微日志执行状态
|
|
|
+ super.updateLogStatusIfExist(context, ExecutionStatusEnum.WAITING, ExecutionStatusEnum.WAITING);
|
|
|
+ super.asyncWorkflowForBlockingNode(context.getWorkflowInstanceId(), nodeKey, context, ExecutionStatusEnum.WAITING);
|
|
|
+ List<CompanyWorkflowEdge> edges = companyWorkflowEdgeMapper.selectListByWorkflowIdAndNodeKey(exec.getWorkflowId(), nodeKey);
|
|
|
+ edges.forEach(edge -> {
|
|
|
+ List<AiCallWorkflowConditionVo> conditions = JSONObject.parseArray(edge.getConditionExpr(), AiCallWorkflowConditionVo.class);
|
|
|
+ if (CollectionUtil.isEmpty(conditions)) {
|
|
|
+ super.runNextNode(context, edge);
|
|
|
+ } else {
|
|
|
+ AiCallWorkflowConditionVo condition = conditions.get(0);
|
|
|
+ //节点包含延时条件
|
|
|
+ if (null != condition.getAddTime() && !condition.isAdd()) {
|
|
|
+ long l = System.currentTimeMillis() + condition.getAddTime() * 60 * 1000;
|
|
|
+ String redisKey = getDelayAddWxKeyPrefix(exec.getCidGroupNo(),l) + workflowInstanceId;
|
|
|
+ ExecutionContext nextContext = context.clone();
|
|
|
+ nextContext.setCurrentNodeKey(edge.getTargetNodeKey());
|
|
|
+ super.redisCache.setCacheObject(redisKey, nextContext);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
}
|