|
@@ -1,18 +1,26 @@
|
|
|
package com.fs.company.service.impl.call.node;
|
|
package com.fs.company.service.impl.call.node;
|
|
|
|
|
|
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
import com.fs.common.utils.spring.SpringUtils;
|
|
|
|
|
+import com.fs.company.domain.CompanyAiWorkflowExec;
|
|
|
|
|
+import com.fs.company.domain.CompanyVoiceRoboticBusiness;
|
|
|
|
|
+import com.fs.company.domain.CompanyWorkflowEdge;
|
|
|
|
|
+import com.fs.company.domain.CompanyWorkflowNode;
|
|
|
import com.fs.company.mapper.CompanyWorkflowNodeMapper;
|
|
import com.fs.company.mapper.CompanyWorkflowNodeMapper;
|
|
|
import com.fs.company.param.ExecutionContext;
|
|
import com.fs.company.param.ExecutionContext;
|
|
|
|
|
+import com.fs.company.service.IWorkflowNode;
|
|
|
import com.fs.company.vo.ExecutionResult;
|
|
import com.fs.company.vo.ExecutionResult;
|
|
|
import com.fs.enums.NodeTypeEnum;
|
|
import com.fs.enums.NodeTypeEnum;
|
|
|
|
|
+import lombok.extern.slf4j.Slf4j;
|
|
|
|
|
|
|
|
|
|
+import java.util.List;
|
|
|
import java.util.Map;
|
|
import java.util.Map;
|
|
|
|
|
|
|
|
/**
|
|
/**
|
|
|
* @author MixLiu
|
|
* @author MixLiu
|
|
|
* @date 2026/1/28 13:39
|
|
* @date 2026/1/28 13:39
|
|
|
- * @description AI外呼电话任务节点
|
|
|
|
|
|
|
+ * @description AI发送短信任务节点
|
|
|
*/
|
|
*/
|
|
|
|
|
+@Slf4j
|
|
|
public class AiSendMsgTaskNode extends AbstractWorkflowNode {
|
|
public class AiSendMsgTaskNode extends AbstractWorkflowNode {
|
|
|
private static final CompanyWorkflowNodeMapper companyWorkflowNodeMapper = SpringUtils.getBean(CompanyWorkflowNodeMapper.class);
|
|
private static final CompanyWorkflowNodeMapper companyWorkflowNodeMapper = SpringUtils.getBean(CompanyWorkflowNodeMapper.class);
|
|
|
|
|
|
|
@@ -20,15 +28,71 @@ public class AiSendMsgTaskNode extends AbstractWorkflowNode {
|
|
|
super(nodeKey, nodeName, properties);
|
|
super(nodeKey, nodeName, properties);
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 收到短信发送回调后的处理(当前不需要)
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param context 执行上下文
|
|
|
|
|
+ * @return 执行结果
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
protected ExecutionResult doContinue(ExecutionContext context) {
|
|
protected ExecutionResult doContinue(ExecutionContext context) {
|
|
|
|
|
+ // 短信发送不需要回调,直接执行下一个节点
|
|
|
|
|
+ List<CompanyWorkflowEdge> edges = companyWorkflowEdgeMapper.selectListByWorkflowIdAndNodeKey(
|
|
|
|
|
+ context.getVariable("workflowId", Long.class), nodeKey);
|
|
|
|
|
+
|
|
|
|
|
+ if (edges != null && !edges.isEmpty()) {
|
|
|
|
|
+ this.runNextNode(context, edges.get(0));
|
|
|
|
|
+ }
|
|
|
return null;
|
|
return null;
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 执行发送短信节点逻辑
|
|
|
|
|
+ * 直接标记为发送成功,然后流转到下一个节点
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param context 执行上下文
|
|
|
|
|
+ * @return 执行结果
|
|
|
|
|
+ */
|
|
|
@Override
|
|
@Override
|
|
|
protected ExecutionResult doExecute(ExecutionContext context) {
|
|
protected ExecutionResult doExecute(ExecutionContext context) {
|
|
|
-
|
|
|
|
|
- return null;
|
|
|
|
|
|
|
+ try {
|
|
|
|
|
+ // 获取业务数据
|
|
|
|
|
+ CompanyVoiceRoboticBusiness business = super.getRoboticBusiness(context.getWorkflowInstanceId());
|
|
|
|
|
+ if (business == null) {
|
|
|
|
|
+ log.error("未找到业务数据 - workflowInstanceId: {}", context.getWorkflowInstanceId());
|
|
|
|
|
+ return ExecutionResult.failure().errorMessage("未找到业务数据").build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ log.info("执行发送短信任务 - workflowInstanceId: {}, roboticId: {}, calleeId: {}",
|
|
|
|
|
+ context.getWorkflowInstanceId(), business.getRoboticId(), business.getCalleeId());
|
|
|
|
|
+
|
|
|
|
|
+ // TODO: 这里可以添加实际的发送短信逻辑
|
|
|
|
|
+ // 更新业务表的发短信动作标记
|
|
|
|
|
+ companyVoiceRoboticBusinessMapper.updateActionCount(3, business.getRoboticId(),
|
|
|
|
|
+ business.getCalleeId(), null);
|
|
|
|
|
+
|
|
|
|
|
+ log.info("短信发送成功 - workflowInstanceId: {}", context.getWorkflowInstanceId());
|
|
|
|
|
+
|
|
|
|
|
+ // 获取下一个节点并执行
|
|
|
|
|
+ CompanyAiWorkflowExec exec = companyAiWorkflowExecMapper.selectByWorkflowInstanceId(context.getWorkflowInstanceId());
|
|
|
|
|
+ List<CompanyWorkflowEdge> edges = companyWorkflowEdgeMapper.selectListByWorkflowIdAndNodeKey(
|
|
|
|
|
+ exec.getWorkflowId(), nodeKey);
|
|
|
|
|
+
|
|
|
|
|
+ if (edges != null && !edges.isEmpty()) {
|
|
|
|
|
+ // 直接执行下一个节点
|
|
|
|
|
+ this.runNextNode(context, edges.get(0));
|
|
|
|
|
+ return ExecutionResult.success().nextNodeKey("").build();
|
|
|
|
|
+ } else {
|
|
|
|
|
+ log.warn("没有找到下一个节点 - workflowInstanceId: {}", context.getWorkflowInstanceId());
|
|
|
|
|
+ return ExecutionResult.success().nextNodeKey("").build();
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ } catch (Exception e) {
|
|
|
|
|
+ log.error("发送短信异常 - workflowInstanceId: {}", context.getWorkflowInstanceId(), e);
|
|
|
|
|
+ return ExecutionResult.failure()
|
|
|
|
|
+ .errorMessage("发送短信异常: " + e.getMessage())
|
|
|
|
|
+ .build();
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
@@ -38,6 +102,27 @@ public class AiSendMsgTaskNode extends AbstractWorkflowNode {
|
|
|
|
|
|
|
|
@Override
|
|
@Override
|
|
|
public Boolean isAsync() {
|
|
public Boolean isAsync() {
|
|
|
- return true;
|
|
|
|
|
|
|
+ return false; // 短信发送为同步节点,直接执行并流转
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ /**
|
|
|
|
|
+ * 运行下一个节点
|
|
|
|
|
+ *
|
|
|
|
|
+ * @param context 执行上下文
|
|
|
|
|
+ * @param edge 边
|
|
|
|
|
+ */
|
|
|
|
|
+ public void runNextNode(ExecutionContext context, CompanyWorkflowEdge edge) {
|
|
|
|
|
+ ExecutionContext nextContext = context.clone();
|
|
|
|
|
+ nextContext.setCurrentNodeKey(edge.getTargetNodeKey());
|
|
|
|
|
+ super.execPointNextNode(nextContext);
|
|
|
|
|
+
|
|
|
|
|
+ CompanyWorkflowNode nextNode = companyWorkflowNodeMapper.selectNodeByNodeKey(edge.getTargetNodeKey());
|
|
|
|
|
+ IWorkflowNode node = super.workflowNodeFactory.createNode(
|
|
|
|
|
+ nextNode.getNodeKey(),
|
|
|
|
|
+ NodeTypeEnum.fromCode(nextNode.getNodeType()),
|
|
|
|
|
+ nextNode.getNodeName(),
|
|
|
|
|
+ null
|
|
|
|
|
+ );
|
|
|
|
|
+ node.execute(nextContext);
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|